react-agentic 0.0.1 → 0.0.4
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/README.md +1 -1
- package/dist/{chunk-263OAOFB.js → chunk-ILV2NZWS.js} +235 -20
- package/dist/chunk-ILV2NZWS.js.map +1 -0
- package/dist/cli/index.js +20 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +40 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-263OAOFB.js.map +0 -1
package/README.md
CHANGED
|
@@ -540,7 +540,7 @@ var init_text_extraction = __esm({
|
|
|
540
540
|
// src/parser/utils/spread-resolution.ts
|
|
541
541
|
import {
|
|
542
542
|
Node as Node13,
|
|
543
|
-
SyntaxKind as
|
|
543
|
+
SyntaxKind as SyntaxKind4
|
|
544
544
|
} from "ts-morph";
|
|
545
545
|
var init_spread_resolution = __esm({
|
|
546
546
|
"src/parser/utils/spread-resolution.ts"() {
|
|
@@ -551,7 +551,7 @@ var init_spread_resolution = __esm({
|
|
|
551
551
|
// src/parser/utils/component-resolution.ts
|
|
552
552
|
import {
|
|
553
553
|
Node as Node14,
|
|
554
|
-
SyntaxKind as
|
|
554
|
+
SyntaxKind as SyntaxKind5
|
|
555
555
|
} from "ts-morph";
|
|
556
556
|
function resolveComponentImport2(componentName, sourceFile, visitedPaths) {
|
|
557
557
|
const visited = visitedPaths ?? /* @__PURE__ */ new Set();
|
|
@@ -741,7 +741,7 @@ var init_type_resolution = __esm({
|
|
|
741
741
|
import {
|
|
742
742
|
Node as Node16
|
|
743
743
|
} from "ts-morph";
|
|
744
|
-
import { SyntaxKind as
|
|
744
|
+
import { SyntaxKind as SyntaxKind6 } from "ts-morph";
|
|
745
745
|
function extractInputObjectLiteral2(objLiteral, variables) {
|
|
746
746
|
const properties = [];
|
|
747
747
|
for (const prop of objLiteral.getProperties()) {
|
|
@@ -882,7 +882,7 @@ function analyzeRenderPropsChildren(element) {
|
|
|
882
882
|
}
|
|
883
883
|
function extractTypeArguments2(element) {
|
|
884
884
|
const openingElement = Node16.isJsxElement(element) ? element.getOpeningElement() : element;
|
|
885
|
-
const typeRefNodes = openingElement.getDescendantsOfKind(
|
|
885
|
+
const typeRefNodes = openingElement.getDescendantsOfKind(SyntaxKind6.TypeReference);
|
|
886
886
|
if (typeRefNodes.length === 0) {
|
|
887
887
|
return void 0;
|
|
888
888
|
}
|
|
@@ -3975,19 +3975,65 @@ ${node.content}
|
|
|
3975
3975
|
}
|
|
3976
3976
|
}
|
|
3977
3977
|
/**
|
|
3978
|
-
* Emit RuntimeCallNode as
|
|
3978
|
+
* Emit RuntimeCallNode as declarative table
|
|
3979
3979
|
*
|
|
3980
3980
|
* Output:
|
|
3981
|
-
*
|
|
3982
|
-
*
|
|
3983
|
-
*
|
|
3981
|
+
* **Runtime Call**: `functionName`
|
|
3982
|
+
*
|
|
3983
|
+
* | Argument | Value |
|
|
3984
|
+
* |----------|-------|
|
|
3985
|
+
* | phaseId | CTX.phaseId |
|
|
3986
|
+
* | mode | If ctx.flags.gaps then "gap_closure", otherwise "standard" |
|
|
3987
|
+
*
|
|
3988
|
+
* **Output Variable**: RESULT
|
|
3984
3989
|
*/
|
|
3985
3990
|
emitRuntimeCall(node) {
|
|
3986
|
-
const
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
+
const lines = [];
|
|
3992
|
+
lines.push(`**Runtime Call**: \`${node.fnName}\``);
|
|
3993
|
+
lines.push("");
|
|
3994
|
+
const argEntries = Object.entries(node.args);
|
|
3995
|
+
if (argEntries.length > 0) {
|
|
3996
|
+
lines.push("| Argument | Value |");
|
|
3997
|
+
lines.push("|----------|-------|");
|
|
3998
|
+
for (const [name, value] of argEntries) {
|
|
3999
|
+
const formattedValue = this.formatArgValue(value);
|
|
4000
|
+
const escapedValue = formattedValue.replace(/\|/g, "\\|");
|
|
4001
|
+
lines.push(`| ${name} | ${escapedValue} |`);
|
|
4002
|
+
}
|
|
4003
|
+
lines.push("");
|
|
4004
|
+
}
|
|
4005
|
+
lines.push(`**Output Variable**: ${node.outputVar}`);
|
|
4006
|
+
return lines.join("\n");
|
|
4007
|
+
}
|
|
4008
|
+
/**
|
|
4009
|
+
* Format a RuntimeCallArgValue for display in the arguments table
|
|
4010
|
+
*/
|
|
4011
|
+
formatArgValue(value) {
|
|
4012
|
+
switch (value.type) {
|
|
4013
|
+
case "literal":
|
|
4014
|
+
if (value.value === null) return "null";
|
|
4015
|
+
if (typeof value.value === "string") return `"${value.value}"`;
|
|
4016
|
+
return String(value.value);
|
|
4017
|
+
case "runtimeVarRef": {
|
|
4018
|
+
const { varName, path: path5 } = value.ref;
|
|
4019
|
+
if (path5.length === 0) {
|
|
4020
|
+
return varName;
|
|
4021
|
+
}
|
|
4022
|
+
return `${varName}.${path5.join(".")}`;
|
|
4023
|
+
}
|
|
4024
|
+
case "expression":
|
|
4025
|
+
return value.description;
|
|
4026
|
+
case "json": {
|
|
4027
|
+
if (Array.isArray(value.value)) {
|
|
4028
|
+
const items = value.value.map((v) => this.formatArgValue(v));
|
|
4029
|
+
return `[${items.join(", ")}]`;
|
|
4030
|
+
}
|
|
4031
|
+
const entries = Object.entries(value.value).map(([k, v]) => `${k}: ${this.formatArgValue(v)}`);
|
|
4032
|
+
return `{ ${entries.join(", ")} }`;
|
|
4033
|
+
}
|
|
4034
|
+
default:
|
|
4035
|
+
return String(value);
|
|
4036
|
+
}
|
|
3991
4037
|
}
|
|
3992
4038
|
/**
|
|
3993
4039
|
* Emit IfNode as prose conditional with jq
|
|
@@ -5277,7 +5323,7 @@ function markRuntimeFnUsed(wrapperName, ctx) {
|
|
|
5277
5323
|
import { Node as Node29 } from "ts-morph";
|
|
5278
5324
|
|
|
5279
5325
|
// src/parser/transformers/runtime-utils.ts
|
|
5280
|
-
import { Node as Node6 } from "ts-morph";
|
|
5326
|
+
import { Node as Node6, SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
5281
5327
|
function getAttributeValue2(element, attrName) {
|
|
5282
5328
|
const attr = element.getAttribute(attrName);
|
|
5283
5329
|
if (!attr || !Node6.isJsxAttribute(attr)) return void 0;
|
|
@@ -5414,6 +5460,161 @@ function extractJsonValue(expr) {
|
|
|
5414
5460
|
}
|
|
5415
5461
|
return expr.getText();
|
|
5416
5462
|
}
|
|
5463
|
+
function describeExpression(expr, ctx) {
|
|
5464
|
+
if (Node6.isConditionalExpression(expr)) {
|
|
5465
|
+
const condition = expr.getCondition();
|
|
5466
|
+
const whenTrue = expr.getWhenTrue();
|
|
5467
|
+
const whenFalse = expr.getWhenFalse();
|
|
5468
|
+
const condDesc = describeExpressionPart(condition, ctx);
|
|
5469
|
+
const trueVal = describeExpressionValue(whenTrue, ctx);
|
|
5470
|
+
const falseVal = describeExpressionValue(whenFalse, ctx);
|
|
5471
|
+
return `If ${condDesc} then ${trueVal}, otherwise ${falseVal}`;
|
|
5472
|
+
}
|
|
5473
|
+
if (Node6.isBinaryExpression(expr)) {
|
|
5474
|
+
const left = expr.getLeft();
|
|
5475
|
+
const right = expr.getRight();
|
|
5476
|
+
const op = expr.getOperatorToken().getText();
|
|
5477
|
+
const leftDesc = describeExpressionPart(left, ctx);
|
|
5478
|
+
const rightDesc = describeExpressionValue(right, ctx);
|
|
5479
|
+
switch (op) {
|
|
5480
|
+
case "===":
|
|
5481
|
+
case "==":
|
|
5482
|
+
return `${leftDesc} equals ${rightDesc}`;
|
|
5483
|
+
case "!==":
|
|
5484
|
+
case "!=":
|
|
5485
|
+
return `${leftDesc} does not equal ${rightDesc}`;
|
|
5486
|
+
case "&&":
|
|
5487
|
+
return `${leftDesc} AND ${describeExpressionPart(right, ctx)}`;
|
|
5488
|
+
case "||":
|
|
5489
|
+
return `${leftDesc} OR ${describeExpressionPart(right, ctx)}`;
|
|
5490
|
+
case ">":
|
|
5491
|
+
return `${leftDesc} is greater than ${rightDesc}`;
|
|
5492
|
+
case ">=":
|
|
5493
|
+
return `${leftDesc} is at least ${rightDesc}`;
|
|
5494
|
+
case "<":
|
|
5495
|
+
return `${leftDesc} is less than ${rightDesc}`;
|
|
5496
|
+
case "<=":
|
|
5497
|
+
return `${leftDesc} is at most ${rightDesc}`;
|
|
5498
|
+
default:
|
|
5499
|
+
return expr.getText();
|
|
5500
|
+
}
|
|
5501
|
+
}
|
|
5502
|
+
if (Node6.isPrefixUnaryExpression(expr)) {
|
|
5503
|
+
const opToken = expr.getOperatorToken();
|
|
5504
|
+
const operand = expr.getOperand();
|
|
5505
|
+
if (opToken === SyntaxKind2.ExclamationToken) {
|
|
5506
|
+
return `NOT ${describeExpressionPart(operand, ctx)}`;
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5509
|
+
return expr.getText();
|
|
5510
|
+
}
|
|
5511
|
+
function describeExpressionPart(expr, ctx) {
|
|
5512
|
+
const ref = parseRuntimeVarRef(expr, ctx);
|
|
5513
|
+
if (ref) {
|
|
5514
|
+
const path5 = ref.path.length === 0 ? ref.varName : `${ref.varName}.${ref.path.join(".")}`;
|
|
5515
|
+
return path5;
|
|
5516
|
+
}
|
|
5517
|
+
if (Node6.isBinaryExpression(expr)) {
|
|
5518
|
+
return describeExpression(expr, ctx);
|
|
5519
|
+
}
|
|
5520
|
+
return expr.getText();
|
|
5521
|
+
}
|
|
5522
|
+
function describeExpressionValue(expr, ctx) {
|
|
5523
|
+
if (Node6.isStringLiteral(expr)) {
|
|
5524
|
+
return `"${expr.getLiteralValue()}"`;
|
|
5525
|
+
}
|
|
5526
|
+
if (Node6.isNumericLiteral(expr)) {
|
|
5527
|
+
return expr.getLiteralText();
|
|
5528
|
+
}
|
|
5529
|
+
if (Node6.isTrueLiteral(expr)) {
|
|
5530
|
+
return "true";
|
|
5531
|
+
}
|
|
5532
|
+
if (Node6.isFalseLiteral(expr)) {
|
|
5533
|
+
return "false";
|
|
5534
|
+
}
|
|
5535
|
+
if (Node6.isNullLiteral(expr)) {
|
|
5536
|
+
return "null";
|
|
5537
|
+
}
|
|
5538
|
+
const ref = parseRuntimeVarRef(expr, ctx);
|
|
5539
|
+
if (ref) {
|
|
5540
|
+
const path5 = ref.path.length === 0 ? ref.varName : `${ref.varName}.${ref.path.join(".")}`;
|
|
5541
|
+
return path5;
|
|
5542
|
+
}
|
|
5543
|
+
return expr.getText();
|
|
5544
|
+
}
|
|
5545
|
+
function extractRuntimeCallArg(expr, ctx) {
|
|
5546
|
+
const ref = parseRuntimeVarRef(expr, ctx);
|
|
5547
|
+
if (ref) {
|
|
5548
|
+
return { type: "runtimeVarRef", ref };
|
|
5549
|
+
}
|
|
5550
|
+
if (Node6.isStringLiteral(expr)) {
|
|
5551
|
+
return { type: "literal", value: expr.getLiteralValue() };
|
|
5552
|
+
}
|
|
5553
|
+
if (Node6.isNumericLiteral(expr)) {
|
|
5554
|
+
return { type: "literal", value: Number(expr.getLiteralText()) };
|
|
5555
|
+
}
|
|
5556
|
+
if (Node6.isTrueLiteral(expr)) {
|
|
5557
|
+
return { type: "literal", value: true };
|
|
5558
|
+
}
|
|
5559
|
+
if (Node6.isFalseLiteral(expr)) {
|
|
5560
|
+
return { type: "literal", value: false };
|
|
5561
|
+
}
|
|
5562
|
+
if (Node6.isNullLiteral(expr)) {
|
|
5563
|
+
return { type: "literal", value: null };
|
|
5564
|
+
}
|
|
5565
|
+
if (Node6.isNoSubstitutionTemplateLiteral(expr)) {
|
|
5566
|
+
return { type: "literal", value: expr.getLiteralValue() };
|
|
5567
|
+
}
|
|
5568
|
+
if (Node6.isObjectLiteralExpression(expr)) {
|
|
5569
|
+
const nested = {};
|
|
5570
|
+
for (const prop of expr.getProperties()) {
|
|
5571
|
+
if (Node6.isPropertyAssignment(prop)) {
|
|
5572
|
+
const name = prop.getName();
|
|
5573
|
+
const value = prop.getInitializer();
|
|
5574
|
+
if (value) {
|
|
5575
|
+
nested[name] = extractRuntimeCallArg(value, ctx);
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
return { type: "json", value: nested };
|
|
5580
|
+
}
|
|
5581
|
+
if (Node6.isArrayLiteralExpression(expr)) {
|
|
5582
|
+
const items = expr.getElements().map((el) => extractRuntimeCallArg(el, ctx));
|
|
5583
|
+
return { type: "json", value: items };
|
|
5584
|
+
}
|
|
5585
|
+
if (Node6.isConditionalExpression(expr) || Node6.isBinaryExpression(expr) || Node6.isPrefixUnaryExpression(expr)) {
|
|
5586
|
+
return {
|
|
5587
|
+
type: "expression",
|
|
5588
|
+
source: expr.getText(),
|
|
5589
|
+
description: describeExpression(expr, ctx)
|
|
5590
|
+
};
|
|
5591
|
+
}
|
|
5592
|
+
return {
|
|
5593
|
+
type: "expression",
|
|
5594
|
+
source: expr.getText(),
|
|
5595
|
+
description: expr.getText()
|
|
5596
|
+
};
|
|
5597
|
+
}
|
|
5598
|
+
function extractRuntimeCallArgs(objExpr, ctx) {
|
|
5599
|
+
if (!Node6.isObjectLiteralExpression(objExpr)) {
|
|
5600
|
+
throw new Error("args must be an object literal");
|
|
5601
|
+
}
|
|
5602
|
+
const result = {};
|
|
5603
|
+
for (const prop of objExpr.getProperties()) {
|
|
5604
|
+
if (Node6.isPropertyAssignment(prop)) {
|
|
5605
|
+
const name = prop.getName();
|
|
5606
|
+
const value = prop.getInitializer();
|
|
5607
|
+
if (value) {
|
|
5608
|
+
result[name] = extractRuntimeCallArg(value, ctx);
|
|
5609
|
+
}
|
|
5610
|
+
} else if (Node6.isShorthandPropertyAssignment(prop)) {
|
|
5611
|
+
const name = prop.getName();
|
|
5612
|
+
const nameNode = prop.getNameNode();
|
|
5613
|
+
result[name] = extractRuntimeCallArg(nameNode, ctx);
|
|
5614
|
+
}
|
|
5615
|
+
}
|
|
5616
|
+
return result;
|
|
5617
|
+
}
|
|
5417
5618
|
function getJsxElementName(node) {
|
|
5418
5619
|
if (Node6.isJsxElement(node)) {
|
|
5419
5620
|
return node.getOpeningElement().getTagNameNode().getText();
|
|
@@ -5447,11 +5648,11 @@ function processIfElseSiblings(jsxChildren, ifIndex, onElseFound) {
|
|
|
5447
5648
|
}
|
|
5448
5649
|
|
|
5449
5650
|
// src/parser/transformers/runtime-control.ts
|
|
5450
|
-
import { Node as Node7, SyntaxKind as
|
|
5651
|
+
import { Node as Node7, SyntaxKind as SyntaxKind3 } from "ts-morph";
|
|
5451
5652
|
function parseConditionExpression(node, ctx) {
|
|
5452
5653
|
if (Node7.isPrefixUnaryExpression(node)) {
|
|
5453
5654
|
const operatorText = node.getOperatorToken();
|
|
5454
|
-
if (operatorText ===
|
|
5655
|
+
if (operatorText === SyntaxKind3.ExclamationToken) {
|
|
5455
5656
|
const operand = node.getOperand();
|
|
5456
5657
|
return {
|
|
5457
5658
|
type: "not",
|
|
@@ -5701,7 +5902,7 @@ function transformRuntimeCall(node, ctx) {
|
|
|
5701
5902
|
}
|
|
5702
5903
|
let args;
|
|
5703
5904
|
if (Node8.isObjectLiteralExpression(argsExpr)) {
|
|
5704
|
-
args =
|
|
5905
|
+
args = extractRuntimeCallArgs(argsExpr, ctx);
|
|
5705
5906
|
} else {
|
|
5706
5907
|
throw ctx.createError(
|
|
5707
5908
|
`${wrapperName}.Call args must be an object literal`,
|
|
@@ -6727,10 +6928,24 @@ function transformRuntimeIndent(node, ctx) {
|
|
|
6727
6928
|
}
|
|
6728
6929
|
function transformRuntimeCodeBlock(node, ctx) {
|
|
6729
6930
|
const openingElement = Node29.isJsxElement(node) ? node.getOpeningElement() : node;
|
|
6730
|
-
|
|
6931
|
+
let language = getAttributeValue2(openingElement, "lang") || getAttributeValue2(openingElement, "language");
|
|
6731
6932
|
if (Node29.isJsxSelfClosingElement(node)) {
|
|
6732
6933
|
return { kind: "codeBlock", language, content: "" };
|
|
6733
6934
|
}
|
|
6935
|
+
const children = node.getJsxChildren();
|
|
6936
|
+
for (const child of children) {
|
|
6937
|
+
if (Node29.isJsxElement(child) && getElementName2(child) === "code") {
|
|
6938
|
+
const codeOpening = child.getOpeningElement();
|
|
6939
|
+
const codeClassName = getAttributeValue2(codeOpening, "className");
|
|
6940
|
+
const codeLanguage = codeClassName?.replace(/^language-/, "") || language;
|
|
6941
|
+
const content2 = extractCodeContentWithProps(child, ctx);
|
|
6942
|
+
return { kind: "codeBlock", language: codeLanguage, content: content2 };
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6945
|
+
const content = extractCodeContentWithProps(node, ctx);
|
|
6946
|
+
return { kind: "codeBlock", language, content };
|
|
6947
|
+
}
|
|
6948
|
+
function extractCodeContentWithProps(node, ctx) {
|
|
6734
6949
|
const parts = [];
|
|
6735
6950
|
for (const child of node.getJsxChildren()) {
|
|
6736
6951
|
if (Node29.isJsxText(child)) {
|
|
@@ -6793,7 +7008,7 @@ function transformRuntimeCodeBlock(node, ctx) {
|
|
|
6793
7008
|
content = lines.map((line) => line.slice(minIndent)).join("\n");
|
|
6794
7009
|
}
|
|
6795
7010
|
}
|
|
6796
|
-
return
|
|
7011
|
+
return content;
|
|
6797
7012
|
}
|
|
6798
7013
|
function transformToRuntimeBlock(node, ctx) {
|
|
6799
7014
|
if (Node29.isJsxText(node)) {
|
|
@@ -7900,4 +8115,4 @@ export {
|
|
|
7900
8115
|
getSourceCode,
|
|
7901
8116
|
formatTranspileError
|
|
7902
8117
|
};
|
|
7903
|
-
//# sourceMappingURL=chunk-
|
|
8118
|
+
//# sourceMappingURL=chunk-ILV2NZWS.js.map
|