adamantite 0.32.3 → 0.33.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
@@ -192,7 +192,9 @@ Opinionated Knip configuration for dependency and unused-file analysis. The publ
192
192
 
193
193
  ### TypeScript ([presets/tsconfig.json](./presets/tsconfig.json))
194
194
 
195
- Strict TypeScript configuration for maximum type safety. Catches errors at compile-time that would otherwise cause runtime failures.
195
+ Strict TypeScript configuration for maximum type safety. Catches errors at compile-time that would otherwise cause runtime failures. The preset requires TypeScript 7 or newer.
196
+
197
+ ````
196
198
 
197
199
  ## 🛠️ Development
198
200
 
@@ -210,7 +212,7 @@ bun run build
210
212
 
211
213
  # Linting and type checking
212
214
  bun run check
213
- ```
215
+ ````
214
216
 
215
217
  ## 🤝 Contributing
216
218
 
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import*as pr from"@effect/platform-node/NodeRuntime";import*as ur from"@effect/platform-node/NodeServices";import*as A from"effect/Effect";import*as cr from"effect/Exit";import*as dr from"effect/Layer";import*as yr from"effect/Runtime";import*as ce from"effect/unstable/cli/Command";import*as mr from"effect/unstable/process/ChildProcessSpawner";import*as Zt from"effect/Effect";import*as je from"effect/unstable/cli/Command";import*as Fe from"effect/unstable/cli/Flag";import*as Xt from"effect/unstable/process/ChildProcessSpawner";import*as Oe from"effect/Effect";import*as He from"effect/FileSystem";import*as Ge from"effect/Path";function P(e){return e}import*as v from"effect/Data";import{printParseErrorCode as hr}from"jsonc-parser";function Er(e=[]){if(e.length===0)return"- Unknown JSON/JSONC parsing error";return e.slice(0,3).map((t)=>`- ${hr(t.error)} (offset: ${t.offset})`).join(`
2
- `)}class Ot extends v.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class I extends v.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class de extends v.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class St extends v.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Ze extends v.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class jt extends v.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Ft extends v.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:",Er(this.errors)].join(`
3
- `)}}class T extends v.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class re extends v.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class S extends v.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class $t extends v.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class J extends v.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 vt extends v.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 Ue extends v.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 gr extends v.TaggedError("MissingPackageVersion"){get message(){let e=this.path?`\`${this.path}\``:"package.json";if(this.dependency)return`Missing \`${this.dependency}\` in ${e} dependencies or devDependencies.`;return`Missing version field in ${e}.`}}class Y extends v.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class Xe extends v.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class Rt extends v.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class Dt extends v.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 Or}from"defu";import*as G from"effect/Effect";import{parse as Sr}from"jsonc-parser";var U=(e,t)=>G.sync(()=>{let r=[],n=Sr(e,r,{allowTrailingComma:!0});return{errors:r,parsed:n}}).pipe(G.flatMap(({errors:r,parsed:n})=>r.length>0?G.fail(new Ft({errors:r,path:t})):G.succeed(n)));function V(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function he(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(`
1
+ import*as hr from"@effect/platform-node/NodeRuntime";import*as Er from"@effect/platform-node/NodeServices";import*as U from"effect/Effect";import*as gr from"effect/Exit";import*as Or from"effect/Layer";import*as jr from"effect/Runtime";import*as ct from"effect/unstable/cli/Command";import*as Sr from"effect/unstable/process/ChildProcessSpawner";import*as Me from"effect/Effect";import*as $t from"effect/unstable/cli/Command";import*as Ft from"effect/unstable/cli/Flag";import*as Ke from"effect/unstable/process/ChildProcessSpawner";import*as jt from"effect/Effect";import*as Gt from"effect/FileSystem";import*as Ct from"effect/Path";function P(t){return t}import*as D from"effect/Data";import{printParseErrorCode as $r}from"jsonc-parser";function Fr(t=[]){if(t.length===0)return"- Unknown JSON/JSONC parsing error";return t.slice(0,3).map((e)=>`- ${$r(e.error)} (offset: ${e.offset})`).join(`
2
+ `)}class Se extends D.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class T extends D.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class yt extends D.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class $e extends D.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Mt extends D.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class Fe extends D.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class ve extends D.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:",Fr(this.errors)].join(`
3
+ `)}}class v extends D.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class rt extends D.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class O extends D.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class Re extends D.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class W extends D.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 De extends D.TaggedError("UnsupportedConfigState"){get message(){let t=this.path?`\`${this.path}\``:"the target config file",e=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${t}.${e}`}}class bt extends D.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 vr extends D.TaggedError("MissingPackageVersion"){get message(){let t=this.path?`\`${this.path}\``:"package.json";if(this.dependency)return`Missing \`${this.dependency}\` in ${t} dependencies or devDependencies.`;return`Missing version field in ${t}.`}}class H extends D.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class Kt extends D.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class Ve extends D.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class Pe extends D.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 Rr}from"defu";import*as L from"effect/Effect";import{parse as Dr}from"jsonc-parser";var J=(t,e)=>L.sync(()=>{let r=[],n=Dr(t,r,{allowTrailingComma:!0});return{errors:r,parsed:n}}).pipe(L.flatMap(({errors:r,parsed:n})=>r.length>0?L.fail(new ve({errors:r,path:e})):L.succeed(n)));function N(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function Et(t,e={}){let{continuationIndent:r,indentation:n=2}=e,o=JSON.stringify(t,null,n).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!r)return o;return o.replaceAll(`
4
4
  `,`
5
- ${r}`)}var Ee=(e,t)=>G.try({catch:(r)=>new jt({cause:r}),try:()=>Or(e,t)});function Ye(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}: ${he(a,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
6
- `);return` ${r}: ${he(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 jr from"node:process";import*as ge from"effect/Effect";import*as Nt from"effect/FileSystem";import*as Pt from"effect/Path";var Fr=/^workspace:/,$r=/^[\^~]/;function B(e){return e.trim().replace(Fr,"").replace($r,"")}var $=(e=jr.cwd())=>ge.gen(function*(){let t=yield*Nt.FileSystem,n=(yield*Pt.Path).join(e,"package.json"),o=yield*t.readFileString(n).pipe(ge.mapError((a)=>new T({cause:a,path:n})));return yield*U(o,n)}),wt=(e,t)=>ge.gen(function*(){let r=yield*Nt.FileSystem,o=(yield*Pt.Path).join(e,"package.json");yield*r.writeFileString(o,`${JSON.stringify(t,null,2)}
9
- `).pipe(ge.mapError((i)=>new S({cause:i,path:o})))});function Ke(e){return e==="bun"||e==="deno"||e==="npm"||e==="pnpm"||e==="yarn"}var Tt={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(Tt))if(t[n]===o)r.push(n);return r}var M=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}];var y=P({assess:(e)=>Oe.gen(function*(){let t=yield*He.FileSystem,r=yield*Ge.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,M[0].path),u=r.join(e,M[1].path),d=r.join(e,M[2].path),s=yield*t.exists(a),p=yield*t.exists(u),l=yield*t.exists(d),h=s?"ts":l?"jsonc":p?"json":null,j=[],D=[];if(s&&(p||l))D.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!s&&p&&l)D.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)j.push({description:`Install \`knip@${"6.23.0"}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:"6.23.0",type:"install_package"});else if(B(i)!=="6.23.0")j.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${"6.23.0"}\`.`,package:"knip",targetVersion:"6.23.0",type:"update_package"});if(h===null)j.push({description:`Create \`${M[0].path}\` for \`knip\`.`,path:M[0].path,type:"create_config"});if(h==="json"||h==="jsonc")j.push({description:`Migrate legacy \`${h==="json"?M[1].path:M[2].path}\` to \`${M[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:j,applicable:!0,warnings:D}}),config:M[0].path,create:(e)=>Oe.gen(function*(){let t=yield*He.FileSystem,n=(yield*Ge.Path).join(e,M[0].path);yield*t.writeFileString(n,Ye()).pipe(Oe.mapError((o)=>new S({cause:o,path:n})))}),exists:(e)=>Oe.gen(function*(){let t=yield*He.FileSystem,r=yield*Ge.Path,n=r.join(e,M[0].path),o=r.join(e,M[1].path),i=r.join(e,M[2].path),a=yield*t.exists(n),u=yield*t.exists(o),d=yield*t.exists(i),s=a?"ts":d?"jsonc":u?"json":null,p=[];if(a&&u)p.push({format:"json",path:o});if(a&&d)p.push({format:"jsonc",path:i});if(!a&&u&&d)p.push({format:"json",path:o});return{active:s===null?null:{format:s,path:s==="ts"?n:s==="jsonc"?i:o},legacy:p}}),files:M,kind:"tooling",name:"knip",version:"6.23.0"});import*as Wt from"effect/Context";import*as Se from"effect/Effect";import*as Bt from"effect/Layer";import*as Qt from"effect/unstable/process/ChildProcess";class _ extends Wt.Service()("CommandRunner"){static layer=Bt.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*Qt.make(t,e,{cwd:r,stderr:n,stdin:o,stdout:i})).exitCode})),(a)=>a.reason._tag==="NotFound"?new Ot({command:t}):a)})}var vr=Fe.boolean("fix").pipe(Fe.withDescription("Automatically fix issues")),Rr=Fe.boolean("strict").pipe(Fe.withDescription("Enable strict mode")),Yt=je.make("analyze",{fix:vr,strict:Rr}).pipe(je.withDescription("Find unused dependencies, exports, and files using knip"),je.withHandler(({fix:e,strict:t})=>Zt.gen(function*(){let r=yield*_,n=[];if(e)n.push("--fix","--allow-remove-files");if(t)n.push("--production","--strict");let o=yield*r.run({args:n,command:y.name});if(o!==Xt.ExitCode(0))yield*new I({command:y.name,exitCode:o})})));import*as rn from"effect/Effect";import*as $e from"effect/unstable/cli/Argument";import*as ve from"effect/unstable/cli/Command";import*as on from"effect/unstable/process/ChildProcessSpawner";import*as L from"effect/Effect";import*as Me from"effect/FileSystem";import*as xe from"effect/Path";import*as C from"effect/Effect";import*as g from"effect/Option";import{print as Dr}from"esrap";import Nr from"esrap/languages/ts";import{parseSync as Pr}from"oxc-parser";var en=["respectEslintDisableDirectives","typeAware","typeCheck"],Kt="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",Ht="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",Gt="`oxlint.config.ts` has an `options` object Adamantite cannot patch safely. Make sure each required option is a plain `key: true | false` property—avoid spreads (`...rest`), computed keys (`[name]: ...`), duplicate keys, methods/getters/setters, and non-boolean-literal values.",tn="Adamantite could not generate the required `options` patch.";function Le(e=[]){return e.includes("core")?e:["core",...e]}function Ct(e){return e.replaceAll(/-([a-z])/g,(t,r)=>r.toUpperCase())}function et(e,t,r=[]){let{options:n,...o}=e,i=['import { defineConfig } from "oxlint"',...t.map((h)=>`import ${Ct(h)} from "${h==="core"?"adamantite/lint":`adamantite/lint/${h}`}"`)],u=[...t.map((h)=>Ct(h)),...r.map((h)=>JSON.stringify(h))],d=JSON.stringify(V(n)?{...n,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),s=Object.entries(o).map(([h,j])=>[h,JSON.stringify(j,null,2)]),p=`[${u.join(", ")}]`,l=[["options",d],...s,["extends",p]].map(([h,j])=>` ${h}: ${j},`).join(`
5
+ ${r}`)}var gt=(t,e)=>L.try({catch:(r)=>new Fe({cause:r}),try:()=>Rr(t,e)});function Lt(t={}){let e=Object.entries(t).map(([r,n])=>{if(r==="rules"&&typeof n==="object"&&n!==null&&!Array.isArray(n))return[" rules: {"," ...analyze.rules,",...Object.entries(n).map(([i,f])=>` ${i}: ${Et(f,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
6
+ `);return` ${r}: ${Et(n)},`});if(e.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,",...e,"}","","export default config",""].join(`
8
+ `)}import Vr from"node:process";import*as Ot from"effect/Effect";import*as Ne from"effect/FileSystem";import*as _e from"effect/Path";var Pr=/^workspace:/,Nr=/^[\^~]/;function x(t){return t.trim().replace(Pr,"").replace(Nr,"")}var F=(t=Vr.cwd())=>Ot.gen(function*(){let e=yield*Ne.FileSystem,n=(yield*_e.Path).join(t,"package.json"),o=yield*e.readFileString(n).pipe(Ot.mapError((f)=>new v({cause:f,path:n})));return yield*J(o,n)}),Xe=(t,e)=>Ot.gen(function*(){let r=yield*Ne.FileSystem,o=(yield*_e.Path).join(t,"package.json");yield*r.writeFileString(o,`${JSON.stringify(e,null,2)}
9
+ `).pipe(Ot.mapError((i)=>new O({cause:i,path:o})))});function At(t){return t==="bun"||t==="deno"||t==="npm"||t==="pnpm"||t==="yarn"}var Bt={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function X(t){let e=t.scripts??{},r=[];for(let[n,o]of Object.entries(Bt))if(e[n]===o)r.push(n);return r}var b=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}];var d=P({assess:(t)=>jt.gen(function*(){let e=yield*Gt.FileSystem,r=yield*Ct.Path,n=yield*F(t);if(!X(n).includes("analyze"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.knip??n.dependencies?.knip,f=r.join(t,b[0].path),s=r.join(t,b[1].path),c=r.join(t,b[2].path),a=yield*e.exists(f),p=yield*e.exists(s),l=yield*e.exists(c),h=a?"ts":l?"jsonc":p?"json":null,$=[],R=[];if(a&&(p||l))R.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!a&&p&&l)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(!i)$.push({description:`Install \`knip@${"6.29.0"}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:"6.29.0",type:"install_package"});else if(x(i)!=="6.29.0")$.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${"6.29.0"}\`.`,package:"knip",targetVersion:"6.29.0",type:"update_package"});if(h===null)$.push({description:`Create \`${b[0].path}\` for \`knip\`.`,path:b[0].path,type:"create_config"});if(h==="json"||h==="jsonc")$.push({description:`Migrate legacy \`${h==="json"?b[1].path:b[2].path}\` to \`${b[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:$,applicable:!0,warnings:R}}),config:b[0].path,create:(t)=>jt.gen(function*(){let e=yield*Gt.FileSystem,n=(yield*Ct.Path).join(t,b[0].path);yield*e.writeFileString(n,Lt()).pipe(jt.mapError((o)=>new O({cause:o,path:n})))}),exists:(t)=>jt.gen(function*(){let e=yield*Gt.FileSystem,r=yield*Ct.Path,n=r.join(t,b[0].path),o=r.join(t,b[1].path),i=r.join(t,b[2].path),f=yield*e.exists(n),s=yield*e.exists(o),c=yield*e.exists(i),a=f?"ts":c?"jsonc":s?"json":null,p=[];if(f&&s)p.push({format:"json",path:o});if(f&&c)p.push({format:"jsonc",path:i});if(!f&&s&&c)p.push({format:"json",path:o});return{active:a===null?null:{format:a,path:a==="ts"?n:a==="jsonc"?i:o},legacy:p}}),files:b,kind:"tooling",name:"knip",version:"6.29.0"});import*as Ye from"effect/Context";import*as St from"effect/Effect";import*as we from"effect/Layer";import*as He from"effect/unstable/process/ChildProcess";class I extends Ye.Service()("CommandRunner"){static layer=we.succeed(this)({run:({args:t,command:e,cwd:r,stderr:n="inherit",stdin:o="ignore",stdout:i="inherit"})=>St.mapError(St.scoped(St.gen(function*(){return yield*(yield*He.make(e,t,{cwd:r,stderr:n,stdin:o,stdout:i})).exitCode})),(f)=>f.reason._tag==="NotFound"?new Se({command:e}):f)})}var _r=Ft.boolean("fix").pipe(Ft.withDescription("Automatically fix issues")),Ir=Ft.boolean("strict").pipe(Ft.withDescription("Enable strict mode")),Le=$t.make("analyze",{fix:_r,strict:Ir}).pipe($t.withDescription("Find unused dependencies, exports, and files using knip"),$t.withHandler(({fix:t,strict:e})=>Me.gen(function*(){let r=yield*I,n=[];if(t)n.push("--fix","--allow-remove-files");if(e)n.push("--production","--strict");let o=yield*r.run({args:n,command:d.name});if(o!==Ke.ExitCode(0))yield*new T({command:d.name,exitCode:o})})));import*as fn from"effect/Effect";import*as vt from"effect/unstable/cli/Argument";import*as Rt from"effect/unstable/cli/Command";import*as an from"effect/unstable/process/ChildProcessSpawner";import*as G from"effect/Effect";import*as Qt from"effect/FileSystem";import*as Wt from"effect/Path";import*as A from"effect/Effect";import*as S from"effect/Option";import{print as Tr}from"esrap";import qr from"esrap/languages/ts";import{parseSync as zr}from"oxc-parser";var nn=["respectEslintDisableDirectives","typeAware","typeCheck"],Ae="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",Ge="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",Ce="`oxlint.config.ts` has an `options` object Adamantite cannot patch safely. Make sure each required option is a plain `key: true | false` property—avoid spreads (`...rest`), computed keys (`[name]: ...`), duplicate keys, methods/getters/setters, and non-boolean-literal values.",rn="Adamantite could not generate the required `options` patch.";function ee(t=[]){return t.includes("core")?t:["core",...t]}function tn(t){return t.replaceAll(/-([a-z])/g,(e,r)=>r.toUpperCase())}function ne(t,e,r=[]){let{options:n,...o}=t,i=['import { defineConfig } from "oxlint"',...e.map((h)=>`import ${tn(h)} from "${h==="core"?"adamantite/lint":`adamantite/lint/${h}`}"`)],s=[...e.map((h)=>tn(h)),...r.map((h)=>JSON.stringify(h))],c=JSON.stringify(N(n)?{...n,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),a=Object.entries(o).map(([h,$])=>[h,JSON.stringify($,null,2)]),p=`[${s.join(", ")}]`,l=[["options",c],...a,["extends",p]].map(([h,$])=>` ${h}: ${$},`).join(`
10
10
  `);return[...i,"","export default defineConfig({",l,"})",""].join(`
11
- `)}function Ce(e){return V(e)&&e.type==="ObjectExpression"&&Array.isArray(e.properties)}function Vt(e){return V(e)&&e.type==="Property"}function _t(e){return C.try({catch:()=>null,try:()=>Pr("oxlint.config.ts",e,{astType:"ts",lang:"ts",sourceType:"module"})}).pipe(C.match({onFailure:()=>g.none(),onSuccess:(t)=>t.errors.length===0?g.fromNullishOr(t.program):g.none()}))}function nn(e){let{code:t}=Dr(e,Nr({quotes:"double"}));return t.endsWith(`
12
- `)?t:`${t}
13
- `}function Lt(e){if(e.type==="Identifier")return e.name;if(e.type==="Literal"&&typeof e.value==="string")return e.value;return null}function It(e){let t=e.body.filter((i)=>i.type==="ExportDefaultDeclaration");if(t.length!==1)return g.none();let[r]=t;if(!r)return g.none();let n=r.declaration;if(Ce(n))return g.fromNullishOr(n);if(n.type!=="CallExpression")return g.none();if(n.callee.type!=="Identifier"||n.callee.name!=="defineConfig")return g.none();if(n.arguments.length!==1)return g.none();let[o]=n.arguments;if(Ce(o))return g.fromNullishOr(o);return g.none()}function kt(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(Lt(n.key)===t)return{status:"manual"};continue}if(Lt(n.key)!==t)continue;if(r)return{status:"manual"};r=n}if(!r)return{status:"missing"};return{property:r,status:"found"}}function Tr(e){let t=`export default { options: { ${e.map((r)=>`${r}: true`).join(", ")} } }
14
- `;return _t(t).pipe(C.map((r)=>{if(g.isNone(r))return g.none();let n=It(r.value);if(g.isNone(n))return g.none();let o=kt(n.value,"options");if(o.status!=="found")return g.none();if(!Ce(o.property.value))return g.none();let i=o.property.value.properties.filter(Vt);return i.length===o.property.value.properties.length?g.fromNullishOr(i):g.none()}))}function Vr(){let e=`export default { options: { ${en.map((t)=>`${t}: true`).join(", ")} } }
15
- `;return _t(e).pipe(C.map((t)=>{if(g.isNone(t))return g.none();let r=It(t.value);if(g.isNone(r)||r.value.properties.length!==1)return g.none();let[n]=r.value.properties;if(!n||!Vt(n)||n.computed||n.method||n.kind!=="init")return g.none();return g.fromNullishOr(n)}))}function _r(e,t){return C.gen(function*(){let r=[],n=!1;for(let o of en){let i=kt(t,o);if(i.status==="manual")return{kind:"manual",reason:Gt};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:Gt};if(a.value)continue;a.raw="true",a.value=!0,n=!0}if(r.length>0){let o=yield*Tr(r);if(g.isNone(o))return{kind:"manual",reason:tn};t.properties.unshift(...o.value),n=!0}if(!n)return{kind:"configured"};return{kind:"patchable",updatedContent:nn(e)}})}function qt(e){return C.gen(function*(){let t=yield*_t(e);if(g.isNone(t))return{kind:"manual",reason:Kt};let r=It(t.value);if(g.isNone(r))return{kind:"manual",reason:Kt};let n=kt(r.value,"options");if(n.status==="manual")return{kind:"manual",reason:Ht};if(n.status==="missing"){let o=yield*Vr();if(g.isNone(o))return{kind:"manual",reason:tn};return r.value.properties.unshift(o.value),{kind:"patchable",updatedContent:nn(t.value)}}if(!Ce(n.property.value))return{kind:"manual",reason:Ht};return yield*_r(t.value,n.property.value)})}var k=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}];var c=P({assess:(e)=>L.gen(function*(){let t=yield*Me.FileSystem,r=yield*xe.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,k[0].path),u=r.join(e,k[1].path),d=yield*t.exists(a),s=yield*t.exists(u),p={active:d?{format:"ts",path:a}:s?{format:"json",path:u}:null,legacy:d&&s?[{format:"json",path:u}]:[]},l=[],h=[];if(p.active?.format==="ts"&&p.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@${"1.72.0"}\` for the managed lint scripts.`,package:"oxlint",targetVersion:"1.72.0",type:"install_package"});else if(B(i)!=="1.72.0")l.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${"1.72.0"}\`.`,package:"oxlint",targetVersion:"1.72.0",type:"update_package"});if(p.active===null)l.push({description:`Create \`${k[0].path}\` for \`oxlint\`.`,path:k[0].path,type:"create_config"});if(p.active?.format==="json")l.push({description:`Migrate legacy \`${k[1].path}\` to \`${k[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(p.active?.format==="ts"){let j=yield*t.readFileString(a).pipe(L.mapError((N)=>new T({cause:N,path:a}))),D=yield*qt(j);if(D.kind==="patchable")l.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:k[0].path,type:"update_config"});if(D.kind==="manual")l.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:k[0].path,type:"manual_fix"})}return{actions:l,applicable:!0,warnings:h}}),config:k[0].path,create:(e,t=[])=>L.gen(function*(){let r=yield*Me.FileSystem,o=(yield*xe.Path).join(e,k[0].path),i=et({},Le(t));yield*r.writeFileString(o,i).pipe(L.mapError((a)=>new S({cause:a,path:o})))}),exists:(e)=>L.gen(function*(){let t=yield*Me.FileSystem,r=yield*xe.Path,n=r.join(e,k[0].path),o=r.join(e,k[1].path),i=yield*t.exists(n),a=yield*t.exists(o),u=i?"ts":a?"json":null,d=[];if(i&&a)d.push({format:"json",path:o});return{active:u===null?null:{format:u,path:u==="ts"?n:o},legacy:d}}),files:k,kind:"tooling",name:"oxlint",update:(e)=>L.gen(function*(){let t=yield*Me.FileSystem,n=(yield*xe.Path).join(e,k[0].path);if(!(yield*t.exists(n)))return yield*new $t({path:k[0].path});let o=yield*t.readFileString(n).pipe(L.mapError((a)=>new T({cause:a,path:n}))),i=yield*qt(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new vt({path:k[0].path,reason:i.reason});yield*t.writeFileString(n,i.updatedContent).pipe(L.mapError((a)=>new S({cause:a,path:n})))}),version:"1.72.0"});var Ir=$e.file("files",{mustExist:!0}).pipe($e.withDescription("Specific files to lint (optional)"),$e.variadic()),an=ve.make("check",{files:Ir}).pipe(ve.withDescription("Find issues and type errors in code using oxlint"),ve.withHandler(({files:e})=>rn.gen(function*(){let r=yield*(yield*_).run({args:[...e],command:c.name});if(r!==on.ExitCode(0))yield*new I({command:c.name,exitCode:r})})));import Xr from"node:process";import*as Ne from"effect/Effect";import*as Pe from"effect/unstable/cli/Command";import*as ct from"effect/unstable/cli/Flag";import*as xt from"effect/unstable/process/ChildProcessSpawner";import*as Re from"effect/Effect";import*as nt from"effect/FileSystem";import*as rt from"effect/Path";var kr=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function qr(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 zr(e,t){let r=he(t),n=qr(r);return[` ${e}: {`,` ...format.${e},`,...n===""?[]:[n]," },"].join(`
18
- `)}function tt(e={}){let t=Object.entries(e).map(([r,n])=>{if(kr.has(r)&&V(n))return zr(r,n);let o=he(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 x=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var m=P({assess:(e)=>Re.gen(function*(){let t=yield*nt.FileSystem,r=yield*rt.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,x[0].path),u=r.join(e,x[1].path),d=r.join(e,x[2].path),s=yield*t.exists(a),p=yield*t.exists(u),l=yield*t.exists(d),h=s?"ts":l?"jsonc":p?"json":null,j=[],D=[];if(s&&(p||l))D.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!s&&p&&l)D.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)j.push({description:`Install \`oxfmt@${"0.57.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.57.0",type:"install_package"});else if(B(i)!=="0.57.0")j.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.57.0"}\`.`,package:"oxfmt",targetVersion:"0.57.0",type:"update_package"});if(h===null)j.push({description:`Create \`${x[0].path}\` for \`oxfmt\`.`,path:x[0].path,type:"create_config"});if(h==="json"||h==="jsonc")j.push({description:`Migrate legacy \`${h==="json"?x[1].path:x[2].path}\` to \`${x[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:j,applicable:!0,warnings:D}}),config:x[0].path,create:(e)=>Re.gen(function*(){let t=yield*nt.FileSystem,n=(yield*rt.Path).join(e,x[0].path);yield*t.writeFileString(n,tt()).pipe(Re.mapError((o)=>new S({cause:o,path:n})))}),exists:(e)=>Re.gen(function*(){let t=yield*nt.FileSystem,r=yield*rt.Path,n=r.join(e,x[0].path),o=r.join(e,x[1].path),i=r.join(e,x[2].path),a=yield*t.exists(n),u=yield*t.exists(o),d=yield*t.exists(i),s=a?"ts":d?"jsonc":u?"json":null,p=[];if(a&&u)p.push({format:"json",path:o});if(a&&d)p.push({format:"jsonc",path:i});if(!a&&u&&d)p.push({format:"json",path:o});return{active:s===null?null:{format:s,path:s==="ts"?n:s==="jsonc"?i:o},legacy:p}}),files:x,kind:"tooling",name:"oxfmt",version:"0.57.0"});import*as sn from"effect/Effect";var K=P({assess:(e)=>sn.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@${"1.12.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.12.0",type:"install_package"});else if(B(n)!=="1.12.0")o.push({currentVersion:n,description:`Update \`sherif\` from \`${n}\` to \`${"1.12.0"}\`.`,package:"sherif",targetVersion:"1.12.0",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:"1.12.0"});import*as fn from"effect/Effect";var fe=P({assess:(e)=>fn.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@${"0.24.0"}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:"0.24.0",type:"install_package"});else if(B(n)!=="0.24.0")o.push({currentVersion:n,description:`Update \`oxlint-tsgolint\` from \`${n}\` to \`${"0.24.0"}\`.`,package:"oxlint-tsgolint",targetVersion:"0.24.0",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:"0.24.0"});import*as z from"effect/Effect";import*as ln from"effect/Exit";import*as pn from"effect/FileSystem";import*as un from"effect/Path";function le(e){return e}function be(e,t,r){return z.gen(function*(){let n=yield*pn.FileSystem,o=yield*un.Path,i=e.files??[],a=new Map;for(let d of i){let s=o.join(t.cwd,d);if(yield*n.exists(s)){let l=yield*n.readFileString(s);a.set(s,l)}else a.set(s,null)}let u=yield*z.exit(e.migrate(t).pipe(z.andThen(()=>e.validate?.(t)??z.void)));if(ln.isSuccess(u))return;if(r?.onRestore)yield*r.onRestore;for(let[d,s]of a){if(s!==null){yield*n.writeFileString(d,s).pipe(z.ignore);continue}if(!(yield*n.exists(d).pipe(z.orElseSucceed(()=>!1))))continue;yield*n.remove(d).pipe(z.ignore)}return yield*z.failCause(u.cause)})}import*as ee from"effect/Effect";import*as yn from"effect/FileSystem";import*as mn from"effect/Path";import*as R from"@clack/prompts";import*as cn from"effect/Context";import*as b from"effect/Effect";import*as dn from"effect/Layer";class E extends cn.Service()("Prompter"){static layer=dn.succeed(this)({cancel:(e)=>b.sync(()=>{R.cancel(e)}),confirm:(e)=>b.promise(()=>R.confirm(e)).pipe(b.filterOrFail((t)=>!R.isCancel(t),()=>new Xe({}))),intro:(e)=>b.sync(()=>{R.intro(e)}),log:{error:(e)=>b.sync(()=>{R.log.error(e)}),info:(e)=>b.sync(()=>{R.log.info(e)}),success:(e)=>b.sync(()=>{R.log.success(e)}),warning:(e)=>b.sync(()=>{R.log.warning(e)})},multiselect:(e)=>b.promise(()=>R.multiselect(e)).pipe(b.filterOrFail((t)=>!R.isCancel(t),()=>new Xe({}))),outro:(e)=>b.sync(()=>{R.outro(e)}),spinner:()=>R.spinner()})}function hn(){return[y.files[1].path,y.files[2].path]}function Ar(e){let t=hn();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${y.config}\`.`}function Ur(e){return ee.gen(function*(){let t=yield*yn.FileSystem,r=yield*mn.Path,n=yield*y.exists(e);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(e,y.config),a=yield*t.readFileString(o).pipe(ee.mapError((l)=>new T({cause:l,path:o}))),u=yield*U(a,o);if(!V(u))return yield*new J({path:o});let{$schema:d,...s}=u;yield*t.writeFileString(i,Ye(s)).pipe(ee.mapError((l)=>new S({cause:l,path:i}))),yield*t.remove(o).pipe(ee.mapError((l)=>new re({cause:l,path:o})));let p=n.legacy[0]?.path??null;if(p&&p!==o)yield*t.remove(p).pipe(ee.mapError((l)=>new re({cause:l,path:p})))})}var zt=le({check:(e)=>ee.gen(function*(){let t=yield*y.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:Ar(t.active.format),warnings:r};if(t.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[y.config,...hn()],id:"legacy-knip-json",migrate:(e)=>ee.gen(function*(){let r=(yield*E).spinner(),o=(yield*y.exists(e.cwd)).active?.path.endsWith(y.files[2].path)?y.files[2].path:y.files[1].path;r.start(`Migrating \`${o}\` to \`${y.config}\`...`),yield*Ur(e.cwd),r.stop(`Knip config migrated to \`${y.config}\` successfully.`)}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>ee.gen(function*(){if((yield*y.exists(e.cwd)).active?.format!=="ts")return yield*new Y({migrationId:"legacy-knip-json",reason:`\`${y.config}\` is not the active Knip config.`})})});import*as te from"effect/Effect";import*as En from"effect/FileSystem";import*as gn from"effect/Path";function On(){return[m.files[1].path,m.files[2].path]}function Mr(e){let t=On();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function xr(e){return te.gen(function*(){let t=yield*En.FileSystem,r=yield*gn.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(te.mapError((l)=>new T({cause:l,path:o}))),u=yield*U(a,o);if(!V(u))return yield*new J({path:o});let{$schema:d,...s}=u;yield*t.writeFileString(i,tt(s)).pipe(te.mapError((l)=>new S({cause:l,path:i}))),yield*t.remove(o).pipe(te.mapError((l)=>new re({cause:l,path:o})));let p=n.legacy[0]?.path??null;if(p&&p!==o)yield*t.remove(p).pipe(te.mapError((l)=>new re({cause:l,path:p})))})}var At=le({check:(e)=>te.gen(function*(){let t=yield*m.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:Mr(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-oxfmt-json",migrate:(e)=>te.gen(function*(){let r=(yield*E).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*xr(e.cwd),r.stop(`Oxfmt config migrated to \`${m.config}\` successfully.`)}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>te.gen(function*(){if((yield*m.exists(e.cwd)).active?.format!=="ts")return yield*new Y({migrationId:"legacy-oxfmt-json",reason:`\`${m.config}\` is not the active oxfmt config.`})})});import*as oe from"effect/Effect";import*as Sn from"effect/FileSystem";import*as jn from"effect/Path";function br(e){return oe.gen(function*(){let t=yield*Sn.FileSystem,r=yield*jn.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((N)=>new T({cause:N,path:o}))),u=yield*U(a,o);if(!V(u))return yield*new J({path:o});let{$schema:d,...s}=u,p=Array.isArray(s.extends)?s.extends.filter((N)=>typeof N==="string"):typeof s.extends==="string"?[s.extends]:[],l=new Set(Le()),h=new Set;for(let N of p){let W=N.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),f=N.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),F=W?.[1]??(f?f[1]??"core":null);if(F)l.add(F);else h.add(N)}let{extends:j,...D}=s;yield*t.writeFileString(i,et(D,[...l],[...h])).pipe(oe.mapError((N)=>new S({cause:N,path:i}))),yield*t.remove(o).pipe(oe.mapError((N)=>new re({cause:N,path:o})))})}var Ut=le({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*E).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 Y({migrationId:"legacy-oxlint-json",reason:`\`${c.config}\` is not the active oxlint config.`})})});import*as w from"effect/Effect";import*as Mt from"effect/Exit";import*as ye from"effect/Effect";import*as st from"effect/FileSystem";import*as ft from"effect/Path";import*as ot from"effect/Effect";import*as Fn from"effect/FileSystem";var $n=(e)=>ot.gen(function*(){yield*(yield*Fn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(ot.mapError((r)=>new de({cause:r,path:e})))});import{runScriptCommand as Jr}from"nypm";var vn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Rn(e,t){let r=[];for(let n of vn){if(!t.includes(n.script))continue;r.push({command:Jr(e,n.script,{args:n.args}),name:n.name})}return r}function it(e){return vn.some((t)=>e.includes(t.script))}var wr={bun:` - name: Setup Node.js
11
+ `)}function te(t){return N(t)&&t.type==="ObjectExpression"&&Array.isArray(t.properties)}function Ie(t){return N(t)&&t.type==="Property"}function Te(t){return A.try({catch:()=>null,try:()=>zr("oxlint.config.ts",t,{astType:"ts",lang:"ts",sourceType:"module"})}).pipe(A.match({onFailure:()=>S.none(),onSuccess:(e)=>e.errors.length===0?S.fromNullishOr(e.program):S.none()}))}function on(t){let{code:e}=Tr(t,qr({quotes:"double"}));return e.endsWith(`
12
+ `)?e:`${e}
13
+ `}function en(t){if(t.type==="Identifier")return t.name;if(t.type==="Literal"&&typeof t.value==="string")return t.value;return null}function qe(t){let e=t.body.filter((i)=>i.type==="ExportDefaultDeclaration");if(e.length!==1)return S.none();let[r]=e;if(!r)return S.none();let n=r.declaration;if(te(n))return S.fromNullishOr(n);if(n.type!=="CallExpression")return S.none();if(n.callee.type!=="Identifier"||n.callee.name!=="defineConfig")return S.none();if(n.arguments.length!==1)return S.none();let[o]=n.arguments;if(te(o))return S.fromNullishOr(o);return S.none()}function ze(t,e){let r=null;for(let n of t.properties){if(n.type==="SpreadElement")return{status:"manual"};if(!Ie(n))return{status:"manual"};if(n.computed)return{status:"manual"};if(n.method||n.kind!=="init"){if(en(n.key)===e)return{status:"manual"};continue}if(en(n.key)!==e)continue;if(r)return{status:"manual"};r=n}if(!r)return{status:"missing"};return{property:r,status:"found"}}function kr(t){let e=`export default { options: { ${t.map((r)=>`${r}: true`).join(", ")} } }
14
+ `;return Te(e).pipe(A.map((r)=>{if(S.isNone(r))return S.none();let n=qe(r.value);if(S.isNone(n))return S.none();let o=ze(n.value,"options");if(o.status!=="found")return S.none();if(!te(o.property.value))return S.none();let i=o.property.value.properties.filter(Ie);return i.length===o.property.value.properties.length?S.fromNullishOr(i):S.none()}))}function Ur(){let t=`export default { options: { ${nn.map((e)=>`${e}: true`).join(", ")} } }
15
+ `;return Te(t).pipe(A.map((e)=>{if(S.isNone(e))return S.none();let r=qe(e.value);if(S.isNone(r)||r.value.properties.length!==1)return S.none();let[n]=r.value.properties;if(!n||!Ie(n)||n.computed||n.method||n.kind!=="init")return S.none();return S.fromNullishOr(n)}))}function Jr(t,e){return A.gen(function*(){let r=[],n=!1;for(let o of nn){let i=ze(e,o);if(i.status==="manual")return{kind:"manual",reason:Ce};if(i.status==="missing"){r.push(o);continue}let f=i.property.value;if(f.type!=="Literal"||typeof f.value!=="boolean")return{kind:"manual",reason:Ce};if(f.value)continue;f.raw="true",f.value=!0,n=!0}if(r.length>0){let o=yield*kr(r);if(S.isNone(o))return{kind:"manual",reason:rn};e.properties.unshift(...o.value),n=!0}if(!n)return{kind:"configured"};return{kind:"patchable",updatedContent:on(t)}})}function ke(t){return A.gen(function*(){let e=yield*Te(t);if(S.isNone(e))return{kind:"manual",reason:Ae};let r=qe(e.value);if(S.isNone(r))return{kind:"manual",reason:Ae};let n=ze(r.value,"options");if(n.status==="manual")return{kind:"manual",reason:Ge};if(n.status==="missing"){let o=yield*Ur();if(S.isNone(o))return{kind:"manual",reason:rn};return r.value.properties.unshift(o.value),{kind:"patchable",updatedContent:on(e.value)}}if(!te(n.property.value))return{kind:"manual",reason:Ge};return yield*Jr(e.value,n.property.value)})}var q=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}];var y=P({assess:(t)=>G.gen(function*(){let e=yield*Qt.FileSystem,r=yield*Wt.Path,n=yield*F(t),o=X(n);if(!o.includes("check")&&!o.includes("fix"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxlint??n.dependencies?.oxlint,f=r.join(t,q[0].path),s=r.join(t,q[1].path),c=yield*e.exists(f),a=yield*e.exists(s),p={active:c?{format:"ts",path:f}:a?{format:"json",path:s}:null,legacy:c&&a?[{format:"json",path:s}]:[]},l=[],h=[];if(p.active?.format==="ts"&&p.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@${"1.75.0"}\` for the managed lint scripts.`,package:"oxlint",targetVersion:"1.75.0",type:"install_package"});else if(x(i)!=="1.75.0")l.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${"1.75.0"}\`.`,package:"oxlint",targetVersion:"1.75.0",type:"update_package"});if(p.active===null)l.push({description:`Create \`${q[0].path}\` for \`oxlint\`.`,path:q[0].path,type:"create_config"});if(p.active?.format==="json")l.push({description:`Migrate legacy \`${q[1].path}\` to \`${q[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(p.active?.format==="ts"){let $=yield*e.readFileString(f).pipe(G.mapError((_)=>new v({cause:_,path:f}))),R=yield*ke($);if(R.kind==="patchable")l.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:q[0].path,type:"update_config"});if(R.kind==="manual")l.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:q[0].path,type:"manual_fix"})}return{actions:l,applicable:!0,warnings:h}}),config:q[0].path,create:(t,e=[])=>G.gen(function*(){let r=yield*Qt.FileSystem,o=(yield*Wt.Path).join(t,q[0].path),i=ne({},ee(e));yield*r.writeFileString(o,i).pipe(G.mapError((f)=>new O({cause:f,path:o})))}),exists:(t)=>G.gen(function*(){let e=yield*Qt.FileSystem,r=yield*Wt.Path,n=r.join(t,q[0].path),o=r.join(t,q[1].path),i=yield*e.exists(n),f=yield*e.exists(o),s=i?"ts":f?"json":null,c=[];if(i&&f)c.push({format:"json",path:o});return{active:s===null?null:{format:s,path:s==="ts"?n:o},legacy:c}}),files:q,kind:"tooling",name:"oxlint",update:(t)=>G.gen(function*(){let e=yield*Qt.FileSystem,n=(yield*Wt.Path).join(t,q[0].path);if(!(yield*e.exists(n)))return yield*new Re({path:q[0].path});let o=yield*e.readFileString(n).pipe(G.mapError((f)=>new v({cause:f,path:n}))),i=yield*ke(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new De({path:q[0].path,reason:i.reason});yield*e.writeFileString(n,i.updatedContent).pipe(G.mapError((f)=>new O({cause:f,path:n})))}),version:"1.75.0"});var br=vt.file("files",{mustExist:!0}).pipe(vt.withDescription("Specific files to lint (optional)"),vt.variadic()),ln=Rt.make("check",{files:br}).pipe(Rt.withDescription("Find issues and type errors in code using oxlint"),Rt.withHandler(({files:t})=>fn.gen(function*(){let r=yield*(yield*I).run({args:[...t],command:y.name});if(r!==an.ExitCode(0))yield*new T({command:y.name,exitCode:r})})));import Cr from"node:process";import*as Pt from"effect/Effect";import*as Nt from"effect/unstable/cli/Command";import*as de from"effect/unstable/cli/Flag";import*as Qe from"effect/unstable/process/ChildProcessSpawner";import*as Dt from"effect/Effect";import*as oe from"effect/FileSystem";import*as ie from"effect/Path";var Br=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function Qr(t){let e=t.split(`
16
+ `);if(e.length===1)return t.slice(1,-1).trim();return e.slice(1,-1).map((r)=>` ${r.trimStart()}`).join(`
17
+ `)}function Wr(t,e){let r=Et(e),n=Qr(r);return[` ${t}: {`,` ...format.${t},`,...n===""?[]:[n]," },"].join(`
18
+ `)}function re(t={}){let e=Object.entries(t).map(([r,n])=>{if(Br.has(r)&&N(n))return Wr(r,n);let o=Et(n,{continuationIndent:" "});return` ${r}: ${o},`});if(e.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,",...e,"})",""].join(`
20
+ `)}var B=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var m=P({assess:(t)=>Dt.gen(function*(){let e=yield*oe.FileSystem,r=yield*ie.Path,n=yield*F(t);if(!X(n).includes("format"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxfmt??n.dependencies?.oxfmt,f=r.join(t,B[0].path),s=r.join(t,B[1].path),c=r.join(t,B[2].path),a=yield*e.exists(f),p=yield*e.exists(s),l=yield*e.exists(c),h=a?"ts":l?"jsonc":p?"json":null,$=[],R=[];if(a&&(p||l))R.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!a&&p&&l)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(!i)$.push({description:`Install \`oxfmt@${"0.60.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.60.0",type:"install_package"});else if(x(i)!=="0.60.0")$.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.60.0"}\`.`,package:"oxfmt",targetVersion:"0.60.0",type:"update_package"});if(h===null)$.push({description:`Create \`${B[0].path}\` for \`oxfmt\`.`,path:B[0].path,type:"create_config"});if(h==="json"||h==="jsonc")$.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:$,applicable:!0,warnings:R}}),config:B[0].path,create:(t)=>Dt.gen(function*(){let e=yield*oe.FileSystem,n=(yield*ie.Path).join(t,B[0].path);yield*e.writeFileString(n,re()).pipe(Dt.mapError((o)=>new O({cause:o,path:n})))}),exists:(t)=>Dt.gen(function*(){let e=yield*oe.FileSystem,r=yield*ie.Path,n=r.join(t,B[0].path),o=r.join(t,B[1].path),i=r.join(t,B[2].path),f=yield*e.exists(n),s=yield*e.exists(o),c=yield*e.exists(i),a=f?"ts":c?"jsonc":s?"json":null,p=[];if(f&&s)p.push({format:"json",path:o});if(f&&c)p.push({format:"jsonc",path:i});if(!f&&s&&c)p.push({format:"json",path:o});return{active:a===null?null:{format:a,path:a==="ts"?n:a==="jsonc"?i:o},legacy:p}}),files:B,kind:"tooling",name:"oxfmt",version:"0.60.0"});import*as sn from"effect/Effect";var M=P({assess:(t)=>sn.gen(function*(){let e=yield*F(t),r=X(e);if(!r.includes("check:monorepo")&&!r.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let n=e.devDependencies?.sherif??e.dependencies?.sherif,o=[];if(!n)o.push({description:`Install \`sherif@${"1.13.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.13.0",type:"install_package"});else if(x(n)!=="1.13.0")o.push({currentVersion:n,description:`Update \`sherif\` from \`${n}\` to \`${"1.13.0"}\`.`,package:"sherif",targetVersion:"1.13.0",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:"1.13.0"});import*as pn from"effect/Effect";var lt=P({assess:(t)=>pn.gen(function*(){let e=yield*F(t),r=X(e);if(!r.includes("check")&&!r.includes("fix"))return{applicable:!1,warnings:[]};let n=e.devDependencies?.["oxlint-tsgolint"]??e.dependencies?.["oxlint-tsgolint"],o=[];if(!n)o.push({description:`Install \`oxlint-tsgolint@${"7.0.2001"}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"install_package"});else if(x(n)!=="7.0.2001")o.push({currentVersion:n,description:`Update \`oxlint-tsgolint\` from \`${n}\` to \`${"7.0.2001"}\`.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:"7.0.2001"});import*as k from"effect/Effect";import*as un from"effect/Exit";import*as cn from"effect/FileSystem";import*as yn from"effect/Path";function st(t){return t}function Zt(t,e,r){return k.gen(function*(){let n=yield*cn.FileSystem,o=yield*yn.Path,i=t.files??[],f=new Map;for(let c of i){let a=o.join(e.cwd,c);if(yield*n.exists(a)){let l=yield*n.readFileString(a);f.set(a,l)}else f.set(a,null)}let s=yield*k.exit(t.migrate(e).pipe(k.andThen(()=>t.validate?.(e)??k.void)));if(un.isSuccess(s))return;if(r?.onRestore)yield*r.onRestore;for(let[c,a]of f){if(a!==null){yield*n.writeFileString(c,a).pipe(k.ignore);continue}if(!(yield*n.exists(c).pipe(k.orElseSucceed(()=>!1))))continue;yield*n.remove(c).pipe(k.ignore)}return yield*k.failCause(s.cause)})}import*as C from"effect/Effect";import*as hn from"effect/FileSystem";import*as En from"effect/Path";import*as V from"@clack/prompts";import*as dn from"effect/Context";import*as Q from"effect/Effect";import*as mn from"effect/Layer";class E extends dn.Service()("Prompter"){static layer=mn.succeed(this)({cancel:(t)=>Q.sync(()=>{V.cancel(t)}),confirm:(t)=>Q.promise(()=>V.confirm(t)).pipe(Q.filterOrFail((e)=>!V.isCancel(e),()=>new Kt({}))),intro:(t)=>Q.sync(()=>{V.intro(t)}),log:{error:(t)=>Q.sync(()=>{V.log.error(t)}),info:(t)=>Q.sync(()=>{V.log.info(t)}),success:(t)=>Q.sync(()=>{V.log.success(t)}),warning:(t)=>Q.sync(()=>{V.log.warning(t)})},multiselect:(t)=>Q.promise(()=>V.multiselect(t)).pipe(Q.filterOrFail((e)=>!V.isCancel(e),()=>new Kt({}))),outro:(t)=>Q.sync(()=>{V.outro(t)}),spinner:()=>V.spinner()})}function gn(){return[d.files[1].path,d.files[2].path]}function Zr(t){let e=gn();return`Migrating legacy \`${t==="json"?e[0]:e[1]}\` configuration to \`${d.config}\`.`}function xr(t){return C.gen(function*(){let e=yield*hn.FileSystem,r=yield*En.Path,n=yield*d.exists(t);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(t,d.config),f=yield*e.readFileString(o).pipe(C.mapError((l)=>new v({cause:l,path:o}))),s=yield*J(f,o);if(!N(s))return yield*new W({path:o});let{$schema:c,...a}=s;yield*e.writeFileString(i,Lt(a)).pipe(C.mapError((l)=>new O({cause:l,path:i}))),yield*e.remove(o).pipe(C.mapError((l)=>new rt({cause:l,path:o})));let p=n.legacy[0]?.path??null;if(p&&p!==o)yield*e.remove(p).pipe(C.mapError((l)=>new rt({cause:l,path:p})))})}var Ue=st({check:(t)=>C.gen(function*(){let e=yield*d.exists(t.cwd),r=[];if(e.active?.format==="ts"&&e.legacy.length>0)r.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(e.active&&e.active.format!=="ts"&&e.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(e.active?.format==="json"||e.active?.format==="jsonc")return{applicable:!0,summary:Zr(e.active.format),warnings:r};if(e.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[d.config,...gn()],id:"legacy-knip-json",migrate:(t)=>C.gen(function*(){let r=(yield*E).spinner(),o=(yield*d.exists(t.cwd)).active?.path.endsWith(d.files[2].path)?d.files[2].path:d.files[1].path;r.start(`Migrating \`${o}\` to \`${d.config}\`...`),yield*xr(t.cwd),r.stop(`Knip config migrated to \`${d.config}\` successfully.`)}),tags:["update"],title:"Legacy Knip JSON config",validate:(t)=>C.gen(function*(){if((yield*d.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-knip-json",reason:`\`${d.config}\` is not the active Knip config.`})})});import*as tt from"effect/Effect";import*as On from"effect/FileSystem";import*as jn from"effect/Path";function Sn(){return[m.files[1].path,m.files[2].path]}function Xr(t){let e=Sn();return`Migrating legacy \`${t==="json"?e[0]:e[1]}\` configuration to \`${m.config}\`.`}function Yr(t){return tt.gen(function*(){let e=yield*On.FileSystem,r=yield*jn.Path,n=yield*m.exists(t);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(t,m.config),f=yield*e.readFileString(o).pipe(tt.mapError((l)=>new v({cause:l,path:o}))),s=yield*J(f,o);if(!N(s))return yield*new W({path:o});let{$schema:c,...a}=s;yield*e.writeFileString(i,re(a)).pipe(tt.mapError((l)=>new O({cause:l,path:i}))),yield*e.remove(o).pipe(tt.mapError((l)=>new rt({cause:l,path:o})));let p=n.legacy[0]?.path??null;if(p&&p!==o)yield*e.remove(p).pipe(tt.mapError((l)=>new rt({cause:l,path:p})))})}var Je=st({check:(t)=>tt.gen(function*(){let e=yield*m.exists(t.cwd),r=[];if(e.active?.format==="ts"&&e.legacy.length>0)r.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(e.active&&e.active.format!=="ts"&&e.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(e.active?.format==="json"||e.active?.format==="jsonc")return{applicable:!0,summary:Xr(e.active.format),warnings:r};if(e.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[m.config,...Sn()],id:"legacy-oxfmt-json",migrate:(t)=>tt.gen(function*(){let r=(yield*E).spinner(),o=(yield*m.exists(t.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;r.start(`Migrating \`${o}\` to \`${m.config}\`...`),yield*Yr(t.cwd),r.stop(`Oxfmt config migrated to \`${m.config}\` successfully.`)}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(t)=>tt.gen(function*(){if((yield*m.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxfmt-json",reason:`\`${m.config}\` is not the active oxfmt config.`})})});import*as ot from"effect/Effect";import*as $n from"effect/FileSystem";import*as Fn from"effect/Path";function wr(t){return ot.gen(function*(){let e=yield*$n.FileSystem,r=yield*Fn.Path,n=yield*y.exists(t);if(n.active?.format!=="json")return;let o=n.active.path,i=r.join(t,y.config),f=yield*e.readFileString(o).pipe(ot.mapError((_)=>new v({cause:_,path:o}))),s=yield*J(f,o);if(!N(s))return yield*new W({path:o});let{$schema:c,...a}=s,p=Array.isArray(a.extends)?a.extends.filter((_)=>typeof _==="string"):typeof a.extends==="string"?[a.extends]:[],l=new Set(ee()),h=new Set;for(let _ of p){let nt=_.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),u=_.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),j=nt?.[1]??(u?u[1]??"core":null);if(j)l.add(j);else h.add(_)}let{extends:$,...R}=a;yield*e.writeFileString(i,ne(R,[...l],[...h])).pipe(ot.mapError((_)=>new O({cause:_,path:i}))),yield*e.remove(o).pipe(ot.mapError((_)=>new rt({cause:_,path:o})))})}var be=st({id:"legacy-oxlint-json",files:[y.config,y.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(t)=>ot.gen(function*(){let e=yield*y.exists(t.cwd),r=e.active?.format==="ts"&&e.legacy.length>0?[`Found both \`${y.config}\` and \`${y.files[1].path}\`. Adamantite will use \`${y.config}\`.`]:[];if(e.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${y.files[1].path}\` configuration to \`${y.config}\`.`,warnings:r};if(e.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),migrate:(t)=>ot.gen(function*(){let r=(yield*E).spinner();r.start(`Migrating \`${y.files[1].path}\` to \`${y.config}\`...`),yield*wr(t.cwd),r.stop(`Oxlint config migrated to \`${y.config}\` successfully.`)}),validate:(t)=>ot.gen(function*(){if((yield*y.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxlint-json",reason:`\`${y.config}\` is not the active oxlint config.`})})});import*as Z from"effect/Effect";import*as Be from"effect/Exit";import*as dt from"effect/Effect";import*as se from"effect/FileSystem";import*as pe from"effect/Path";import*as fe from"effect/Effect";import*as vn from"effect/FileSystem";var Rn=(t)=>fe.gen(function*(){yield*(yield*vn.FileSystem).makeDirectory(t,{recursive:!0}).pipe(fe.mapError((r)=>new yt({cause:r,path:t})))});import{runScriptCommand as Hr}from"nypm";var Dn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Vn(t,e){let r=[];for(let n of Dn){if(!e.includes(n.script))continue;r.push({command:Hr(t,n.script,{args:n.args}),name:n.name})}return r}function ae(t){return Dn.some((e)=>t.includes(e.script))}var Mr={bun:` - name: Setup Node.js
21
21
  uses: actions/setup-node@v6
22
22
  with:
23
23
  node-version: "22"
@@ -64,7 +64,7 @@ ${r}`)}var Ee=(e,t)=>G.try({catch:(r)=>new jt({cause:r}),try:()=>Or(e,t)});funct
64
64
  cache: "yarn"
65
65
 
66
66
  - name: Install dependencies
67
- run: yarn install --frozen-lockfile`};function Dn({packageManager:e,scripts:t}){let r=Rn(e,t);if(r.length===0)return null;return`${`name: adamantite
67
+ run: yarn install --frozen-lockfile`};function Pn({packageManager:t,scripts:e}){let r=Vn(t,e);if(r.length===0)return null;return`${`name: adamantite
68
68
 
69
69
  on:
70
70
  push:
@@ -97,16 +97,26 @@ ${r.map((i)=>` - name: ${i.name}
97
97
  - name: Checkout
98
98
  uses: actions/checkout@v4
99
99
 
100
- ${wr[e]}
100
+ ${Mr[t]}
101
101
 
102
102
  - name: Run \${{ matrix.name }}
103
103
  run: \${{ matrix.command }}`}
104
- `}var at=[{path:".github/workflows/adamantite.yml",type:"ci"}],ie=P({create:(e,t)=>ye.gen(function*(){let r=yield*st.FileSystem,n=yield*ft.Path,o=n.join(e,at[0].path);yield*$n(n.dirname(o));let i=Dn(t);if(!i)return;yield*r.writeFileString(o,i).pipe(ye.mapError((a)=>new S({cause:a,path:o})))}),exists:(e)=>ye.gen(function*(){let t=yield*st.FileSystem,r=yield*ft.Path;return yield*t.exists(r.join(e,at[0].path))}),files:at,kind:"ci",name:"github",update:(e,t)=>ye.gen(function*(){let r=yield*st.FileSystem,o=(yield*ft.Path).join(e,at[0].path),i=Dn(t);if(!i)return;yield*r.writeFileString(o,i).pipe(ye.mapError((a)=>new S({cause:a,path:o})))})});import*as Nn from"effect/Context";import*as me from"effect/Effect";import*as Pn from"effect/Layer";import{addDevDependency as Wr,detectPackageManager as Br}from"nypm";class Z extends Nn.Service()("DependencyInstaller"){static layer=Pn.succeed(this)({addDevDependencies:(e,t,r)=>me.tryPromise({catch:(n)=>new St({cause:n,packages:e}),try:()=>Wr(e,{...r,cwd:t})}).pipe(me.asVoid),detectPackageManager:(e)=>me.tryPromise({catch:(t)=>new Ue({cause:t}),try:()=>Br(e)}).pipe(me.map((t)=>t??null))})}import*as pe from"effect/Effect";import*as lt from"effect/FileSystem";import*as pt from"effect/Path";var Je=[{path:"tsconfig.json",type:"config"}],Tn={extends:"adamantite/typescript"},q=P({config:Je[0].path,create:(e)=>pe.gen(function*(){let t=yield*lt.FileSystem,n=(yield*pt.Path).join(e,Je[0].path),o=JSON.stringify(Tn,null,2);yield*t.writeFileString(n,`${o}
105
- `).pipe(pe.mapError((i)=>new S({cause:i,path:n})))}),exists:(e)=>pe.gen(function*(){let t=yield*lt.FileSystem,r=yield*pt.Path;return yield*t.exists(r.join(e,Je[0].path))}),files:Je,kind:"workspace",name:"tsconfig",update:(e)=>pe.gen(function*(){let t=yield*lt.FileSystem,n=(yield*pt.Path).join(e,Je[0].path),o=yield*t.readFileString(n).pipe(pe.mapError((u)=>new T({cause:u,path:n}))),i=yield*U(o,n);if(!V(i))return yield*new J({path:n});let a=yield*Ee(Tn,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
106
- `).pipe(pe.mapError((u)=>new S({cause:u,path:n})))})});var _n="adamantite typecheck";function Qr(){return c.files[1].path}function Zr(){return ie.files[0].path}function Vn(e){let t={...e.scripts};if(t.typecheck!==_n)return{migrated:!1,packageJson:e};return delete t.typecheck,t.check??=Tt.check,{migrated:!0,packageJson:{...e,scripts:t}}}var In=le({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,Qr(),q.config,Zr()],id:"legacy-typecheck-script",migrate:(e)=>w.gen(function*(){let t=yield*E,r=yield*Z,n=t.spinner(),o=w.gen(function*(){let i=yield*$(e.cwd),a=Vn(i);if(!a.migrated)return"noop";yield*wt(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*q.exists(e.cwd))?q.update(e.cwd):q.create(e.cwd);let s=yield*ie.exists(e.cwd),p=Q(a.packageJson);if(s&&it(p)){let l=yield*r.detectPackageManager(e.cwd);if(l&&Ke(l.name)){let h=l.name,j=t.spinner();j.start("Updating GitHub Actions workflow..."),yield*ie.update(e.cwd,{packageManager:h,scripts:p}).pipe(w.onExit((D)=>w.sync(()=>{j.stop(Mt.match(D,{onFailure:()=>"Failed to update GitHub Actions workflow.",onSuccess:()=>"GitHub Actions workflow updated successfully"}))})))}else if(l)yield*t.log.warning(`\`${l.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`);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(Mt.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===_n)return yield*new Y({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 Y({migrationId:"legacy-typecheck-script",reason:`\`${c.config}\` is not the active oxlint config.`});if(!(yield*q.exists(e.cwd)))return yield*new Y({migrationId:"legacy-typecheck-script",reason:`\`${q.config}\` is missing after the migration.`})})});var ut=[At,zt,Ut,In],kn=Object.fromEntries(ut.map((e)=>[e.id,e])),qn={[zt.id]:y.name,[At.id]:m.name,[Ut.id]:c.name};import*as zn from"effect/Console";import*as An from"effect/Effect";import*as Un from"effect/Terminal";var De=()=>An.gen(function*(){let t=yield*(yield*Un.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*zn.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 Yr=ct.boolean("fix").pipe(ct.withDescription("Automatically fix safe package install/update issues")),Kr=[y,m,c,K,fe];function Hr(e){return e.applicable&&Array.isArray(e.actions)}var Mn={[y.name]:y,[m.name]:m,[c.name]:c},xn={[c.name]:c};function bn(e,t){return Object.hasOwn(e,t)}function we(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 Jn=Pe.make("doctor",{fix:Yr}).pipe(Pe.withDescription("Check Adamantite-managed integrations in the current project"),Pe.withHandler(({fix:e})=>Ne.gen(function*(){let t=Xr.cwd(),r=yield*E;yield*De(),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 I({command:"doctor",exitCode:xt.ExitCode(1)});let o=[];for(let d of Kr){let s=yield*d.assess(t);if(Hr(s))o.push({assessment:s,integration:d})}for(let{assessment:d}of o)for(let s of d.warnings)yield*r.log.warning(s);if(o.length===0){yield*r.log.success("No applicable integrations found."),yield*r.outro("✅ Doctor completed successfully!");return}let i=o.flatMap(({assessment:d,integration:s})=>d.actions.map((p)=>({action:p,integration:s})));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*Ne.gen(function*(){let d=i.filter(({action:s})=>s.type==="install_package"||s.type==="update_package");if(d.length>0){let s=yield*Z,p=[];for(let{action:l}of d)if(l.type==="install_package"||l.type==="update_package")p.push(`${l.package}@${l.targetVersion}`);yield*s.addDevDependencies(p,t,{silent:!0});for(let{action:l,integration:h}of d){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(we(h.name,l))}}for(let{action:s,integration:p}of i){if(s.type!=="create_config")continue;if(!bn(Mn,p.name))continue;yield*Mn[p.name].create(t),yield*r.log.success(`Fixed: created \`${s.path}\`.`),a.add(we(p.name,s))}for(let{action:s,integration:p}of i){if(s.type!=="update_config")continue;if(!bn(xn,p.name))continue;yield*xn[p.name].update(t),yield*r.log.success(`Fixed: updated \`${s.path}\`.`),a.add(we(p.name,s))}for(let{action:s,integration:p}of i){if(s.type!=="run_migration")continue;let l=kn[s.migrationId];if(!l)continue;yield*be(l,{cwd:t}),a.add(we(p.name,s))}}).pipe(Ne.tapError(()=>Ne.gen(function*(){yield*r.outro("❌ Doctor failed")})));let u=i.filter(({action:d,integration:s})=>!a.has(we(s.name,d)));if(e&&u.length===0){yield*r.outro("✅ Doctor completed successfully!");return}for(let{action:d}of e?u:i)yield*r.log.warning(`Needs attention: ${d.description}`);yield*r.outro("⚠️ Doctor found issues."),yield*new I({command:"doctor",exitCode:xt.ExitCode(1)})})));import*as wn from"effect/Effect";import*as Te from"effect/unstable/cli/Argument";import*as Ve from"effect/unstable/cli/Command";import*as ue from"effect/unstable/cli/Flag";import*as Wn from"effect/unstable/process/ChildProcessSpawner";var Gr=Te.file("files",{mustExist:!0}).pipe(Te.withDescription("Specific files to fix (optional)"),Te.variadic()),Cr=ue.boolean("suggested").pipe(ue.withDescription("Apply suggested fixes")),Lr=ue.boolean("dangerous").pipe(ue.withDescription("Apply dangerous fixes")),eo=ue.boolean("all").pipe(ue.withDescription("Apply all fixes, including suggested and dangerous fixes")),Bn=Ve.make("fix",{all:eo,dangerous:Lr,files:Gr,suggested:Cr}).pipe(Ve.withDescription("Fix issues in code using oxlint"),Ve.withHandler(({all:e,dangerous:t,files:r,suggested:n})=>wn.gen(function*(){let o=yield*_,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!==Wn.ExitCode(0))yield*new I({command:c.name,exitCode:a})})));import*as Qn from"effect/Effect";import*as _e from"effect/unstable/cli/Argument";import*as Ie from"effect/unstable/cli/Command";import*as dt from"effect/unstable/cli/Flag";import*as Zn from"effect/unstable/process/ChildProcessSpawner";var to=_e.file("files",{mustExist:!0}).pipe(_e.withDescription("Specific files to format (optional)"),_e.variadic()),no=dt.boolean("check").pipe(dt.withDescription("Check if files are formatted without writing")),Xn=Ie.make("format",{check:no,files:to}).pipe(Ie.withDescription("Format files using oxfmt"),Ie.withHandler(({check:e,files:t})=>Qn.gen(function*(){let r=yield*_,n=[];if(e)n.push("--check");n.push(...t);let o=yield*r.run({args:n,command:m.name});if(o!==Zn.ExitCode(0))yield*new I({command:m.name,exitCode:o})})));import oo from"node:process";import*as O from"effect/Effect";import*as er from"effect/FileSystem";import*as tr from"effect/Path";import*as ke from"effect/unstable/cli/Command";import*as H from"effect/Effect";import*as yt from"effect/FileSystem";import*as mt from"effect/Path";import*as Kn from"effect/unstable/process/ChildProcessSpawner";var We=[{path:".vscode/settings.json",type:"config"}],Yn={"[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=P({config:We[0].path,create:(e)=>H.gen(function*(){let t=yield*yt.FileSystem,r=yield*mt.Path,n=r.join(e,We[0].path),o=r.dirname(n);yield*t.makeDirectory(o,{recursive:!0}).pipe(H.mapError((i)=>new de({cause:i,path:o}))),yield*t.writeFileString(n,`${JSON.stringify(Yn,null,2)}
108
- `).pipe(H.mapError((i)=>new S({cause:i,path:n})))}),exists:(e)=>H.gen(function*(){let t=yield*yt.FileSystem,r=yield*mt.Path;return yield*t.exists(r.join(e,We[0].path))}),extension:(e=[])=>H.gen(function*(){let t=[];if(e.includes("check")||e.includes("fix")||e.includes("format"))t.push("oxc.oxc-vscode");if(e.includes("analyze"))t.push("webpro.vscode-knip");for(let r of t){let o=yield*(yield*_).run({args:["--install-extension",r],command:"code"}).pipe(H.mapError((i)=>i._tag==="CliNotFound"&&i.command==="code"?new Dt({cause:i}):new Ze({cause:i,extension:r})));if(o!==Kn.ExitCode(0))return yield*new Ze({cause:o,extension:r})}}),files:We,kind:"editor",name:"vscode",update:(e)=>H.gen(function*(){let t=yield*yt.FileSystem,n=(yield*mt.Path).join(e,We[0].path),o=yield*t.readFileString(n).pipe(H.mapError((u)=>new T({cause:u,path:n}))),i=yield*U(o,n);if(!V(i))return yield*new J({path:n});let a=yield*Ee(Yn,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
109
- `).pipe(H.mapError((u)=>new S({cause:u,path:n})))})});import*as ae from"effect/Effect";import*as ht from"effect/FileSystem";import*as Et from"effect/Path";var Be=[{path:".zed/settings.json",type:"config"}],Hn={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"}}}}},se=P({config:Be[0].path,create:(e)=>ae.gen(function*(){let t=yield*ht.FileSystem,r=yield*Et.Path,n=r.join(e,Be[0].path),o=r.dirname(n);yield*t.makeDirectory(o,{recursive:!0}).pipe(ae.mapError((i)=>new de({cause:i,path:o}))),yield*t.writeFileString(n,`${JSON.stringify(Hn,null,2)}
110
- `).pipe(ae.mapError((i)=>new S({cause:i,path:n})))}),exists:(e)=>ae.gen(function*(){let t=yield*ht.FileSystem,r=yield*Et.Path;return yield*t.exists(r.join(e,Be[0].path))}),files:Be,kind:"editor",name:"zed",update:(e)=>ae.gen(function*(){let t=yield*ht.FileSystem,n=(yield*Et.Path).join(e,Be[0].path),o=yield*t.readFileString(n).pipe(ae.mapError((u)=>new T({cause:u,path:n}))),i=yield*U(o,n);if(!V(i))return yield*new J({path:n});let a=yield*Ee(Hn,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
111
- `).pipe(ae.mapError((u)=>new S({cause:u,path:n})))})});import ro from"node:process";import*as Gn from"effect/Effect";import*as Cn from"effect/FileSystem";import*as Ln from"effect/Path";var bt=(e=ro.cwd())=>Gn.gen(function*(){let t=yield*Cn.FileSystem,r=yield*Ln.Path;if(yield*t.exists(r.join(e,"pnpm-workspace.yaml")))return!0;return(yield*$(e)).workspaces!==void 0});var io=(e,t)=>O.gen(function*(){let r=yield*Z,o=(yield*E).spinner();o.start("Installing dependencies...");let i=yield*bt(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:i}).pipe(O.tapError(()=>O.sync(()=>{o.stop("Failed to install dependencies.")}))),o.stop("Dependencies installed.")});function Jt(e,t){return O.gen(function*(){yield*(yield*E).log.info(`Legacy \`${t}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${e} configs yet.`)})}var ao=(e,t)=>O.gen(function*(){let r=yield*E,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*Jt("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.")}),so=(e)=>O.gen(function*(){let t=yield*E,r=t.spinner();r.start("Setting up oxfmt 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 \`.oxfmtrc.json(c)\`. Adamantite will use \`${m.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(m.files[1].path)?m.files[1].path:m.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("oxfmt config is ready."),yield*Jt("oxfmt",o)}else if(n.active?.format==="ts")r.message(`Found \`${m.config}\`, keeping existing config.`),r.stop("oxfmt config is ready.");else r.message(`\`${m.config}\` not found, creating...`),yield*m.create(e),r.stop("oxfmt config created successfully.")}),fo=(e,t)=>O.gen(function*(){let r=yield*er.FileSystem,n=yield*tr.Path,o=yield*E,i=yield*$(e),a=o.spinner();a.start("Adding scripts to your `package.json`..."),i.scripts??={};for(let d of t)switch(d){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 Rt({script:d})}let u=n.join(e,"package.json");yield*r.writeFileString(u,`${JSON.stringify(i,null,2)}
112
- `).pipe(O.mapError((d)=>new S({cause:d,path:u}))),a.stop("Scripts added to your `package.json`")}),lo=(e)=>O.gen(function*(){let t=yield*E,r=t.spinner();r.start("Setting up knip config...");let n=yield*y.exists(e);if(n.active?.format==="ts"&&n.legacy.length>0)yield*t.log.warning(`Found both \`${y.config}\` and \`knip.json(c)\`. Adamantite will use \`${y.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(y.files[1].path)?y.files[1].path:y.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("knip config is ready."),yield*Jt("knip",o)}else if(n.active?.format==="ts")r.message(`Found \`${y.config}\`, keeping existing config.`),r.stop("knip config is ready.");else r.message(`\`${y.config}\` not found, creating...`),yield*y.create(e),r.stop("knip config created successfully.")}),po=(e)=>O.gen(function*(){let r=(yield*E).spinner();if(r.start("Setting up TypeScript config..."),yield*q.exists(e))r.message(`\`${q.config}\` found, updating...`),yield*q.update(e),r.stop(`\`${q.config}\` updated successfully`);else r.message(`\`${q.config}\` not found, creating...`),yield*q.create(e),r.stop(`\`${q.config}\` created successfully`)}),uo=(e,t)=>O.gen(function*(){let r=yield*E;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 \`${se.config}\`...`),yield*se.exists(e))n.message(`\`${se.config}\` found, updating...`),yield*se.update(e),n.stop(`\`${se.config}\` updated with Adamantite preset.`);else n.message(`\`${se.config}\` not found, creating...`),yield*se.create(e),n.stop(`\`${se.config}\` created with Adamantite preset.`)}}),co=(e,t)=>O.gen(function*(){let r=yield*E,n=r.spinner();n.start("Installing editor extensions...");let o=e.includes("zed"),i=e.includes("vscode");if(yield*O.gen(function*(){if(e.includes("vscode"))n.message("Installing VS Code extension..."),yield*ne.extension(t);return!0}).pipe(O.tapError(()=>O.sync(()=>{n.stop()})),O.catchTag("FailedToInstallExtension",(u)=>O.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})),O.catchTag("VscodeCliNotFound",()=>O.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")}),yo=(e,t,r)=>O.gen(function*(){let o=(yield*E).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(O.option),nr=ke.make("init").pipe(ke.withDescription("Initialize Adamantite in the current directory"),ke.withHandler(()=>O.gen(function*(){let e=oo.cwd(),t=yield*E;yield*De(),yield*t.intro("\uD83D\uDCA0 adamantite init");let n=yield*(yield*Z).detectPackageManager(e);if(!n)return yield*new Ue({});if(n.warnings?.length)for(let f of n.warnings)yield*t.log.warning(f);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 d=!1;if(a)d=yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"});let s=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}),p=!1;if(s.length>0)p=yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let l=it(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 j=i.includes("format"),D=i.includes("check:monorepo")||i.includes("fix:monorepo"),N=i.includes("analyze"),W=["adamantite"];if(a)W.push(`${c.name}@${c.version}`,`${fe.name}@${fe.version}`);if(j)W.push(`${m.name}@${m.version}`);if(D)W.push(`${K.name}@${K.version}`);if(N)W.push(`${y.name}@${y.version}`);if(yield*io(e,W),j)yield*so(e);if(a)yield*ao(e,u);if(N)yield*lo(e);if(yield*fo(e,i),d)yield*po(e);if(yield*uo(e,s),p)yield*co(s,i);if(h){let f=n.name;if(Ke(f))yield*yo(e,f,i);else yield*t.log.warning(`Skipping GitHub Actions setup: \`${f}\` is not a supported package manager for CI workflow generation.`)}yield*t.log.success("Your project is now configured"),yield*t.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(O.catchTags({OperationCancelled:()=>O.gen(function*(){yield*(yield*E).cancel("You've cancelled the initialization process.")})}))));import*as rr from"effect/Effect";import*as qe from"effect/unstable/cli/Command";import*as gt from"effect/unstable/cli/Flag";import*as or from"effect/unstable/process/ChildProcessSpawner";var mo=gt.boolean("fix").pipe(gt.withDescription("Automatically fix issues")),ir=qe.make("monorepo",{fix:mo}).pipe(qe.withDescription("Find and fix monorepo-specific issues using Sherif"),qe.withHandler(({fix:e})=>rr.gen(function*(){let t=yield*_,r=e?["--fix"]:[],n=yield*t.run({args:r,command:K.name,stdin:"inherit"});if(n!==or.ExitCode(0))yield*new I({command:K.name,exitCode:n})})));import*as ar from"effect/Effect";import*as ze from"effect/unstable/cli/Command";import*as sr from"effect/unstable/process/ChildProcessSpawner";var fr=ze.make("typecheck").pipe(ze.withDescription("Deprecated alias for `check`"),ze.withHandler(()=>ar.gen(function*(){let e=yield*E,t=yield*_;yield*e.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*t.run({args:[],command:c.name});if(r!==sr.ExitCode(0))yield*new I({command:c.name,exitCode:r})})));import ho from"node:process";import*as X from"effect/Effect";import*as Ae from"effect/unstable/cli/Command";var Eo=[c,fe,m,K,y],go=[c,fe,m,K,y];function Oo(e){return e.applicable&&Array.isArray(e.actions)}function So(e,t){let r=[];for(let n of go){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 lr=Ae.make("update").pipe(Ae.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Ae.withHandler(()=>X.gen(function*(){let e=ho.cwd(),t=yield*E,r=yield*Z,n={cwd:e};yield*De(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>X.gen(function*(){let f=[];for(let F of Eo){let Qe=yield*F.assess(e);if(Oo(Qe))f.push({assessment:Qe,integration:F})}return f}),i=yield*o();for(let{assessment:f}of i)for(let F of f.warnings)yield*t.log.warning(F);let a=new Set(i.map(({integration:f})=>f.name)),u=i.flatMap(({assessment:f})=>f.actions),d=new Set(u.filter((f)=>f.type==="run_migration").map((f)=>f.migrationId)),s=[];for(let f of ut.filter((F)=>F.tags.includes("update"))){let F=qn[f.id];if(a.has(F))continue;let Qe=yield*f.check(n);s.push({migration:f,result:Qe})}for(let f of s){for(let F of f.result.warnings)yield*t.log.warning(F);if(f.result.applicable&&f.result.summary)yield*t.log.info(f.result.summary)}let p=[];for(let f of ut){if(!d.has(f.id))continue;yield*be(f,n,{onRestore:t.log.warning(`Migration "${f.title}" failed, restoring files...`)}),p.push(f.id)}for(let{migration:f,result:F}of s){if(!F.applicable||!F.summary)continue;yield*be(f,n,{onRestore:t.log.warning(`Migration "${f.title}" failed, restoring files...`)}),p.push(f.id)}if(p.length>0)yield*t.log.success("Migrations ran successfully.");let l=yield*$(e),h=yield*o(),j=h.flatMap(({assessment:f})=>f.actions).filter((f)=>f.type==="create_config"||f.type==="update_config"||f.type==="manual_fix"),D=h.flatMap(({assessment:f})=>f.actions).filter((f)=>f.type==="install_package"||f.type==="update_package").map((f)=>f.type==="install_package"?{currentVersion:"not installed",name:f.package,targetVersion:f.targetVersion}:{currentVersion:f.currentVersion,name:f.package,targetVersion:f.targetVersion}),N=new Set(D.map((f)=>f.name)),W=[...D,...So(l,N)];if(W.length>0){yield*t.log.info("The following dependencies will be updated:");for(let F of W)yield*t.log.info(` ${F.name}: ${F.currentVersion} → ${F.targetVersion}`);let f=t.spinner();f.start("Updating dependencies..."),yield*r.addDevDependencies(W.map((F)=>`${F.name}@${F.targetVersion}`),e,{silent:!0}).pipe(X.tapError(()=>X.sync(()=>{f.stop("Failed to update dependencies")}))),f.stop("Dependencies updated successfully"),yield*t.log.success("Dependencies updated successfully.")}if(j.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let f of j)yield*t.log.warning(`Doctor follow-up: ${f.description}`)}if(p.length===0&&W.length===0&&j.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(X.tapError(()=>X.gen(function*(){yield*(yield*E).outro("❌ Update failed")})),X.tap((e)=>X.gen(function*(){let t=yield*E;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 jo=ce.make("adamantite").pipe(ce.withDescription("Opinionated preset package for modern TypeScript applications"),ce.withSubcommands([Yt,an,Jn,Bn,Xn,nr,ir,fr,lr]));var Fo=ce.run(jo,{version:"0.32.3"}).pipe(A.as(0),A.catchTag("CommandFailed",(e)=>A.succeed(e.exitCode)),A.catch((e)=>A.service(E).pipe(A.flatMap((t)=>t.log.error(e.message)),A.as(mr.ExitCode(1)))),A.provide(dr.mergeAll(ur.layer,E.layer,_.layer,Z.layer)));pr.runMain(Fo,{teardown:(e,t)=>{if(cr.isSuccess(e)){t(Number(e.value));return}yr.defaultTeardown(e,t)}});
104
+ `}var le=[{path:".github/workflows/adamantite.yml",type:"ci"}],it=P({create:(t,e)=>dt.gen(function*(){let r=yield*se.FileSystem,n=yield*pe.Path,o=n.join(t,le[0].path);yield*Rn(n.dirname(o));let i=Pn(e);if(!i)return;yield*r.writeFileString(o,i).pipe(dt.mapError((f)=>new O({cause:f,path:o})))}),exists:(t)=>dt.gen(function*(){let e=yield*se.FileSystem,r=yield*pe.Path;return yield*e.exists(r.join(t,le[0].path))}),files:le,kind:"ci",name:"github",update:(t,e)=>dt.gen(function*(){let r=yield*se.FileSystem,o=(yield*pe.Path).join(t,le[0].path),i=Pn(e);if(!i)return;yield*r.writeFileString(o,i).pipe(dt.mapError((f)=>new O({cause:f,path:o})))})});import*as Nn from"effect/Context";import*as mt from"effect/Effect";import*as _n from"effect/Layer";import{addDevDependency as Kr,detectPackageManager as Lr}from"nypm";class Y extends Nn.Service()("DependencyInstaller"){static layer=_n.succeed(this)({addDevDependencies:(t,e,r)=>mt.tryPromise({catch:(n)=>new $e({cause:n,packages:t}),try:()=>Kr(t,{...r,cwd:e})}).pipe(mt.asVoid),detectPackageManager:(t)=>mt.tryPromise({catch:(e)=>new bt({cause:e}),try:()=>Lr(t)}).pipe(mt.map((e)=>e??null))})}import*as pt from"effect/Effect";import*as ue from"effect/FileSystem";import*as ce from"effect/Path";var xt=[{path:"tsconfig.json",type:"config"}],In={extends:"adamantite/typescript"},z=P({config:xt[0].path,create:(t)=>pt.gen(function*(){let e=yield*ue.FileSystem,n=(yield*ce.Path).join(t,xt[0].path),o=JSON.stringify(In,null,2);yield*e.writeFileString(n,`${o}
105
+ `).pipe(pt.mapError((i)=>new O({cause:i,path:n})))}),exists:(t)=>pt.gen(function*(){let e=yield*ue.FileSystem,r=yield*ce.Path;return yield*e.exists(r.join(t,xt[0].path))}),files:xt,kind:"workspace",name:"tsconfig",update:(t)=>pt.gen(function*(){let e=yield*ue.FileSystem,n=(yield*ce.Path).join(t,xt[0].path),o=yield*e.readFileString(n).pipe(pt.mapError((s)=>new v({cause:s,path:n}))),i=yield*J(o,n);if(!N(i))return yield*new W({path:n});let f=yield*gt(In,i);yield*e.writeFileString(n,`${JSON.stringify(f,null,2)}
106
+ `).pipe(pt.mapError((s)=>new O({cause:s,path:n})))})});var qn="adamantite typecheck";function Ar(){return y.files[1].path}function Gr(){return it.files[0].path}function Tn(t){let e={...t.scripts};if(e.typecheck!==qn)return{migrated:!1,packageJson:t};return delete e.typecheck,e.check??=Bt.check,{migrated:!0,packageJson:{...t,scripts:e}}}var zn=st({check:(t)=>Z.gen(function*(){let e=yield*F(t.cwd),{migrated:r}=Tn(e);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",y.config,Ar(),z.config,Gr()],id:"legacy-typecheck-script",migrate:(t)=>Z.gen(function*(){let e=yield*E,r=yield*Y,n=e.spinner(),o=Z.gen(function*(){let i=yield*F(t.cwd),f=Tn(i);if(!f.migrated)return"noop";yield*Xe(t.cwd,f.packageJson);let s=yield*y.exists(t.cwd);if(s.active===null)yield*y.create(t.cwd);else if(s.active.format==="ts")yield*y.update(t.cwd);yield*(yield*z.exists(t.cwd))?z.update(t.cwd):z.create(t.cwd);let a=yield*it.exists(t.cwd),p=X(f.packageJson);if(a&&ae(p)){let l=yield*r.detectPackageManager(t.cwd);if(l&&At(l.name)){let h=l.name,$=e.spinner();$.start("Updating GitHub Actions workflow..."),yield*it.update(t.cwd,{packageManager:h,scripts:p}).pipe(Z.onExit((R)=>Z.sync(()=>{$.stop(Be.match(R,{onFailure:()=>"Failed to update GitHub Actions workflow.",onSuccess:()=>"GitHub Actions workflow updated successfully"}))})))}else if(l)yield*e.log.warning(`\`${l.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`);else yield*e.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(Z.onExit((i)=>Z.sync(()=>{n.stop(Be.match(i,{onFailure:()=>"Legacy `typecheck` script migration failed.",onSuccess:(f)=>f==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}))})),Z.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(t)=>Z.gen(function*(){if((yield*F(t.cwd)).scripts?.typecheck===qn)return yield*new H({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*y.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${y.config}\` is not the active oxlint config.`});if(!(yield*z.exists(t.cwd)))return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${z.config}\` is missing after the migration.`})})});var ye=[Je,Ue,be,zn],kn=Object.fromEntries(ye.map((t)=>[t.id,t])),Un={[Ue.id]:d.name,[Je.id]:m.name,[be.id]:y.name};import*as Jn from"effect/Console";import*as bn from"effect/Effect";import*as Bn from"effect/Terminal";var Vt=()=>bn.gen(function*(){let e=yield*(yield*Bn.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(!e||e<r)return;yield*Jn.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 to=de.boolean("fix").pipe(de.withDescription("Automatically fix safe package install/update issues")),eo=[d,m,y,M,lt];function no(t){return t.applicable&&Array.isArray(t.actions)}var Qn={[d.name]:d,[m.name]:m,[y.name]:y},Wn={[y.name]:y};function Zn(t,e){return Object.hasOwn(t,e)}function Xt(t,e){switch(e.type){case"install_package":return`${t}:${e.type}:${e.package}:${e.targetVersion}`;case"update_package":return`${t}:${e.type}:${e.package}:${e.targetVersion}`;case"create_config":case"update_config":return`${t}:${e.type}:${e.path}`;case"manual_fix":return`${t}:${e.type}:${e.path??e.description}`;case"run_migration":return`${t}:${e.type}:${e.migrationId}`}}var xn=Nt.make("doctor",{fix:to}).pipe(Nt.withDescription("Check Adamantite-managed integrations in the current project"),Nt.withHandler(({fix:t})=>Pt.gen(function*(){let e=Cr.cwd(),r=yield*E;yield*Vt(),yield*r.intro("\uD83D\uDCA0 adamantite doctor");let n=yield*F(e);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 T({command:"doctor",exitCode:Qe.ExitCode(1)});let o=[];for(let c of eo){let a=yield*c.assess(e);if(no(a))o.push({assessment:a,integration:c})}for(let{assessment:c}of o)for(let a of c.warnings)yield*r.log.warning(a);if(o.length===0){yield*r.log.success("No applicable integrations found."),yield*r.outro("✅ Doctor completed successfully!");return}let i=o.flatMap(({assessment:c,integration:a})=>c.actions.map((p)=>({action:p,integration:a})));if(i.length===0){yield*r.log.success("No issues found."),yield*r.outro("✅ Doctor completed successfully!");return}let f=new Set;if(t)yield*Pt.gen(function*(){let c=i.filter(({action:a})=>a.type==="install_package"||a.type==="update_package");if(c.length>0){let a=yield*Y,p=[];for(let{action:l}of c)if(l.type==="install_package"||l.type==="update_package")p.push(`${l.package}@${l.targetVersion}`);yield*a.addDevDependencies(p,e,{silent:!0});for(let{action:l,integration:h}of c){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}\`.`);f.add(Xt(h.name,l))}}for(let{action:a,integration:p}of i){if(a.type!=="create_config")continue;if(!Zn(Qn,p.name))continue;yield*Qn[p.name].create(e),yield*r.log.success(`Fixed: created \`${a.path}\`.`),f.add(Xt(p.name,a))}for(let{action:a,integration:p}of i){if(a.type!=="update_config")continue;if(!Zn(Wn,p.name))continue;yield*Wn[p.name].update(e),yield*r.log.success(`Fixed: updated \`${a.path}\`.`),f.add(Xt(p.name,a))}for(let{action:a,integration:p}of i){if(a.type!=="run_migration")continue;let l=kn[a.migrationId];if(!l)continue;yield*Zt(l,{cwd:e}),f.add(Xt(p.name,a))}}).pipe(Pt.tapError(()=>Pt.gen(function*(){yield*r.outro("❌ Doctor failed")})));let s=i.filter(({action:c,integration:a})=>!f.has(Xt(a.name,c)));if(t&&s.length===0){yield*r.outro("✅ Doctor completed successfully!");return}for(let{action:c}of t?s:i)yield*r.log.warning(`Needs attention: ${c.description}`);yield*r.outro("⚠️ Doctor found issues."),yield*new T({command:"doctor",exitCode:Qe.ExitCode(1)})})));import*as Xn from"effect/Effect";import*as _t from"effect/unstable/cli/Argument";import*as It from"effect/unstable/cli/Command";import*as ut from"effect/unstable/cli/Flag";import*as Yn from"effect/unstable/process/ChildProcessSpawner";var ro=_t.file("files",{mustExist:!0}).pipe(_t.withDescription("Specific files to fix (optional)"),_t.variadic()),oo=ut.boolean("suggested").pipe(ut.withDescription("Apply suggested fixes")),io=ut.boolean("dangerous").pipe(ut.withDescription("Apply dangerous fixes")),fo=ut.boolean("all").pipe(ut.withDescription("Apply all fixes, including suggested and dangerous fixes")),wn=It.make("fix",{all:fo,dangerous:io,files:ro,suggested:oo}).pipe(It.withDescription("Fix issues in code using oxlint"),It.withHandler(({all:t,dangerous:e,files:r,suggested:n})=>Xn.gen(function*(){let o=yield*I,i=new Set(["--fix"]);if(n||t)i.add("--fix-suggestions");if(e||t)i.add("--fix-dangerously");for(let s of r)i.add(s);let f=yield*o.run({args:[...i],command:y.name});if(f!==Yn.ExitCode(0))yield*new T({command:y.name,exitCode:f})})));import*as Hn from"effect/Effect";import*as Tt from"effect/unstable/cli/Argument";import*as qt from"effect/unstable/cli/Command";import*as me from"effect/unstable/cli/Flag";import*as Mn from"effect/unstable/process/ChildProcessSpawner";var ao=Tt.file("files",{mustExist:!0}).pipe(Tt.withDescription("Specific files to format (optional)"),Tt.variadic()),lo=me.boolean("check").pipe(me.withDescription("Check if files are formatted without writing")),Kn=qt.make("format",{check:lo,files:ao}).pipe(qt.withDescription("Format files using oxfmt"),qt.withHandler(({check:t,files:e})=>Hn.gen(function*(){let r=yield*I,n=[];if(t)n.push("--check");n.push(...e);let o=yield*r.run({args:n,command:m.name});if(o!==Mn.ExitCode(0))yield*new T({command:m.name,exitCode:o})})));import mo from"node:process";import*as g from"effect/Effect";import*as fr from"effect/FileSystem";import*as ar from"effect/Path";import*as zt from"effect/unstable/cli/Command";import*as K from"effect/Effect";import*as he from"effect/FileSystem";import*as Ee from"effect/Path";import*as An from"effect/unstable/process/ChildProcessSpawner";var Yt=[{path:".vscode/settings.json",type:"config"}],Ln={"[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},et=P({config:Yt[0].path,create:(t)=>K.gen(function*(){let e=yield*he.FileSystem,r=yield*Ee.Path,n=r.join(t,Yt[0].path),o=r.dirname(n);yield*e.makeDirectory(o,{recursive:!0}).pipe(K.mapError((i)=>new yt({cause:i,path:o}))),yield*e.writeFileString(n,`${JSON.stringify(Ln,null,2)}
108
+ `).pipe(K.mapError((i)=>new O({cause:i,path:n})))}),exists:(t)=>K.gen(function*(){let e=yield*he.FileSystem,r=yield*Ee.Path;return yield*e.exists(r.join(t,Yt[0].path))}),extension:(t=[])=>K.gen(function*(){let e=[];if(t.includes("check")||t.includes("fix")||t.includes("format"))e.push("oxc.oxc-vscode");if(t.includes("analyze"))e.push("webpro.vscode-knip");for(let r of e){let o=yield*(yield*I).run({args:["--install-extension",r],command:"code"}).pipe(K.mapError((i)=>i._tag==="CliNotFound"&&i.command==="code"?new Pe({cause:i}):new Mt({cause:i,extension:r})));if(o!==An.ExitCode(0))return yield*new Mt({cause:o,extension:r})}}),files:Yt,kind:"editor",name:"vscode",update:(t)=>K.gen(function*(){let e=yield*he.FileSystem,n=(yield*Ee.Path).join(t,Yt[0].path),o=yield*e.readFileString(n).pipe(K.mapError((s)=>new v({cause:s,path:n}))),i=yield*J(o,n);if(!N(i))return yield*new W({path:n});let f=yield*gt(Ln,i);yield*e.writeFileString(n,`${JSON.stringify(f,null,2)}
109
+ `).pipe(K.mapError((s)=>new O({cause:s,path:n})))})});import*as ft from"effect/Effect";import*as ge from"effect/FileSystem";import*as Oe from"effect/Path";var wt=[{path:".zed/settings.json",type:"config"}],Gn={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"}}}}},at=P({config:wt[0].path,create:(t)=>ft.gen(function*(){let e=yield*ge.FileSystem,r=yield*Oe.Path,n=r.join(t,wt[0].path),o=r.dirname(n);yield*e.makeDirectory(o,{recursive:!0}).pipe(ft.mapError((i)=>new yt({cause:i,path:o}))),yield*e.writeFileString(n,`${JSON.stringify(Gn,null,2)}
110
+ `).pipe(ft.mapError((i)=>new O({cause:i,path:n})))}),exists:(t)=>ft.gen(function*(){let e=yield*ge.FileSystem,r=yield*Oe.Path;return yield*e.exists(r.join(t,wt[0].path))}),files:wt,kind:"editor",name:"zed",update:(t)=>ft.gen(function*(){let e=yield*ge.FileSystem,n=(yield*Oe.Path).join(t,wt[0].path),o=yield*e.readFileString(n).pipe(ft.mapError((s)=>new v({cause:s,path:n}))),i=yield*J(o,n);if(!N(i))return yield*new W({path:n});let f=yield*gt(Gn,i);yield*e.writeFileString(n,`${JSON.stringify(f,null,2)}
111
+ `).pipe(ft.mapError((s)=>new O({cause:s,path:n})))})});import*as ht from"effect/Effect";import*as Cn from"effect/FileSystem";import*as tr from"effect/Path";import{runScriptCommand as so}from"nypm";var po="AGENTS.md",er="<!-- ADAMANTITE:START -->",We="<!-- ADAMANTITE:END -->";function uo(t,e){let r=so(t,e),n=Bt[e];switch(e){case"analyze":return`- Run \`${r}\` after changing dependencies, imports, or exports. Direct command: \`${n}\`.`;case"check":return`- Run \`${r}\` to catch lint and type issues. Direct command: \`${n}\`.`;case"check:monorepo":return`- Run \`${r}\` to check monorepo package consistency. Direct command: \`${n}\`.`;case"fix":return`- Run \`${r}\` to apply safe lint fixes. Direct command: \`${n}\`.`;case"fix:monorepo":return`- Run \`${r}\` to fix monorepo package consistency. Direct command: \`${n}\`.`;case"format":return`- Run \`${r}\` after editing files. Direct command: \`${n}\`.`}}function co({packageManager:t,scripts:e}){let n=["format","check","fix","analyze","check:monorepo","fix:monorepo"].filter((i)=>e.includes(i)).map((i)=>uo(t,i)),o=["## Adamantite","","This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.","",...n.length>0?["- Prefer the package scripts Adamantite added for this workspace.",...n]:[],"- Use `adamantite doctor` to inspect managed setup and `adamantite doctor --fix` for safe local fixes."].join(`
112
+ `);return[er,"",o,"",We,""].join(`
113
+ `)}var nr=(t,e)=>ht.gen(function*(){let r=yield*Cn.FileSystem,o=(yield*tr.Path).join(t,po),f=(yield*r.exists(o).pipe(ht.mapError((l)=>new v({cause:l,path:o}))))?yield*r.readFileString(o).pipe(ht.mapError((l)=>new v({cause:l,path:o}))):"",s=f.indexOf(er),c=f.indexOf(We),a=co(e);if(s!==-1&&c!==-1&&s<c){let l=c+We.length,h=`${f.slice(0,s)}${a.trimEnd()}${f.slice(l)}`;return yield*r.writeFileString(o,h.endsWith(`
114
+ `)?h:`${h}
115
+ `).pipe(ht.mapError(($)=>new O({cause:$,path:o}))),"updated"}if(s!==-1||c!==-1)return"malformed";let p=f.length===0||f.endsWith(`
116
+
117
+ `)?"":f.endsWith(`
118
+ `)?`
119
+ `:`
120
+
121
+ `;return yield*r.writeFileString(o,`${f}${p}${a}`).pipe(ht.mapError((l)=>new O({cause:l,path:o}))),"updated"});import yo from"node:process";import*as rr from"effect/Effect";import*as or from"effect/FileSystem";import*as ir from"effect/Path";var Ze=(t=yo.cwd())=>rr.gen(function*(){let e=yield*or.FileSystem,r=yield*ir.Path;if(yield*e.exists(r.join(t,"pnpm-workspace.yaml")))return!0;return(yield*F(t)).workspaces!==void 0});var ho=(t,e)=>g.gen(function*(){let r=yield*Y,o=(yield*E).spinner();o.start("Installing dependencies...");let i=yield*Ze(t);yield*r.addDevDependencies(e,t,{silent:!0,workspace:i}).pipe(g.tapError(()=>g.sync(()=>{o.stop("Failed to install dependencies.")}))),o.stop("Dependencies installed.")});function xe(t,e){return g.gen(function*(){yield*(yield*E).log.info(`Legacy \`${e}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${t} configs yet.`)})}var Eo=(t,e)=>g.gen(function*(){let r=yield*E,n=r.spinner();n.start("Setting up oxlint config...");let o=yield*y.exists(t),i=y.files[1].path;if(o.active?.format==="ts"&&o.legacy.length>0)yield*r.log.warning(`Found both \`${y.config}\` and \`${i}\`. Adamantite will use \`${y.config}\`.`);if(o.active?.format==="json")n.message(`Found \`${i}\`, keeping existing config.`),n.stop("oxlint config is ready."),yield*xe("oxlint",i);else if(o.active?.format==="ts")n.message(`Found \`${y.config}\`, keeping existing config.`),n.stop("oxlint config is ready.");else n.message(`\`${y.config}\` not found, creating...`),yield*y.create(t,e),n.stop("oxlint config created successfully.")}),go=(t)=>g.gen(function*(){let e=yield*E,r=e.spinner();r.start("Setting up oxfmt config...");let n=yield*m.exists(t);if(n.active?.format==="ts"&&n.legacy.length>0)yield*e.log.warning(`Found both \`${m.config}\` and \`.oxfmtrc.json(c)\`. Adamantite will use \`${m.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*e.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(m.files[1].path)?m.files[1].path:m.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("oxfmt config is ready."),yield*xe("oxfmt",o)}else if(n.active?.format==="ts")r.message(`Found \`${m.config}\`, keeping existing config.`),r.stop("oxfmt config is ready.");else r.message(`\`${m.config}\` not found, creating...`),yield*m.create(t),r.stop("oxfmt config created successfully.")}),Oo=(t,e)=>g.gen(function*(){let r=yield*fr.FileSystem,n=yield*ar.Path,o=yield*E,i=yield*F(t),f=o.spinner();f.start("Adding scripts to your `package.json`..."),i.scripts??={};for(let c of e)switch(c){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 Ve({script:c})}let s=n.join(t,"package.json");yield*r.writeFileString(s,`${JSON.stringify(i,null,2)}
122
+ `).pipe(g.mapError((c)=>new O({cause:c,path:s}))),f.stop("Scripts added to your `package.json`")}),jo=(t)=>g.gen(function*(){let e=yield*E,r=e.spinner();r.start("Setting up knip config...");let n=yield*d.exists(t);if(n.active?.format==="ts"&&n.legacy.length>0)yield*e.log.warning(`Found both \`${d.config}\` and \`knip.json(c)\`. Adamantite will use \`${d.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*e.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(d.files[1].path)?d.files[1].path:d.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("knip config is ready."),yield*xe("knip",o)}else if(n.active?.format==="ts")r.message(`Found \`${d.config}\`, keeping existing config.`),r.stop("knip config is ready.");else r.message(`\`${d.config}\` not found, creating...`),yield*d.create(t),r.stop("knip config created successfully.")}),So=(t)=>g.gen(function*(){let r=(yield*E).spinner();if(r.start("Setting up TypeScript config..."),yield*z.exists(t))r.message(`\`${z.config}\` found, updating...`),yield*z.update(t),r.stop(`\`${z.config}\` updated successfully`);else r.message(`\`${z.config}\` not found, creating...`),yield*z.create(t),r.stop(`\`${z.config}\` created successfully`)}),$o=(t,e)=>g.gen(function*(){let r=yield*E;if(e.includes("vscode")){let n=r.spinner();if(n.start(`Checking for \`${et.config}\`...`),yield*et.exists(t))n.message(`\`${et.config}\` found, updating...`),yield*et.update(t),n.stop(`\`${et.config}\` updated with Adamantite preset.`);else n.message(`\`${et.config}\` not found, creating...`),yield*et.create(t),n.stop(`\`${et.config}\` created with Adamantite preset.`)}if(e.includes("zed")){let n=r.spinner();if(n.start(`Checking for \`${at.config}\`...`),yield*at.exists(t))n.message(`\`${at.config}\` found, updating...`),yield*at.update(t),n.stop(`\`${at.config}\` updated with Adamantite preset.`);else n.message(`\`${at.config}\` not found, creating...`),yield*at.create(t),n.stop(`\`${at.config}\` created with Adamantite preset.`)}}),Fo=(t,e)=>g.gen(function*(){let r=yield*E,n=r.spinner();n.start("Installing editor extensions...");let o=t.includes("zed"),i=t.includes("vscode");if(yield*g.gen(function*(){if(t.includes("vscode"))n.message("Installing VS Code extension..."),yield*et.extension(e);return!0}).pipe(g.tapError(()=>g.sync(()=>{n.stop()})),g.catchTag("FailedToInstallExtension",(s)=>g.gen(function*(){return yield*r.log.warning(`⚠️ Failed to install the \`${s.extension}\` extension.`),yield*r.log.warning("Please install it manually after setup completes."),!1})),g.catchTag("VscodeCliNotFound",()=>g.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")}),vo=(t,e,r)=>g.gen(function*(){let o=(yield*E).spinner();o.start("Setting up GitHub Actions workflow...");let i=yield*it.exists(t),f=it.files[0].path;if(i)o.message(`\`${f}\` found, updating...`),yield*it.update(t,{packageManager:e,scripts:r}),o.stop("GitHub Actions workflow updated successfully.");else o.message(`Creating \`${f}\`...`),yield*it.create(t,{packageManager:e,scripts:r}),o.stop("GitHub Actions workflow created successfully.")}).pipe(g.option),Ro=(t,e,r)=>g.gen(function*(){let n=yield*E,o=n.spinner();o.start("Updating AGENTS.md...");let i=yield*nr(t,{packageManager:e,scripts:r}).pipe(g.catchTag(["FailedToReadFile","FailedToWriteFile"],(f)=>g.gen(function*(){return o.stop("Failed to update AGENTS.md."),yield*n.log.warning(`Could not update AGENTS.md. ${f.message} Adamantite will continue initialization.`),"failed"})));if(i==="failed")return;if(o.stop("AGENTS.md check complete."),i==="malformed")yield*n.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),lr=zt.make("init").pipe(zt.withDescription("Initialize Adamantite in the current directory"),zt.withHandler(()=>g.gen(function*(){let t=mo.cwd(),e=yield*E;yield*Vt(),yield*e.intro("\uD83D\uDCA0 adamantite init");let n=yield*(yield*Y).detectPackageManager(t);if(!n)return yield*new bt({});if(n.warnings?.length)for(let j of n.warnings)yield*e.log.warning(j);yield*e.log.info(`Detected package manager: ${n.name}`);let o=yield*Ze(t);if(o)yield*e.log.info("We've detected a monorepo setup in your project.");let i=yield*e.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"}]}),f=i.includes("check")||i.includes("fix"),s=[];if(f)s=yield*e.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 c=!1;if(f)c=yield*e.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"});let a=yield*e.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),p=!1;if(a.length>0)p=yield*e.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let l=ae(i),h=!1;if(l)h=yield*e.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let $=yield*e.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),R=i.includes("format"),_=i.includes("check:monorepo")||i.includes("fix:monorepo"),nt=i.includes("analyze"),u=["adamantite"];if(f)u.push(`${y.name}@${y.version}`,`${lt.name}@${lt.version}`);if(R)u.push(`${m.name}@${m.version}`);if(_)u.push(`${M.name}@${M.version}`);if(nt)u.push(`${d.name}@${d.version}`);if(yield*ho(t,u),R)yield*go(t);if(f)yield*Eo(t,s);if(nt)yield*jo(t);if(yield*Oo(t,i),$)yield*Ro(t,n.name,i);if(c)yield*So(t);if(yield*$o(t,a),p)yield*Fo(a,i);if(h){let j=n.name;if(At(j))yield*vo(t,j,i);else yield*e.log.warning(`Skipping GitHub Actions setup: \`${j}\` is not a supported package manager for CI workflow generation.`)}yield*e.log.success("Your project is now configured"),yield*e.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(g.catchTags({OperationCancelled:()=>g.gen(function*(){yield*(yield*E).cancel("You've cancelled the initialization process.")})}))));import*as sr from"effect/Effect";import*as kt from"effect/unstable/cli/Command";import*as je from"effect/unstable/cli/Flag";import*as pr from"effect/unstable/process/ChildProcessSpawner";var Do=je.boolean("fix").pipe(je.withDescription("Automatically fix issues")),ur=kt.make("monorepo",{fix:Do}).pipe(kt.withDescription("Find and fix monorepo-specific issues using Sherif"),kt.withHandler(({fix:t})=>sr.gen(function*(){let e=yield*I,r=t?["--fix"]:[],n=yield*e.run({args:r,command:M.name,stdin:"inherit"});if(n!==pr.ExitCode(0))yield*new T({command:M.name,exitCode:n})})));import*as cr from"effect/Effect";import*as Ut from"effect/unstable/cli/Command";import*as yr from"effect/unstable/process/ChildProcessSpawner";var dr=Ut.make("typecheck").pipe(Ut.withDescription("Deprecated alias for `check`"),Ut.withHandler(()=>cr.gen(function*(){let t=yield*E,e=yield*I;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*e.run({args:[],command:y.name});if(r!==yr.ExitCode(0))yield*new T({command:y.name,exitCode:r})})));import Vo from"node:process";import*as w from"effect/Effect";import*as Jt from"effect/unstable/cli/Command";var Po=[y,lt,m,M,d],No=[y,lt,m,M,d];function _o(t){return t.applicable&&Array.isArray(t.actions)}function Io(t,e){let r=[];for(let n of No){if(e.has(n.name))continue;let o=t.devDependencies?.[n.name]??t.dependencies?.[n.name];if(o&&x(o)!==n.version)r.push({currentVersion:o,name:n.name,targetVersion:n.version})}return r}var mr=Jt.make("update").pipe(Jt.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Jt.withHandler(()=>w.gen(function*(){let t=Vo.cwd(),e=yield*E,r=yield*Y,n={cwd:t};yield*Vt(),yield*e.intro("\uD83D\uDCA0 adamantite update");let o=()=>w.gen(function*(){let u=[];for(let j of Po){let Ht=yield*j.assess(t);if(_o(Ht))u.push({assessment:Ht,integration:j})}return u}),i=yield*o();for(let{assessment:u}of i)for(let j of u.warnings)yield*e.log.warning(j);let f=new Set(i.map(({integration:u})=>u.name)),s=i.flatMap(({assessment:u})=>u.actions),c=new Set(s.filter((u)=>u.type==="run_migration").map((u)=>u.migrationId)),a=[];for(let u of ye.filter((j)=>j.tags.includes("update"))){let j=Un[u.id];if(f.has(j))continue;let Ht=yield*u.check(n);a.push({migration:u,result:Ht})}for(let u of a){for(let j of u.result.warnings)yield*e.log.warning(j);if(u.result.applicable&&u.result.summary)yield*e.log.info(u.result.summary)}let p=[];for(let u of ye){if(!c.has(u.id))continue;yield*Zt(u,n,{onRestore:e.log.warning(`Migration "${u.title}" failed, restoring files...`)}),p.push(u.id)}for(let{migration:u,result:j}of a){if(!j.applicable||!j.summary)continue;yield*Zt(u,n,{onRestore:e.log.warning(`Migration "${u.title}" failed, restoring files...`)}),p.push(u.id)}if(p.length>0)yield*e.log.success("Migrations ran successfully.");let l=yield*F(t),h=yield*o(),$=h.flatMap(({assessment:u})=>u.actions).filter((u)=>u.type==="create_config"||u.type==="update_config"||u.type==="manual_fix"),R=h.flatMap(({assessment:u})=>u.actions).filter((u)=>u.type==="install_package"||u.type==="update_package").map((u)=>u.type==="install_package"?{currentVersion:"not installed",name:u.package,targetVersion:u.targetVersion}:{currentVersion:u.currentVersion,name:u.package,targetVersion:u.targetVersion}),_=new Set(R.map((u)=>u.name)),nt=[...R,...Io(l,_)];if(nt.length>0){yield*e.log.info("The following dependencies will be updated:");for(let j of nt)yield*e.log.info(` ${j.name}: ${j.currentVersion} → ${j.targetVersion}`);let u=e.spinner();u.start("Updating dependencies..."),yield*r.addDevDependencies(nt.map((j)=>`${j.name}@${j.targetVersion}`),t,{silent:!0}).pipe(w.tapError(()=>w.sync(()=>{u.stop("Failed to update dependencies")}))),u.stop("Dependencies updated successfully"),yield*e.log.success("Dependencies updated successfully.")}if($.length>0){yield*e.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let u of $)yield*e.log.warning(`Doctor follow-up: ${u.description}`)}if(p.length===0&&nt.length===0&&$.length===0)return yield*e.log.success("No changes needed."),"no-changes";return"success"}).pipe(w.tapError(()=>w.gen(function*(){yield*(yield*E).outro("❌ Update failed")})),w.tap((t)=>w.gen(function*(){let e=yield*E;switch(t){case"no-changes":yield*e.outro("✅ Adamantite is already up to date.");break;case"success":yield*e.outro("✅ Update completed successfully!");break;default:break}})))));var To=ct.make("adamantite").pipe(ct.withDescription("Opinionated preset package for modern TypeScript applications"),ct.withSubcommands([Le,ln,xn,wn,Kn,lr,ur,dr,mr]));var qo=ct.run(To,{version:"0.33.1"}).pipe(U.as(0),U.catchTag("CommandFailed",(t)=>U.succeed(t.exitCode)),U.catch((t)=>U.service(E).pipe(U.flatMap((e)=>e.log.error(t.message)),U.as(Sr.ExitCode(1)))),U.provide(Or.mergeAll(Er.layer,E.layer,I.layer,Y.layer)));hr.runMain(qo,{teardown:(t,e)=>{if(gr.isSuccess(t)){e(Number(t.value));return}jr.defaultTeardown(t,e)}});
@@ -146,6 +146,7 @@ var config = {
146
146
  "no-unmodified-loop-condition": "error",
147
147
  "no-unneeded-ternary": "error",
148
148
  "no-unreachable": "error",
149
+ "no-unreachable-loop": "error",
149
150
  "no-unsafe-finally": "error",
150
151
  "no-unsafe-negation": "error",
151
152
  "no-unsafe-optional-chaining": "error",
@@ -361,6 +362,7 @@ var config = {
361
362
  "unicorn/error-message": "error",
362
363
  "unicorn/escape-case": "error",
363
364
  "unicorn/explicit-length-check": "error",
365
+ "unicorn/explicit-timer-delay": "error",
364
366
  "unicorn/filename-case": "error",
365
367
  "unicorn/new-for-builtins": "error",
366
368
  "unicorn/no-abusive-eslint-disable": "error",
@@ -372,6 +374,7 @@ var config = {
372
374
  "unicorn/no-array-sort": "error",
373
375
  "unicorn/no-await-expression-member": "error",
374
376
  "unicorn/no-await-in-promise-methods": "error",
377
+ "unicorn/no-confusing-array-with": "error",
375
378
  "unicorn/no-console-spaces": "error",
376
379
  "unicorn/no-document-cookie": "error",
377
380
  "unicorn/no-empty-file": "error",
@@ -38,14 +38,18 @@ var config = {
38
38
  "jsx-a11y/scope": "error",
39
39
  "jsx-a11y/tabindex-no-positive": "error",
40
40
  "react-perf/jsx-no-jsx-as-prop": "error",
41
- "react-perf/jsx-no-new-array-as-prop": "error",
42
- "react-perf/jsx-no-new-function-as-prop": "error",
43
- "react-perf/jsx-no-new-object-as-prop": "error",
44
41
  "react/button-has-type": "error",
45
42
  "react/checked-requires-onchange-or-readonly": "error",
46
43
  "react/display-name": "off",
47
44
  "react/exhaustive-deps": "error",
48
45
  "react/forward-ref-uses-ref": "error",
46
+ "react/function-component-definition": [
47
+ "error",
48
+ {
49
+ namedComponents: "function-declaration",
50
+ unnamedComponents: "arrow-function"
51
+ }
52
+ ],
49
53
  "react/hook-use-state": "error",
50
54
  "react/iframe-missing-sandbox": "error",
51
55
  "react/jsx-boolean-value": "error",
@@ -57,7 +61,6 @@ var config = {
57
61
  }
58
62
  ],
59
63
  "react/jsx-fragments": ["error", "syntax"],
60
- "react/jsx-handler-names": "error",
61
64
  "react/jsx-key": "error",
62
65
  "react/jsx-no-comment-textnodes": "error",
63
66
  "react/jsx-no-constructed-context-values": "error",
@@ -82,7 +85,6 @@ var config = {
82
85
  "react/no-react-children": "error",
83
86
  "react/no-redundant-should-component-update": "error",
84
87
  "react/no-render-return-value": "error",
85
- "react/no-set-state": "error",
86
88
  "react/no-string-refs": "error",
87
89
  "react/no-unescaped-entities": "error",
88
90
  "react/no-unknown-property": "error",
@@ -27,6 +27,7 @@ var config = {
27
27
  "vitest/no-test-prefixes": "error",
28
28
  "vitest/no-test-return-statement": "error",
29
29
  "vitest/no-unneeded-async-expect-function": "error",
30
+ "vitest/padding-around-test-blocks": "error",
30
31
  "vitest/prefer-called-exactly-once-with": "error",
31
32
  "vitest/prefer-called-once": "error",
32
33
  "vitest/prefer-called-times": "error",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adamantite",
3
- "version": "0.32.3",
3
+ "version": "0.33.1",
4
4
  "description": "An strict and opinionated set of presets for modern TypeScript applications",
5
5
  "keywords": [
6
6
  "adamantite",
@@ -69,32 +69,36 @@
69
69
  "version": "changeset version"
70
70
  },
71
71
  "dependencies": {
72
- "@clack/prompts": "1.6.0",
73
- "@effect/platform-node": "4.0.0-beta.92",
72
+ "@clack/prompts": "1.7.0",
73
+ "@effect/platform-node": "4.0.0-beta.99",
74
74
  "defu": "6.1.7",
75
- "effect": "4.0.0-beta.92",
76
- "esrap": "2.2.13",
75
+ "effect": "4.0.0-beta.99",
76
+ "esrap": "2.3.0",
77
77
  "jsonc-parser": "3.3.1",
78
78
  "nypm": "0.6.8",
79
- "oxc-parser": "^0.138.0"
79
+ "oxc-parser": "^0.140.0"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@changesets/changelog-github": "0.7.0",
83
83
  "@changesets/cli": "2.31.0",
84
84
  "@types/bun": "1.3.14",
85
85
  "@types/figlet": "1.7.0",
86
- "@typescript/native-preview": "7.0.0-dev.20260701.1",
87
86
  "bunup": "0.16.32",
88
- "figlet": "1.11.0",
89
- "knip": "6.23.0",
90
- "oxfmt": "0.57.0",
91
- "oxlint": "1.72.0",
92
- "oxlint-tsgolint": "0.24.0",
93
- "sherif": "1.12.0",
94
- "type-fest": "5.7.0"
87
+ "figlet": "1.11.3",
88
+ "knip": "6.29.0",
89
+ "oxfmt": "0.60.0",
90
+ "oxlint": "1.75.0",
91
+ "oxlint-tsgolint": "7.0.2001",
92
+ "sherif": "1.13.0",
93
+ "type-fest": "5.8.0",
94
+ "typescript": "7.0.2"
95
+ },
96
+ "peerDependencies": {
97
+ "typescript": ">=7"
95
98
  },
96
99
  "engines": {
97
- "bun": ">=1.3.14"
100
+ "bun": ">=1.3.14",
101
+ "node": ">=24"
98
102
  },
99
103
  "packageManager": "bun@1.3.14"
100
104
  }
@@ -147,6 +147,7 @@ const config: OxlintConfig = {
147
147
  "no-unmodified-loop-condition": "error",
148
148
  "no-unneeded-ternary": "error",
149
149
  "no-unreachable": "error",
150
+ "no-unreachable-loop": "error",
150
151
  "no-unsafe-finally": "error",
151
152
  "no-unsafe-negation": "error",
152
153
  "no-unsafe-optional-chaining": "error",
@@ -362,6 +363,7 @@ const config: OxlintConfig = {
362
363
  "unicorn/error-message": "error",
363
364
  "unicorn/escape-case": "error",
364
365
  "unicorn/explicit-length-check": "error",
366
+ "unicorn/explicit-timer-delay": "error",
365
367
  "unicorn/filename-case": "error",
366
368
  "unicorn/new-for-builtins": "error",
367
369
  "unicorn/no-abusive-eslint-disable": "error",
@@ -373,6 +375,7 @@ const config: OxlintConfig = {
373
375
  "unicorn/no-array-sort": "error",
374
376
  "unicorn/no-await-expression-member": "error",
375
377
  "unicorn/no-await-in-promise-methods": "error",
378
+ "unicorn/no-confusing-array-with": "error",
376
379
  "unicorn/no-console-spaces": "error",
377
380
  "unicorn/no-document-cookie": "error",
378
381
  "unicorn/no-empty-file": "error",
@@ -39,14 +39,18 @@ const config: OxlintConfig = {
39
39
  "jsx-a11y/scope": "error",
40
40
  "jsx-a11y/tabindex-no-positive": "error",
41
41
  "react-perf/jsx-no-jsx-as-prop": "error",
42
- "react-perf/jsx-no-new-array-as-prop": "error",
43
- "react-perf/jsx-no-new-function-as-prop": "error",
44
- "react-perf/jsx-no-new-object-as-prop": "error",
45
42
  "react/button-has-type": "error",
46
43
  "react/checked-requires-onchange-or-readonly": "error",
47
44
  "react/display-name": "off",
48
45
  "react/exhaustive-deps": "error",
49
46
  "react/forward-ref-uses-ref": "error",
47
+ "react/function-component-definition": [
48
+ "error",
49
+ {
50
+ namedComponents: "function-declaration",
51
+ unnamedComponents: "arrow-function",
52
+ },
53
+ ],
50
54
  "react/hook-use-state": "error",
51
55
  "react/iframe-missing-sandbox": "error",
52
56
  "react/jsx-boolean-value": "error",
@@ -58,7 +62,6 @@ const config: OxlintConfig = {
58
62
  },
59
63
  ],
60
64
  "react/jsx-fragments": ["error", "syntax"],
61
- "react/jsx-handler-names": "error",
62
65
  "react/jsx-key": "error",
63
66
  "react/jsx-no-comment-textnodes": "error",
64
67
  "react/jsx-no-constructed-context-values": "error",
@@ -83,7 +86,6 @@ const config: OxlintConfig = {
83
86
  "react/no-react-children": "error",
84
87
  "react/no-redundant-should-component-update": "error",
85
88
  "react/no-render-return-value": "error",
86
- "react/no-set-state": "error",
87
89
  "react/no-string-refs": "error",
88
90
  "react/no-unescaped-entities": "error",
89
91
  "react/no-unknown-property": "error",
@@ -28,6 +28,7 @@ const config: OxlintConfig = {
28
28
  "vitest/no-test-prefixes": "error",
29
29
  "vitest/no-test-return-statement": "error",
30
30
  "vitest/no-unneeded-async-expect-function": "error",
31
+ "vitest/padding-around-test-blocks": "error",
31
32
  "vitest/prefer-called-exactly-once-with": "error",
32
33
  "vitest/prefer-called-once": "error",
33
34
  "vitest/prefer-called-times": "error",