Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion codemods/debarrel/scripts/codemod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Transform, Edit, SgNode } from "codemod:ast-grep";
import type { Transform, Edit, SgNode, GetSelector } from "codemod:ast-grep";
import type TSX from "codemod:ast-grep/langs/tsx";
import type TypeScript from "codemod:ast-grep/langs/typescript";
import type JavaScript from "codemod:ast-grep/langs/javascript";
Expand Down Expand Up @@ -432,4 +432,12 @@ const transform: Transform<Language> = async (root) => {
return rootNode.commitEdits(edits);
};

export const getSelector: GetSelector<Language> = () => {
return {
rule: {
any: [{ kind: "import_statement" }, { kind: "export_statement" }],
},
};
};

export default transform;
7 changes: 4 additions & 3 deletions codemods/debarrel/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"types": ["@codemod.com/jssg-types"],
"allowImportingTsExtensions": true,
"noEmit": true,
"verbatimModuleSyntax": true,
"erasableSyntaxOnly": true,
"strict": true,
"strictNullChecks": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true
"noUncheckedIndexedAccess": true,
// Keep this until the LLRT ambient declarations in @codemod.com/jssg-types
// stop conflicting with TypeScript's standard library declarations.
"skipLibCheck": true
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting skipLibCheck: true weakens the check-types gate by skipping type-checking of all declaration files, which can mask real type issues introduced by dependency updates. If this was added to work around a specific library typing problem, it would be better to address that directly (or at least document why this relaxation is necessary).

Suggested change
"skipLibCheck": true
"skipLibCheck": false

Copilot uses AI. Check for mistakes.
},
"exclude": ["tests"]
}
89 changes: 86 additions & 3 deletions codemods/debarrel/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,102 @@

version: "1"

state:
schema:
shards:
type: array
items:
type: object
properties:
name:
type: string
team:
type: string
directory:
type: string
_meta_shard:
type: number
_meta_files:
type: array
items:
type: string

params:
schema:
shardingMethod:
name: "Sharding Method"
description: "The method to use for sharding"
type: string
default: "codeowner"
oneOf:
- type: string
enum:
- "codeowner"
- "directory"
shardingDirectoryTarget:
name: "Sharding Directory Target"
description: "When sharding by directory, the directory to target for the codemod"
type: string
default: "./src"

nodes:
- id: evaluate-shards
name: Evaluate Shards
trigger:
type: automatic
steps:
- name: "Evaluate shards by directory"
if: params.shardingMethod == "directory"
shard:
method:
type: directory
max_files_per_shard: 30
target: ${{ params.shardingDirectoryTarget }}
output_state: shards
js-ast-grep:
js_file: scripts/codemod.ts
language: "typescript"
- name: "Evaluate shards by codeowner"
if: params.shardingMethod == "codeowner"
shard:
method:
type: codeowner
max_files_per_shard: 30
target: "."
output_state: shards
js-ast-grep:
js_file: scripts/codemod.ts
language: "typescript"

- id: apply-transforms
name: Apply AST Transformations
type: automatic
trigger:
type: manual
depends_on:
- evaluate-shards
strategy:
type: matrix
from_state: shards
pull_request:
title: "[DRAFT] refactor: Run debarrel shard ${{ matrix.name }}"
body: "This pull request runs debarrel for shard ${{ matrix.name }}."
draft: true
steps:
- id: debarrel-js-ast-grep
name: "Debarrel: rewrite imports and clean up barrels"
js-ast-grep:
js_file: scripts/codemod.ts
language: "typescript"
semantic_analysis: workspace
- id: install-package-skill
name: Install package skill

- id: install-skill
name: Install Skill
trigger:
type: manual
depends_on:
- apply-transforms
steps:
- name: "Install debarrel skill"
install-skill:
package: "debarrel"
path: "./agents/skill/SKILL.md"
24 changes: 20 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading