@codedrifters/configulator 0.0.177 → 0.0.178

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 CHANGED
@@ -1255,44 +1255,42 @@ const project = new MonorepoProject({
1255
1255
  });
1256
1256
  ```
1257
1257
 
1258
- **Monorepo with per-package overrides:**
1258
+ **Monorepo with per-package opt-in:**
1259
+
1260
+ `AgentConfig` is **not** auto-inherited by sub-projects. Agent rule files are
1261
+ rendered only on projects that explicitly opt in, so the monorepo root's
1262
+ `AgentConfig` does not duplicate `.cursor/`, `.claude/`, or `CLAUDE.md` into
1263
+ each sub-project's `outdir`. Sub-projects that opt in do still resolve
1264
+ `ProjectMetadata` from the root, so template tokens like
1265
+ `{{repository.owner}}` work without redeclaring metadata.
1259
1266
 
1260
1267
  ```typescript
1261
1268
  const root = new MonorepoProject({
1262
1269
  name: "my-monorepo",
1263
1270
  agentConfig: {
1264
- // Root-level config applies to all sub-projects
1271
+ // Root-level config renders into the monorepo root only
1265
1272
  rules: [{ name: "monorepo-rule", description: "...", scope: AGENT_RULE_SCOPE.ALWAYS, content: "..." }],
1266
1273
  },
1267
1274
  });
1268
1275
 
1269
- // Sub-project inherits parent config by default
1276
+ // Sub-project with no agent config nothing rendered into packages/api/
1270
1277
  const api = new TypeScriptProject({
1271
1278
  parent: root,
1272
1279
  name: "@my-org/api",
1273
1280
  outdir: "packages/api",
1274
- // Inherits agentConfig from root
1275
1281
  });
1276
1282
 
1277
- // Sub-project with explicit overrides
1283
+ // Sub-project that explicitly opts into its own agent config
1278
1284
  const frontend = new TypeScriptProject({
1279
1285
  parent: root,
1280
1286
  name: "@my-org/frontend",
1281
1287
  outdir: "packages/frontend",
1282
1288
  agentConfig: {
1283
- // Override: only generate Claude config for this package
1289
+ // Only generate Claude config for this package
1284
1290
  platforms: [AGENT_PLATFORM.CLAUDE],
1285
1291
  excludeBundles: ["jest"], // This package uses Vitest, not Jest
1286
1292
  },
1287
1293
  });
