@wairon/cli 5.1.1-dev.20 → 5.1.1-dev.21
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/dist/cli/index.js +171 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +144 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1113,7 +1113,7 @@ var init_defaults = __esm({
|
|
|
1113
1113
|
copilot: ".github/prompts",
|
|
1114
1114
|
codex: ".codex/agents"
|
|
1115
1115
|
};
|
|
1116
|
-
WAIRON_VERSION = "5.1.1-dev.
|
|
1116
|
+
WAIRON_VERSION = "5.1.1-dev.21";
|
|
1117
1117
|
GITHUB_REPO = "SYW-Apps/Waffle-AIron";
|
|
1118
1118
|
ARCHITECT_AGENT_ID = "agent-architect";
|
|
1119
1119
|
ARCHITECT_TEMPLATE_ID = "architect";
|
|
@@ -19930,6 +19930,15 @@ function componentIdsUnder(dir) {
|
|
|
19930
19930
|
}
|
|
19931
19931
|
return ids;
|
|
19932
19932
|
}
|
|
19933
|
+
function specKind(raw) {
|
|
19934
|
+
if ("componentType" in raw) return "component";
|
|
19935
|
+
if ("parentSystem" in raw) return "subsystem";
|
|
19936
|
+
if ("vision" in raw) return "system";
|
|
19937
|
+
if ("component" in raw && Array.isArray(raw.methods)) return "interface";
|
|
19938
|
+
if ("contract" in raw && Array.isArray(raw.methods)) return "implementation";
|
|
19939
|
+
if ("kind" in raw && Array.isArray(raw.fields)) return "type";
|
|
19940
|
+
return void 0;
|
|
19941
|
+
}
|
|
19933
19942
|
function rewriteRefFields(specsDir, remap, excludeDir) {
|
|
19934
19943
|
const rewritten = [];
|
|
19935
19944
|
for (const file of listFilesRecursive(specsDir, ".yaml")) {
|
|
@@ -19951,6 +19960,15 @@ function rewriteRefFields(specsDir, remap, excludeDir) {
|
|
|
19951
19960
|
changed = true;
|
|
19952
19961
|
}
|
|
19953
19962
|
};
|
|
19963
|
+
const rewriteMethod = (holder, key, owner) => {
|
|
19964
|
+
const name = holder?.[key];
|
|
19965
|
+
if (typeof name !== "string" || typeof owner !== "string") return;
|
|
19966
|
+
const next = remap(name, "method", owner);
|
|
19967
|
+
if (next !== name) {
|
|
19968
|
+
holder[key] = next;
|
|
19969
|
+
changed = true;
|
|
19970
|
+
}
|
|
19971
|
+
};
|
|
19954
19972
|
const entries = (list) => Array.isArray(list) ? list : [];
|
|
19955
19973
|
const rewriteEach = (list, position) => {
|
|
19956
19974
|
entries(list).forEach((_, i) => rewrite(list, i, position));
|
|
@@ -19961,30 +19979,32 @@ function rewriteRefFields(specsDir, remap, excludeDir) {
|
|
|
19961
19979
|
rewrite(published, "interface", "interface");
|
|
19962
19980
|
}
|
|
19963
19981
|
};
|
|
19964
|
-
|
|
19965
|
-
if ("
|
|
19966
|
-
kind = "component";
|
|
19982
|
+
const kind = specKind(raw);
|
|
19983
|
+
if (kind === "component") {
|
|
19967
19984
|
rewriteEach(raw.dependsOn, "component");
|
|
19968
19985
|
rewriteEach(raw.owns, "component");
|
|
19969
|
-
for (const binding of entries(raw.dispatch))
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
|
|
19986
|
+
for (const binding of entries(raw.dispatch)) {
|
|
19987
|
+
rewriteMethod(binding, "method", binding?.component);
|
|
19988
|
+
rewrite(binding, "component", "component");
|
|
19989
|
+
}
|
|
19990
|
+
} else if (kind === "subsystem") {
|
|
19991
|
+
for (const entrypoint of entries(raw.lifecycle)) {
|
|
19992
|
+
rewriteMethod(entrypoint, "method", entrypoint?.component);
|
|
19993
|
+
rewrite(entrypoint, "component", "component");
|
|
19994
|
+
}
|
|
19973
19995
|
rewritePublished(raw.publicInterfaces);
|
|
19974
|
-
} else if ("
|
|
19975
|
-
kind = "system";
|
|
19996
|
+
} else if (kind === "system") {
|
|
19976
19997
|
rewritePublished(raw.publicInterfaces);
|
|
19977
|
-
} else if ("
|
|
19978
|
-
kind = "interface";
|
|
19998
|
+
} else if (kind === "interface") {
|
|
19979
19999
|
rewrite(raw, "component", "component");
|
|
19980
20000
|
for (const method of raw.methods) {
|
|
19981
20001
|
for (const param of entries(method?.params)) rewrite(param, "type", "type");
|
|
19982
20002
|
}
|
|
19983
|
-
} else if ("
|
|
19984
|
-
kind = "implementation";
|
|
20003
|
+
} else if (kind === "implementation") {
|
|
19985
20004
|
rewrite(raw, "contract", "interface");
|
|
19986
20005
|
for (const method of raw.methods) {
|
|
19987
20006
|
for (const step of entries(method?.narrative)) {
|
|
20007
|
+
rewriteMethod(step, "targetMethod", step?.targetComponent);
|
|
19988
20008
|
rewrite(step, "targetComponent", "component");
|
|
19989
20009
|
const source = step?.auth?.from;
|
|
19990
20010
|
if (typeof source === "string" && source.startsWith(COMPONENT_AUTH_SOURCE)) {
|
|
@@ -19997,8 +20017,7 @@ function rewriteRefFields(specsDir, remap, excludeDir) {
|
|
|
19997
20017
|
}
|
|
19998
20018
|
}
|
|
19999
20019
|
}
|
|
20000
|
-
} else if (
|
|
20001
|
-
kind = "type";
|
|
20020
|
+
} else if (kind === "type") {
|
|
20002
20021
|
rewrite(raw, "componentClass", "entity-class");
|
|
20003
20022
|
for (const field of raw.fields) rewrite(field, "type", "type");
|
|
20004
20023
|
}
|
|
@@ -20118,7 +20137,101 @@ function removeSpecFile(file, id) {
|
|
|
20118
20137
|
fs14.rmdirSync(dir);
|
|
20119
20138
|
}
|
|
20120
20139
|
}
|
|
20121
|
-
|
|
20140
|
+
function renameMethod(componentId, methodName, newName, pinSymbol) {
|
|
20141
|
+
const component = loadComponentSpec(componentId);
|
|
20142
|
+
if (!component) {
|
|
20143
|
+
throw new WaironError(`component-missing: no component has the id "${componentId}".`);
|
|
20144
|
+
}
|
|
20145
|
+
if (componentId.includes("::")) {
|
|
20146
|
+
throw new WaironError(
|
|
20147
|
+
`chained-component: "${componentId}" lives in a chained subproject; rename its method from that project's own root.`
|
|
20148
|
+
);
|
|
20149
|
+
}
|
|
20150
|
+
if (!METHOD_NAME.test(newName)) {
|
|
20151
|
+
throw new WaironError(`invalid-name: "${newName}" is not a camel-case identifier.`);
|
|
20152
|
+
}
|
|
20153
|
+
const contracts = loadInterfaceSpecs().filter((i) => i.component === componentId);
|
|
20154
|
+
const moving = contracts.filter((i) => i.methods.some((m) => m.name === methodName));
|
|
20155
|
+
if (moving.length === 0) {
|
|
20156
|
+
throw new WaironError(`method-missing: no contract of "${componentId}" declares the method "${methodName}".`);
|
|
20157
|
+
}
|
|
20158
|
+
const taken = moving.filter((i) => i.methods.some((m) => m.name === newName)).map((i) => `"${i.id}"`);
|
|
20159
|
+
if (taken.length > 0) {
|
|
20160
|
+
throw new WaironError(`name-taken: ${taken.join(", ")} already declares a method under the name "${newName}".`);
|
|
20161
|
+
}
|
|
20162
|
+
const implementations = loadImplementationSpecs();
|
|
20163
|
+
const movingContracts = new Set(moving.map((i) => i.id));
|
|
20164
|
+
const renamed = [];
|
|
20165
|
+
for (const contract of moving) {
|
|
20166
|
+
saveInterfaceSpec({
|
|
20167
|
+
...contract,
|
|
20168
|
+
methods: contract.methods.map((m) => m.name === methodName ? { ...m, name: newName, signature: renameInSignature(m.signature, methodName, newName) } : m)
|
|
20169
|
+
});
|
|
20170
|
+
renamed.push(contract.id);
|
|
20171
|
+
}
|
|
20172
|
+
let pinnedSymbol;
|
|
20173
|
+
for (const implementation of implementations) {
|
|
20174
|
+
if (!movingContracts.has(implementation.contract)) continue;
|
|
20175
|
+
const realization = implementation.methods.find((m) => m.name === methodName);
|
|
20176
|
+
if (!realization) continue;
|
|
20177
|
+
const pin = realization.symbol === void 0 && pinSymbol !== false;
|
|
20178
|
+
if (pin) pinnedSymbol = methodName;
|
|
20179
|
+
saveImplementationSpec({
|
|
20180
|
+
...implementation,
|
|
20181
|
+
methods: implementation.methods.map((m) => m.name === methodName ? { ...m, name: newName, ...pin ? { symbol: methodName } : {} } : m)
|
|
20182
|
+
});
|
|
20183
|
+
renamed.push(implementation.id);
|
|
20184
|
+
}
|
|
20185
|
+
invalidateSpecCache();
|
|
20186
|
+
const specsDir = aiPathsAt(getProjectRoot()).specsDir();
|
|
20187
|
+
const rewritten = rewriteRefFields(specsDir, (ref, position, owner) => position === "method" && owner === componentId && ref === methodName ? newName : ref).map((spec) => spec.id);
|
|
20188
|
+
const mentions = collectMentions(specsDir, methodName, moving);
|
|
20189
|
+
return {
|
|
20190
|
+
component: componentId,
|
|
20191
|
+
from: methodName,
|
|
20192
|
+
to: newName,
|
|
20193
|
+
renamed,
|
|
20194
|
+
rewritten,
|
|
20195
|
+
mentions,
|
|
20196
|
+
...pinnedSymbol ? { pinnedSymbol } : {}
|
|
20197
|
+
};
|
|
20198
|
+
}
|
|
20199
|
+
function renameInSignature(signature, from, to) {
|
|
20200
|
+
return signature.replace(identifierPattern(from), to);
|
|
20201
|
+
}
|
|
20202
|
+
function collectMentions(specsDir, methodName, moved) {
|
|
20203
|
+
const mentions = /* @__PURE__ */ new Set();
|
|
20204
|
+
for (const contract of moved) {
|
|
20205
|
+
const wireBound = contract.methods.some((m) => {
|
|
20206
|
+
const endpoint = m.endpoint;
|
|
20207
|
+
return endpoint?.transport === "gRPC" && endpoint.method === methodName;
|
|
20208
|
+
});
|
|
20209
|
+
if (wireBound) mentions.add(contract.id);
|
|
20210
|
+
}
|
|
20211
|
+
const named = identifierPattern(methodName);
|
|
20212
|
+
const namesMethod = (value) => {
|
|
20213
|
+
if (Array.isArray(value)) return value.some(namesMethod);
|
|
20214
|
+
if (!value || typeof value !== "object") return false;
|
|
20215
|
+
return Object.entries(value).some(([key, nested]) => typeof nested === "string" ? PROSE_FIELDS.has(key) && named.test(nested) : namesMethod(nested));
|
|
20216
|
+
};
|
|
20217
|
+
for (const file of listFilesRecursive(specsDir, ".yaml")) {
|
|
20218
|
+
let raw;
|
|
20219
|
+
try {
|
|
20220
|
+
raw = readYamlFile(file);
|
|
20221
|
+
} catch {
|
|
20222
|
+
continue;
|
|
20223
|
+
}
|
|
20224
|
+
if (!raw || typeof raw !== "object") continue;
|
|
20225
|
+
const kind = specKind(raw);
|
|
20226
|
+
if (!kind || !namesMethod(raw)) continue;
|
|
20227
|
+
mentions.add(kind === "system" ? "system" : String(raw.id));
|
|
20228
|
+
}
|
|
20229
|
+
return [...mentions];
|
|
20230
|
+
}
|
|
20231
|
+
function identifierPattern(methodName) {
|
|
20232
|
+
return new RegExp(`(?<![A-Za-z0-9_])${methodName}(?![A-Za-z0-9_])`);
|
|
20233
|
+
}
|
|
20234
|
+
var fs14, path20, COMPONENT_AUTH_SOURCE, METHOD_NAME, PROSE_FIELDS;
|
|
20122
20235
|
var init_provision = __esm({
|
|
20123
20236
|
"src/core/provision.ts"() {
|
|
20124
20237
|
"use strict";
|
|
@@ -20132,6 +20245,18 @@ var init_provision = __esm({
|
|
|
20132
20245
|
init_errors();
|
|
20133
20246
|
init_models();
|
|
20134
20247
|
COMPONENT_AUTH_SOURCE = "component:";
|
|
20248
|
+
METHOD_NAME = /^[a-z][a-zA-Z0-9]*$/;
|
|
20249
|
+
PROSE_FIELDS = /* @__PURE__ */ new Set([
|
|
20250
|
+
"description",
|
|
20251
|
+
"intent",
|
|
20252
|
+
"summary",
|
|
20253
|
+
"condition",
|
|
20254
|
+
"over",
|
|
20255
|
+
"outcome",
|
|
20256
|
+
"error",
|
|
20257
|
+
"note",
|
|
20258
|
+
"caller"
|
|
20259
|
+
]);
|
|
20135
20260
|
}
|
|
20136
20261
|
});
|
|
20137
20262
|
|
|
@@ -24701,6 +24826,7 @@ __export(src_exports, {
|
|
|
24701
24826
|
removePackSelection: () => removePackSelection,
|
|
24702
24827
|
removeSnapshot: () => removeSnapshot,
|
|
24703
24828
|
renameComponent: () => renameComponent,
|
|
24829
|
+
renameMethod: () => renameMethod,
|
|
24704
24830
|
renderDiagram: () => renderDiagram,
|
|
24705
24831
|
renderDomainsDoc: () => renderDomainsDoc,
|
|
24706
24832
|
renderTemplateInstructions: () => renderTemplateInstructions,
|
|
@@ -25419,6 +25545,7 @@ function loadProjectConfig4() {
|
|
|
25419
25545
|
removePackSelection,
|
|
25420
25546
|
removeSnapshot,
|
|
25421
25547
|
renameComponent,
|
|
25548
|
+
renameMethod,
|
|
25422
25549
|
renderDiagram,
|
|
25423
25550
|
renderDomainsDoc,
|
|
25424
25551
|
renderTemplateInstructions,
|