@userreason/wizard 0.2.0 → 0.2.1
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/agent-note.js +2 -2
- package/dist/bin.js +3 -3
- package/dist/{chunk-6DCCEVPD.js → chunk-5SC2K42Q.js} +31 -9
- package/dist/{chunk-KV6GSBTQ.js → chunk-ULHKVBPD.js} +1 -1
- package/dist/{chunk-FC7PZNYW.js → chunk-ZGZOBW2B.js} +1 -1
- package/dist/integrate.js +1 -1
- package/dist/state.js +2 -2
- package/package.json +1 -1
package/dist/agent-note.js
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
applyAgentNote,
|
|
4
4
|
offerAgentNote,
|
|
5
5
|
planAgentNote
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ULHKVBPD.js";
|
|
7
7
|
import "./chunk-SJVLAYGG.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-5SC2K42Q.js";
|
|
9
9
|
import "./chunk-YMSGDC4B.js";
|
|
10
10
|
import "./chunk-OEGNGGZ2.js";
|
|
11
11
|
import "./chunk-GGARVSPT.js";
|
package/dist/bin.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire as createWizardRequire } from 'node:module'; import { fil
|
|
|
3
3
|
import {
|
|
4
4
|
offerAgentNote,
|
|
5
5
|
planAgentNote
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ULHKVBPD.js";
|
|
7
7
|
import {
|
|
8
8
|
offerAgentSkill,
|
|
9
9
|
planAgentSkill
|
|
@@ -37,14 +37,14 @@ import {
|
|
|
37
37
|
resolveInstallation,
|
|
38
38
|
saveInstallation,
|
|
39
39
|
savedInstallation
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-ZGZOBW2B.js";
|
|
41
41
|
import {
|
|
42
42
|
applyIntegration,
|
|
43
43
|
detectInstallation,
|
|
44
44
|
integrationAdditions,
|
|
45
45
|
integrationPreview,
|
|
46
46
|
planIntegration
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-5SC2K42Q.js";
|
|
48
48
|
import {
|
|
49
49
|
SdkInstallError,
|
|
50
50
|
cliCommand,
|
|
@@ -673,8 +673,26 @@ function reactRoots(ast) {
|
|
|
673
673
|
if (!creationCount && renders.length > 1) return [];
|
|
674
674
|
return renders.flatMap((node) => node.arguments[0] ? [node.arguments[0]] : []);
|
|
675
675
|
}
|
|
676
|
-
function
|
|
677
|
-
const
|
|
676
|
+
function integrationReferences(ast) {
|
|
677
|
+
const modules = nodes(ast, import_typescript.default.isStringLiteral).filter((literal) => {
|
|
678
|
+
const parent = literal.parent;
|
|
679
|
+
return (import_typescript.default.isImportDeclaration(parent) || import_typescript.default.isExportDeclaration(parent)) && parent.moduleSpecifier === literal || import_typescript.default.isExternalModuleReference(parent) && parent.expression === literal || import_typescript.default.isCallExpression(parent) && parent.arguments[0] === literal && (parent.expression.kind === import_typescript.default.SyntaxKind.ImportKeyword || import_typescript.default.isIdentifier(parent.expression) && parent.expression.text === "require");
|
|
680
|
+
}).map((literal) => literal.text);
|
|
681
|
+
const tags = nodes(ast, (node) => import_typescript.default.isJsxOpeningElement(node) || import_typescript.default.isJsxSelfClosingElement(node)).map((node) => node.tagName.getText(ast));
|
|
682
|
+
const globalAccess = nodes(ast, import_typescript.default.isElementAccessExpression).some((node) => import_typescript.default.isIdentifier(node.expression) && ["window", "globalThis", "self", "global"].includes(node.expression.text) && import_typescript.default.isStringLiteralLike(node.argumentExpression) && node.argumentExpression.text === "UserReason");
|
|
683
|
+
const identifier = nodes(ast, import_typescript.default.isIdentifier).some((node) => {
|
|
684
|
+
if (node.text !== "UserReason") return false;
|
|
685
|
+
const parent = node.parent;
|
|
686
|
+
if ((import_typescript.default.isPropertyAssignment(parent) || import_typescript.default.isPropertyDeclaration(parent) || import_typescript.default.isPropertySignature(parent) || import_typescript.default.isMethodDeclaration(parent) || import_typescript.default.isMethodSignature(parent) || import_typescript.default.isGetAccessorDeclaration(parent) || import_typescript.default.isSetAccessorDeclaration(parent) || import_typescript.default.isJsxAttribute(parent)) && parent.name === node) return false;
|
|
687
|
+
if ((import_typescript.default.isBindingElement(parent) || import_typescript.default.isImportSpecifier(parent)) && parent.propertyName === node) return false;
|
|
688
|
+
if (import_typescript.default.isExportSpecifier(parent) && parent.name === node && parent.propertyName) return false;
|
|
689
|
+
if (import_typescript.default.isLabeledStatement(parent) || import_typescript.default.isBreakStatement(parent) || import_typescript.default.isContinueStatement(parent)) return false;
|
|
690
|
+
return true;
|
|
691
|
+
});
|
|
692
|
+
return { modules, tags, identifier: identifier || globalAccess };
|
|
693
|
+
}
|
|
694
|
+
function existing(text, config = dummy, path = "entry.tsx") {
|
|
695
|
+
const ast = parse(path, text), calls = ast ? sdkCalls(ast) : [];
|
|
678
696
|
if (calls.length) {
|
|
679
697
|
try {
|
|
680
698
|
let first;
|
|
@@ -690,11 +708,13 @@ function existing(text, config = dummy) {
|
|
|
690
708
|
}
|
|
691
709
|
return { status: "integrated", reason: "SDK initialization is already present; its configuration is preserved." };
|
|
692
710
|
}
|
|
693
|
-
if (
|
|
711
|
+
if (!ast) return;
|
|
712
|
+
const references = integrationReferences(ast);
|
|
713
|
+
if (references.modules.some((name) => /userreason\.generated/.test(name)) && references.tags.includes("UserReasonProvider"))
|
|
694
714
|
return { status: "integrated", reason: "Existing generated initialization is already present." };
|
|
695
|
-
if (/userreason\.client/.test(
|
|
715
|
+
if (references.modules.some((name) => /userreason\.client/.test(name)) && references.tags.includes("UserReasonInit"))
|
|
696
716
|
return { status: "integrated", reason: "Browser initialization is already present." };
|
|
697
|
-
if (
|
|
717
|
+
if (references.identifier || references.modules.some((name) => name === "@userreason/js" || /userreason\.(?:generated|client)/.test(name)))
|
|
698
718
|
return { status: "manual", reason: "An existing UserReason integration needs review before editing the entry." };
|
|
699
719
|
}
|
|
700
720
|
async function planIntegration(project, config = dummy) {
|
|
@@ -716,11 +736,13 @@ async function planIntegration(project, config = dummy) {
|
|
|
716
736
|
const found2 = files.filter((value) => value.text !== void 0);
|
|
717
737
|
if (found2.length > 1) return { status: "manual", reason: "Multiple instrumentation-client files need review." };
|
|
718
738
|
for (const root of ["app/layout.tsx", "app/layout.jsx", "app/layout.js", "pages/_app.tsx", "pages/_app.jsx", "pages/_app.js"]) {
|
|
719
|
-
const rootText = await source(project,
|
|
720
|
-
|
|
739
|
+
const rootPath = join(directory, root), rootText = await source(project, rootPath);
|
|
740
|
+
const rootAst = rootText ? parse(rootPath, rootText) : void 0;
|
|
741
|
+
if (rootText && rootAst && integrationReferences(rootAst).modules.some((name2) => /userreason\.(?:generated|client)/.test(name2)))
|
|
742
|
+
return existing(rootText, dummy, rootPath) ?? { status: "manual", reason: "Existing root initialization needs review." };
|
|
721
743
|
}
|
|
722
744
|
const { path: path2, text: text2 } = found2[0] ?? files[project.typescript ? 0 : 1];
|
|
723
|
-
const current2 = text2 ? existing(text2, config) : void 0;
|
|
745
|
+
const current2 = text2 ? existing(text2, config, path2) : void 0;
|
|
724
746
|
if (current2) return current2;
|
|
725
747
|
const ast = parse(path2, text2 ?? "");
|
|
726
748
|
if (!ast) return { status: "manual", reason: "Client instrumentation could not be parsed safely." };
|
|
@@ -776,7 +798,7 @@ ${initializationSource(config)}`),
|
|
|
776
798
|
};
|
|
777
799
|
const { path, text } = found[0];
|
|
778
800
|
const name = project.framework === "next" ? "UserReasonInit" : "UserReason";
|
|
779
|
-
const current = existing(text, config);
|
|
801
|
+
const current = existing(text, config, path);
|
|
780
802
|
if (current) return current;
|
|
781
803
|
let after;
|
|
782
804
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as createWizardRequire } from 'node:module'; import { fileURLToPath as wizardFileURLToPath } from 'node:url'; import { dirname as wizardDirname } from 'node:path'; const require = createWizardRequire(import.meta.url); const __filename = wizardFileURLToPath(import.meta.url); const __dirname = wizardDirname(__filename);
|
|
2
2
|
import {
|
|
3
3
|
detectInstallation
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5SC2K42Q.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_API
|
|
7
7
|
} from "./chunk-YMSGDC4B.js";
|
package/dist/integrate.js
CHANGED
package/dist/state.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
resolveInstallation,
|
|
5
5
|
saveInstallation,
|
|
6
6
|
savedInstallation
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-ZGZOBW2B.js";
|
|
8
|
+
import "./chunk-5SC2K42Q.js";
|
|
9
9
|
import "./chunk-YMSGDC4B.js";
|
|
10
10
|
import "./chunk-OEGNGGZ2.js";
|
|
11
11
|
import "./chunk-GGARVSPT.js";
|