@codedrifters/configulator 0.0.257 → 0.0.258

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.js CHANGED
@@ -243,9 +243,12 @@ __export(index_exports, {
243
243
  pnpmBundle: () => pnpmBundle,
244
244
  prReviewBundle: () => prReviewBundle,
245
245
  projenBundle: () => projenBundle,
246
+ renderCustomDocSectionBlock: () => renderCustomDocSectionBlock,
247
+ renderCustomDocSections: () => renderCustomDocSections,
246
248
  renderFocusSection: () => renderFocusSection,
247
249
  renderMeetingTypesSection: () => renderMeetingTypesSection,
248
250
  renderPriorityRulesSection: () => renderPriorityRulesSection,
251
+ renderSourceTierExamples: () => renderSourceTierExamples,
249
252
  requirementsAnalystBundle: () => requirementsAnalystBundle,
250
253
  requirementsReviewerBundle: () => requirementsReviewerBundle,
251
254
  requirementsWriterBundle: () => requirementsWriterBundle,
@@ -1390,6 +1393,98 @@ var baseBundle = {
1390
1393
  ].join("\n"),
1391
1394
  tags: ["project"]
1392
1395
  },
1396
+ {
1397
+ name: "source-quality-verification",
1398
+ description: "Source tier hierarchy (T1\u2013T4), conflict resolution, temporal validity, and source-annotation format for research-producing agents",
1399
+ scope: AGENT_RULE_SCOPE.ALWAYS,
1400
+ content: [
1401
+ "# Source Quality & Verification",
1402
+ "",
1403
+ "All research-producing agents must follow this source hierarchy when",
1404
+ "writing profiles and reference documents. The tiers govern which",
1405
+ "source to prefer when claims conflict and when time-sensitive claims",
1406
+ "need re-verification.",
1407
+ "",
1408
+ "## Source Tier Hierarchy",
1409
+ "",
1410
+ "### T1 \u2014 Primary Living",
1411
+ "",
1412
+ "Authoritative sources that update when reality changes.",
1413
+ "Use these for current-state claims. Examples:",
1414
+ "",
1415
+ "- Official product docs and API references",
1416
+ "- Company about / leadership / team pages",
1417
+ "- Live government registries (SEC EDGAR, Companies House)",
1418
+ "- Current-role LinkedIn profiles",
1419
+ "- Investor relations pages",
1420
+ "",
1421
+ "### T2 \u2014 Primary Snapshot",
1422
+ "",
1423
+ "Authoritative but time-stamped sources straight from the subject.",
1424
+ "Trust for current state only when fresh (< 6 months) and no T1",
1425
+ "source contradicts them. Examples:",
1426
+ "",
1427
+ "- Press releases from the entity",
1428
+ "- Earnings transcripts and investor calls",
1429
+ "- Regulatory filings (10-K, 10-Q, 8-K)",
1430
+ "- Official announcements and conference presentations",
1431
+ "",
1432
+ "### T3 \u2014 Secondary",
1433
+ "",
1434
+ "Third-party sources that interpret or re-report primary material.",
1435
+ "Good for context and triangulation; T1 wins on conflict. Examples:",
1436
+ "",
1437
+ "- News articles and trade press",
1438
+ "- Industry reports and analyst research",
1439
+ "- Database aggregators (Crunchbase, PitchBook, Owler)",
1440
+ "",
1441
+ "### T4 \u2014 Self-Reported / Marketing",
1442
+ "",
1443
+ "Promotional or unverified sources. Use for discovery and leads only",
1444
+ "\u2014 never as the sole source for a factual claim, and always note the",
1445
+ "self-reported nature in the annotation. Examples:",
1446
+ "",
1447
+ "- Vendor comparison pages and customer testimonials on vendor sites",
1448
+ "- Social-media posts",
1449
+ "- Job postings",
1450
+ "- Wikipedia",
1451
+ "",
1452
+ "## Conflict Resolution",
1453
+ "",
1454
+ "Higher tier wins. Within the same tier, more recent wins. If a newer",
1455
+ "T2 source contradicts an older T1 source on a time-sensitive claim,",
1456
+ "flag for re-verification \u2014 the T1 source may simply not have been",
1457
+ "updated yet.",
1458
+ "",
1459
+ "## Temporal Validity",
1460
+ "",
1461
+ "Some claims decay faster than others. When a fast-decay claim comes",
1462
+ "from a source older than 6 months, agents **must** attempt to",
1463
+ "corroborate it with a T1 living source. If no T1 source is available,",
1464
+ "add an inline note: `_(source: YYYY-MM, may need re-verification)_`.",
1465
+ "",
1466
+ "| Decay | Re-verify if source older than | Typical claims |",
1467
+ "|-------|-------------------------------|----------------|",
1468
+ "| **Fast** | 6 months | Leadership roles, employee count, pricing, product features, funding status, office locations |",
1469
+ "| **Slow** | 18 months | Founding year, ownership structure, core business description, industry classification, HQ location |",
1470
+ "| **Stable** | Verify once, note source date | Historical facts (acquisition dates, founding story), published financials for a specific period |",
1471
+ "",
1472
+ "## Source Annotation Format",
1473
+ "",
1474
+ "In the `## Sources` section of profiles and reference documents,",
1475
+ "annotate each source with its tier and date:",
1476
+ "",
1477
+ "```",
1478
+ "1. [Company Leadership Page](https://...) \u2014 T1, accessed 2026-04",
1479
+ "2. [Company press release](https://...) \u2014 T2, published 2026-02",
1480
+ "3. [TechCrunch coverage](https://...) \u2014 T3, published 2025-11",
1481
+ "```",
1482
+ "",
1483
+ "Use `accessed YYYY-MM` for living sources (T1) and `published YYYY-MM`",
1484
+ "for snapshot sources (T2, T3, T4)."
1485
+ ].join("\n"),
1486
+ tags: ["workflow"]
1487
+ },
1393
1488
  {
1394
1489
  name: "issue-conventions",
1395
1490
  description: "Issue title prefixes, GitHub issue type mapping, prerequisite issues",
@@ -14583,6 +14678,141 @@ var vitestBundle = {
14583
14678
  }
14584
14679
  };
14585
14680
 
14681
+ // src/agent/bundles/features.ts
14682
+ var SOURCE_TIER_HEADINGS = [
14683
+ { key: "t1", heading: "### T1 \u2014 Primary Living" },
14684
+ { key: "t2", heading: "### T2 \u2014 Primary Snapshot" },
14685
+ { key: "t3", heading: "### T3 \u2014 Secondary" },
14686
+ { key: "t4", heading: "### T4 \u2014 Self-Reported / Marketing" }
14687
+ ];
14688
+ function renderSourceTierExamples(content, examples) {
14689
+ if (!examples) {
14690
+ return content;
14691
+ }
14692
+ const tierEntries = SOURCE_TIER_HEADINGS.flatMap(({ key, heading }) => {
14693
+ const list = examples[key];
14694
+ if (!list || list.length === 0) {
14695
+ return [];
14696
+ }
14697
+ return [{ heading, list }];
14698
+ });
14699
+ if (tierEntries.length === 0) {
14700
+ return content;
14701
+ }
14702
+ let updated = content;
14703
+ for (const { heading, list } of tierEntries) {
14704
+ const injection = [
14705
+ "",
14706
+ "**Project-specific examples:**",
14707
+ "",
14708
+ ...list.map((ex) => `- ${ex}`)
14709
+ ].join("\n");
14710
+ updated = insertAfterHeadingBlock(updated, heading, injection);
14711
+ }
14712
+ return updated;
14713
+ }
14714
+ function renderCustomDocSections(bundle, sections) {
14715
+ const matching = sections.filter((s) => s.bundleName === bundle.name);
14716
+ if (matching.length === 0) {
14717
+ return bundle;
14718
+ }
14719
+ let rules = bundle.rules;
14720
+ const currentAnchorByTarget = /* @__PURE__ */ new Map();
14721
+ for (const section of matching) {
14722
+ const injection = renderCustomDocSectionBlock(section);
14723
+ const seededAnchor = currentAnchorByTarget.get(section.afterSection);
14724
+ let targetIndex = -1;
14725
+ let targetHeading = "";
14726
+ for (let i = 0; i < rules.length; i += 1) {
14727
+ if (seededAnchor && rules[i].content.includes(seededAnchor)) {
14728
+ targetIndex = i;
14729
+ targetHeading = seededAnchor;
14730
+ break;
14731
+ }
14732
+ if (!seededAnchor) {
14733
+ const match = findHeadingForTitle(
14734
+ rules[i].content,
14735
+ section.afterSection
14736
+ );
14737
+ if (match) {
14738
+ targetIndex = i;
14739
+ targetHeading = match;
14740
+ break;
14741
+ }
14742
+ }
14743
+ }
14744
+ if (targetIndex === -1) {
14745
+ continue;
14746
+ }
14747
+ const targetRule = rules[targetIndex];
14748
+ const updatedRule = {
14749
+ ...targetRule,
14750
+ content: insertAfterHeadingBlock(
14751
+ targetRule.content,
14752
+ targetHeading,
14753
+ injection
14754
+ )
14755
+ };
14756
+ rules = [
14757
+ ...rules.slice(0, targetIndex),
14758
+ updatedRule,
14759
+ ...rules.slice(targetIndex + 1)
14760
+ ];
14761
+ currentAnchorByTarget.set(
14762
+ section.afterSection,
14763
+ `## ${section.sectionTitle}`
14764
+ );
14765
+ }
14766
+ if (rules === bundle.rules) {
14767
+ return bundle;
14768
+ }
14769
+ return { ...bundle, rules };
14770
+ }
14771
+ function renderCustomDocSectionBlock(section) {
14772
+ const body = section.body.replace(/[\r\n]+$/u, "");
14773
+ return ["", `## ${section.sectionTitle}`, "", body].join("\n");
14774
+ }
14775
+ function findHeadingForTitle(content, title) {
14776
+ const lines = content.split("\n");
14777
+ for (const line of lines) {
14778
+ const match = line.match(/^(#{1,6}) (.+)$/u);
14779
+ if (match && match[2] === title) {
14780
+ return line;
14781
+ }
14782
+ }
14783
+ return void 0;
14784
+ }
14785
+ function insertAfterHeadingBlock(content, heading, injection) {
14786
+ const lines = content.split("\n");
14787
+ const headingIndex = lines.findIndex((line) => line === heading);
14788
+ if (headingIndex === -1) {
14789
+ return content;
14790
+ }
14791
+ const headingLevel = countLeadingHashes(heading);
14792
+ let endIndex = lines.length - 1;
14793
+ for (let i = headingIndex + 1; i < lines.length; i += 1) {
14794
+ const nextLevel = countLeadingHashes(lines[i]);
14795
+ if (nextLevel > 0 && nextLevel <= headingLevel) {
14796
+ endIndex = i - 1;
14797
+ break;
14798
+ }
14799
+ }
14800
+ while (endIndex > headingIndex && lines[endIndex] === "") {
14801
+ endIndex -= 1;
14802
+ }
14803
+ const injectionLines = injection.split("\n");
14804
+ const next = [
14805
+ ...lines.slice(0, endIndex + 1),
14806
+ ...injectionLines,
14807
+ ...lines.slice(endIndex + 1)
14808
+ ];
14809
+ return next.join("\n");
14810
+ }
14811
+ function countLeadingHashes(line) {
14812
+ const match = line.match(/^(#{1,6}) /u);
14813
+ return match ? match[1].length : 0;
14814
+ }
14815
+
14586
14816
  // src/agent/bundles/focus.ts
14587
14817
  var DEFAULT_FOCUS_FILE_PATH = ".claude/focus.json";
14588
14818
  var DEFAULT_SCHEMA_VERSION = 1;
@@ -15553,6 +15783,19 @@ var AgentConfig = class _AgentConfig extends import_projen8.Component {
15553
15783
  const isAgentConfig = (c) => c instanceof _AgentConfig;
15554
15784
  return project.components.find(isAgentConfig);
15555
15785
  }
15786
+ /**
15787
+ * Returns `true` when at least one tier array on the supplied
15788
+ * `SourceTierExamples` is non-empty, signalling that the consuming
15789
+ * repo has opted into rendering the base bundle's
15790
+ * `source-quality-verification` rule. Returns `false` for
15791
+ * `undefined`, `{}`, or a fully-empty `{ t1: [], t2: [], t3: [], t4: [] }`.
15792
+ */
15793
+ static hasActiveTierExamples(examples) {
15794
+ if (!examples) {
15795
+ return false;
15796
+ }
15797
+ return (examples.t1?.length ?? 0) > 0 || (examples.t2?.length ?? 0) > 0 || (examples.t3?.length ?? 0) > 0 || (examples.t4?.length ?? 0) > 0;
15798
+ }
15556
15799
  /**
15557
15800
  * Merges default Claude permissions with bundle and user-supplied settings.
15558
15801
  *
@@ -15772,6 +16015,24 @@ ${section}`
15772
16015
  }
15773
16016
  }
15774
16017
  }
16018
+ const tierExamples = this.options.features?.sourceTierExamples;
16019
+ if (_AgentConfig.hasActiveTierExamples(tierExamples)) {
16020
+ const sourceRule = ruleMap.get("source-quality-verification");
16021
+ if (sourceRule) {
16022
+ const updated = renderSourceTierExamples(
16023
+ sourceRule.content,
16024
+ tierExamples
16025
+ );
16026
+ if (updated !== sourceRule.content) {
16027
+ ruleMap.set("source-quality-verification", {
16028
+ ...sourceRule,
16029
+ content: updated
16030
+ });
16031
+ }
16032
+ }
16033
+ } else {
16034
+ ruleMap.delete("source-quality-verification");
16035
+ }
15775
16036
  return [...ruleMap.values()].sort((a, b) => {
15776
16037
  if (a.name === "project-overview") return -1;
15777
16038
  if (b.name === "project-overview") return 1;
@@ -15784,19 +16045,24 @@ ${section}`
15784
16045
  /**
15785
16046
  * Return a bundle's rules with `filePatterns` narrowed to the projects
15786
16047
  * that actually matched the bundle's detection predicate (when the bundle
15787
- * provides `findApplicableProjects`). Rules with `ALWAYS` scope and rules
15788
- * on bundles that don't implement the hook are returned unchanged.
16048
+ * provides `findApplicableProjects`) and any project-specified
16049
+ * `features.customDocSections` entries injected into the matching rule
16050
+ * content. Rules with `ALWAYS` scope and rules on bundles that don't
16051
+ * implement the hook are returned with only the custom-section
16052
+ * transformation (if any) applied.
15789
16053
  */
15790
16054
  bundleRulesFor(bundle) {
15791
- if (!bundle.findApplicableProjects) {
15792
- return bundle.rules;
16055
+ const customSections = this.options.features?.customDocSections ?? [];
16056
+ const withCustomSections = customSections.length > 0 ? renderCustomDocSections(bundle, customSections) : bundle;
16057
+ if (!withCustomSections.findApplicableProjects) {
16058
+ return withCustomSections.rules;
15793
16059
  }
15794
- const detected = bundle.findApplicableProjects(this.project);
16060
+ const detected = withCustomSections.findApplicableProjects(this.project);
15795
16061
  if (detected.length === 0) {
15796
- return bundle.rules;
16062
+ return withCustomSections.rules;
15797
16063
  }
15798
16064
  const scoped = scopeFilePatternsToProjects(this.project, detected);
15799
- return bundle.rules.map(
16065
+ return withCustomSections.rules.map(
15800
16066
  (rule) => rule.scope === AGENT_RULE_SCOPE.FILE_PATTERN ? { ...rule, filePatterns: scoped } : rule
15801
16067
  );
15802
16068
  }
@@ -18583,9 +18849,12 @@ var TypeScriptConfig = class extends import_projen22.Component {
18583
18849
  pnpmBundle,
18584
18850
  prReviewBundle,
18585
18851
  projenBundle,
18852
+ renderCustomDocSectionBlock,
18853
+ renderCustomDocSections,
18586
18854
  renderFocusSection,
18587
18855
  renderMeetingTypesSection,
18588
18856
  renderPriorityRulesSection,
18857
+ renderSourceTierExamples,
18589
18858
  requirementsAnalystBundle,
18590
18859
  requirementsReviewerBundle,
18591
18860
  requirementsWriterBundle,