1288
-
1289
- // Sub-project with agent config disabled
1290
- const scripts = new TypeScriptProject({
1291
- parent: root,
1292
- name: "@my-org/scripts",
1293
- outdir: "packages/scripts",
1294
- agentConfig: false, // No agent config for this package
1295
- });
1296
1294
  ```
1297
1295
 
1298
1296
  ## Troubleshooting
package/lib/index.d.mts CHANGED
@@ -2561,8 +2561,10 @@ declare class MonorepoProject extends TypeScriptAppProject {
2561
2561
  */
2562
2562
  declare class ProjectMetadata extends Component {
2563
2563
  /**
2564
- * Returns the ProjectMetadata instance for a project, or undefined
2565
- * if the component has not been added.
2564
+ * Returns the ProjectMetadata instance for a project. Walks up the parent
2565
+ * chain so sub-projects resolve the metadata declared on a root
2566
+ * `MonorepoProject` without needing a duplicate declaration of their own.
2567
+ * Returns `undefined` if no ancestor has a `ProjectMetadata` component.
2566
2568
  */
2567
2569
  static of(project: Project$1): ProjectMetadata | undefined;
2568
2570
  /** Resolved metadata with auto-detected values filled in. */
@@ -2718,8 +2720,10 @@ interface TypeScriptProjectOptions extends Omit<typescript.TypeScriptProjectOpti
2718
2720
  * - `AgentConfigOptions`: enable with explicit configuration
2719
2721
  * - `false` or `undefined`: disabled (default)
2720
2722
  *
2721
- * When the parent is a MonorepoProject with AgentConfig enabled and this
2722
- * option is not explicitly set, the sub-project inherits enablement.
2723
+ * Sub-projects do not inherit `AgentConfig` from their parent
2724
+ * `MonorepoProject`. Agent rule files are rendered only on projects that
2725
+ * explicitly opt in, so a monorepo's root `AgentConfig` does not duplicate
2726
+ * `.cursor/`, `.claude/`, or `CLAUDE.md` into each sub-project's `outdir`.
2723
2727
  *
2724
2728
  * @default false
2725
2729
  */
package/lib/index.d.ts CHANGED
@@ -2610,8 +2610,10 @@ declare class MonorepoProject extends TypeScriptAppProject {
2610
2610
  */
2611
2611
  declare class ProjectMetadata extends Component {
2612
2612
  /**
2613
- * Returns the ProjectMetadata instance for a project, or undefined
2614
- * if the component has not been added.
2613
+ * Returns the ProjectMetadata instance for a project. Walks up the parent
2614
+ * chain so sub-projects resolve the metadata declared on a root
2615
+ * `MonorepoProject` without needing a duplicate declaration of their own.
2616
+ * Returns `undefined` if no ancestor has a `ProjectMetadata` component.
2615
2617
  */
2616
2618
  static of(project: Project): ProjectMetadata | undefined;
2617
2619
  /** Resolved metadata with auto-detected values filled in. */
@@ -2767,8 +2769,10 @@ interface TypeScriptProjectOptions extends Omit<typescript.TypeScriptProjectOpti
2767
2769
  * - `AgentConfigOptions`: enable with explicit configuration
2768
2770
  * - `false` or `undefined`: disabled (default)
2769
2771
  *
2770
- * When the parent is a MonorepoProject with AgentConfig enabled and this
2771
- * option is not explicitly set, the sub-project inherits enablement.
2772
+ * Sub-projects do not inherit `AgentConfig` from their parent
2773
+ * `MonorepoProject`. Agent rule files are rendered only on projects that
2774
+ * explicitly opt in, so a monorepo's root `AgentConfig` does not duplicate
2775
+ * `.cursor/`, `.claude/`, or `CLAUDE.md` into each sub-project's `outdir`.
2772
2776
  *
2773
2777
  * @default false
2774
2778
  */
package/lib/index.js CHANGED
@@ -2001,12 +2001,22 @@ function parseGitHubUrl(url) {
2001
2001
  }
2002
2002
  var ProjectMetadata = class _ProjectMetadata extends import_projen5.Component {
2003
2003
  /**
2004
- * Returns the ProjectMetadata instance for a project, or undefined
2005
- * if the component has not been added.
2004
+ * Returns the ProjectMetadata instance for a project. Walks up the parent
2005
+ * chain so sub-projects resolve the metadata declared on a root
2006
+ * `MonorepoProject` without needing a duplicate declaration of their own.
2007
+ * Returns `undefined` if no ancestor has a `ProjectMetadata` component.
2006
2008
  */
2007
2009
  static of(project) {
2008
2010
  const isProjectMetadata = (c) => c instanceof _ProjectMetadata;
2009
- return project.components.find(isProjectMetadata);
2011
+ let current = project;
2012
+ while (current) {
2013
+ const found = current.components.find(isProjectMetadata);
2014
+ if (found) {
2015
+ return found;
2016
+ }
2017
+ current = current.parent;
2018
+ }
2019
+ return void 0;
2010
2020
  }
2011
2021
  constructor(project, options = {}) {
2012
2022
  super(project);
@@ -3502,15 +3512,11 @@ var TypeScriptProject = class extends import_projen12.typescript.TypeScriptProje
3502
3512
  turbo.compileTask?.outputs.push("dist/**");
3503
3513
  turbo.compileTask?.outputs.push("lib/**");
3504
3514
  }
3505
- const parentHasAgentConfig = userOptions.parent instanceof MonorepoProject && AgentConfig.of(userOptions.parent) !== void 0;
3506
- if (options.agentConfig !== false) {
3507
- const shouldEnable = typeof options.agentConfig === "object" || options.agentConfig === true || parentHasAgentConfig;
3508
- if (shouldEnable) {
3509
- new AgentConfig(
3510
- this,
3511
- typeof options.agentConfig === "object" ? options.agentConfig : {}
3512
- );
3513
- }
3515
+ if (options.agentConfig === true || typeof options.agentConfig === "object") {
3516
+ new AgentConfig(
3517
+ this,
3518
+ typeof options.agentConfig === "object" ? options.agentConfig : {}
3519
+ );
3514
3520
  }
3515
3521
  if (options.resetTask !== false) {
3516
3522
  const defaultResetTaskOptions = {