@nshiab/setup-data-project 1.0.37 → 1.0.39
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,
|
|
1
|
+
{"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,QAiJvD"}
|
|
@@ -6,21 +6,24 @@ export function ensureAgents(docsMapping, runtime, installedPackages = Object.ke
|
|
|
6
6
|
let sdaClassesAndMethods = "";
|
|
7
7
|
let sdaDocsPath = "";
|
|
8
8
|
let sdaLibraryName = "";
|
|
9
|
+
const journalismFunctionsByPackage = new Map();
|
|
9
10
|
for (const [pkg, doc] of Object.entries(docsMapping)) {
|
|
10
11
|
const pkgConfig = SUPPORTED_PACKAGES.find((p) => p.value === pkg);
|
|
11
12
|
const pkgType = pkgConfig?.type || "other";
|
|
12
13
|
if (pkgType === "journalism") {
|
|
13
14
|
const repoName = pkg.split("/")[1];
|
|
14
|
-
|
|
15
|
-
journalismFunctions += doc
|
|
15
|
+
const functions = doc
|
|
16
16
|
.split("\n")
|
|
17
17
|
.filter((line) => line.trim().startsWith("#"))
|
|
18
18
|
.filter((line) => {
|
|
19
19
|
const depth = line.match(/^#+/)?.[0].length || 0;
|
|
20
|
-
return depth
|
|
20
|
+
return depth === 2;
|
|
21
21
|
})
|
|
22
|
-
.map((line) => line.replace(/^#+\s+/, "").trim())
|
|
23
|
-
|
|
22
|
+
.map((line) => line.replace(/^#+\s+/, "").trim());
|
|
23
|
+
journalismFunctionsByPackage.set(pkg, functions);
|
|
24
|
+
journalismFunctions += `\n### ${repoName}\n\n`;
|
|
25
|
+
journalismFunctions += functions.map((name) => `- ${name}`).join("\n") +
|
|
26
|
+
"\n";
|
|
24
27
|
}
|
|
25
28
|
else if (pkgType === "sda") {
|
|
26
29
|
const repoName = pkg.split("/")[1];
|
|
@@ -31,7 +34,13 @@ export function ensureAgents(docsMapping, runtime, installedPackages = Object.ke
|
|
|
31
34
|
.filter((line) => line.trim().startsWith("#"))
|
|
32
35
|
.filter((line) => {
|
|
33
36
|
const depth = line.match(/^#+/)?.[0].length || 0;
|
|
34
|
-
|
|
37
|
+
if (depth === 2)
|
|
38
|
+
return true;
|
|
39
|
+
if (depth !== 4)
|
|
40
|
+
return false;
|
|
41
|
+
const heading = line.replace(/^#+\s+/, "").replaceAll("`", "")
|
|
42
|
+
.trim();
|
|
43
|
+
return heading !== "Parameters";
|
|
35
44
|
})
|
|
36
45
|
.map((line) => {
|
|
37
46
|
const depth = line.match(/^#+/)?.[0].length || 0;
|
|
@@ -39,8 +48,7 @@ export function ensureAgents(docsMapping, runtime, installedPackages = Object.ke
|
|
|
39
48
|
return "\n" + line.replace(/^#+\s+/, "").trim();
|
|
40
49
|
}
|
|
41
50
|
else {
|
|
42
|
-
return line.replace(/^#+\s
|
|
43
|
-
.replace(/^#+\s+/, " - ")
|
|
51
|
+
return line.replace(/^#+\s+/, " - ")
|
|
44
52
|
.replaceAll("`", "");
|
|
45
53
|
}
|
|
46
54
|
})
|
|
@@ -60,21 +68,34 @@ export function ensureAgents(docsMapping, runtime, installedPackages = Object.ke
|
|
|
60
68
|
? "bun run all-tests"
|
|
61
69
|
: "npm run all-tests";
|
|
62
70
|
const installedPackageConfigs = getInstalledPackageConfigs(installedPackages);
|
|
63
|
-
const importExamples = installedPackageConfigs.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
const importExamples = installedPackageConfigs.flatMap((pkg) => {
|
|
72
|
+
if (pkg.type === "sda") {
|
|
73
|
+
return [`import { SimpleDB } from "${pkg.value}";`];
|
|
74
|
+
}
|
|
75
|
+
const functionName = journalismFunctionsByPackage.get(pkg.value)
|
|
76
|
+
?.map((name) => name.replaceAll("`", ""))
|
|
77
|
+
.find((name) => /^[A-Za-z_$][\w$]*$/.test(name));
|
|
78
|
+
return functionName
|
|
79
|
+
? [`import { ${functionName} } from "${pkg.value}";`]
|
|
80
|
+
: [];
|
|
67
81
|
});
|
|
68
82
|
let libraryGuidance = "";
|
|
69
83
|
if (installedPackageConfigs.length > 0) {
|
|
70
|
-
const libraryNames = installedPackageConfigs.map((pkg) => `"${pkg.
|
|
84
|
+
const libraryNames = installedPackageConfigs.map((pkg) => `"${pkg.value}"`)
|
|
71
85
|
.join(", ");
|
|
86
|
+
const libraryNoun = installedPackageConfigs.length === 1
|
|
87
|
+
? "library"
|
|
88
|
+
: "libraries";
|
|
72
89
|
libraryGuidance = `
|
|
73
|
-
Always prioritize the installed ${libraryNames}
|
|
90
|
+
Always prioritize the installed ${libraryNames} ${libraryNoun} when relevant.
|
|
91
|
+
`;
|
|
92
|
+
if (importExamples.length > 0) {
|
|
93
|
+
libraryGuidance += `APIs can be imported with named imports like this:
|
|
74
94
|
\`\`\`typescript
|
|
75
95
|
${importExamples.join("\n")}
|
|
76
96
|
\`\`\`
|
|
77
97
|
`;
|
|
98
|
+
}
|
|
78
99
|
}
|
|
79
100
|
let content = `Always verify if there is a ${configFile} file in the root of the project and familiarize yourself with the scripts available in it and the libraries already installed in the project.
|
|
80
101
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,
|
|
1
|
+
{"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,QAiJvD"}
|
|
@@ -9,21 +9,24 @@ function ensureAgents(docsMapping, runtime, installedPackages = Object.keys(docs
|
|
|
9
9
|
let sdaClassesAndMethods = "";
|
|
10
10
|
let sdaDocsPath = "";
|
|
11
11
|
let sdaLibraryName = "";
|
|
12
|
+
const journalismFunctionsByPackage = new Map();
|
|
12
13
|
for (const [pkg, doc] of Object.entries(docsMapping)) {
|
|
13
14
|
const pkgConfig = packageRegistry_js_1.SUPPORTED_PACKAGES.find((p) => p.value === pkg);
|
|
14
15
|
const pkgType = pkgConfig?.type || "other";
|
|
15
16
|
if (pkgType === "journalism") {
|
|
16
17
|
const repoName = pkg.split("/")[1];
|
|
17
|
-
|
|
18
|
-
journalismFunctions += doc
|
|
18
|
+
const functions = doc
|
|
19
19
|
.split("\n")
|
|
20
20
|
.filter((line) => line.trim().startsWith("#"))
|
|
21
21
|
.filter((line) => {
|
|
22
22
|
const depth = line.match(/^#+/)?.[0].length || 0;
|
|
23
|
-
return depth
|
|
23
|
+
return depth === 2;
|
|
24
24
|
})
|
|
25
|
-
.map((line) => line.replace(/^#+\s+/, "").trim())
|
|
26
|
-
|
|
25
|
+
.map((line) => line.replace(/^#+\s+/, "").trim());
|
|
26
|
+
journalismFunctionsByPackage.set(pkg, functions);
|
|
27
|
+
journalismFunctions += `\n### ${repoName}\n\n`;
|
|
28
|
+
journalismFunctions += functions.map((name) => `- ${name}`).join("\n") +
|
|
29
|
+
"\n";
|
|
27
30
|
}
|
|
28
31
|
else if (pkgType === "sda") {
|
|
29
32
|
const repoName = pkg.split("/")[1];
|
|
@@ -34,7 +37,13 @@ function ensureAgents(docsMapping, runtime, installedPackages = Object.keys(docs
|
|
|
34
37
|
.filter((line) => line.trim().startsWith("#"))
|
|
35
38
|
.filter((line) => {
|
|
36
39
|
const depth = line.match(/^#+/)?.[0].length || 0;
|
|
37
|
-
|
|
40
|
+
if (depth === 2)
|
|
41
|
+
return true;
|
|
42
|
+
if (depth !== 4)
|
|
43
|
+
return false;
|
|
44
|
+
const heading = line.replace(/^#+\s+/, "").replaceAll("`", "")
|
|
45
|
+
.trim();
|
|
46
|
+
return heading !== "Parameters";
|
|
38
47
|
})
|
|
39
48
|
.map((line) => {
|
|
40
49
|
const depth = line.match(/^#+/)?.[0].length || 0;
|
|
@@ -42,8 +51,7 @@ function ensureAgents(docsMapping, runtime, installedPackages = Object.keys(docs
|
|
|
42
51
|
return "\n" + line.replace(/^#+\s+/, "").trim();
|
|
43
52
|
}
|
|
44
53
|
else {
|
|
45
|
-
return line.replace(/^#+\s
|
|
46
|
-
.replace(/^#+\s+/, " - ")
|
|
54
|
+
return line.replace(/^#+\s+/, " - ")
|
|
47
55
|
.replaceAll("`", "");
|
|
48
56
|
}
|
|
49
57
|
})
|
|
@@ -63,21 +71,34 @@ function ensureAgents(docsMapping, runtime, installedPackages = Object.keys(docs
|
|
|
63
71
|
? "bun run all-tests"
|
|
64
72
|
: "npm run all-tests";
|
|
65
73
|
const installedPackageConfigs = (0, packageRegistry_js_1.getInstalledPackageConfigs)(installedPackages);
|
|
66
|
-
const importExamples = installedPackageConfigs.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
const importExamples = installedPackageConfigs.flatMap((pkg) => {
|
|
75
|
+
if (pkg.type === "sda") {
|
|
76
|
+
return [`import { SimpleDB } from "${pkg.value}";`];
|
|
77
|
+
}
|
|
78
|
+
const functionName = journalismFunctionsByPackage.get(pkg.value)
|
|
79
|
+
?.map((name) => name.replaceAll("`", ""))
|
|
80
|
+
.find((name) => /^[A-Za-z_$][\w$]*$/.test(name));
|
|
81
|
+
return functionName
|
|
82
|
+
? [`import { ${functionName} } from "${pkg.value}";`]
|
|
83
|
+
: [];
|
|
70
84
|
});
|
|
71
85
|
let libraryGuidance = "";
|
|
72
86
|
if (installedPackageConfigs.length > 0) {
|
|
73
|
-
const libraryNames = installedPackageConfigs.map((pkg) => `"${pkg.
|
|
87
|
+
const libraryNames = installedPackageConfigs.map((pkg) => `"${pkg.value}"`)
|
|
74
88
|
.join(", ");
|
|
89
|
+
const libraryNoun = installedPackageConfigs.length === 1
|
|
90
|
+
? "library"
|
|
91
|
+
: "libraries";
|
|
75
92
|
libraryGuidance = `
|
|
76
|
-
Always prioritize the installed ${libraryNames}
|
|
93
|
+
Always prioritize the installed ${libraryNames} ${libraryNoun} when relevant.
|
|
94
|
+
`;
|
|
95
|
+
if (importExamples.length > 0) {
|
|
96
|
+
libraryGuidance += `APIs can be imported with named imports like this:
|
|
77
97
|
\`\`\`typescript
|
|
78
98
|
${importExamples.join("\n")}
|
|
79
99
|
\`\`\`
|
|
80
100
|
`;
|
|
101
|
+
}
|
|
81
102
|
}
|
|
82
103
|
let content = `Always verify if there is a ${configFile} file in the root of the project and familiarize yourself with the scripts available in it and the libraries already installed in the project.
|
|
83
104
|
|