@rogatio/cli 5.18.0 → 5.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/dist/editor/index.js +56 -3
- package/dist/node/index.js +1683 -384
- package/package.json +1 -1
package/dist/editor/index.js
CHANGED
|
@@ -2000,6 +2000,7 @@ function ownString(record, ...keys) {
|
|
|
2000
2000
|
}
|
|
2001
2001
|
return void 0;
|
|
2002
2002
|
}
|
|
2003
|
+
var RULE_PATH_PATTERN = /^\/groups\/(0|[1-9][0-9]*)\/rules\/(0|[1-9][0-9]*)(?:\/|$)/;
|
|
2003
2004
|
function applyRuleProposalAction(rule, ruleProposal) {
|
|
2004
2005
|
const action = ruleProposal.action;
|
|
2005
2006
|
switch (ruleProposal.kind) {
|
|
@@ -2123,6 +2124,7 @@ var EditorControllerImpl = class {
|
|
|
2123
2124
|
testRequestId = 0;
|
|
2124
2125
|
aiAssistPanel = null;
|
|
2125
2126
|
aiAssistInFlight = false;
|
|
2127
|
+
aiRepairTargets = [];
|
|
2126
2128
|
constructor(options, initial, extensions) {
|
|
2127
2129
|
this.root = options.root;
|
|
2128
2130
|
this.document = options.root.ownerDocument;
|
|
@@ -2972,6 +2974,8 @@ var EditorControllerImpl = class {
|
|
|
2972
2974
|
this.render();
|
|
2973
2975
|
}
|
|
2974
2976
|
applyAIProposal(proposal) {
|
|
2977
|
+
const repairs = [...this.aiRepairTargets];
|
|
2978
|
+
this.aiRepairTargets = [];
|
|
2975
2979
|
for (const ruleProposal of proposal.rules) {
|
|
2976
2980
|
let group = this.groupById(ruleProposal.groupId);
|
|
2977
2981
|
if (!group) {
|
|
@@ -2985,7 +2989,19 @@ var EditorControllerImpl = class {
|
|
|
2985
2989
|
group = this.groupById(groupId);
|
|
2986
2990
|
}
|
|
2987
2991
|
if (!group) return;
|
|
2988
|
-
const
|
|
2992
|
+
const rules = group.rules;
|
|
2993
|
+
const repair = repairs.find(
|
|
2994
|
+
(target) => target.groupId === ruleProposal.groupId && rules.some((existing) => String(existing.id) === target.ruleId)
|
|
2995
|
+
);
|
|
2996
|
+
let repairIndex = -1;
|
|
2997
|
+
let ruleId = this.nextId("rule-ai");
|
|
2998
|
+
if (repair) {
|
|
2999
|
+
repairs.splice(repairs.indexOf(repair), 1);
|
|
3000
|
+
ruleId = repair.ruleId;
|
|
3001
|
+
repairIndex = rules.findIndex(
|
|
3002
|
+
(existing) => String(existing.id) === repair.ruleId
|
|
3003
|
+
);
|
|
3004
|
+
}
|
|
2989
3005
|
const rule = {
|
|
2990
3006
|
id: ruleId,
|
|
2991
3007
|
name: ruleProposal.name,
|
|
@@ -2998,20 +3014,56 @@ var EditorControllerImpl = class {
|
|
|
2998
3014
|
rule.method = ruleProposal.method;
|
|
2999
3015
|
}
|
|
3000
3016
|
applyRuleProposalAction(rule, ruleProposal);
|
|
3001
|
-
|
|
3017
|
+
if (repairIndex >= 0) {
|
|
3018
|
+
rules[repairIndex] = rule;
|
|
3019
|
+
} else {
|
|
3020
|
+
rules.push(rule);
|
|
3021
|
+
}
|
|
3002
3022
|
this.markChanged();
|
|
3003
3023
|
const groupIdStr = String(group.id);
|
|
3004
3024
|
this.focusRequest = pointer(
|
|
3005
3025
|
"groups",
|
|
3006
3026
|
this.groupIndex(groupIdStr),
|
|
3007
3027
|
"rules",
|
|
3008
|
-
|
|
3028
|
+
repairIndex >= 0 ? repairIndex : rules.length - 1,
|
|
3009
3029
|
"name"
|
|
3010
3030
|
);
|
|
3011
3031
|
}
|
|
3012
3032
|
this.statusMessage = `Applied ${proposal.rules.length} rule${proposal.rules.length === 1 ? "" : "s"} from AI.`;
|
|
3013
3033
|
this.render();
|
|
3014
3034
|
}
|
|
3035
|
+
/**
|
|
3036
|
+
* Rules carrying validation errors, in stable path order. A fix proposal
|
|
3037
|
+
* repairs these rules in place (keeping their ids) instead of adding new ones.
|
|
3038
|
+
*/
|
|
3039
|
+
repairTargetsFrom(diagnostics) {
|
|
3040
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3041
|
+
const positions = [];
|
|
3042
|
+
for (const diagnostic2 of diagnostics) {
|
|
3043
|
+
const match = RULE_PATH_PATTERN.exec(diagnostic2.path);
|
|
3044
|
+
if (!match) continue;
|
|
3045
|
+
const groupIndex = Number(match[1]);
|
|
3046
|
+
const ruleIndex = Number(match[2]);
|
|
3047
|
+
if (!Number.isSafeInteger(groupIndex) || !Number.isSafeInteger(ruleIndex)) {
|
|
3048
|
+
continue;
|
|
3049
|
+
}
|
|
3050
|
+
const key = `${groupIndex}/${ruleIndex}`;
|
|
3051
|
+
if (seen.has(key)) continue;
|
|
3052
|
+
seen.add(key);
|
|
3053
|
+
positions.push({ groupIndex, ruleIndex });
|
|
3054
|
+
}
|
|
3055
|
+
positions.sort(
|
|
3056
|
+
(left, right) => left.groupIndex - right.groupIndex || left.ruleIndex - right.ruleIndex
|
|
3057
|
+
);
|
|
3058
|
+
const targets = [];
|
|
3059
|
+
for (const position of positions) {
|
|
3060
|
+
const group = this.draft.groups[position.groupIndex];
|
|
3061
|
+
const rule = group?.rules[position.ruleIndex];
|
|
3062
|
+
if (!group || !rule) continue;
|
|
3063
|
+
targets.push({ groupId: String(group.id), ruleId: String(rule.id) });
|
|
3064
|
+
}
|
|
3065
|
+
return targets;
|
|
3066
|
+
}
|
|
3015
3067
|
async runAIAssist(prompt) {
|
|
3016
3068
|
const handler = this.options.aiAssist;
|
|
3017
3069
|
const panel = this.aiAssistPanel;
|
|
@@ -3030,6 +3082,7 @@ var EditorControllerImpl = class {
|
|
|
3030
3082
|
diagnostics: diagnostics.length > 0 ? diagnostics : void 0
|
|
3031
3083
|
}
|
|
3032
3084
|
};
|
|
3085
|
+
this.aiRepairTargets = request.kind === "fix" && diagnostics.length > 0 ? this.repairTargetsFrom(diagnostics) : [];
|
|
3033
3086
|
panel.startStreaming("assistant");
|
|
3034
3087
|
try {
|
|
3035
3088
|
const result = handler(request);
|