@codedrifters/configulator 0.0.178 → 0.0.179
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/lib/index.d.mts +20 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +109 -22
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +114 -27
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.mts
CHANGED
|
@@ -388,6 +388,19 @@ interface AgentRuleBundle {
|
|
|
388
388
|
* @example (project) => Vitest.of(project) !== undefined
|
|
389
389
|
*/
|
|
390
390
|
readonly appliesWhen: (project: Project) => boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Optional. When set, returns the list of projects (root and/or
|
|
393
|
+
* subprojects) that matched this bundle's detection predicate. Enables
|
|
394
|
+
* AgentConfig to narrow each rule's `filePatterns` to the outdirs of
|
|
395
|
+
* those projects instead of the bundle's original repo-wide patterns.
|
|
396
|
+
*
|
|
397
|
+
* Bundles that provide `FILE_PATTERN`-scoped rules about TypeScript or
|
|
398
|
+
* TypeScript-adjacent code (e.g. typescript, aws-cdk, vitest, jest) should
|
|
399
|
+
* implement this so their rules only activate for files in the packages
|
|
400
|
+
* that actually use them.
|
|
401
|
+
* @example (project) => findProjectsWithFile(project, 'tsconfig.json')
|
|
402
|
+
*/
|
|
403
|
+
readonly findApplicableProjects?: (project: Project) => ReadonlyArray<Project>;
|
|
391
404
|
/** Rules included in this bundle. */
|
|
392
405
|
readonly rules: ReadonlyArray<AgentRule>;
|
|
393
406
|
/** Skills included in this bundle (cross-platform where supported). */
|
|
@@ -836,6 +849,13 @@ declare class AgentConfig extends Component {
|
|
|
836
849
|
preSynthesize(): void;
|
|
837
850
|
private resolvePlatforms;
|
|
838
851
|
private resolveRules;
|
|
852
|
+
/**
|
|
853
|
+
* Return a bundle's rules with `filePatterns` narrowed to the projects
|
|
854
|
+
* that actually matched the bundle's detection predicate (when the bundle
|
|
855
|
+
* provides `findApplicableProjects`). Rules with `ALWAYS` scope and rules
|
|
856
|
+
* on bundles that don't implement the hook are returned unchanged.
|
|
857
|
+
*/
|
|
858
|
+
private bundleRulesFor;
|
|
839
859
|
private resolveSkills;
|
|
840
860
|
private resolveSubAgents;
|
|
841
861
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -437,6 +437,19 @@ interface AgentRuleBundle {
|
|
|
437
437
|
* @example (project) => Vitest.of(project) !== undefined
|
|
438
438
|
*/
|
|
439
439
|
readonly appliesWhen: (project: Project$1) => boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Optional. When set, returns the list of projects (root and/or
|
|
442
|
+
* subprojects) that matched this bundle's detection predicate. Enables
|
|
443
|
+
* AgentConfig to narrow each rule's `filePatterns` to the outdirs of
|
|
444
|
+
* those projects instead of the bundle's original repo-wide patterns.
|
|
445
|
+
*
|
|
446
|
+
* Bundles that provide `FILE_PATTERN`-scoped rules about TypeScript or
|
|
447
|
+
* TypeScript-adjacent code (e.g. typescript, aws-cdk, vitest, jest) should
|
|
448
|
+
* implement this so their rules only activate for files in the packages
|
|
449
|
+
* that actually use them.
|
|
450
|
+
* @example (project) => findProjectsWithFile(project, 'tsconfig.json')
|
|
451
|
+
*/
|
|
452
|
+
readonly findApplicableProjects?: (project: Project$1) => ReadonlyArray<Project$1>;
|
|
440
453
|
/** Rules included in this bundle. */
|
|
441
454
|
readonly rules: ReadonlyArray<AgentRule>;
|
|
442
455
|
/** Skills included in this bundle (cross-platform where supported). */
|
|
@@ -885,6 +898,13 @@ declare class AgentConfig extends Component {
|
|
|
885
898
|
preSynthesize(): void;
|
|
886
899
|
private resolvePlatforms;
|
|
887
900
|
private resolveRules;
|
|
901
|
+
/**
|
|
902
|
+
* Return a bundle's rules with `filePatterns` narrowed to the projects
|
|
903
|
+
* that actually matched the bundle's detection predicate (when the bundle
|
|
904
|
+
* provides `findApplicableProjects`). Rules with `ALWAYS` scope and rules
|
|
905
|
+
* on bundles that don't implement the hook are returned unchanged.
|
|
906
|
+
*/
|
|
907
|
+
private bundleRulesFor;
|
|
888
908
|
private resolveSkills;
|
|
889
909
|
private resolveSubAgents;
|
|
890
910
|
/**
|
package/lib/index.js
CHANGED
|
@@ -256,23 +256,50 @@ var MCP_TRANSPORT = {
|
|
|
256
256
|
};
|
|
257
257
|
|
|
258
258
|
// src/agent/bundles/utils.ts
|
|
259
|
+
function findProjectsWithComponent(project, ctor) {
|
|
260
|
+
const out = [];
|
|
261
|
+
if (project.components.some((c) => c instanceof ctor)) {
|
|
262
|
+
out.push(project);
|
|
263
|
+
}
|
|
264
|
+
for (const sub of project.subprojects) {
|
|
265
|
+
if (sub.components.some((c) => c instanceof ctor)) {
|
|
266
|
+
out.push(sub);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
function findProjectsWithDep(project, name) {
|
|
272
|
+
const out = [];
|
|
273
|
+
if (project.deps.all.some((d) => d.name === name)) {
|
|
274
|
+
out.push(project);
|
|
275
|
+
}
|
|
276
|
+
for (const sub of project.subprojects) {
|
|
277
|
+
if (sub.deps.all.some((d) => d.name === name)) {
|
|
278
|
+
out.push(sub);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
}
|
|
283
|
+
function findProjectsWithFile(project, filename) {
|
|
284
|
+
const out = [];
|
|
285
|
+
if (project.tryFindFile(filename) !== void 0) {
|
|
286
|
+
out.push(project);
|
|
287
|
+
}
|
|
288
|
+
for (const sub of project.subprojects) {
|
|
289
|
+
if (sub.tryFindFile(filename) !== void 0) {
|
|
290
|
+
out.push(sub);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return out;
|
|
294
|
+
}
|
|
259
295
|
function hasComponent(project, ctor) {
|
|
260
|
-
|
|
261
|
-
return project.subprojects.some(
|
|
262
|
-
(sub) => sub.components.some((c) => c instanceof ctor)
|
|
263
|
-
);
|
|
296
|
+
return findProjectsWithComponent(project, ctor).length > 0;
|
|
264
297
|
}
|
|
265
298
|
function hasDep(project, name) {
|
|
266
|
-
|
|
267
|
-
return project.subprojects.some(
|
|
268
|
-
(sub) => sub.deps.all.some((d) => d.name === name)
|
|
269
|
-
);
|
|
299
|
+
return findProjectsWithDep(project, name).length > 0;
|
|
270
300
|
}
|
|
271
301
|
function hasFile(project, filename) {
|
|
272
|
-
|
|
273
|
-
return project.subprojects.some(
|
|
274
|
-
(sub) => sub.tryFindFile(filename) !== void 0
|
|
275
|
-
);
|
|
302
|
+
return findProjectsWithFile(project, filename).length > 0;
|
|
276
303
|
}
|
|
277
304
|
|
|
278
305
|
// src/agent/bundles/aws-cdk.ts
|
|
@@ -280,6 +307,7 @@ var awsCdkBundle = {
|
|
|
280
307
|
name: "aws-cdk",
|
|
281
308
|
description: "AWS CDK construct patterns, L2/L3 conventions, IAM best practices",
|
|
282
309
|
appliesWhen: (project) => hasDep(project, "aws-cdk-lib"),
|
|
310
|
+
findApplicableProjects: (project) => findProjectsWithDep(project, "aws-cdk-lib"),
|
|
283
311
|
rules: [
|
|
284
312
|
{
|
|
285
313
|
name: "aws-cdk-conventions",
|
|
@@ -911,6 +939,7 @@ var jestBundle = {
|
|
|
911
939
|
name: "jest",
|
|
912
940
|
description: "Jest testing conventions and patterns",
|
|
913
941
|
appliesWhen: (project) => hasDep(project, "jest"),
|
|
942
|
+
findApplicableProjects: (project) => findProjectsWithDep(project, "jest"),
|
|
914
943
|
rules: [
|
|
915
944
|
{
|
|
916
945
|
name: "jest-testing",
|
|
@@ -1697,6 +1726,7 @@ var typescriptBundle = {
|
|
|
1697
1726
|
name: "typescript",
|
|
1698
1727
|
description: "TypeScript conventions, type safety, naming, JSDoc, member ordering",
|
|
1699
1728
|
appliesWhen: (project) => hasFile(project, "tsconfig.json"),
|
|
1729
|
+
findApplicableProjects: (project) => findProjectsWithFile(project, "tsconfig.json"),
|
|
1700
1730
|
rules: [
|
|
1701
1731
|
{
|
|
1702
1732
|
name: "typescript-conventions",
|
|
@@ -1914,6 +1944,7 @@ var vitestBundle = {
|
|
|
1914
1944
|
name: "vitest",
|
|
1915
1945
|
description: "Vitest testing conventions, patterns, and file scoping",
|
|
1916
1946
|
appliesWhen: (project) => hasComponent(project, Vitest),
|
|
1947
|
+
findApplicableProjects: (project) => findProjectsWithComponent(project, Vitest),
|
|
1917
1948
|
rules: [
|
|
1918
1949
|
{
|
|
1919
1950
|
name: "vitest-testing",
|
|
@@ -1983,6 +2014,38 @@ var BUILT_IN_BUNDLES = [
|
|
|
1983
2014
|
slackBundle
|
|
1984
2015
|
];
|
|
1985
2016
|
|
|
2017
|
+
// src/agent/bundles/scope.ts
|
|
2018
|
+
var path = __toESM(require("path"));
|
|
2019
|
+
function scopeFilePatternsToProjects(root, detected) {
|
|
2020
|
+
const patterns = /* @__PURE__ */ new Set();
|
|
2021
|
+
for (const project of detected) {
|
|
2022
|
+
const rel = path.relative(root.outdir, project.outdir);
|
|
2023
|
+
const include = readTsconfigInclude(project);
|
|
2024
|
+
if (include && include.length > 0) {
|
|
2025
|
+
for (const entry of include) {
|
|
2026
|
+
patterns.add(prefix(rel, entry));
|
|
2027
|
+
}
|
|
2028
|
+
} else {
|
|
2029
|
+
const srcdir = project.srcdir ?? "src";
|
|
2030
|
+
patterns.add(prefix(rel, path.posix.join(srcdir, "**/*.ts")));
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
return [...patterns].sort();
|
|
2034
|
+
}
|
|
2035
|
+
function readTsconfigInclude(project) {
|
|
2036
|
+
const tsconfig = project.tsconfig;
|
|
2037
|
+
if (!tsconfig) {
|
|
2038
|
+
return void 0;
|
|
2039
|
+
}
|
|
2040
|
+
return tsconfig.include;
|
|
2041
|
+
}
|
|
2042
|
+
function prefix(rel, entry) {
|
|
2043
|
+
if (!rel) {
|
|
2044
|
+
return entry;
|
|
2045
|
+
}
|
|
2046
|
+
return path.posix.join(rel, entry);
|
|
2047
|
+
}
|
|
2048
|
+
|
|
1986
2049
|
// src/projects/project-metadata.ts
|
|
1987
2050
|
var import_projen5 = require("projen");
|
|
1988
2051
|
var import_javascript2 = require("projen/lib/javascript");
|
|
@@ -2565,8 +2628,8 @@ var FALLBACKS = {
|
|
|
2565
2628
|
docsPath: "<docs-path>"
|
|
2566
2629
|
};
|
|
2567
2630
|
var TEMPLATE_RE = /\{\{(\w+(?:\.\w+)*)\}\}/g;
|
|
2568
|
-
function getNestedValue(obj,
|
|
2569
|
-
const parts =
|
|
2631
|
+
function getNestedValue(obj, path2) {
|
|
2632
|
+
const parts = path2.split(".");
|
|
2570
2633
|
let current = obj;
|
|
2571
2634
|
for (const part of parts) {
|
|
2572
2635
|
if (current == null || typeof current !== "object") {
|
|
@@ -2807,7 +2870,7 @@ var AgentConfig = class _AgentConfig extends import_projen8.Component {
|
|
|
2807
2870
|
continue;
|
|
2808
2871
|
}
|
|
2809
2872
|
if (bundle.appliesWhen(this.project)) {
|
|
2810
|
-
for (const rule of bundle
|
|
2873
|
+
for (const rule of this.bundleRulesFor(bundle)) {
|
|
2811
2874
|
ruleMap.set(rule.name, rule);
|
|
2812
2875
|
}
|
|
2813
2876
|
}
|
|
@@ -2817,7 +2880,7 @@ var AgentConfig = class _AgentConfig extends import_projen8.Component {
|
|
|
2817
2880
|
for (const bundleName of this.options.includeBundles) {
|
|
2818
2881
|
const bundle = BUILT_IN_BUNDLES.find((b) => b.name === bundleName);
|
|
2819
2882
|
if (bundle) {
|
|
2820
|
-
for (const rule of bundle
|
|
2883
|
+
for (const rule of this.bundleRulesFor(bundle)) {
|
|
2821
2884
|
ruleMap.set(rule.name, rule);
|
|
2822
2885
|
}
|
|
2823
2886
|
}
|
|
@@ -2857,6 +2920,25 @@ ${extra}`
|
|
|
2857
2920
|
return a.name.localeCompare(b.name);
|
|
2858
2921
|
});
|
|
2859
2922
|
}
|
|
2923
|
+
/**
|
|
2924
|
+
* Return a bundle's rules with `filePatterns` narrowed to the projects
|
|
2925
|
+
* that actually matched the bundle's detection predicate (when the bundle
|
|
2926
|
+
* provides `findApplicableProjects`). Rules with `ALWAYS` scope and rules
|
|
2927
|
+
* on bundles that don't implement the hook are returned unchanged.
|
|
2928
|
+
*/
|
|
2929
|
+
bundleRulesFor(bundle) {
|
|
2930
|
+
if (!bundle.findApplicableProjects) {
|
|
2931
|
+
return bundle.rules;
|
|
2932
|
+
}
|
|
2933
|
+
const detected = bundle.findApplicableProjects(this.project);
|
|
2934
|
+
if (detected.length === 0) {
|
|
2935
|
+
return bundle.rules;
|
|
2936
|
+
}
|
|
2937
|
+
const scoped = scopeFilePatternsToProjects(this.project, detected);
|
|
2938
|
+
return bundle.rules.map(
|
|
2939
|
+
(rule) => rule.scope === AGENT_RULE_SCOPE.FILE_PATTERN ? { ...rule, filePatterns: scoped } : rule
|
|
2940
|
+
);
|
|
2941
|
+
}
|
|
2860
2942
|
resolveSkills() {
|
|
2861
2943
|
const skillMap = /* @__PURE__ */ new Map();
|
|
2862
2944
|
if (this.options.autoDetectBundles !== false) {
|
|
@@ -3570,8 +3652,8 @@ var ResetTask = class _ResetTask extends import_projen13.Component {
|
|
|
3570
3652
|
const resetTask = this.project.tasks.addTask(this.taskName, {
|
|
3571
3653
|
description: "Delete build artifacts specified by pathsToRemove option, or artifactsDirectory if pathsToRemove is empty"
|
|
3572
3654
|
});
|
|
3573
|
-
this.pathsToRemove.forEach((
|
|
3574
|
-
resetTask.exec(`[ -e "${
|
|
3655
|
+
this.pathsToRemove.forEach((path2) => {
|
|
3656
|
+
resetTask.exec(`[ -e "${path2}" ] && rm -rf ${path2} || true`);
|
|
3575
3657
|
});
|
|
3576
3658
|
const rootHasTurbo = TurboRepo.of(this.project.root) !== void 0;
|
|
3577
3659
|
const isSubproject = this.project !== this.project.root;
|
|
@@ -3886,7 +3968,11 @@ var MonorepoProject = class extends import_typescript3.TypeScriptAppProject {
|
|
|
3886
3968
|
*/
|
|
3887
3969
|
disableTsconfigDev: true,
|
|
3888
3970
|
/**
|
|
3889
|
-
* Kill the srcdir in the root since we aren't using one.
|
|
3971
|
+
* Kill the srcdir in the root since we aren't using one. Projen's
|
|
3972
|
+
* default `tsconfig.include` still points at `src/**\/*.ts`, so
|
|
3973
|
+
* callers that want to treat the monorepo root as a pure shell
|
|
3974
|
+
* should see an empty include — consumers add their own entries via
|
|
3975
|
+
* `tsconfig.addInclude(...)` (e.g. `.projenrc.ts`, `projenrc/**\/*.ts`).
|
|
3890
3976
|
*/
|
|
3891
3977
|
tsconfig: {
|
|
3892
3978
|
compilerOptions: {
|
|
@@ -3960,6 +4046,7 @@ var MonorepoProject = class extends import_typescript3.TypeScriptAppProject {
|
|
|
3960
4046
|
);
|
|
3961
4047
|
super({ ...options });
|
|
3962
4048
|
postInstallDependenciesMap.set(this, []);
|
|
4049
|
+
this.tsconfig?.removeInclude(`${this.srcdir}/**/*.ts`);
|
|
3963
4050
|
this.pnpmVersion = options.pnpmVersion;
|
|
3964
4051
|
this.configulatorRegistryConsumer = options.configulatorRegistryConsumer ?? true;
|
|
3965
4052
|
new VSCodeConfig(this);
|
|
@@ -4169,9 +4256,9 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen16.Compone
|
|
|
4169
4256
|
for (const branch of branches) {
|
|
4170
4257
|
const branchPattern = branch.branch;
|
|
4171
4258
|
if (branchPattern.includes("*")) {
|
|
4172
|
-
const
|
|
4173
|
-
conditions.push(`startsWith(github.ref, 'refs/heads/${
|
|
4174
|
-
conditions.push(`startsWith(github.head_ref, '${
|
|
4259
|
+
const prefix2 = branchPattern.replace(/\*.*$/, "");
|
|
4260
|
+
conditions.push(`startsWith(github.ref, 'refs/heads/${prefix2}')`);
|
|
4261
|
+
conditions.push(`startsWith(github.head_ref, '${prefix2}')`);
|
|
4175
4262
|
} else {
|
|
4176
4263
|
conditions.push(`github.ref == 'refs/heads/${branchPattern}'`);
|
|
4177
4264
|
}
|