adamantite 0.31.0 → 0.32.1

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
@@ -67,7 +67,7 @@ This interactive command will:
67
67
 
68
68
  - Install Adamantite, [oxlint](https://oxc.rs/docs/guide/usage/linter.html), and [oxfmt](https://oxc.rs/docs/guide/usage/formatter.html) as dev dependencies
69
69
  - Create `oxlint.config.ts` with opinionated presets
70
- - Create `.oxfmtrc.json` with formatting configuration
70
+ - Create `oxfmt.config.ts` with formatting configuration
71
71
  - Set up `tsconfig.json` with strict TypeScript rules
72
72
  - Add lint/format scripts to your `package.json`
73
73
  - Also adds monorepo-specific scripts if running a monorepo
@@ -151,6 +151,8 @@ Run applicable migrations and update Adamantite-managed dependencies:
151
151
  adamantite update
152
152
  ```
153
153
 
154
+ This also migrates legacy `.oxfmtrc.json(c)` configs to `oxfmt.config.ts` and `knip.json(c)` configs to `knip.config.ts`.
155
+
154
156
  ## Presets
155
157
 
156
158
  ### Linting ([presets/lint/](./presets/lint/))
@@ -180,9 +182,13 @@ Framework-specific presets are available for:
180
182
  - **Jest** ([jest.ts](./presets/lint/jest.ts)) - Jest testing rules
181
183
  - **Vitest** ([vitest.ts](./presets/lint/vitest.ts)) - Vitest testing rules
182
184
 
183
- ### Formatting ([presets/format.json](./presets/format.json))
185
+ ### Formatting ([format.ts](./presets/format.ts))
186
+
187
+ Opinionated code formatting with oxfmt, configured for consistency and readability. The published formatter preset is available as `adamantite/format` and is designed to be used from `oxfmt.config.ts`.
188
+
189
+ ### Analyze ([analyze.ts](./presets/analyze.ts))
184
190
 
185
- Opinionated code formatting with oxfmt, configured for consistency and readability. Includes automatic import sorting and organization.
191
+ Opinionated Knip configuration for dependency and unused-file analysis. The published analyze preset is available as `adamantite/analyze` and is designed to be used from `knip.config.ts`.
186
192
 
187
193
  ### TypeScript ([presets/tsconfig.json](./presets/tsconfig.json))
188
194
 
package/dist/index.js CHANGED
@@ -1,12 +1,23 @@
1
- import*as Nr from"@effect/platform-node/NodeRuntime";import*as er from"@effect/platform-node/NodeServices";import*as H from"effect/Effect";import*as Pr from"effect/Exit";import*as hr from"effect/Layer";import*as or from"effect/Runtime";import*as p from"effect/unstable/cli/Command";import*as Or from"effect/unstable/process/ChildProcessSpawner";import*as Ll from"effect/Effect";import*as mf from"effect/unstable/cli/Command";import*as Ef from"effect/unstable/cli/Flag";import*as Bl from"effect/unstable/process/ChildProcessSpawner";import*as w from"effect/Effect";import*as Lf from"effect/FileSystem";import*as Bf from"effect/Path";function C(f){return f}import*as z from"effect/Data";import{printParseErrorCode as Cr}from"jsonc-parser";function Rr(f=[]){if(f.length===0)return"- Unknown JSON/JSONC parsing error";return f.slice(0,3).map((r)=>`- ${Cr(r.error)} (offset: ${r.offset})`).join(`
2
- `)}class fl extends z.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class W extends z.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class c extends z.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class ll extends z.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Uf extends z.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class rl extends z.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Fl extends z.TaggedError("FailedToParseFile"){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:"the target file"}.`,"Please fix the JSON/JSONC syntax and run the command again.","","Parse details:",Rr(this.errors)].join(`
3
- `)}}class X extends z.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class al extends z.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class M extends z.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class ff extends z.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class Y extends z.TaggedError("InvalidConfigFormat"){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:"the target config file"}. The config must be a JSON object (for example: {}).`}}class Sf extends z.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class kr extends z.TaggedError("MissingPackageVersion"){get message(){return`Missing version field in ${this.path?`\`${this.path}\``:"package.json"}.`}}class P extends z.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class Wf extends z.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class ml extends z.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class El extends z.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}import{defu as wr}from"defu";import*as h from"effect/Effect";import{parse as xr}from"jsonc-parser";var S=(f,r)=>h.sync(()=>{let l=[],F=xr(f,l,{allowTrailingComma:!0});return{errors:l,parsed:F}}).pipe(h.flatMap(({errors:l,parsed:F})=>l.length>0?h.fail(new Fl({errors:l,path:r})):h.succeed(F)));function _(f){return f!==null&&typeof f==="object"&&!Array.isArray(f)}var o=(f,r)=>h.try({catch:(l)=>new rl({cause:l}),try:()=>wr(f,r)});var Yf={$schema:"https://unpkg.com/knip@5/schema.json",rules:{files:"error",dependencies:"error",devDependencies:"error",optionalPeerDependencies:"warn",unlisted:"error",binaries:"error",unresolved:"error",exports:"warn",nsExports:"warn",types:"warn",nsTypes:"warn",enumMembers:"off",classMembers:"off",duplicates:"warn"},ignoreExportsUsedInFile:!0,ignoreFiles:["**/dist/**","**/build/**","**/coverage/**","**/.next/**","**/.vercel/**","**/.turbo/**"],ignore:["**/*.d.ts"]};var _f="knip.json",Ul="knip.jsonc",L=C({config:Yf,create:(f)=>w.gen(function*(){let r=yield*Lf.FileSystem,F=(yield*Bf.Path).join(f,_f),a=JSON.stringify(Yf,null,2);yield*r.writeFileString(F,`${a}
4
- `).pipe(w.mapError((m)=>new M({cause:m,path:F})))}),exists:(f)=>w.gen(function*(){let r=yield*Lf.FileSystem,l=yield*Bf.Path,F=l.join(f,_f),a=l.join(f,Ul);if(yield*r.exists(F))return{path:F};if(yield*r.exists(a))return{path:a};return{path:null}}),name:"knip",update:(f)=>w.gen(function*(){let r=yield*Lf.FileSystem,l=yield*Bf.Path,F=l.join(f,_f),a=l.join(f,Ul),m=(yield*r.exists(F))?F:(yield*r.exists(a))?a:null;if(!m)return yield*new ff({path:_f});let E=yield*r.readFileString(m).pipe(w.mapError((v)=>new X({cause:v,path:m}))),y=yield*S(E,m);if(!_(y))return yield*new Y({path:m});let u=yield*o(y,Yf),T=m.endsWith(".jsonc");u.$schema=T?"https://unpkg.com/knip@5/schema-jsonc.json":"https://unpkg.com/knip@5/schema.json",yield*r.writeFileString(m,`${JSON.stringify(u,null,2)}
5
- `).pipe(w.mapError((v)=>new M({cause:v,path:m})))}),version:"5.86.0"});import*as x from"effect/Effect";import*as Wl from"effect/Layer";import*as Yl from"effect/ServiceMap";import*as _l from"effect/unstable/process/ChildProcess";class q extends Yl.Service()("CommandRunner"){static layer=Wl.succeed(this)({run:({args:f,command:r,cwd:l,stderr:F="inherit",stdin:a="ignore",stdout:m="inherit"})=>x.mapError(x.scoped(x.gen(function*(){return yield*(yield*x.fromYieldable(_l.make(r,f,{cwd:l,stderr:F,stdin:a,stdout:m}))).exitCode})),(E)=>E.reason._tag==="NotFound"?new fl({command:r}):E)})}var br=Ef.boolean("fix").pipe(Ef.withDescription("Automatically fix issues")),tr=Ef.boolean("strict").pipe(Ef.withDescription("Enable strict mode")),Gl=mf.make("analyze",{fix:br,strict:tr}).pipe(mf.withDescription("Find unused dependencies, exports, and files using knip"),mf.withHandler(({fix:f,strict:r})=>Ll.gen(function*(){let l=yield*q,F=[];if(f)F.push("--fix","--allow-remove-files");if(r)F.push("--production","--strict");let a=yield*l.run({args:F,command:L.name});if(a!==Bl.ExitCode(0))yield*new W({command:L.name,exitCode:a})})));import*as el from"effect/Effect";import*as yf from"effect/unstable/cli/Argument";import*as vf from"effect/unstable/cli/Command";import*as Pl from"effect/unstable/process/ChildProcessSpawner";import*as R from"effect/Effect";import*as Af from"effect/FileSystem";import*as Jf from"effect/Path";var Gf="oxlint.config.ts",yl=".oxlintrc.json",nr=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,sr=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function Al(f=[]){return f.includes("core")?f:["core",...f]}function Jl(f){return f.replaceAll(/-([a-z])/g,(r,l)=>l.toUpperCase())}function Nl(f,r,l=[]){let{options:F,...a}=f,m=['import { defineConfig } from "oxlint"',...r.map((V)=>`import ${Jl(V)} from "${V==="core"?"adamantite/lint":`adamantite/lint/${V}`}"`)],y=[...r.map((V)=>Jl(V)),...l.map((V)=>JSON.stringify(V))],u=JSON.stringify(_(F)?{...F,typeAware:!0,typeCheck:!0}:{typeAware:!0,typeCheck:!0},null,2),T=Object.entries(a).map(([V,Z])=>[V,JSON.stringify(Z,null,2)]),v=`[${y.join(", ")}]`,i=[["options",u],...T,["extends",v]].map(([V,Z])=>` ${V}: ${Z},`).join(`
6
- `);return[...m,"","export default defineConfig({",i,"})",""].join(`
7
- `)}var $=C({create:(f,r=[])=>R.gen(function*(){let l=yield*Af.FileSystem,a=(yield*Jf.Path).join(f,Gf),m=Nl({},Al(r));yield*l.writeFileString(a,m).pipe(R.mapError((E)=>new M({cause:E,path:a})))}),exists:(f)=>R.gen(function*(){let r=yield*Af.FileSystem,l=yield*Jf.Path,F=l.join(f,Gf),a=l.join(f,yl),m=yield*r.exists(F),E=yield*r.exists(a),y=m?"ts":E?"json":null;return{format:y,hasBoth:m&&E,jsonPath:E?a:null,path:y==="ts"?F:y==="json"?a:null,tsPath:m?F:null}}),name:"oxlint",update:(f,r=[])=>R.gen(function*(){let l=yield*Af.FileSystem,F=yield*Jf.Path,a=F.join(f,Gf),m=F.join(f,yl),E=yield*l.exists(a),y=yield*l.exists(m);if(E)return;if(!y)return yield*new ff({path:yl});let u=m,T=F.join(f,Gf),v=yield*l.readFileString(u).pipe(R.mapError((e)=>new X({cause:e,path:u}))),i=yield*S(v,u);if(!_(i))return yield*new Y({path:u});let{$schema:V,...Z}=i,cf=Array.isArray(Z.extends)?Z.extends.filter((e)=>typeof e==="string"):typeof Z.extends==="string"?[Z.extends]:[],Kf=new Set(Al(r)),j=new Set;for(let e of cf){let jr=e.match(nr),Hl=e.match(sr),Sl=jr?.[1]??(Hl?Hl[1]??"core":null);if(Sl)Kf.add(Sl);else j.add(e)}let{extends:Hf,...Ir}=Z;yield*l.writeFileString(T,Nl(Ir,[...Kf],[...j])).pipe(R.mapError((e)=>new M({cause:e,path:T}))),yield*l.remove(u).pipe(R.mapError((e)=>new al({cause:e,path:u})))}),version:"1.55.0"}),lf=C({name:"oxlint-tsgolint",version:"0.17.0"});var pr=yf.file("files",{mustExist:!0}).pipe(yf.withDescription("Specific files to lint (optional)"),yf.variadic()),hl=vf.make("check",{files:pr}).pipe(vf.withDescription("Find issues and type errors in code using oxlint"),vf.withHandler(({files:f})=>el.gen(function*(){let l=yield*(yield*q).run({args:[...f],command:$.name});if(l!==Pl.ExitCode(0))yield*new W({command:$.name,exitCode:l})})));import*as ol from"effect/Effect";import*as Tf from"effect/unstable/cli/Argument";import*as $f from"effect/unstable/cli/Command";import*as d from"effect/unstable/cli/Flag";import*as Ol from"effect/unstable/process/ChildProcessSpawner";var cr=Tf.file("files",{mustExist:!0}).pipe(Tf.withDescription("Specific files to fix (optional)"),Tf.variadic()),fF=d.boolean("suggested").pipe(d.withDescription("Apply suggested fixes")),lF=d.boolean("dangerous").pipe(d.withDescription("Apply dangerous fixes")),rF=d.boolean("all").pipe(d.withDescription("Apply all fixes, including suggested and dangerous fixes")),Il=$f.make("fix",{all:rF,dangerous:lF,files:cr,suggested:fF}).pipe($f.withDescription("Fix issues in code using oxlint"),$f.withHandler(({all:f,dangerous:r,files:l,suggested:F})=>ol.gen(function*(){let a=yield*q,m=new Set(["--fix"]);if(F||f)m.add("--fix-suggestions");if(r||f)m.add("--fix-dangerously");for(let y of l)m.add(y);let E=yield*a.run({args:[...m],command:$.name});if(E!==Ol.ExitCode(0))yield*new W({command:$.name,exitCode:E})})));import*as Cl from"effect/Effect";import*as uf from"effect/unstable/cli/Argument";import*as Df from"effect/unstable/cli/Command";import*as of from"effect/unstable/cli/Flag";import*as Rl from"effect/unstable/process/ChildProcessSpawner";import*as b from"effect/Effect";import*as Pf from"effect/FileSystem";import*as hf from"effect/Path";var Nf={$schema:"../node_modules/oxfmt/configuration_schema.json",arrowParens:"always",bracketSameLine:!1,bracketSpacing:!0,embeddedLanguageFormatting:"auto",endOfLine:"lf",sortImports:{groups:[["value-builtin","type-import"],["value-external"],["type-internal"],["value-internal"],["type-subpath"],["value-subpath"],["type-parent","type-sibling","type-index"],["value-parent","value-sibling","value-index"],["unknown"]],ignoreCase:!0,newlinesBetween:!1,partitionByNewline:!0,order:"asc",partitionByComment:!0,sortSideEffects:!1},sortTailwindcss:{attributes:["className","class"],functions:["clsx","cn","cva","tw","twMerge"],preserveDuplicates:!1,preserveWhitespace:!1},insertFinalNewline:!0,jsxSingleQuote:!1,objectWrap:"preserve",printWidth:100,quoteProps:"as-needed",semi:!1,singleAttributePerLine:!1,singleQuote:!1,tabWidth:2,trailingComma:"es5",useTabs:!1};var ef=".oxfmtrc.jsonc",jl=".oxfmtrc.json",B=C({config:{...Nf,$schema:"./node_modules/oxfmt/configuration_schema.json"},create:(f)=>b.gen(function*(){let r=yield*Pf.FileSystem,F=(yield*hf.Path).join(f,ef),a=JSON.stringify({...Nf,$schema:"./node_modules/oxfmt/configuration_schema.json"},null,2);yield*r.writeFileString(F,`${a}
8
- `).pipe(b.mapError((m)=>new M({cause:m,path:F})))}),exists:(f)=>b.gen(function*(){let r=yield*Pf.FileSystem,l=yield*hf.Path,F=l.join(f,ef),a=l.join(f,jl);if(yield*r.exists(F))return{path:F};if(yield*r.exists(a))return{path:a};return{path:null}}),name:"oxfmt",update:(f)=>b.gen(function*(){let r=yield*Pf.FileSystem,l=yield*hf.Path,F=l.join(f,ef),a=l.join(f,jl),m=(yield*r.exists(F))?F:(yield*r.exists(a))?a:null;if(!m)return yield*new ff({path:ef});let E=yield*r.readFileString(m).pipe(b.mapError((T)=>new X({cause:T,path:m}))),y=yield*S(E,m);if(!_(y))return yield*new Y({path:m});let u=yield*o(y,{...Nf,$schema:"./node_modules/oxfmt/configuration_schema.json"});u.$schema="./node_modules/oxfmt/configuration_schema.json",yield*r.writeFileString(m,`${JSON.stringify(u,null,2)}
9
- `).pipe(b.mapError((T)=>new M({cause:T,path:m})))}),version:"0.40.0"});var aF=uf.file("files",{mustExist:!0}).pipe(uf.withDescription("Specific files to format (optional)"),uf.variadic()),mF=of.boolean("check").pipe(of.withDescription("Check if files are formatted without writing")),kl=Df.make("format",{check:mF,files:aF}).pipe(Df.withDescription("Format files using oxfmt"),Df.withHandler(({check:f,files:r})=>Cl.gen(function*(){let l=yield*q,F=[];if(f)F.push("--check");F.push(...r);let a=yield*l.run({args:F,command:B.name});if(a!==Rl.ExitCode(0))yield*new W({command:B.name,exitCode:a})})));import gF from"node:process";import*as D from"effect/Effect";import*as vr from"effect/FileSystem";import*as Tr from"effect/Path";import*as Vf from"effect/unstable/cli/Command";import*as rf from"effect/Effect";import*as If from"effect/FileSystem";import*as jf from"effect/Path";import{runScriptCommand as EF}from"nypm";import*as Of from"effect/Effect";import*as wl from"effect/FileSystem";var xl=(f)=>Of.gen(function*(){yield*(yield*wl.FileSystem).makeDirectory(f,{recursive:!0}).pipe(Of.mapError((l)=>new c({cause:l,path:f})))});var yF={bun:` - name: Setup Node.js
1
+ import*as mr from"@effect/platform-node/NodeRuntime";import*as dr from"@effect/platform-node/NodeServices";import*as M from"effect/Effect";import*as hr from"effect/Exit";import*as gr from"effect/Layer";import*as Er from"effect/Runtime";import*as ye from"effect/unstable/cli/Command";import*as jr from"effect/unstable/process/ChildProcessSpawner";import*as Kt from"effect/Effect";import*as Fe from"effect/unstable/cli/Command";import*as $e from"effect/unstable/cli/Flag";import*as Gt from"effect/unstable/process/ChildProcessSpawner";import*as Se from"effect/Effect";import*as et from"effect/FileSystem";import*as tt from"effect/Path";function _(e){return e}import*as T from"effect/Data";import{printParseErrorCode as Or}from"jsonc-parser";function Sr(e=[]){if(e.length===0)return"- Unknown JSON/JSONC parsing error";return e.slice(0,3).map((t)=>`- ${Or(t.error)} (offset: ${t.offset})`).join(`
2
+ `)}class $t extends T.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class A extends T.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class me extends T.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class Tt extends T.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Ge extends T.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class vt extends T.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Pt extends T.TaggedError("FailedToParseFile"){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:"the target file"}.`,"Please fix the JSON/JSONC syntax and run the command again.","","Parse details:",Sr(this.errors)].join(`
3
+ `)}}class D extends T.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class re extends T.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class O extends T.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class _t extends T.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class x extends T.TaggedError("InvalidConfigFormat"){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:"the target config file"}. The config must be a JSON object (for example: {}).`}}class Dt extends T.TaggedError("UnsupportedConfigState"){get message(){let e=this.path?`\`${this.path}\``:"the target config file",t=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${e}.${t}`}}class xe extends T.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Fr extends T.TaggedError("MissingPackageVersion"){get message(){return`Missing version field in ${this.path?`\`${this.path}\``:"package.json"}.`}}class H extends T.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class Ce extends T.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class Nt extends T.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class kt extends T.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}import{defu as $r}from"defu";import*as G from"effect/Effect";import{parse as Tr}from"jsonc-parser";var w=(e,t)=>G.sync(()=>{let r=[],n=Tr(e,r,{allowTrailingComma:!0});return{errors:r,parsed:n}}).pipe(G.flatMap(({errors:r,parsed:n})=>r.length>0?G.fail(new Pt({errors:r,path:t})):G.succeed(n)));function N(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function ge(e,t={}){let{continuationIndent:r,indentation:n=2}=t,o=JSON.stringify(e,null,n).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!r)return o;return o.replaceAll(`
4
+ `,`
5
+ ${r}`)}var Ee=(e,t)=>G.try({catch:(r)=>new vt({cause:r}),try:()=>$r(e,t)});function Le(e={}){let t=Object.entries(e).map(([r,n])=>{if(r==="rules"&&typeof n==="object"&&n!==null&&!Array.isArray(n))return[" rules: {"," ...analyze.rules,",...Object.entries(n).map(([i,a])=>` ${i}: ${ge(a,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
6
+ `);return` ${r}: ${ge(n)},`});if(t.length===0)return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = analyze","","export default config",""].join(`
7
+ `);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...t,"}","","export default config",""].join(`
8
+ `)}import vr from"node:process";import*as je from"effect/Effect";import*as Rt from"effect/FileSystem";import*as At from"effect/Path";var Pr=/^workspace:/,_r=/^[\^~]/;function B(e){return e.trim().replace(Pr,"").replace(_r,"")}var $=(e=vr.cwd())=>je.gen(function*(){let t=yield*Rt.FileSystem,n=(yield*At.Path).join(e,"package.json"),o=yield*t.readFileString(n).pipe(je.mapError((a)=>new D({cause:a,path:n})));return yield*w(o,n)}),Zt=(e,t)=>je.gen(function*(){let r=yield*Rt.FileSystem,o=(yield*At.Path).join(e,"package.json");yield*r.writeFileString(o,`${JSON.stringify(t,null,2)}
9
+ `).pipe(je.mapError((i)=>new O({cause:i,path:o})))}),It={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function Q(e){let t=e.scripts??{},r=[];for(let[n,o]of Object.entries(It))if(t[n]===o)r.push(n);return r}var U=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}],Oe="6.6.1",m=_({assess:(e)=>Se.gen(function*(){let t=yield*et.FileSystem,r=yield*tt.Path,n=yield*$(e);if(!Q(n).includes("analyze"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.knip??n.dependencies?.knip,a=r.join(e,U[0].path),u=r.join(e,U[1].path),y=r.join(e,U[2].path),f=yield*t.exists(a),s=yield*t.exists(u),l=yield*t.exists(y),h=f?"ts":l?"jsonc":s?"json":null,S=[],k=[];if(f&&(s||l))k.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!f&&s&&l)k.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(!i)S.push({description:`Install \`knip@${Oe}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:Oe,type:"install_package"});else if(B(i)!==Oe)S.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${Oe}\`.`,package:"knip",targetVersion:Oe,type:"update_package"});if(h===null)S.push({description:`Create \`${U[0].path}\` for \`knip\`.`,path:U[0].path,type:"create_config"});if(h==="json"||h==="jsonc")S.push({description:`Migrate legacy \`${h==="json"?U[1].path:U[2].path}\` to \`${U[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:k}}),config:U[0].path,create:(e)=>Se.gen(function*(){let t=yield*et.FileSystem,n=(yield*tt.Path).join(e,U[0].path);yield*t.writeFileString(n,Le()).pipe(Se.mapError((o)=>new O({cause:o,path:n})))}),exists:(e)=>Se.gen(function*(){let t=yield*et.FileSystem,r=yield*tt.Path,n=r.join(e,U[0].path),o=r.join(e,U[1].path),i=r.join(e,U[2].path),a=yield*t.exists(n),u=yield*t.exists(o),y=yield*t.exists(i),f=a?"ts":y?"jsonc":u?"json":null,s=[];if(a&&u)s.push({format:"json",path:o});if(a&&y)s.push({format:"jsonc",path:i});if(!a&&u&&y)s.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?n:f==="jsonc"?i:o},legacy:s}}),files:U,kind:"tooling",name:"knip",version:Oe});import*as Xt from"effect/Context";import*as se from"effect/Effect";import*as Yt from"effect/Layer";import*as Ht from"effect/unstable/process/ChildProcess";class R extends Xt.Service()("CommandRunner"){static layer=Yt.succeed(this)({run:({args:e,command:t,cwd:r,stderr:n="inherit",stdin:o="ignore",stdout:i="inherit"})=>se.mapError(se.scoped(se.gen(function*(){return yield*(yield*se.fromYieldable(Ht.make(t,e,{cwd:r,stderr:n,stdin:o,stdout:i}))).exitCode})),(a)=>a.reason._tag==="NotFound"?new $t({command:t}):a)})}var Dr=$e.boolean("fix").pipe($e.withDescription("Automatically fix issues")),Nr=$e.boolean("strict").pipe($e.withDescription("Enable strict mode")),Ct=Fe.make("analyze",{fix:Dr,strict:Nr}).pipe(Fe.withDescription("Find unused dependencies, exports, and files using knip"),Fe.withHandler(({fix:e,strict:t})=>Kt.gen(function*(){let r=yield*R,n=[];if(e)n.push("--fix","--allow-remove-files");if(t)n.push("--production","--strict");let o=yield*r.run({args:n,command:m.name});if(o!==Gt.ExitCode(0))yield*new A({command:m.name,exitCode:o})})));import*as sn from"effect/Effect";import*as ve from"effect/unstable/cli/Argument";import*as Pe from"effect/unstable/cli/Command";import*as ln from"effect/unstable/process/ChildProcessSpawner";import*as L from"effect/Effect";import*as We from"effect/FileSystem";import*as Be from"effect/Path";import*as C from"effect/Effect";import*as E from"effect/Option";import{print as kr}from"esrap";import Rr from"esrap/languages/ts";import{parseSync as Ar}from"oxc-parser";var on=["typeAware","typeCheck"],Lt="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",en="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",tn="`oxlint.config.ts` already defines `typeAware` or `typeCheck`, but not as a boolean literal Adamantite can safely patch.",an="Adamantite could not generate the required `options.typeAware` and `options.typeCheck` patch.";function rt(e=[]){return e.includes("core")?e:["core",...e]}function nn(e){return e.replaceAll(/-([a-z])/g,(t,r)=>r.toUpperCase())}function ot(e,t,r=[]){let{options:n,...o}=e,i=['import { defineConfig } from "oxlint"',...t.map((h)=>`import ${nn(h)} from "${h==="core"?"adamantite/lint":`adamantite/lint/${h}`}"`)],u=[...t.map((h)=>nn(h)),...r.map((h)=>JSON.stringify(h))],y=JSON.stringify(N(n)?{...n,typeAware:!0,typeCheck:!0}:{typeAware:!0,typeCheck:!0},null,2),f=Object.entries(o).map(([h,S])=>[h,JSON.stringify(S,null,2)]),s=`[${u.join(", ")}]`,l=[["options",y],...f,["extends",s]].map(([h,S])=>` ${h}: ${S},`).join(`
10
+ `);return[...i,"","export default defineConfig({",l,"})",""].join(`
11
+ `)}function nt(e){return N(e)&&e.type==="ObjectExpression"&&Array.isArray(e.properties)}function Vt(e){return N(e)&&e.type==="Property"}function zt(e){return C.try({catch:()=>null,try:()=>Ar("oxlint.config.ts",e,{astType:"ts",lang:"ts",sourceType:"module"})}).pipe(C.match({onFailure:()=>E.none(),onSuccess:(t)=>t.errors.length===0?E.fromNullishOr(t.program):E.none()}))}function fn(e){let{code:t}=kr(e,Rr({quotes:"double"}));return t.endsWith(`
12
+ `)?t:`${t}
13
+ `}function rn(e){if(e.type==="Identifier")return e.name;if(e.type==="Literal"&&typeof e.value==="string")return e.value;return null}function Mt(e){let t=e.body.filter((i)=>i.type==="ExportDefaultDeclaration");if(t.length!==1)return E.none();let[r]=t;if(!r)return E.none();let n=r.declaration;if(nt(n))return E.fromNullishOr(n);if(n.type!=="CallExpression")return E.none();if(n.callee.type!=="Identifier"||n.callee.name!=="defineConfig")return E.none();if(n.arguments.length!==1)return E.none();let[o]=n.arguments;if(nt(o))return E.fromNullishOr(o);return E.none()}function wt(e,t){let r=null;for(let n of e.properties){if(n.type==="SpreadElement")return{status:"manual"};if(!Vt(n))return{status:"manual"};if(n.computed)return{status:"manual"};if(n.method||n.kind!=="init"){if(rn(n.key)===t)return{status:"manual"};continue}if(rn(n.key)!==t)continue;if(r)return{status:"manual"};r=n}if(!r)return{status:"missing"};return{property:r,status:"found"}}function Ir(e){let t=`export default { options: { ${e.map((r)=>`${r}: true`).join(", ")} } }
14
+ `;return zt(t).pipe(C.map((r)=>{if(E.isNone(r))return E.none();let n=Mt(r.value);if(E.isNone(n))return E.none();let o=wt(n.value,"options");if(o.status!=="found")return E.none();if(!nt(o.property.value))return E.none();let i=o.property.value.properties.filter(Vt);return i.length===o.property.value.properties.length?E.fromNullishOr(i):E.none()}))}function Vr(){let e=`export default { options: { ${on.map((t)=>`${t}: true`).join(", ")} } }
15
+ `;return zt(e).pipe(C.map((t)=>{if(E.isNone(t))return E.none();let r=Mt(t.value);if(E.isNone(r)||r.value.properties.length!==1)return E.none();let[n]=r.value.properties;if(!n||!Vt(n)||n.computed||n.method||n.kind!=="init")return E.none();return E.fromNullishOr(n)}))}function zr(e,t){return C.gen(function*(){let r=[],n=!1;for(let o of on){let i=wt(t,o);if(i.status==="manual")return{kind:"manual",reason:tn};if(i.status==="missing"){r.push(o);continue}let a=i.property.value;if(a.type!=="Literal"||typeof a.value!=="boolean")return{kind:"manual",reason:tn};if(a.value)continue;a.raw="true",a.value=!0,n=!0}if(r.length>0){let o=yield*Ir(r);if(E.isNone(o))return{kind:"manual",reason:an};t.properties.unshift(...o.value),n=!0}if(!n)return{kind:"configured"};return{kind:"patchable",updatedContent:fn(e)}})}function Ut(e){return C.gen(function*(){let t=yield*zt(e);if(E.isNone(t))return{kind:"manual",reason:Lt};let r=Mt(t.value);if(E.isNone(r))return{kind:"manual",reason:Lt};let n=wt(r.value,"options");if(n.status==="manual")return{kind:"manual",reason:en};if(n.status==="missing"){let o=yield*Vr();if(E.isNone(o))return{kind:"manual",reason:an};return r.value.properties.unshift(o.value),{kind:"patchable",updatedContent:fn(t.value)}}if(!nt(n.property.value))return{kind:"manual",reason:en};return yield*zr(t.value,n.property.value)})}var I=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}],Te="1.61.0",c=_({assess:(e)=>L.gen(function*(){let t=yield*We.FileSystem,r=yield*Be.Path,n=yield*$(e),o=Q(n);if(!o.includes("check")&&!o.includes("fix"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxlint??n.dependencies?.oxlint,a=r.join(e,I[0].path),u=r.join(e,I[1].path),y=yield*t.exists(a),f=yield*t.exists(u),s={active:y?{format:"ts",path:a}:f?{format:"json",path:u}:null,legacy:y&&f?[{format:"json",path:u}]:[]},l=[],h=[];if(s.active?.format==="ts"&&s.legacy.length>0)h.push("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(!i)l.push({description:`Install \`oxlint@${Te}\` for the managed lint scripts.`,package:"oxlint",targetVersion:Te,type:"install_package"});else if(B(i)!==Te)l.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${Te}\`.`,package:"oxlint",targetVersion:Te,type:"update_package"});if(s.active===null)l.push({description:`Create \`${I[0].path}\` for \`oxlint\`.`,path:I[0].path,type:"create_config"});if(s.active?.format==="json")l.push({description:`Migrate legacy \`${I[1].path}\` to \`${I[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(s.active?.format==="ts"){let S=yield*t.readFileString(a).pipe(L.mapError((P)=>new D({cause:P,path:a}))),k=yield*Ut(S);if(k.kind==="patchable")l.push({description:"Update `oxlint.config.ts` to enable `options.typeAware` and `options.typeCheck`.",path:I[0].path,type:"update_config"});if(k.kind==="manual")l.push({description:"Manually update `oxlint.config.ts` to enable `options.typeAware` and `options.typeCheck`; Adamantite cannot patch the current file shape safely.",path:I[0].path,type:"manual_fix"})}return{actions:l,applicable:!0,warnings:h}}),config:I[0].path,create:(e,t=[])=>L.gen(function*(){let r=yield*We.FileSystem,o=(yield*Be.Path).join(e,I[0].path),i=ot({},rt(t));yield*r.writeFileString(o,i).pipe(L.mapError((a)=>new O({cause:a,path:o})))}),exists:(e)=>L.gen(function*(){let t=yield*We.FileSystem,r=yield*Be.Path,n=r.join(e,I[0].path),o=r.join(e,I[1].path),i=yield*t.exists(n),a=yield*t.exists(o),u=i?"ts":a?"json":null,y=[];if(i&&a)y.push({format:"json",path:o});return{active:u===null?null:{format:u,path:u==="ts"?n:o},legacy:y}}),files:I,kind:"tooling",name:"oxlint",update:(e)=>L.gen(function*(){let t=yield*We.FileSystem,n=(yield*Be.Path).join(e,I[0].path);if(!(yield*t.exists(n)))return yield*new _t({path:I[0].path});let o=yield*t.readFileString(n).pipe(L.mapError((a)=>new D({cause:a,path:n}))),i=yield*Ut(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new Dt({path:I[0].path,reason:i.reason});yield*t.writeFileString(n,i.updatedContent).pipe(L.mapError((a)=>new O({cause:a,path:n})))}),version:Te});var Mr=ve.file("files",{mustExist:!0}).pipe(ve.withDescription("Specific files to lint (optional)"),ve.variadic()),pn=Pe.make("check",{files:Mr}).pipe(Pe.withDescription("Find issues and type errors in code using oxlint"),Pe.withHandler(({files:e})=>sn.gen(function*(){let r=yield*(yield*R).run({args:[...e],command:c.name});if(r!==ln.ExitCode(0))yield*new A({command:c.name,exitCode:r})})));import Gr from"node:process";import*as Ae from"effect/Effect";import*as Ie from"effect/unstable/cli/Command";import*as ht from"effect/unstable/cli/Flag";import*as Wt from"effect/unstable/process/ChildProcessSpawner";import*as De from"effect/Effect";import*as at from"effect/FileSystem";import*as ft from"effect/Path";var wr=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function Ur(e){let t=e.split(`
16
+ `);if(t.length===1)return e.slice(1,-1).trim();return t.slice(1,-1).map((r)=>` ${r.trimStart()}`).join(`
17
+ `)}function br(e,t){let r=ge(t),n=Ur(r);return[` ${e}: {`,` ...format.${e},`,...n===""?[]:[n]," },"].join(`
18
+ `)}function it(e={}){let t=Object.entries(e).map(([r,n])=>{if(wr.has(r)&&N(n))return br(r,n);let o=ge(n,{continuationIndent:" "});return` ${r}: ${o},`});if(t.length===0)return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig(format)",""].join(`
19
+ `);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...t,"})",""].join(`
20
+ `)}var b=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}],_e="0.46.0",d=_({assess:(e)=>De.gen(function*(){let t=yield*at.FileSystem,r=yield*ft.Path,n=yield*$(e);if(!Q(n).includes("format"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxfmt??n.dependencies?.oxfmt,a=r.join(e,b[0].path),u=r.join(e,b[1].path),y=r.join(e,b[2].path),f=yield*t.exists(a),s=yield*t.exists(u),l=yield*t.exists(y),h=f?"ts":l?"jsonc":s?"json":null,S=[],k=[];if(f&&(s||l))k.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!f&&s&&l)k.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(!i)S.push({description:`Install \`oxfmt@${_e}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:_e,type:"install_package"});else if(B(i)!==_e)S.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${_e}\`.`,package:"oxfmt",targetVersion:_e,type:"update_package"});if(h===null)S.push({description:`Create \`${b[0].path}\` for \`oxfmt\`.`,path:b[0].path,type:"create_config"});if(h==="json"||h==="jsonc")S.push({description:`Migrate legacy \`${h==="json"?b[1].path:b[2].path}\` to \`${b[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:k}}),config:b[0].path,create:(e)=>De.gen(function*(){let t=yield*at.FileSystem,n=(yield*ft.Path).join(e,b[0].path);yield*t.writeFileString(n,it()).pipe(De.mapError((o)=>new O({cause:o,path:n})))}),exists:(e)=>De.gen(function*(){let t=yield*at.FileSystem,r=yield*ft.Path,n=r.join(e,b[0].path),o=r.join(e,b[1].path),i=r.join(e,b[2].path),a=yield*t.exists(n),u=yield*t.exists(o),y=yield*t.exists(i),f=a?"ts":y?"jsonc":u?"json":null,s=[];if(a&&u)s.push({format:"json",path:o});if(a&&y)s.push({format:"jsonc",path:i});if(!a&&u&&y)s.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?n:f==="jsonc"?i:o},legacy:s}}),files:b,kind:"tooling",name:"oxfmt",version:_e});import*as un from"effect/Effect";var Ne="1.11.1",K=_({assess:(e)=>un.gen(function*(){let t=yield*$(e),r=Q(t);if(!r.includes("check:monorepo")&&!r.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let n=t.devDependencies?.sherif??t.dependencies?.sherif,o=[];if(!n)o.push({description:`Install \`sherif@${Ne}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:Ne,type:"install_package"});else if(B(n)!==Ne)o.push({currentVersion:n,description:`Update \`sherif\` from \`${n}\` to \`${Ne}\`.`,package:"sherif",targetVersion:Ne,type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:Ne});import*as cn from"effect/Effect";var ke="0.21.1",le=_({assess:(e)=>cn.gen(function*(){let t=yield*$(e),r=Q(t);if(!r.includes("check")&&!r.includes("fix"))return{applicable:!1,warnings:[]};let n=t.devDependencies?.["oxlint-tsgolint"]??t.dependencies?.["oxlint-tsgolint"],o=[];if(!n)o.push({description:`Install \`oxlint-tsgolint@${ke}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:ke,type:"install_package"});else if(B(n)!==ke)o.push({currentVersion:n,description:`Update \`oxlint-tsgolint\` from \`${n}\` to \`${ke}\`.`,package:"oxlint-tsgolint",targetVersion:ke,type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:ke});import*as z from"effect/Effect";import*as yn from"effect/Exit";import*as mn from"effect/FileSystem";import*as dn from"effect/Path";function pe(e){return e}function Qe(e,t,r){return z.gen(function*(){let n=yield*mn.FileSystem,o=yield*dn.Path,i=e.files??[],a=new Map;for(let y of i){let f=o.join(t.cwd,y);if(yield*n.exists(f)){let l=yield*n.readFileString(f);a.set(f,l)}else a.set(f,null)}let u=yield*z.exit(e.migrate(t).pipe(z.andThen(()=>e.validate?.(t)??z.void)));if(yn.isSuccess(u))return;if(r?.onRestore)yield*r.onRestore;for(let[y,f]of a){if(f!==null){yield*n.writeFileString(y,f).pipe(z.ignore);continue}if(!(yield*n.exists(y).pipe(z.orElseSucceed(()=>!1))))continue;yield*n.remove(y).pipe(z.ignore)}return yield*z.failCause(u.cause)})}import*as ee from"effect/Effect";import*as En from"effect/FileSystem";import*as jn from"effect/Path";import*as v from"@clack/prompts";import*as hn from"effect/Context";import*as q from"effect/Effect";import*as gn from"effect/Layer";class g extends hn.Service()("Prompter"){static layer=gn.succeed(this)({cancel:(e)=>q.sync(()=>{v.cancel(e)}),confirm:(e)=>q.promise(()=>v.confirm(e)).pipe(q.filterOrFail((t)=>!v.isCancel(t),()=>new Ce({}))),intro:(e)=>q.sync(()=>{v.intro(e)}),log:{error:(e)=>q.sync(()=>{v.log.error(e)}),info:(e)=>q.sync(()=>{v.log.info(e)}),success:(e)=>q.sync(()=>{v.log.success(e)}),warning:(e)=>q.sync(()=>{v.log.warning(e)})},multiselect:(e)=>q.promise(()=>v.multiselect(e)).pipe(q.filterOrFail((t)=>!v.isCancel(t),()=>new Ce({}))),outro:(e)=>q.sync(()=>{v.outro(e)}),spinner:()=>v.spinner()})}function On(){return[m.files[1].path,m.files[2].path]}function qr(e){let t=On();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function Jr(e){return ee.gen(function*(){let t=yield*En.FileSystem,r=yield*jn.Path,n=yield*m.exists(e);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(e,m.config),a=yield*t.readFileString(o).pipe(ee.mapError((l)=>new D({cause:l,path:o}))),u=yield*w(a,o);if(!N(u))return yield*new x({path:o});let{$schema:y,...f}=u;yield*t.writeFileString(i,Le(f)).pipe(ee.mapError((l)=>new O({cause:l,path:i}))),yield*t.remove(o).pipe(ee.mapError((l)=>new re({cause:l,path:o})));let s=n.legacy[0]?.path??null;if(s&&s!==o)yield*t.remove(s).pipe(ee.mapError((l)=>new re({cause:l,path:s})))})}var bt=pe({check:(e)=>ee.gen(function*(){let t=yield*m.exists(e.cwd),r=[];if(t.active?.format==="ts"&&t.legacy.length>0)r.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)r.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:qr(t.active.format),warnings:r};if(t.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[m.config,...On()],id:"legacy-knip-json",migrate:(e)=>ee.gen(function*(){let r=(yield*g).spinner(),o=(yield*m.exists(e.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;r.start(`Migrating \`${o}\` to \`${m.config}\`...`),yield*Jr(e.cwd),r.stop(`Knip config migrated to \`${m.config}\` successfully.`)}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>ee.gen(function*(){if((yield*m.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-knip-json",reason:`\`${m.config}\` is not the active Knip config.`})})});import*as te from"effect/Effect";import*as Sn from"effect/FileSystem";import*as Fn from"effect/Path";function $n(){return[d.files[1].path,d.files[2].path]}function xr(e){let t=$n();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${d.config}\`.`}function Wr(e){return te.gen(function*(){let t=yield*Sn.FileSystem,r=yield*Fn.Path,n=yield*d.exists(e);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(e,d.config),a=yield*t.readFileString(o).pipe(te.mapError((l)=>new D({cause:l,path:o}))),u=yield*w(a,o);if(!N(u))return yield*new x({path:o});let{$schema:y,...f}=u;yield*t.writeFileString(i,it(f)).pipe(te.mapError((l)=>new O({cause:l,path:i}))),yield*t.remove(o).pipe(te.mapError((l)=>new re({cause:l,path:o})));let s=n.legacy[0]?.path??null;if(s&&s!==o)yield*t.remove(s).pipe(te.mapError((l)=>new re({cause:l,path:s})))})}var qt=pe({check:(e)=>te.gen(function*(){let t=yield*d.exists(e.cwd),r=[];if(t.active?.format==="ts"&&t.legacy.length>0)r.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)r.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:xr(t.active.format),warnings:r};if(t.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[d.config,...$n()],id:"legacy-oxfmt-json",migrate:(e)=>te.gen(function*(){let r=(yield*g).spinner(),o=(yield*d.exists(e.cwd)).active?.path.endsWith(d.files[2].path)?d.files[2].path:d.files[1].path;r.start(`Migrating \`${o}\` to \`${d.config}\`...`),yield*Wr(e.cwd),r.stop(`Oxfmt config migrated to \`${d.config}\` successfully.`)}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>te.gen(function*(){if((yield*d.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxfmt-json",reason:`\`${d.config}\` is not the active oxfmt config.`})})});import*as oe from"effect/Effect";import*as Tn from"effect/FileSystem";import*as vn from"effect/Path";function Br(e){return oe.gen(function*(){let t=yield*Tn.FileSystem,r=yield*vn.Path,n=yield*c.exists(e);if(n.active?.format!=="json")return;let o=n.active.path,i=r.join(e,c.config),a=yield*t.readFileString(o).pipe(oe.mapError((P)=>new D({cause:P,path:o}))),u=yield*w(a,o);if(!N(u))return yield*new x({path:o});let{$schema:y,...f}=u,s=Array.isArray(f.extends)?f.extends.filter((P)=>typeof P==="string"):typeof f.extends==="string"?[f.extends]:[],l=new Set(rt()),h=new Set;for(let P of s){let J=P.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),p=P.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),F=J?.[1]??(p?p[1]??"core":null);if(F)l.add(F);else h.add(P)}let{extends:S,...k}=f;yield*t.writeFileString(i,ot(k,[...l],[...h])).pipe(oe.mapError((P)=>new O({cause:P,path:i}))),yield*t.remove(o).pipe(oe.mapError((P)=>new re({cause:P,path:o})))})}var Jt=pe({id:"legacy-oxlint-json",files:[c.config,c.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(e)=>oe.gen(function*(){let t=yield*c.exists(e.cwd),r=t.active?.format==="ts"&&t.legacy.length>0?[`Found both \`${c.config}\` and \`${c.files[1].path}\`. Adamantite will use \`${c.config}\`.`]:[];if(t.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${c.files[1].path}\` configuration to \`${c.config}\`.`,warnings:r};if(t.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),migrate:(e)=>oe.gen(function*(){let r=(yield*g).spinner();r.start(`Migrating \`${c.files[1].path}\` to \`${c.config}\`...`),yield*Br(e.cwd),r.stop(`Oxlint config migrated to \`${c.config}\` successfully.`)}),validate:(e)=>oe.gen(function*(){if((yield*c.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxlint-json",reason:`\`${c.config}\` is not the active oxlint config.`})})});import*as W from"effect/Effect";import*as xt from"effect/Exit";import*as de from"effect/Effect";import*as ut from"effect/FileSystem";import*as ct from"effect/Path";import*as st from"effect/Effect";import*as Pn from"effect/FileSystem";var _n=(e)=>st.gen(function*(){yield*(yield*Pn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(st.mapError((r)=>new me({cause:r,path:e})))});import{runScriptCommand as Qr}from"nypm";var Dn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Nn(e,t){let r=[];for(let n of Dn){if(!t.includes(n.script))continue;r.push({command:Qr(e,n.script,{args:n.args}),name:n.name})}return r}function lt(e){return Dn.some((t)=>e.includes(t.script))}var Zr={bun:` - name: Setup Node.js
10
21
  uses: actions/setup-node@v6
11
22
  with:
12
23
  node-version: "22"
@@ -53,7 +64,7 @@ import*as Nr from"@effect/platform-node/NodeRuntime";import*as er from"@effect/p
53
64
  cache: "yarn"
54
65
 
55
66
  - name: Install dependencies
56
- run: yarn install --frozen-lockfile`},bl=[{name:"lint",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function dl({packageManager:f,scripts:r}){let l=[];for(let m of bl){if(!r.includes(m.script))continue;l.push({command:EF(f,m.script,{args:m.args}),name:m.name})}if(l.length===0)return null;return`${`name: adamantite
67
+ run: yarn install --frozen-lockfile`};function kn({packageManager:e,scripts:t}){let r=Nn(e,t);if(r.length===0)return null;return`${`name: adamantite
57
68
 
58
69
  on:
59
70
  push:
@@ -78,29 +89,24 @@ jobs:
78
89
  fail-fast: false
79
90
  matrix:
80
91
  include:
81
- ${l.map((m)=>` - name: ${m.name}
82
- command: ${m.command}`).join(`
92
+ ${r.map((i)=>` - name: ${i.name}
93
+ command: ${i.command}`).join(`
83
94
  `)}
84
95
 
85
96
  steps:
86
97
  - name: Checkout
87
98
  uses: actions/checkout@v4
88
99
 
89
- ${yF[f]}
100
+ ${Zr[e]}
90
101
 
91
102
  - name: Run \${{ matrix.name }}
92
103
  run: \${{ matrix.command }}`}
93
- `}var vF=new Set(bl.map((f)=>f.script));function Cf(f){return f.some((r)=>vF.has(r))}var t={create:(f,r)=>rf.gen(function*(){let l=yield*If.FileSystem,F=yield*jf.Path,a=F.join(f,".github","workflows");yield*xl(a);let m=dl(r);if(!m)return;let E=F.join(a,"adamantite.yml");yield*l.writeFileString(E,m).pipe(rf.mapError((y)=>new M({cause:y,path:E})))}),exists:(f)=>rf.gen(function*(){let r=yield*If.FileSystem,l=yield*jf.Path;return yield*r.exists(l.join(f,".github","workflows","adamantite.yml"))}),update:(f,r)=>rf.gen(function*(){let l=yield*If.FileSystem,a=(yield*jf.Path).join(f,".github","workflows","adamantite.yml"),m=dl(r);if(!m)return;yield*l.writeFileString(a,m).pipe(rf.mapError((E)=>new M({cause:E,path:a})))}),workflowPath:".github/workflows/adamantite.yml"};import*as A from"effect/Effect";import*as Rf from"effect/FileSystem";import*as kf from"effect/Path";import*as tl from"effect/unstable/process/ChildProcessSpawner";var vl="settings.json",Ff={config:{"[css]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[graphql]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[json]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[jsonc]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"editor.codeActionsOnSave":{"source.fixAll.oxc":"explicit"},"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0},create:(f)=>A.gen(function*(){let r=yield*Rf.FileSystem,l=yield*kf.Path,F=l.join(f,".vscode"),a=l.join(F,vl);yield*r.makeDirectory(F,{recursive:!0}).pipe(A.mapError((m)=>new c({cause:m,path:F}))),yield*r.writeFileString(a,`${JSON.stringify(Ff.config,null,2)}
94
- `).pipe(A.mapError((m)=>new M({cause:m,path:a})))}),exists:(f)=>A.gen(function*(){let r=yield*Rf.FileSystem,l=yield*kf.Path;return yield*r.exists(l.join(f,".vscode",vl))}),extension:(f=[])=>A.gen(function*(){function r(F){return A.gen(function*(){let m=yield*(yield*q).run({args:["--install-extension",F],command:"code"}).pipe(A.mapError((E)=>E._tag==="CliNotFound"&&E.command==="code"?new El({cause:E}):new Uf({cause:E,extension:F})));if(m!==tl.ExitCode(0))return yield*new Uf({cause:m,extension:F})})}let l=[];if(f.includes("check")||f.includes("fix")||f.includes("format"))l.push("oxc.oxc-vscode");if(f.includes("analyze"))l.push("webpro.vscode-knip");for(let F of l)yield*r(F)}),update:(f)=>A.gen(function*(){let r=yield*Rf.FileSystem,F=(yield*kf.Path).join(f,".vscode",vl),a=yield*r.readFileString(F).pipe(A.mapError((y)=>new X({cause:y,path:F}))),m=yield*S(a,F);if(!_(m))return yield*new Y({path:F});let E=yield*o(Ff.config,m);yield*r.writeFileString(F,`${JSON.stringify(E,null,2)}
95
- `).pipe(A.mapError((y)=>new M({cause:y,path:F})))})};import*as k from"effect/Effect";import*as wf from"effect/FileSystem";import*as xf from"effect/Path";var Tl="settings.json",Mf={config:{languages:{CSS:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},HTML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSON:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSONC:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JavaScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},MDX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},Markdown:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},TSX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},YAML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}},create:(f)=>k.gen(function*(){let r=yield*wf.FileSystem,l=yield*xf.Path,F=l.join(f,".zed"),a=l.join(F,Tl);yield*r.makeDirectory(F,{recursive:!0}).pipe(k.mapError((m)=>new c({cause:m,path:F}))),yield*r.writeFileString(a,`${JSON.stringify(Mf.config,null,2)}
96
- `).pipe(k.mapError((m)=>new M({cause:m,path:a})))}),exists:(f)=>k.gen(function*(){let r=yield*wf.FileSystem,l=yield*xf.Path;return yield*r.exists(l.join(f,".zed",Tl))}),update:(f)=>k.gen(function*(){let r=yield*wf.FileSystem,F=(yield*xf.Path).join(f,".zed",Tl),a=yield*r.readFileString(F).pipe(k.mapError((y)=>new X({cause:y,path:F}))),m=yield*S(a,F);if(!_(m))return yield*new Y({path:F});let E=yield*o(Mf.config,m);yield*r.writeFileString(F,`${JSON.stringify(E,null,2)}
97
- `).pipe(k.mapError((y)=>new M({cause:y,path:F})))})};var O=C({name:"sherif",version:"1.10.0"});import*as af from"effect/Effect";import*as nl from"effect/Layer";import*as sl from"effect/ServiceMap";import{addDevDependency as TF,detectPackageManager as $F}from"nypm";class I extends sl.Service()("DependencyInstaller"){static layer=nl.succeed(this)({addDevDependencies:(f,r,l)=>af.tryPromise({catch:(F)=>new ll({cause:F,packages:f}),try:()=>TF(f,{...l,cwd:r})}).pipe(af.asVoid),detectPackageManager:(f)=>af.tryPromise({catch:(r)=>new Sf({cause:r}),try:()=>$F(f)}).pipe(af.map((r)=>r??null))})}import*as Q from"@clack/prompts";import*as U from"effect/Effect";import*as pl from"effect/Layer";import*as cl from"effect/ServiceMap";class g extends cl.Service()("Prompter"){static layer=pl.succeed(this)({cancel:(f)=>U.sync(()=>{Q.cancel(f)}),confirm:(f)=>U.promise(()=>Q.confirm(f)).pipe(U.filterOrFail((r)=>!Q.isCancel(r),()=>new Wf({}))),intro:(f)=>U.sync(()=>{Q.intro(f)}),log:{error:(f)=>U.sync(()=>{Q.log.error(f)}),info:(f)=>U.sync(()=>{Q.log.info(f)}),success:(f)=>U.sync(()=>{Q.log.success(f)}),warning:(f)=>U.sync(()=>{Q.log.warning(f)})},multiselect:(f)=>U.promise(()=>Q.multiselect(f)).pipe(U.filterOrFail((r)=>!Q.isCancel(r),()=>new Wf({}))),outro:(f)=>U.sync(()=>{Q.outro(f)}),spinner:()=>Q.spinner()})}import*as fr from"effect/Console";import*as lr from"effect/Effect";import*as rr from"effect/Terminal";var df=()=>lr.gen(function*(){let r=yield*(yield*rr.Terminal).columns,l=' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n '.split(`
98
- `).reduce((F,a)=>Math.max(F,a.trim().length),0);if(!r||r<l)return;yield*fr.info(' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n ')});import MF from"node:process";import*as mr from"effect/Effect";import*as Er from"effect/FileSystem";import*as yr from"effect/Path";import uF from"node:process";import*as gf from"effect/Effect";import*as $l from"effect/FileSystem";import*as ul from"effect/Path";var DF=/^workspace:/,iF=/^[\^~]/;function Fr(f){return f.trim().replace(DF,"").replace(iF,"")}var J=(f=uF.cwd())=>gf.gen(function*(){let r=yield*$l.FileSystem,F=(yield*ul.Path).join(f,"package.json"),a=yield*r.readFileString(F).pipe(gf.mapError((E)=>new X({cause:E,path:F})));return yield*S(a,F)}),ar=(f,r)=>gf.gen(function*(){let l=yield*$l.FileSystem,a=(yield*ul.Path).join(f,"package.json");yield*l.writeFileString(a,`${JSON.stringify(r,null,2)}
99
- `).pipe(gf.mapError((m)=>new M({cause:m,path:a})))});var Dl=(f=MF.cwd())=>mr.gen(function*(){let r=yield*Er.FileSystem,l=yield*yr.Path;if(yield*r.exists(l.join(f,"pnpm-workspace.yaml")))return!0;return(yield*J(f)).workspaces!==void 0});import*as n from"effect/Effect";import*as bf from"effect/FileSystem";import*as tf from"effect/Path";var il="tsconfig.json",N={config:{extends:"adamantite/typescript"},create:(f)=>n.gen(function*(){let r=yield*bf.FileSystem,F=(yield*tf.Path).join(f,il),a=JSON.stringify(N.config,null,2);yield*r.writeFileString(F,`${a}
100
- `).pipe(n.mapError((m)=>new M({cause:m,path:F})))}),exists:(f)=>n.gen(function*(){let r=yield*bf.FileSystem,l=yield*tf.Path;return yield*r.exists(l.join(f,il))}),update:(f)=>n.gen(function*(){let r=yield*bf.FileSystem,F=(yield*tf.Path).join(f,il),a=yield*r.readFileString(F).pipe(n.mapError((y)=>new X({cause:y,path:F}))),m=yield*S(a,F);if(!_(m))return yield*new Y({path:F});let E=yield*o(N.config,m);yield*r.writeFileString(F,`${JSON.stringify(E,null,2)}
101
- `).pipe(n.mapError((y)=>new M({cause:y,path:F})))})};var VF=(f,r)=>D.gen(function*(){let l=yield*I,a=(yield*g).spinner();a.start("Installing dependencies...");let m=yield*Dl(f);yield*l.addDevDependencies(r,f,{silent:!0,workspace:m}).pipe(D.tapError(()=>D.sync(()=>{a.stop("Failed to install dependencies.")}))),a.stop("Dependencies installed.")}),QF=(f,r)=>D.gen(function*(){let l=yield*g,F=l.spinner();F.start("Setting up oxlint config...");let a=yield*$.exists(f);if(a.hasBoth)yield*l.log.warning("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(a.format==="json")F.message("Found `.oxlintrc.json`, migrating to `oxlint.config.ts`..."),yield*$.update(f,r),F.stop("oxlint config migrated successfully.");else if(a.format==="ts")F.message("Found `oxlint.config.ts`, keeping existing config."),F.stop("oxlint config is ready.");else F.message("`oxlint.config.ts` not found, creating..."),yield*$.create(f,r),F.stop("oxlint config created successfully.")}),zF=(f)=>D.gen(function*(){let l=(yield*g).spinner();l.start("Setting up oxfmt config...");let F=yield*B.exists(f);if(F.path)l.message(`Found \`${F.path}\`, updating...`),yield*B.update(f),l.stop("oxfmt config updated successfully.");else l.message("`.oxfmtrc.jsonc` or `.oxfmtrc.json` not found, creating..."),yield*B.create(f),l.stop("oxfmt config created successfully.")}),XF=(f,r)=>D.gen(function*(){let l=yield*vr.FileSystem,F=yield*Tr.Path,a=yield*g,m=yield*J(f),E=a.spinner();E.start("Adding scripts to your `package.json`..."),m.scripts??={};for(let u of r)switch(u){case"check":m.scripts.check="adamantite check";break;case"fix":m.scripts.fix="adamantite fix";break;case"format":m.scripts.format="adamantite format";break;case"check:monorepo":m.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":m.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":m.scripts.analyze="adamantite analyze";break;default:return yield*new ml({script:u})}let y=F.join(f,"package.json");yield*l.writeFileString(y,`${JSON.stringify(m,null,2)}
102
- `).pipe(D.mapError((u)=>new M({cause:u,path:y}))),E.stop("Scripts added to your `package.json`")}),qF=(f)=>D.gen(function*(){let l=(yield*g).spinner();l.start("Setting up knip config...");let F=yield*L.exists(f);if(F.path)l.message(`Found \`${F.path}\`, updating...`),yield*L.update(f),l.stop("knip config updated successfully.");else l.message("`knip.json` not found, creating..."),yield*L.create(f),l.stop("knip config created successfully.")}),ZF=(f)=>D.gen(function*(){let l=(yield*g).spinner();if(l.start("Setting up TypeScript config..."),yield*N.exists(f))l.message("`tsconfig.json` found, updating..."),yield*N.update(f),l.stop("`tsconfig.json` updated successfully");else l.message("`tsconfig.json` not found, creating..."),yield*N.create(f),l.stop("`tsconfig.json` created successfully")}),KF=(f,r)=>D.gen(function*(){let l=yield*g;if(r.includes("vscode")){let F=l.spinner();if(F.start("Checking for `.vscode/settings.json`..."),yield*Ff.exists(f))F.message("`.vscode/settings.json` found, updating..."),yield*Ff.update(f),F.stop("`.vscode/settings.json` updated with Adamantite preset.");else F.message("`.vscode/settings.json` not found, creating..."),yield*Ff.create(f),F.stop("`.vscode/settings.json` created with Adamantite preset.")}if(r.includes("zed")){let F=l.spinner();if(F.start("Checking for `.zed/settings.json`..."),yield*Mf.exists(f))F.message("`.zed/settings.json` found, updating..."),yield*Mf.update(f),F.stop("`.zed/settings.json` updated with Adamantite preset.");else F.message("`.zed/settings.json` not found, creating..."),yield*Mf.create(f),F.stop("`.zed/settings.json` created with Adamantite preset.")}}),HF=(f,r)=>D.gen(function*(){let l=yield*g,F=l.spinner();F.start("Installing editor extensions...");let a=f.includes("zed"),m=f.includes("vscode");if(yield*D.gen(function*(){if(f.includes("vscode"))F.message("Installing VS Code extension..."),yield*Ff.extension(r);return!0}).pipe(D.tapError(()=>D.sync(()=>{F.stop()})),D.catchTag("FailedToInstallExtension",(y)=>D.gen(function*(){return yield*l.log.warning(`⚠️ Failed to install the \`${y.extension}\` extension.`),yield*l.log.warning("Please install it manually after setup completes."),!1})),D.catchTag("VscodeCliNotFound",()=>D.gen(function*(){return yield*l.log.error("VSCode CLI ('code' command) not found."),yield*l.log.info("To install it:"),yield*l.log.info(" 1. Open VS Code"),yield*l.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*l.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))))if(a&&!m)F.stop("Zed extensions require manual install.");else F.stop("Editor extensions installed successfully.");if(a)yield*l.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),SF=(f,r,l)=>D.gen(function*(){let a=(yield*g).spinner();if(a.start("Setting up GitHub Actions workflow..."),yield*t.exists(f))a.message("`.github/workflows/adamantite.yml` found, updating..."),yield*t.update(f,{packageManager:r,scripts:l}),a.stop("GitHub Actions workflow updated successfully.");else a.message("Creating `.github/workflows/adamantite.yml`..."),yield*t.create(f,{packageManager:r,scripts:l}),a.stop("GitHub Actions workflow created successfully.")}).pipe(D.option),$r=Vf.make("init").pipe(Vf.withDescription("Initialize Adamantite in the current directory"),Vf.withHandler(()=>D.gen(function*(){let f=gF.cwd(),r=yield*g;yield*df(),yield*r.intro("\uD83D\uDCA0 adamantite init");let F=yield*(yield*I).detectPackageManager(f);if(!F)return yield*new Sf({});if(F.warnings?.length)for(let Hf of F.warnings)yield*r.log.warning(Hf);yield*r.log.info(`Detected package manager: ${F.name}`);let a=yield*Dl(f);if(a)yield*r.log.info("We've detected a monorepo setup in your project.");let m=yield*r.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues and type errors using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{disabled:!a,hint:a?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!a,hint:a?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),E=m.includes("check")||m.includes("fix"),y=[];if(E)y=yield*r.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let u=!1;if(E)u=yield*r.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"});let T=yield*r.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),v=!1;if(T.length>0)v=yield*r.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let i=Cf(m),V=!1;if(i)V=yield*r.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let Z=m.includes("format"),cf=m.includes("check:monorepo")||m.includes("fix:monorepo"),Kf=m.includes("analyze"),j=["adamantite"];if(E)j.push(`${$.name}@${$.version}`),j.push(`${lf.name}@${lf.version}`);if(Z)j.push(`${B.name}@${B.version}`);if(cf)j.push(`${O.name}@${O.version}`);if(Kf)j.push(`${L.name}@${L.version}`);if(yield*VF(f,j),Z)yield*zF(f);if(E)yield*QF(f,y);if(Kf)yield*qF(f);if(yield*XF(f,m),u)yield*ZF(f);if(yield*KF(f,T),v)yield*HF(T,m);if(V)yield*SF(f,F.name,m);yield*r.log.success("Your project is now configured"),yield*r.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(D.catchTags({OperationCancelled:()=>D.gen(function*(){yield*(yield*g).cancel("You've cancelled the initialization process.")})}))));import*as ur from"effect/Effect";import*as Qf from"effect/unstable/cli/Command";import*as nf from"effect/unstable/cli/Flag";import*as Dr from"effect/unstable/process/ChildProcessSpawner";var UF=nf.boolean("fix").pipe(nf.withDescription("Automatically fix issues")),ir=Qf.make("monorepo",{fix:UF}).pipe(Qf.withDescription("Find and fix monorepo-specific issues using Sherif"),Qf.withHandler(({fix:f})=>ur.gen(function*(){let r=yield*q,l=f?["--fix"]:[],F=yield*r.run({args:l,command:O.name,stdin:"inherit"});if(F!==Dr.ExitCode(0))yield*new W({command:O.name,exitCode:F})})));import*as Mr from"effect/Effect";import*as zf from"effect/unstable/cli/Command";import*as gr from"effect/unstable/process/ChildProcessSpawner";var Vr=zf.make("typecheck").pipe(zf.withDescription("Deprecated alias for `check`"),zf.withHandler(()=>Mr.gen(function*(){let f=yield*g,r=yield*q;yield*f.log.warning("Deprecated. Use `adamantite check` for typechecking.");let l=yield*r.run({args:[],command:$.name});if(l!==gr.ExitCode(0))yield*new W({command:$.name,exitCode:l})})));import RF from"node:process";import*as K from"effect/Effect";import*as Zf from"effect/unstable/cli/Command";import*as Ml from"effect/Effect";import*as gl from"effect/FileSystem";import*as Qr from"effect/Path";function Xf(f){return f}function zr(f,r){return Ml.gen(function*(){let l=yield*gl.FileSystem,F=yield*Qr.Path,a=new Map;for(let m of r){let E=F.join(f,m);if(yield*l.exists(E)){let u=yield*l.readFileString(E);a.set(E,u)}else a.set(E,null)}return a})}function Xr(f){return Ml.gen(function*(){let r=yield*gl.FileSystem;for(let[l,F]of f)if(F===null){if(yield*r.exists(l))yield*r.remove(l)}else yield*r.writeFileString(l,F)})}import*as sf from"effect/Effect";var WF="Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.",YF="Migrating legacy `.oxlintrc.json` configuration to `oxlint.config.ts`.",qr=Xf({id:"legacy-oxlint-json",files:["oxlint.config.ts",".oxlintrc.json"],tags:["update"],title:"Legacy oxlint JSON config",check:(f)=>sf.gen(function*(){let r=yield*$.exists(f.cwd),l=r.hasBoth?[WF]:[];if(r.format==="json")return{status:"needs_migration",summary:YF,warnings:l};if(r.format==="ts")return{status:"valid",warnings:l};return{status:"not_applicable",warnings:l}}),migrate:(f)=>sf.gen(function*(){let l=(yield*g).spinner();l.start("Migrating `.oxlintrc.json` to `oxlint.config.ts`..."),yield*$.update(f.cwd),l.stop("Oxlint config migrated to `oxlint.config.ts` successfully.")}),validate:(f)=>sf.gen(function*(){if((yield*$.exists(f.cwd)).format!=="ts")return yield*new P({migrationId:"legacy-oxlint-json",reason:"`oxlint.config.ts` is not the active oxlint config."})})});import*as G from"effect/Effect";import*as Ql from"effect/Exit";var Vl={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function qf(f){let r=f.scripts??{},l=[];for(let[F,a]of Object.entries(Vl))if(r[F]===a)l.push(F);return l}var Zr="adamantite typecheck";function pf(f){let r={...f.scripts};if(r.typecheck!==Zr)return{migrated:!1,packageJson:f};return delete r.typecheck,r.check??=Vl.check,{migrated:!0,packageJson:{...f,scripts:r}}}var Kr=Xf({check:(f)=>G.gen(function*(){let r=yield*J(f.cwd),{migrated:l}=pf(r);if(!l)return{status:"not_applicable",warnings:[]};return{status:"needs_migration",summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json","oxlint.config.ts",".oxlintrc.json","tsconfig.json",t.workflowPath],id:"legacy-typecheck-script",migrate:(f)=>G.gen(function*(){let r=yield*g,l=yield*I,F=r.spinner(),a=G.gen(function*(){let m=yield*J(f.cwd),E=pf(m);if(!E.migrated)return"noop";if(yield*ar(f.cwd,E.packageJson),(yield*$.exists(f.cwd)).format===null)yield*$.create(f.cwd);yield*(yield*N.exists(f.cwd))?N.update(f.cwd):N.create(f.cwd);let T=yield*t.exists(f.cwd),v=qf(E.packageJson);if(T&&Cf(v)){let i=yield*l.detectPackageManager(f.cwd);if(i){let V=r.spinner();V.start("Updating GitHub Actions workflow..."),yield*t.update(f.cwd,{packageManager:i.name,scripts:v}).pipe(G.onExit((Z)=>G.sync(()=>{V.stop(Ql.match(Z,{onFailure:()=>"Failed to update GitHub Actions workflow.",onSuccess:()=>"GitHub Actions workflow updated successfully"}))})))}else yield*r.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});F.start("Migrating `typecheck` script to unified `check` command..."),yield*a.pipe(G.onExit((m)=>G.sync(()=>{F.stop(Ql.match(m,{onFailure:()=>"Legacy `typecheck` script migration failed.",onSuccess:(E)=>E==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}))})),G.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(f)=>G.gen(function*(){if((yield*J(f.cwd)).scripts?.typecheck===Zr)return yield*new P({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*$.exists(f.cwd)).format!=="ts")return yield*new P({migrationId:"legacy-typecheck-script",reason:"`oxlint.config.ts` is not the active oxlint config."});if(!(yield*N.exists(f.cwd)))return yield*new P({migrationId:"legacy-typecheck-script",reason:"`tsconfig.json` is missing after the migration."})})});import{parse as _F}from"@babel/parser";import*as s from"effect/Effect";import*as Kl from"effect/FileSystem";import*as Ur from"effect/Path";var LF="oxlint.config.ts",BF="Updating `oxlint.config.ts` so `options.typeAware` and `options.typeCheck` are enabled for managed lint scripts.",GF="Adamantite found an `oxlint.config.ts` that still needs `typeAware` and `typeCheck`, but the file shape is not supported for automatic patching. The migration will stop and ask for a manual fix.",Wr=["typeAware","typeCheck"],ql="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",Zl="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",Hr="`oxlint.config.ts` already defines `typeAware` or `typeCheck`, but not as a boolean literal Adamantite can safely patch.";function AF(f){let r=pf(f).packageJson,l=qf(r);return l.includes("check")||l.includes("fix")}function Yr(f){return typeof f.start==="number"&&typeof f.end==="number"}function JF(f){return f.includes(`\r
103
- `)?`\r
104
- `:`
105
- `}function NF(f,r){let l=f.lastIndexOf(`
106
- `,r-1)+1,F=l;while(F<r){let a=f[F];if(a!==" "&&a!=="\t")break;F+=1}return f.slice(l,F)}function eF(f,r,l,F,a){let m=f.slice(r,l);if(!m.includes(a))return`${F} `;for(let E of m.split(a)){if(E.trim().length===0)continue;return E.match(/^[ \t]*/)?.[0]??`${F} `}return`${F} `}function _r(f,r){if(!Yr(r))return null;let l=r.end-1;if(f[r.start]!=="{"||f[l]!=="}")return null;let F=JF(f),a=NF(f,l);return{bodyEnd:l,bodyStart:r.start+1,closeIndent:a,newline:F,propertyIndent:eF(f,r.start+1,l,a,F)}}function Lr(f,r,l){if(r.length===0)return f;let F=f.startsWith(l.newline)?f.slice(l.newline.length):f.trim();if(F.trim().length===0)return`${l.newline}${r.join(l.newline)}${l.newline}${l.closeIndent}`;if(f.startsWith(l.newline))return`${l.newline}${r.join(l.newline)}${l.newline}${F}`;return`${l.newline}${r.join(l.newline)}${l.newline}${l.propertyIndent}${f.trim()}${l.newline}${l.closeIndent}`}function PF(f){let r=`${f.propertyIndent} `;return[`${f.propertyIndent}options: {`,...Wr.map((l)=>`${r}${l}: true,`),`${f.propertyIndent}},`].join(f.newline)}function hF(f,r){let l=f;for(let F of r)l=l.slice(0,F.start)+F.text+l.slice(F.end);return l}function oF(f,r){let l=f.findIndex((F)=>r.start>F.start);if(l===-1){f.push(r);return}f.splice(l,0,r)}function OF(f){try{return _F(f,{plugins:["typescript"],sourceType:"module"})}catch{return null}}function Sr(f){if(typeof f==="object"&&f!==null&&"type"in f&&f.type==="Identifier"&&"name"in f&&typeof f.name==="string")return f.name;if(typeof f==="object"&&f!==null&&"type"in f&&f.type==="StringLiteral"&&"value"in f&&typeof f.value==="string")return f.value;return null}function IF(f){let r=[];for(let a of f.program.body)if(typeof a==="object"&&"type"in a&&a.type==="ExportDefaultDeclaration"&&"declaration"in a)r.push(a);if(r.length!==1)return null;let l=r[0]?.declaration;if(typeof l==="object"&&l!==null&&"type"in l&&l.type==="ObjectExpression"&&"properties"in l&&Array.isArray(l.properties))return l;if(typeof l!=="object"||l===null||!("type"in l)||l.type!=="CallExpression"||!("callee"in l)||!("arguments"in l)||!Array.isArray(l.arguments))return null;if(typeof l.callee!=="object"||l.callee===null||!("type"in l.callee)||l.callee.type!=="Identifier"||!("name"in l.callee)||l.callee.name!=="defineConfig")return null;if(l.arguments.length!==1)return null;let[F]=l.arguments;if(typeof F==="object"&&F!==null&&"type"in F&&F.type==="ObjectExpression"&&"properties"in F&&Array.isArray(F.properties))return F;return null}function Br(f,r){let l=null;for(let F of f.properties){if(typeof F==="object"&&F!==null&&"type"in F&&F.type==="SpreadElement")return{status:"manual"};if(typeof F==="object"&&F!==null&&"type"in F&&F.type==="ObjectMethod"&&"key"in F){let m=F;if(m.computed)return{status:"manual"};if(Sr(m.key)===r)return{status:"manual"};continue}if(typeof F!=="object"||F===null||!("type"in F)||F.type!=="ObjectProperty"||!("key"in F)||!("value"in F))return{status:"manual"};let a=F;if(a.computed)return{status:"manual"};if(Sr(a.key)!==r)continue;if(l)return{status:"manual"};l=a}if(!l)return{status:"missing"};return{property:l,status:"found"}}function jF(f,r){let l=_r(f,r);if(!l)return{kind:"manual",reason:Zl};let F=f.slice(l.bodyStart,l.bodyEnd),a=[],m=[];for(let y of Wr){let u=Br(r,y);if(u.status==="manual")return{kind:"manual",reason:Hr};if(u.status==="missing"){a.push(y);continue}let T=u.property.value;if(typeof T!=="object"||T===null||!("type"in T)||T.type!=="BooleanLiteral"||!("value"in T)||typeof T.value!=="boolean"||!("start"in T)||!("end"in T)||!Yr(T))return{kind:"manual",reason:Hr};let v=T;if(v.value)continue;oF(m,{end:v.end-l.bodyStart,start:v.start-l.bodyStart,text:"true"})}let E=hF(F,m);if(a.length>0)E=Lr(E,a.map((y)=>`${l.propertyIndent}${y}: true,`),l);if(E===F)return{kind:"configured"};return{kind:"patchable",updatedContent:`${f.slice(0,l.bodyStart)}${E}${f.slice(l.bodyEnd)}`}}function CF(f,r){let l=_r(f,r);if(!l)return{kind:"manual",reason:ql};let F=Lr(f.slice(l.bodyStart,l.bodyEnd),[PF(l)],l);return{kind:"patchable",updatedContent:`${f.slice(0,l.bodyStart)}${F}${f.slice(l.bodyEnd)}`}}function zl(f){let r=OF(f);if(!r)return{kind:"manual",reason:ql};let l=IF(r);if(!l)return{kind:"manual",reason:ql};let F=Br(l,"options");if(F.status==="manual")return{kind:"manual",reason:Zl};if(F.status==="missing")return CF(f,l);if(typeof F.property.value!=="object"||F.property.value===null||!("type"in F.property.value)||F.property.value.type!=="ObjectExpression"||!("properties"in F.property.value)||!Array.isArray(F.property.value.properties))return{kind:"manual",reason:Zl};let a=F.property.value;return jF(f,a)}function Xl(f){return s.gen(function*(){let r=yield*J(f);if(!AF(r))return{status:"not_applicable"};if((yield*$.exists(f)).format!=="ts")return{status:"not_applicable"};let F=yield*Kl.FileSystem,m=(yield*Ur.Path).join(f,LF),E=yield*F.readFileString(m).pipe(s.mapError((y)=>new X({cause:y,path:m})));return{configPath:m,content:E,status:"applicable"}})}var Gr=Xf({check:(f)=>s.gen(function*(){let r=yield*Xl(f.cwd);if(r.status==="not_applicable")return{status:"not_applicable",warnings:[]};let l=zl(r.content);if(l.kind==="configured")return{status:"valid",warnings:[]};return{status:"needs_migration",summary:BF,warnings:l.kind==="manual"?[GF]:[]}}),files:["oxlint.config.ts"],id:"oxlint-typecheck",migrate:(f)=>s.gen(function*(){let l=(yield*g).spinner();l.start("Updating `oxlint.config.ts` for type-aware linting...");let F=yield*Xl(f.cwd);if(F.status==="not_applicable"){l.stop("No migration needed.");return}let a=zl(F.content);if(a.kind==="configured"){l.stop("`oxlint.config.ts` already enables type-aware linting.");return}if(a.kind==="manual")return yield*new P({migrationId:"oxlint-typecheck",reason:a.reason});yield*(yield*Kl.FileSystem).writeFileString(F.configPath,a.updatedContent).pipe(s.mapError((E)=>new M({cause:E,path:F.configPath}))),l.stop("`oxlint.config.ts` updated for type-aware linting.")}),tags:["update"],title:"Oxlint type-aware config",validate:(f)=>s.gen(function*(){let r=yield*Xl(f.cwd);if(r.status==="not_applicable")return;let l=zl(r.content);if(l.kind==="configured")return;return yield*new P({migrationId:"oxlint-typecheck",reason:l.kind==="patchable"?"`oxlint.config.ts` still needs `options.typeAware` and `options.typeCheck` set to `true`.":l.reason})})});var Ar=[qr,Gr,Kr];function kF(f){let r=new Map;if(f.includes("check")||f.includes("fix"))r.set($.name,$),r.set(lf.name,lf);if(f.includes("format"))r.set(B.name,B);if(f.includes("check:monorepo")||f.includes("fix:monorepo"))r.set(O.name,O);if(f.includes("analyze"))r.set(L.name,L);return[...r.values()]}var Jr=Zf.make("update").pipe(Zf.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Zf.withHandler(()=>K.gen(function*(){let f=RF.cwd(),r=yield*g,l=yield*I,F={cwd:f};yield*df(),yield*r.intro("\uD83D\uDCA0 adamantite update");let a=[];for(let v of Ar.filter((i)=>i.tags.includes("update"))){let i=yield*v.check(F);a.push({migration:v,result:i})}for(let v of a){for(let i of v.result.warnings)yield*r.log.warning(i);if(v.result.status==="needs_migration"&&v.result.summary)yield*r.log.info(v.result.summary)}let m=[];for(let{migration:v,result:i}of a){if(i.status!=="needs_migration")continue;let V=v.files??[],Z=yield*zr(f,V);yield*K.gen(function*(){if(yield*v.migrate(F),v.validate)yield*v.validate(F);m.push(v.id)}).pipe(K.tapError(()=>K.gen(function*(){yield*r.log.warning(`Migration "${v.title}" failed, restoring files...`),yield*Xr(Z).pipe(K.ignore)})))}if(m.length>0)yield*r.log.success("Migrations ran successfully.");let E=yield*J(f),y=qf(E),u=kF(y),T=[];for(let v of[$,lf,B,O,L]){let i=E.devDependencies?.[v.name];if(i&&Fr(i)!==v.version)T.push({currentVersion:i,isDevDependency:!0,name:v.name,targetVersion:v.version})}for(let v of u)if(!E.devDependencies?.[v.name])T.push({currentVersion:"not installed",isDevDependency:!0,name:v.name,targetVersion:v.version});if(T.length>0){yield*r.log.info("The following dependencies will be updated:");for(let i of T)yield*r.log.info(` ${i.name}: ${i.currentVersion} → ${i.targetVersion}`);let v=r.spinner();v.start("Updating dependencies..."),yield*l.addDevDependencies(T.map((i)=>`${i.name}@${i.targetVersion}`),f,{silent:!0}).pipe(K.tapError(()=>K.sync(()=>{v.stop("Failed to update dependencies")}))),v.stop("Dependencies updated successfully"),yield*r.log.success("Dependencies updated successfully.")}if(m.length===0&&T.length===0)return yield*r.log.success("No changes needed."),"no-changes";return"success"}).pipe(K.tapError(()=>K.gen(function*(){yield*(yield*g).outro("❌ Update failed")})),K.tap((f)=>K.gen(function*(){let r=yield*g;switch(f){case"no-changes":yield*r.outro("✅ Adamantite is already up to date.");break;case"success":yield*r.outro("✅ Update completed successfully!");break;default:break}})))));var wF=p.make("adamantite").pipe(p.withDescription("Opinionated preset package for modern TypeScript applications"),p.withSubcommands([Gl,hl,Il,kl,$r,ir,Vr,Jr])),xF=await"0.31.0",dF=p.run(wF,{version:xF}).pipe(H.as(0),H.catchTag("CommandFailed",(f)=>H.succeed(f.exitCode)),H.catch((f)=>H.service(g).pipe(H.flatMap((r)=>r.log.error(f.message)),H.as(Or.ExitCode(1)))),H.provide(hr.mergeAll(er.layer,g.layer,q.layer,I.layer)));Nr.runMain(dF,{teardown:(f,r)=>{if(Pr.isSuccess(f)){r(Number(f.value));return}or.defaultTeardown(f,r)}});
104
+ `}var pt=[{path:".github/workflows/adamantite.yml",type:"ci"}],ie=_({create:(e,t)=>de.gen(function*(){let r=yield*ut.FileSystem,n=yield*ct.Path,o=n.join(e,pt[0].path);yield*_n(n.dirname(o));let i=kn(t);if(!i)return;yield*r.writeFileString(o,i).pipe(de.mapError((a)=>new O({cause:a,path:o})))}),exists:(e)=>de.gen(function*(){let t=yield*ut.FileSystem,r=yield*ct.Path;return yield*t.exists(r.join(e,pt[0].path))}),files:pt,kind:"ci",name:"github",update:(e,t)=>de.gen(function*(){let r=yield*ut.FileSystem,o=(yield*ct.Path).join(e,pt[0].path),i=kn(t);if(!i)return;yield*r.writeFileString(o,i).pipe(de.mapError((a)=>new O({cause:a,path:o})))})});import*as Rn from"effect/Context";import*as he from"effect/Effect";import*as An from"effect/Layer";import{addDevDependency as Xr,detectPackageManager as Yr}from"nypm";class Z extends Rn.Service()("DependencyInstaller"){static layer=An.succeed(this)({addDevDependencies:(e,t,r)=>he.tryPromise({catch:(n)=>new Tt({cause:n,packages:e}),try:()=>Xr(e,{...r,cwd:t})}).pipe(he.asVoid),detectPackageManager:(e)=>he.tryPromise({catch:(t)=>new xe({cause:t}),try:()=>Yr(e)}).pipe(he.map((t)=>t??null))})}import*as ue from"effect/Effect";import*as yt from"effect/FileSystem";import*as mt from"effect/Path";var Ze=[{path:"tsconfig.json",type:"config"}],In={extends:"adamantite/typescript"},V=_({config:Ze[0].path,create:(e)=>ue.gen(function*(){let t=yield*yt.FileSystem,n=(yield*mt.Path).join(e,Ze[0].path),o=JSON.stringify(In,null,2);yield*t.writeFileString(n,`${o}
105
+ `).pipe(ue.mapError((i)=>new O({cause:i,path:n})))}),exists:(e)=>ue.gen(function*(){let t=yield*yt.FileSystem,r=yield*mt.Path;return yield*t.exists(r.join(e,Ze[0].path))}),files:Ze,kind:"workspace",name:"tsconfig",update:(e)=>ue.gen(function*(){let t=yield*yt.FileSystem,n=(yield*mt.Path).join(e,Ze[0].path),o=yield*t.readFileString(n).pipe(ue.mapError((u)=>new D({cause:u,path:n}))),i=yield*w(o,n);if(!N(i))return yield*new x({path:n});let a=yield*Ee(In,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
106
+ `).pipe(ue.mapError((u)=>new O({cause:u,path:n})))})});var zn="adamantite typecheck";function Hr(){return c.files[1].path}function Kr(){return ie.files[0].path}function Vn(e){let t={...e.scripts};if(t.typecheck!==zn)return{migrated:!1,packageJson:e};return delete t.typecheck,t.check??=It.check,{migrated:!0,packageJson:{...e,scripts:t}}}var Mn=pe({check:(e)=>W.gen(function*(){let t=yield*$(e.cwd),{migrated:r}=Vn(t);if(!r)return{applicable:!1,warnings:[]};return{applicable:!0,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json",c.config,Hr(),V.config,Kr()],id:"legacy-typecheck-script",migrate:(e)=>W.gen(function*(){let t=yield*g,r=yield*Z,n=t.spinner(),o=W.gen(function*(){let i=yield*$(e.cwd),a=Vn(i);if(!a.migrated)return"noop";yield*Zt(e.cwd,a.packageJson);let u=yield*c.exists(e.cwd);if(u.active===null)yield*c.create(e.cwd);else if(u.active.format==="ts")yield*c.update(e.cwd);yield*(yield*V.exists(e.cwd))?V.update(e.cwd):V.create(e.cwd);let f=yield*ie.exists(e.cwd),s=Q(a.packageJson);if(f&&lt(s)){let l=yield*r.detectPackageManager(e.cwd);if(l){let h=t.spinner();h.start("Updating GitHub Actions workflow..."),yield*ie.update(e.cwd,{packageManager:l.name,scripts:s}).pipe(W.onExit((S)=>W.sync(()=>{h.stop(xt.match(S,{onFailure:()=>"Failed to update GitHub Actions workflow.",onSuccess:()=>"GitHub Actions workflow updated successfully"}))})))}else yield*t.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});n.start("Migrating `typecheck` script to unified `check` command..."),yield*o.pipe(W.onExit((i)=>W.sync(()=>{n.stop(xt.match(i,{onFailure:()=>"Legacy `typecheck` script migration failed.",onSuccess:(a)=>a==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}))})),W.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(e)=>W.gen(function*(){if((yield*$(e.cwd)).scripts?.typecheck===zn)return yield*new H({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*c.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${c.config}\` is not the active oxlint config.`});if(!(yield*V.exists(e.cwd)))return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${V.config}\` is missing after the migration.`})})});var dt=[qt,bt,Jt,Mn],wn=Object.fromEntries(dt.map((e)=>[e.id,e])),Un={[bt.id]:m.name,[qt.id]:d.name,[Jt.id]:c.name};import*as bn from"effect/Console";import*as qn from"effect/Effect";import*as Jn from"effect/Terminal";var Re=()=>qn.gen(function*(){let t=yield*(yield*Jn.Terminal).columns,r=' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n '.split(`
107
+ `).reduce((n,o)=>Math.max(n,o.trim().length),0);if(!t||t<r)return;yield*bn.info(' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n ')});var Cr=ht.boolean("fix").pipe(ht.withDescription("Automatically fix safe package install/update issues")),Lr=[m,d,c,K,le];function eo(e){return e.applicable&&Array.isArray(e.actions)}var xn={[m.name]:m,[d.name]:d,[c.name]:c},Wn={[c.name]:c};function Bn(e,t){return Object.hasOwn(e,t)}function Xe(e,t){switch(t.type){case"install_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"update_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"create_config":case"update_config":return`${e}:${t.type}:${t.path}`;case"manual_fix":return`${e}:${t.type}:${t.path??t.description}`;case"run_migration":return`${e}:${t.type}:${t.migrationId}`}}var Qn=Ie.make("doctor",{fix:Cr}).pipe(Ie.withDescription("Check Adamantite-managed integrations in the current project"),Ie.withHandler(({fix:e})=>Ae.gen(function*(){let t=Gr.cwd(),r=yield*g;yield*Re(),yield*r.intro("\uD83D\uDCA0 adamantite doctor");let n=yield*$(t);if(!n.devDependencies?.adamantite&&!n.dependencies?.adamantite)yield*r.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*r.outro("⚠️ Doctor found issues."),yield*new A({command:"doctor",exitCode:Wt.ExitCode(1)});let o=[];for(let y of Lr){let f=yield*y.assess(t);if(eo(f))o.push({assessment:f,integration:y})}for(let{assessment:y}of o)for(let f of y.warnings)yield*r.log.warning(f);if(o.length===0){yield*r.log.success("No applicable integrations found."),yield*r.outro("✅ Doctor completed successfully!");return}let i=o.flatMap(({assessment:y,integration:f})=>y.actions.map((s)=>({action:s,integration:f})));if(i.length===0){yield*r.log.success("No issues found."),yield*r.outro("✅ Doctor completed successfully!");return}let a=new Set;if(e)yield*Ae.gen(function*(){let y=i.filter(({action:f})=>f.type==="install_package"||f.type==="update_package");if(y.length>0){let f=yield*Z,s=[];for(let{action:l}of y)if(l.type==="install_package"||l.type==="update_package")s.push(`${l.package}@${l.targetVersion}`);yield*f.addDevDependencies(s,t,{silent:!0});for(let{action:l,integration:h}of y){if(l.type==="install_package")yield*r.log.success(`Fixed: installed \`${l.package}@${l.targetVersion}\`.`);if(l.type==="update_package")yield*r.log.success(`Fixed: updated \`${l.package}\` from \`${l.currentVersion}\` to \`${l.targetVersion}\`.`);a.add(Xe(h.name,l))}}for(let{action:f,integration:s}of i){if(f.type!=="create_config")continue;if(!Bn(xn,s.name))continue;yield*xn[s.name].create(t),yield*r.log.success(`Fixed: created \`${f.path}\`.`),a.add(Xe(s.name,f))}for(let{action:f,integration:s}of i){if(f.type!=="update_config")continue;if(!Bn(Wn,s.name))continue;yield*Wn[s.name].update(t),yield*r.log.success(`Fixed: updated \`${f.path}\`.`),a.add(Xe(s.name,f))}for(let{action:f,integration:s}of i){if(f.type!=="run_migration")continue;let l=wn[f.migrationId];if(!l)continue;yield*Qe(l,{cwd:t}),a.add(Xe(s.name,f))}}).pipe(Ae.tapError(()=>Ae.gen(function*(){yield*r.outro("❌ Doctor failed")})));let u=i.filter(({action:y,integration:f})=>!a.has(Xe(f.name,y)));if(e&&u.length===0){yield*r.outro("✅ Doctor completed successfully!");return}for(let{action:y}of e?u:i)yield*r.log.warning(`Needs attention: ${y.description}`);yield*r.outro("⚠️ Doctor found issues."),yield*new A({command:"doctor",exitCode:Wt.ExitCode(1)})})));import*as Zn from"effect/Effect";import*as Ve from"effect/unstable/cli/Argument";import*as ze from"effect/unstable/cli/Command";import*as ce from"effect/unstable/cli/Flag";import*as Xn from"effect/unstable/process/ChildProcessSpawner";var to=Ve.file("files",{mustExist:!0}).pipe(Ve.withDescription("Specific files to fix (optional)"),Ve.variadic()),no=ce.boolean("suggested").pipe(ce.withDescription("Apply suggested fixes")),ro=ce.boolean("dangerous").pipe(ce.withDescription("Apply dangerous fixes")),oo=ce.boolean("all").pipe(ce.withDescription("Apply all fixes, including suggested and dangerous fixes")),Yn=ze.make("fix",{all:oo,dangerous:ro,files:to,suggested:no}).pipe(ze.withDescription("Fix issues in code using oxlint"),ze.withHandler(({all:e,dangerous:t,files:r,suggested:n})=>Zn.gen(function*(){let o=yield*R,i=new Set(["--fix"]);if(n||e)i.add("--fix-suggestions");if(t||e)i.add("--fix-dangerously");for(let u of r)i.add(u);let a=yield*o.run({args:[...i],command:c.name});if(a!==Xn.ExitCode(0))yield*new A({command:c.name,exitCode:a})})));import*as Hn from"effect/Effect";import*as Me from"effect/unstable/cli/Argument";import*as we from"effect/unstable/cli/Command";import*as gt from"effect/unstable/cli/Flag";import*as Kn from"effect/unstable/process/ChildProcessSpawner";var io=Me.file("files",{mustExist:!0}).pipe(Me.withDescription("Specific files to format (optional)"),Me.variadic()),ao=gt.boolean("check").pipe(gt.withDescription("Check if files are formatted without writing")),Gn=we.make("format",{check:ao,files:io}).pipe(we.withDescription("Format files using oxfmt"),we.withHandler(({check:e,files:t})=>Hn.gen(function*(){let r=yield*R,n=[];if(e)n.push("--check");n.push(...t);let o=yield*r.run({args:n,command:d.name});if(o!==Kn.ExitCode(0))yield*new A({command:d.name,exitCode:o})})));import so from"node:process";import*as j from"effect/Effect";import*as or from"effect/FileSystem";import*as ir from"effect/Path";import*as Ue from"effect/unstable/cli/Command";import*as X from"effect/Effect";import*as Et from"effect/FileSystem";import*as jt from"effect/Path";import*as Ln from"effect/unstable/process/ChildProcessSpawner";var Ye=[{path:".vscode/settings.json",type:"config"}],Cn={"[css]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[graphql]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[json]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[jsonc]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"editor.codeActionsOnSave":{"source.fixAll.oxc":"explicit"},"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0},ne=_({config:Ye[0].path,create:(e)=>X.gen(function*(){let t=yield*Et.FileSystem,r=yield*jt.Path,n=r.join(e,Ye[0].path),o=r.dirname(n);yield*t.makeDirectory(o,{recursive:!0}).pipe(X.mapError((i)=>new me({cause:i,path:o}))),yield*t.writeFileString(n,`${JSON.stringify(Cn,null,2)}
108
+ `).pipe(X.mapError((i)=>new O({cause:i,path:n})))}),exists:(e)=>X.gen(function*(){let t=yield*Et.FileSystem,r=yield*jt.Path;return yield*t.exists(r.join(e,Ye[0].path))}),extension:(e=[])=>X.gen(function*(){function t(n){return X.gen(function*(){let i=yield*(yield*R).run({args:["--install-extension",n],command:"code"}).pipe(X.mapError((a)=>a._tag==="CliNotFound"&&a.command==="code"?new kt({cause:a}):new Ge({cause:a,extension:n})));if(i!==Ln.ExitCode(0))return yield*new Ge({cause:i,extension:n})})}let r=[];if(e.includes("check")||e.includes("fix")||e.includes("format"))r.push("oxc.oxc-vscode");if(e.includes("analyze"))r.push("webpro.vscode-knip");for(let n of r)yield*t(n)}),files:Ye,kind:"editor",name:"vscode",update:(e)=>X.gen(function*(){let t=yield*Et.FileSystem,n=(yield*jt.Path).join(e,Ye[0].path),o=yield*t.readFileString(n).pipe(X.mapError((u)=>new D({cause:u,path:n}))),i=yield*w(o,n);if(!N(i))return yield*new x({path:n});let a=yield*Ee(Cn,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
109
+ `).pipe(X.mapError((u)=>new O({cause:u,path:n})))})});import*as ae from"effect/Effect";import*as Ot from"effect/FileSystem";import*as St from"effect/Path";var He=[{path:".zed/settings.json",type:"config"}],er={languages:{CSS:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},HTML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSON:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSONC:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JavaScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},MDX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},Markdown:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},TSX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},YAML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}},fe=_({config:He[0].path,create:(e)=>ae.gen(function*(){let t=yield*Ot.FileSystem,r=yield*St.Path,n=r.join(e,He[0].path),o=r.dirname(n);yield*t.makeDirectory(o,{recursive:!0}).pipe(ae.mapError((i)=>new me({cause:i,path:o}))),yield*t.writeFileString(n,`${JSON.stringify(er,null,2)}
110
+ `).pipe(ae.mapError((i)=>new O({cause:i,path:n})))}),exists:(e)=>ae.gen(function*(){let t=yield*Ot.FileSystem,r=yield*St.Path;return yield*t.exists(r.join(e,He[0].path))}),files:He,kind:"editor",name:"zed",update:(e)=>ae.gen(function*(){let t=yield*Ot.FileSystem,n=(yield*St.Path).join(e,He[0].path),o=yield*t.readFileString(n).pipe(ae.mapError((u)=>new D({cause:u,path:n}))),i=yield*w(o,n);if(!N(i))return yield*new x({path:n});let a=yield*Ee(er,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
111
+ `).pipe(ae.mapError((u)=>new O({cause:u,path:n})))})});import fo from"node:process";import*as tr from"effect/Effect";import*as nr from"effect/FileSystem";import*as rr from"effect/Path";var Bt=(e=fo.cwd())=>tr.gen(function*(){let t=yield*nr.FileSystem,r=yield*rr.Path;if(yield*t.exists(r.join(e,"pnpm-workspace.yaml")))return!0;return(yield*$(e)).workspaces!==void 0});var lo=(e,t)=>j.gen(function*(){let r=yield*Z,o=(yield*g).spinner();o.start("Installing dependencies...");let i=yield*Bt(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:i}).pipe(j.tapError(()=>j.sync(()=>{o.stop("Failed to install dependencies.")}))),o.stop("Dependencies installed.")});function Qt(e,t){return j.gen(function*(){yield*(yield*g).log.info(`Legacy \`${t}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${e} configs yet.`)})}var po=(e,t)=>j.gen(function*(){let r=yield*g,n=r.spinner();n.start("Setting up oxlint config...");let o=yield*c.exists(e),i=c.files[1].path;if(o.active?.format==="ts"&&o.legacy.length>0)yield*r.log.warning(`Found both \`${c.config}\` and \`${i}\`. Adamantite will use \`${c.config}\`.`);if(o.active?.format==="json")n.message(`Found \`${i}\`, keeping existing config.`),n.stop("oxlint config is ready."),yield*Qt("oxlint",i);else if(o.active?.format==="ts")n.message(`Found \`${c.config}\`, keeping existing config.`),n.stop("oxlint config is ready.");else n.message(`\`${c.config}\` not found, creating...`),yield*c.create(e,t),n.stop("oxlint config created successfully.")}),uo=(e)=>j.gen(function*(){let t=yield*g,r=t.spinner();r.start("Setting up oxfmt config...");let n=yield*d.exists(e);if(n.active?.format==="ts"&&n.legacy.length>0)yield*t.log.warning(`Found both \`${d.config}\` and \`.oxfmtrc.json(c)\`. Adamantite will use \`${d.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*t.log.warning("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(n.active?.format==="json"||n.active?.format==="jsonc"){let o=n.active.path.endsWith(d.files[1].path)?d.files[1].path:d.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("oxfmt config is ready."),yield*Qt("oxfmt",o)}else if(n.active?.format==="ts")r.message(`Found \`${d.config}\`, keeping existing config.`),r.stop("oxfmt config is ready.");else r.message(`\`${d.config}\` not found, creating...`),yield*d.create(e),r.stop("oxfmt config created successfully.")}),co=(e,t)=>j.gen(function*(){let r=yield*or.FileSystem,n=yield*ir.Path,o=yield*g,i=yield*$(e),a=o.spinner();a.start("Adding scripts to your `package.json`..."),i.scripts??={};for(let y of t)switch(y){case"check":i.scripts.check="adamantite check";break;case"fix":i.scripts.fix="adamantite fix";break;case"format":i.scripts.format="adamantite format";break;case"check:monorepo":i.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":i.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":i.scripts.analyze="adamantite analyze";break;default:return yield*new Nt({script:y})}let u=n.join(e,"package.json");yield*r.writeFileString(u,`${JSON.stringify(i,null,2)}
112
+ `).pipe(j.mapError((y)=>new O({cause:y,path:u}))),a.stop("Scripts added to your `package.json`")}),yo=(e)=>j.gen(function*(){let t=yield*g,r=t.spinner();r.start("Setting up knip config...");let n=yield*m.exists(e);if(n.active?.format==="ts"&&n.legacy.length>0)yield*t.log.warning(`Found both \`${m.config}\` and \`knip.json(c)\`. Adamantite will use \`${m.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*t.log.warning("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(n.active?.format==="json"||n.active?.format==="jsonc"){let o=n.active.path.endsWith(m.files[1].path)?m.files[1].path:m.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("knip config is ready."),yield*Qt("knip",o)}else if(n.active?.format==="ts")r.message(`Found \`${m.config}\`, keeping existing config.`),r.stop("knip config is ready.");else r.message(`\`${m.config}\` not found, creating...`),yield*m.create(e),r.stop("knip config created successfully.")}),mo=(e)=>j.gen(function*(){let r=(yield*g).spinner();if(r.start("Setting up TypeScript config..."),yield*V.exists(e))r.message(`\`${V.config}\` found, updating...`),yield*V.update(e),r.stop(`\`${V.config}\` updated successfully`);else r.message(`\`${V.config}\` not found, creating...`),yield*V.create(e),r.stop(`\`${V.config}\` created successfully`)}),ho=(e,t)=>j.gen(function*(){let r=yield*g;if(t.includes("vscode")){let n=r.spinner();if(n.start(`Checking for \`${ne.config}\`...`),yield*ne.exists(e))n.message(`\`${ne.config}\` found, updating...`),yield*ne.update(e),n.stop(`\`${ne.config}\` updated with Adamantite preset.`);else n.message(`\`${ne.config}\` not found, creating...`),yield*ne.create(e),n.stop(`\`${ne.config}\` created with Adamantite preset.`)}if(t.includes("zed")){let n=r.spinner();if(n.start(`Checking for \`${fe.config}\`...`),yield*fe.exists(e))n.message(`\`${fe.config}\` found, updating...`),yield*fe.update(e),n.stop(`\`${fe.config}\` updated with Adamantite preset.`);else n.message(`\`${fe.config}\` not found, creating...`),yield*fe.create(e),n.stop(`\`${fe.config}\` created with Adamantite preset.`)}}),go=(e,t)=>j.gen(function*(){let r=yield*g,n=r.spinner();n.start("Installing editor extensions...");let o=e.includes("zed"),i=e.includes("vscode");if(yield*j.gen(function*(){if(e.includes("vscode"))n.message("Installing VS Code extension..."),yield*ne.extension(t);return!0}).pipe(j.tapError(()=>j.sync(()=>{n.stop()})),j.catchTag("FailedToInstallExtension",(u)=>j.gen(function*(){return yield*r.log.warning(`⚠️ Failed to install the \`${u.extension}\` extension.`),yield*r.log.warning("Please install it manually after setup completes."),!1})),j.catchTag("VscodeCliNotFound",()=>j.gen(function*(){return yield*r.log.error("VSCode CLI ('code' command) not found."),yield*r.log.info("To install it:"),yield*r.log.info(" 1. Open VS Code"),yield*r.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))))if(o&&!i)n.stop("Zed extensions require manual install.");else n.stop("Editor extensions installed successfully.");if(o)yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Eo=(e,t,r)=>j.gen(function*(){let o=(yield*g).spinner();o.start("Setting up GitHub Actions workflow...");let i=yield*ie.exists(e),a=ie.files[0].path;if(i)o.message(`\`${a}\` found, updating...`),yield*ie.update(e,{packageManager:t,scripts:r}),o.stop("GitHub Actions workflow updated successfully.");else o.message(`Creating \`${a}\`...`),yield*ie.create(e,{packageManager:t,scripts:r}),o.stop("GitHub Actions workflow created successfully.")}).pipe(j.option),ar=Ue.make("init").pipe(Ue.withDescription("Initialize Adamantite in the current directory"),Ue.withHandler(()=>j.gen(function*(){let e=so.cwd(),t=yield*g;yield*Re(),yield*t.intro("\uD83D\uDCA0 adamantite init");let n=yield*(yield*Z).detectPackageManager(e);if(!n)return yield*new xe({});if(n.warnings?.length)for(let p of n.warnings)yield*t.log.warning(p);yield*t.log.info(`Detected package manager: ${n.name}`);let o=yield*Bt(e);if(o)yield*t.log.info("We've detected a monorepo setup in your project.");let i=yield*t.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues and type errors using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{disabled:!o,hint:o?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!o,hint:o?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),a=i.includes("check")||i.includes("fix"),u=[];if(a)u=yield*t.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let y=!1;if(a)y=yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"});let f=yield*t.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),s=!1;if(f.length>0)s=yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let l=lt(i),h=!1;if(l)h=yield*t.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let S=i.includes("format"),k=i.includes("check:monorepo")||i.includes("fix:monorepo"),P=i.includes("analyze"),J=["adamantite"];if(a)J.push(`${c.name}@${c.version}`),J.push(`${le.name}@${le.version}`);if(S)J.push(`${d.name}@${d.version}`);if(k)J.push(`${K.name}@${K.version}`);if(P)J.push(`${m.name}@${m.version}`);if(yield*lo(e,J),S)yield*uo(e);if(a)yield*po(e,u);if(P)yield*yo(e);if(yield*co(e,i),y)yield*mo(e);if(yield*ho(e,f),s)yield*go(f,i);if(h)yield*Eo(e,n.name,i);yield*t.log.success("Your project is now configured"),yield*t.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(j.catchTags({OperationCancelled:()=>j.gen(function*(){yield*(yield*g).cancel("You've cancelled the initialization process.")})}))));import*as fr from"effect/Effect";import*as be from"effect/unstable/cli/Command";import*as Ft from"effect/unstable/cli/Flag";import*as sr from"effect/unstable/process/ChildProcessSpawner";var jo=Ft.boolean("fix").pipe(Ft.withDescription("Automatically fix issues")),lr=be.make("monorepo",{fix:jo}).pipe(be.withDescription("Find and fix monorepo-specific issues using Sherif"),be.withHandler(({fix:e})=>fr.gen(function*(){let t=yield*R,r=e?["--fix"]:[],n=yield*t.run({args:r,command:K.name,stdin:"inherit"});if(n!==sr.ExitCode(0))yield*new A({command:K.name,exitCode:n})})));import*as pr from"effect/Effect";import*as qe from"effect/unstable/cli/Command";import*as ur from"effect/unstable/process/ChildProcessSpawner";var cr=qe.make("typecheck").pipe(qe.withDescription("Deprecated alias for `check`"),qe.withHandler(()=>pr.gen(function*(){let e=yield*g,t=yield*R;yield*e.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*t.run({args:[],command:c.name});if(r!==ur.ExitCode(0))yield*new A({command:c.name,exitCode:r})})));import Oo from"node:process";import*as Y from"effect/Effect";import*as Je from"effect/unstable/cli/Command";var So=[c,le,d,K,m],Fo=[c,le,d,K,m];function $o(e){return e.applicable&&Array.isArray(e.actions)}function To(e,t){let r=[];for(let n of Fo){if(t.has(n.name))continue;let o=e.devDependencies?.[n.name]??e.dependencies?.[n.name];if(o&&B(o)!==n.version)r.push({currentVersion:o,name:n.name,targetVersion:n.version})}return r}var yr=Je.make("update").pipe(Je.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Je.withHandler(()=>Y.gen(function*(){let e=Oo.cwd(),t=yield*g,r=yield*Z,n={cwd:e};yield*Re(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>Y.gen(function*(){let p=[];for(let F of So){let Ke=yield*F.assess(e);if($o(Ke))p.push({assessment:Ke,integration:F})}return p}),i=yield*o();for(let{assessment:p}of i)for(let F of p.warnings)yield*t.log.warning(F);let a=new Set(i.map(({integration:p})=>p.name)),u=i.flatMap(({assessment:p})=>p.actions),y=new Set(u.filter((p)=>p.type==="run_migration").map((p)=>p.migrationId)),f=[];for(let p of dt.filter((F)=>F.tags.includes("update"))){let F=Un[p.id];if(a.has(F))continue;let Ke=yield*p.check(n);f.push({migration:p,result:Ke})}for(let p of f){for(let F of p.result.warnings)yield*t.log.warning(F);if(p.result.applicable&&p.result.summary)yield*t.log.info(p.result.summary)}let s=[];for(let p of dt){if(!y.has(p.id))continue;yield*Qe(p,n,{onRestore:t.log.warning(`Migration "${p.title}" failed, restoring files...`)}),s.push(p.id)}for(let{migration:p,result:F}of f){if(!F.applicable||!F.summary)continue;yield*Qe(p,n,{onRestore:t.log.warning(`Migration "${p.title}" failed, restoring files...`)}),s.push(p.id)}if(s.length>0)yield*t.log.success("Migrations ran successfully.");let l=yield*$(e),h=yield*o(),S=h.flatMap(({assessment:p})=>p.actions).filter((p)=>p.type==="create_config"||p.type==="update_config"||p.type==="manual_fix"),k=h.flatMap(({assessment:p})=>p.actions).filter((p)=>p.type==="install_package"||p.type==="update_package").map((p)=>p.type==="install_package"?{currentVersion:"not installed",name:p.package,targetVersion:p.targetVersion}:{currentVersion:p.currentVersion,name:p.package,targetVersion:p.targetVersion}),P=new Set(k.map((p)=>p.name)),J=[...k,...To(l,P)];if(J.length>0){yield*t.log.info("The following dependencies will be updated:");for(let F of J)yield*t.log.info(` ${F.name}: ${F.currentVersion} → ${F.targetVersion}`);let p=t.spinner();p.start("Updating dependencies..."),yield*r.addDevDependencies(J.map((F)=>`${F.name}@${F.targetVersion}`),e,{silent:!0}).pipe(Y.tapError(()=>Y.sync(()=>{p.stop("Failed to update dependencies")}))),p.stop("Dependencies updated successfully"),yield*t.log.success("Dependencies updated successfully.")}if(S.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let p of S)yield*t.log.warning(`Doctor follow-up: ${p.description}`)}if(s.length===0&&J.length===0&&S.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(Y.tapError(()=>Y.gen(function*(){yield*(yield*g).outro("❌ Update failed")})),Y.tap((e)=>Y.gen(function*(){let t=yield*g;switch(e){case"no-changes":yield*t.outro("✅ Adamantite is already up to date.");break;case"success":yield*t.outro("✅ Update completed successfully!");break;default:break}})))));var vo=ye.make("adamantite").pipe(ye.withDescription("Opinionated preset package for modern TypeScript applications"),ye.withSubcommands([Ct,pn,Qn,Yn,Gn,ar,lr,cr,yr])),Po=await"0.32.1",_o=ye.run(vo,{version:Po}).pipe(M.as(0),M.catchTag("CommandFailed",(e)=>M.succeed(e.exitCode)),M.catch((e)=>M.service(g).pipe(M.flatMap((t)=>t.log.error(e.message)),M.as(jr.ExitCode(1)))),M.provide(gr.mergeAll(dr.layer,g.layer,R.layer,Z.layer)));mr.runMain(_o,{teardown:(e,t)=>{if(hr.isSuccess(e)){t(Number(e.value));return}Er.defaultTeardown(e,t)}});
@@ -0,0 +1,3 @@
1
+ import { RawConfiguration } from "./types/config.ts";
2
+ declare const config: RawConfiguration;
3
+ export { config as default };
@@ -0,0 +1,34 @@
1
+ // presets/analyze.ts
2
+ var config = {
3
+ ignore: ["**/*.d.ts"],
4
+ ignoreExportsUsedInFile: true,
5
+ ignoreFiles: [
6
+ "**/dist/**",
7
+ "**/build/**",
8
+ "**/coverage/**",
9
+ "**/.next/**",
10
+ "**/.vercel/**",
11
+ "**/.turbo/**"
12
+ ],
13
+ rules: {
14
+ binaries: "error",
15
+ catalog: "error",
16
+ dependencies: "error",
17
+ devDependencies: "error",
18
+ duplicates: "warn",
19
+ enumMembers: "off",
20
+ exports: "warn",
21
+ files: "error",
22
+ namespaceMembers: "warn",
23
+ nsExports: "warn",
24
+ nsTypes: "warn",
25
+ optionalPeerDependencies: "warn",
26
+ types: "warn",
27
+ unlisted: "error",
28
+ unresolved: "error"
29
+ }
30
+ };
31
+ var analyze_default = config;
32
+ export {
33
+ analyze_default as default
34
+ };
@@ -0,0 +1,3 @@
1
+ import { FormatConfig } from "oxfmt";
2
+ declare const config: FormatConfig;
3
+ export { config as default };
@@ -0,0 +1,64 @@
1
+ // presets/format.ts
2
+ var config = {
3
+ arrowParens: "always",
4
+ bracketSameLine: false,
5
+ bracketSpacing: true,
6
+ embeddedLanguageFormatting: "auto",
7
+ endOfLine: "lf",
8
+ htmlWhitespaceSensitivity: "css",
9
+ insertFinalNewline: true,
10
+ jsdoc: {
11
+ addDefaultToDescription: true,
12
+ bracketSpacing: false,
13
+ capitalizeDescriptions: true,
14
+ commentLineStrategy: "multiline",
15
+ descriptionTag: false,
16
+ descriptionWithDot: false,
17
+ keepUnparsableExampleIndent: false,
18
+ lineWrappingStyle: "greedy",
19
+ preferCodeFences: false,
20
+ separateReturnsFromParam: true
21
+ },
22
+ jsxSingleQuote: false,
23
+ objectWrap: "preserve",
24
+ printWidth: 100,
25
+ quoteProps: "as-needed",
26
+ semi: false,
27
+ singleAttributePerLine: false,
28
+ singleQuote: false,
29
+ sortImports: {
30
+ groups: [
31
+ ["value-builtin", "type-import"],
32
+ ["value-external"],
33
+ ["type-internal"],
34
+ ["value-internal"],
35
+ ["type-subpath"],
36
+ ["value-subpath"],
37
+ ["type-parent", "type-sibling", "type-index"],
38
+ ["value-parent", "value-sibling", "value-index"],
39
+ ["unknown"]
40
+ ],
41
+ ignoreCase: true,
42
+ newlinesBetween: false,
43
+ order: "asc",
44
+ partitionByComment: true,
45
+ partitionByNewline: true,
46
+ sortSideEffects: false
47
+ },
48
+ sortPackageJson: {
49
+ sortScripts: true
50
+ },
51
+ sortTailwindcss: {
52
+ attributes: ["className", "class"],
53
+ functions: ["clsx", "cn", "cva", "tw", "twMerge"],
54
+ preserveDuplicates: false,
55
+ preserveWhitespace: false
56
+ },
57
+ tabWidth: 2,
58
+ trailingComma: "es5",
59
+ useTabs: false
60
+ };
61
+ var format_default = config;
62
+ export {
63
+ format_default as default
64
+ };