adamantite 0.32.2 → 0.33.0

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 mr from"@effect/platform-node/NodeRuntime";import*as dr from"@effect/platform-node/NodeServices";import*as M from"effect/Effect";import*as hr from"effect/Exit";import*as gr from"effect/Layer";import*as Er from"effect/Runtime";import*as ye from"effect/unstable/cli/Command";import*as jr from"effect/unstable/process/ChildProcessSpawner";import*as Kt from"effect/Effect";import*as Fe from"effect/unstable/cli/Command";import*as $e from"effect/unstable/cli/Flag";import*as Gt from"effect/unstable/process/ChildProcessSpawner";import*as Se from"effect/Effect";import*as et from"effect/FileSystem";import*as tt from"effect/Path";function _(e){return e}import*as T from"effect/Data";import{printParseErrorCode as Or}from"jsonc-parser";function Sr(e=[]){if(e.length===0)return"- Unknown JSON/JSONC parsing error";return e.slice(0,3).map((t)=>`- ${Or(t.error)} (offset: ${t.offset})`).join(`
2
- `)}class $t extends T.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class A extends T.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class me extends T.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class Tt extends T.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Ge extends T.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class vt extends T.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Pt extends T.TaggedError("FailedToParseFile"){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:"the target file"}.`,"Please fix the JSON/JSONC syntax and run the command again.","","Parse details:",Sr(this.errors)].join(`
3
- `)}}class D extends T.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class re extends T.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class O extends T.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class _t extends T.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class x extends T.TaggedError("InvalidConfigFormat"){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:"the target config file"}. The config must be a JSON object (for example: {}).`}}class Dt extends T.TaggedError("UnsupportedConfigState"){get message(){let e=this.path?`\`${this.path}\``:"the target config file",t=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${e}.${t}`}}class xe extends T.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Fr extends T.TaggedError("MissingPackageVersion"){get message(){return`Missing version field in ${this.path?`\`${this.path}\``:"package.json"}.`}}class H extends T.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class Ce extends T.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class Nt extends T.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class kt extends T.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}import{defu as $r}from"defu";import*as G from"effect/Effect";import{parse as Tr}from"jsonc-parser";var w=(e,t)=>G.sync(()=>{let r=[],n=Tr(e,r,{allowTrailingComma:!0});return{errors:r,parsed:n}}).pipe(G.flatMap(({errors:r,parsed:n})=>r.length>0?G.fail(new Pt({errors:r,path:t})):G.succeed(n)));function N(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function ge(e,t={}){let{continuationIndent:r,indentation:n=2}=t,o=JSON.stringify(e,null,n).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!r)return o;return o.replaceAll(`
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 vt({cause:r}),try:()=>$r(e,t)});function Le(e={}){let t=Object.entries(e).map(([r,n])=>{if(r==="rules"&&typeof n==="object"&&n!==null&&!Array.isArray(n))return[" rules: {"," ...analyze.rules,",...Object.entries(n).map(([i,a])=>` ${i}: ${ge(a,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
6
- `);return` ${r}: ${ge(n)},`});if(t.length===0)return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = analyze","","export default config",""].join(`
7
- `);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...t,"}","","export default config",""].join(`
8
- `)}import vr from"node:process";import*as je from"effect/Effect";import*as Rt from"effect/FileSystem";import*as At from"effect/Path";var Pr=/^workspace:/,_r=/^[\^~]/;function B(e){return e.trim().replace(Pr,"").replace(_r,"")}var $=(e=vr.cwd())=>je.gen(function*(){let t=yield*Rt.FileSystem,n=(yield*At.Path).join(e,"package.json"),o=yield*t.readFileString(n).pipe(je.mapError((a)=>new D({cause:a,path:n})));return yield*w(o,n)}),Zt=(e,t)=>je.gen(function*(){let r=yield*Rt.FileSystem,o=(yield*At.Path).join(e,"package.json");yield*r.writeFileString(o,`${JSON.stringify(t,null,2)}
9
- `).pipe(je.mapError((i)=>new O({cause:i,path:o})))}),It={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function Q(e){let t=e.scripts??{},r=[];for(let[n,o]of Object.entries(It))if(t[n]===o)r.push(n);return r}var U=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}],Oe="6.6.1",m=_({assess:(e)=>Se.gen(function*(){let t=yield*et.FileSystem,r=yield*tt.Path,n=yield*$(e);if(!Q(n).includes("analyze"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.knip??n.dependencies?.knip,a=r.join(e,U[0].path),u=r.join(e,U[1].path),y=r.join(e,U[2].path),f=yield*t.exists(a),s=yield*t.exists(u),l=yield*t.exists(y),h=f?"ts":l?"jsonc":s?"json":null,S=[],k=[];if(f&&(s||l))k.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!f&&s&&l)k.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(!i)S.push({description:`Install \`knip@${Oe}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:Oe,type:"install_package"});else if(B(i)!==Oe)S.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${Oe}\`.`,package:"knip",targetVersion:Oe,type:"update_package"});if(h===null)S.push({description:`Create \`${U[0].path}\` for \`knip\`.`,path:U[0].path,type:"create_config"});if(h==="json"||h==="jsonc")S.push({description:`Migrate legacy \`${h==="json"?U[1].path:U[2].path}\` to \`${U[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:k}}),config:U[0].path,create:(e)=>Se.gen(function*(){let t=yield*et.FileSystem,n=(yield*tt.Path).join(e,U[0].path);yield*t.writeFileString(n,Le()).pipe(Se.mapError((o)=>new O({cause:o,path:n})))}),exists:(e)=>Se.gen(function*(){let t=yield*et.FileSystem,r=yield*tt.Path,n=r.join(e,U[0].path),o=r.join(e,U[1].path),i=r.join(e,U[2].path),a=yield*t.exists(n),u=yield*t.exists(o),y=yield*t.exists(i),f=a?"ts":y?"jsonc":u?"json":null,s=[];if(a&&u)s.push({format:"json",path:o});if(a&&y)s.push({format:"jsonc",path:i});if(!a&&u&&y)s.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?n:f==="jsonc"?i:o},legacy:s}}),files:U,kind:"tooling",name:"knip",version:Oe});import*as Xt from"effect/Context";import*as se from"effect/Effect";import*as Yt from"effect/Layer";import*as Ht from"effect/unstable/process/ChildProcess";class R extends Xt.Service()("CommandRunner"){static layer=Yt.succeed(this)({run:({args:e,command:t,cwd:r,stderr:n="inherit",stdin:o="ignore",stdout:i="inherit"})=>se.mapError(se.scoped(se.gen(function*(){return yield*(yield*se.fromYieldable(Ht.make(t,e,{cwd:r,stderr:n,stdin:o,stdout:i}))).exitCode})),(a)=>a.reason._tag==="NotFound"?new $t({command:t}):a)})}var Dr=$e.boolean("fix").pipe($e.withDescription("Automatically fix issues")),Nr=$e.boolean("strict").pipe($e.withDescription("Enable strict mode")),Ct=Fe.make("analyze",{fix:Dr,strict:Nr}).pipe(Fe.withDescription("Find unused dependencies, exports, and files using knip"),Fe.withHandler(({fix:e,strict:t})=>Kt.gen(function*(){let r=yield*R,n=[];if(e)n.push("--fix","--allow-remove-files");if(t)n.push("--production","--strict");let o=yield*r.run({args:n,command:m.name});if(o!==Gt.ExitCode(0))yield*new A({command:m.name,exitCode:o})})));import*as sn from"effect/Effect";import*as ve from"effect/unstable/cli/Argument";import*as Pe from"effect/unstable/cli/Command";import*as ln from"effect/unstable/process/ChildProcessSpawner";import*as L from"effect/Effect";import*as We from"effect/FileSystem";import*as Be from"effect/Path";import*as C from"effect/Effect";import*as E from"effect/Option";import{print as kr}from"esrap";import Rr from"esrap/languages/ts";import{parseSync as Ar}from"oxc-parser";var on=["typeAware","typeCheck"],Lt="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",en="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",tn="`oxlint.config.ts` already defines `typeAware` or `typeCheck`, but not as a boolean literal Adamantite can safely patch.",an="Adamantite could not generate the required `options.typeAware` and `options.typeCheck` patch.";function rt(e=[]){return e.includes("core")?e:["core",...e]}function nn(e){return e.replaceAll(/-([a-z])/g,(t,r)=>r.toUpperCase())}function ot(e,t,r=[]){let{options:n,...o}=e,i=['import { defineConfig } from "oxlint"',...t.map((h)=>`import ${nn(h)} from "${h==="core"?"adamantite/lint":`adamantite/lint/${h}`}"`)],u=[...t.map((h)=>nn(h)),...r.map((h)=>JSON.stringify(h))],y=JSON.stringify(N(n)?{...n,typeAware:!0,typeCheck:!0}:{typeAware:!0,typeCheck:!0},null,2),f=Object.entries(o).map(([h,S])=>[h,JSON.stringify(S,null,2)]),s=`[${u.join(", ")}]`,l=[["options",y],...f,["extends",s]].map(([h,S])=>` ${h}: ${S},`).join(`
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 nt(e){return N(e)&&e.type==="ObjectExpression"&&Array.isArray(e.properties)}function Vt(e){return N(e)&&e.type==="Property"}function zt(e){return C.try({catch:()=>null,try:()=>Ar("oxlint.config.ts",e,{astType:"ts",lang:"ts",sourceType:"module"})}).pipe(C.match({onFailure:()=>E.none(),onSuccess:(t)=>t.errors.length===0?E.fromNullishOr(t.program):E.none()}))}function fn(e){let{code:t}=kr(e,Rr({quotes:"double"}));return t.endsWith(`
12
- `)?t:`${t}
13
- `}function rn(e){if(e.type==="Identifier")return e.name;if(e.type==="Literal"&&typeof e.value==="string")return e.value;return null}function Mt(e){let t=e.body.filter((i)=>i.type==="ExportDefaultDeclaration");if(t.length!==1)return E.none();let[r]=t;if(!r)return E.none();let n=r.declaration;if(nt(n))return E.fromNullishOr(n);if(n.type!=="CallExpression")return E.none();if(n.callee.type!=="Identifier"||n.callee.name!=="defineConfig")return E.none();if(n.arguments.length!==1)return E.none();let[o]=n.arguments;if(nt(o))return E.fromNullishOr(o);return E.none()}function wt(e,t){let r=null;for(let n of e.properties){if(n.type==="SpreadElement")return{status:"manual"};if(!Vt(n))return{status:"manual"};if(n.computed)return{status:"manual"};if(n.method||n.kind!=="init"){if(rn(n.key)===t)return{status:"manual"};continue}if(rn(n.key)!==t)continue;if(r)return{status:"manual"};r=n}if(!r)return{status:"missing"};return{property:r,status:"found"}}function Ir(e){let t=`export default { options: { ${e.map((r)=>`${r}: true`).join(", ")} } }
14
- `;return zt(t).pipe(C.map((r)=>{if(E.isNone(r))return E.none();let n=Mt(r.value);if(E.isNone(n))return E.none();let o=wt(n.value,"options");if(o.status!=="found")return E.none();if(!nt(o.property.value))return E.none();let i=o.property.value.properties.filter(Vt);return i.length===o.property.value.properties.length?E.fromNullishOr(i):E.none()}))}function Vr(){let e=`export default { options: { ${on.map((t)=>`${t}: true`).join(", ")} } }
15
- `;return zt(e).pipe(C.map((t)=>{if(E.isNone(t))return E.none();let r=Mt(t.value);if(E.isNone(r)||r.value.properties.length!==1)return E.none();let[n]=r.value.properties;if(!n||!Vt(n)||n.computed||n.method||n.kind!=="init")return E.none();return E.fromNullishOr(n)}))}function zr(e,t){return C.gen(function*(){let r=[],n=!1;for(let o of on){let i=wt(t,o);if(i.status==="manual")return{kind:"manual",reason:tn};if(i.status==="missing"){r.push(o);continue}let a=i.property.value;if(a.type!=="Literal"||typeof a.value!=="boolean")return{kind:"manual",reason:tn};if(a.value)continue;a.raw="true",a.value=!0,n=!0}if(r.length>0){let o=yield*Ir(r);if(E.isNone(o))return{kind:"manual",reason:an};t.properties.unshift(...o.value),n=!0}if(!n)return{kind:"configured"};return{kind:"patchable",updatedContent:fn(e)}})}function Ut(e){return C.gen(function*(){let t=yield*zt(e);if(E.isNone(t))return{kind:"manual",reason:Lt};let r=Mt(t.value);if(E.isNone(r))return{kind:"manual",reason:Lt};let n=wt(r.value,"options");if(n.status==="manual")return{kind:"manual",reason:en};if(n.status==="missing"){let o=yield*Vr();if(E.isNone(o))return{kind:"manual",reason:an};return r.value.properties.unshift(o.value),{kind:"patchable",updatedContent:fn(t.value)}}if(!nt(n.property.value))return{kind:"manual",reason:en};return yield*zr(t.value,n.property.value)})}var I=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}],Te="1.61.0",c=_({assess:(e)=>L.gen(function*(){let t=yield*We.FileSystem,r=yield*Be.Path,n=yield*$(e),o=Q(n);if(!o.includes("check")&&!o.includes("fix"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxlint??n.dependencies?.oxlint,a=r.join(e,I[0].path),u=r.join(e,I[1].path),y=yield*t.exists(a),f=yield*t.exists(u),s={active:y?{format:"ts",path:a}:f?{format:"json",path:u}:null,legacy:y&&f?[{format:"json",path:u}]:[]},l=[],h=[];if(s.active?.format==="ts"&&s.legacy.length>0)h.push("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(!i)l.push({description:`Install \`oxlint@${Te}\` for the managed lint scripts.`,package:"oxlint",targetVersion:Te,type:"install_package"});else if(B(i)!==Te)l.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${Te}\`.`,package:"oxlint",targetVersion:Te,type:"update_package"});if(s.active===null)l.push({description:`Create \`${I[0].path}\` for \`oxlint\`.`,path:I[0].path,type:"create_config"});if(s.active?.format==="json")l.push({description:`Migrate legacy \`${I[1].path}\` to \`${I[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(s.active?.format==="ts"){let S=yield*t.readFileString(a).pipe(L.mapError((P)=>new D({cause:P,path:a}))),k=yield*Ut(S);if(k.kind==="patchable")l.push({description:"Update `oxlint.config.ts` to enable `options.typeAware` and `options.typeCheck`.",path:I[0].path,type:"update_config"});if(k.kind==="manual")l.push({description:"Manually update `oxlint.config.ts` to enable `options.typeAware` and `options.typeCheck`; Adamantite cannot patch the current file shape safely.",path:I[0].path,type:"manual_fix"})}return{actions:l,applicable:!0,warnings:h}}),config:I[0].path,create:(e,t=[])=>L.gen(function*(){let r=yield*We.FileSystem,o=(yield*Be.Path).join(e,I[0].path),i=ot({},rt(t));yield*r.writeFileString(o,i).pipe(L.mapError((a)=>new O({cause:a,path:o})))}),exists:(e)=>L.gen(function*(){let t=yield*We.FileSystem,r=yield*Be.Path,n=r.join(e,I[0].path),o=r.join(e,I[1].path),i=yield*t.exists(n),a=yield*t.exists(o),u=i?"ts":a?"json":null,y=[];if(i&&a)y.push({format:"json",path:o});return{active:u===null?null:{format:u,path:u==="ts"?n:o},legacy:y}}),files:I,kind:"tooling",name:"oxlint",update:(e)=>L.gen(function*(){let t=yield*We.FileSystem,n=(yield*Be.Path).join(e,I[0].path);if(!(yield*t.exists(n)))return yield*new _t({path:I[0].path});let o=yield*t.readFileString(n).pipe(L.mapError((a)=>new D({cause:a,path:n}))),i=yield*Ut(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new Dt({path:I[0].path,reason:i.reason});yield*t.writeFileString(n,i.updatedContent).pipe(L.mapError((a)=>new O({cause:a,path:n})))}),version:Te});var Mr=ve.file("files",{mustExist:!0}).pipe(ve.withDescription("Specific files to lint (optional)"),ve.variadic()),pn=Pe.make("check",{files:Mr}).pipe(Pe.withDescription("Find issues and type errors in code using oxlint"),Pe.withHandler(({files:e})=>sn.gen(function*(){let r=yield*(yield*R).run({args:[...e],command:c.name});if(r!==ln.ExitCode(0))yield*new A({command:c.name,exitCode:r})})));import Gr from"node:process";import*as Ae from"effect/Effect";import*as Ie from"effect/unstable/cli/Command";import*as ht from"effect/unstable/cli/Flag";import*as Wt from"effect/unstable/process/ChildProcessSpawner";import*as De from"effect/Effect";import*as at from"effect/FileSystem";import*as ft from"effect/Path";var wr=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function Ur(e){let t=e.split(`
16
- `);if(t.length===1)return e.slice(1,-1).trim();return t.slice(1,-1).map((r)=>` ${r.trimStart()}`).join(`
17
- `)}function br(e,t){let r=ge(t),n=Ur(r);return[` ${e}: {`,` ...format.${e},`,...n===""?[]:[n]," },"].join(`
18
- `)}function it(e={}){let t=Object.entries(e).map(([r,n])=>{if(wr.has(r)&&N(n))return br(r,n);let o=ge(n,{continuationIndent:" "});return` ${r}: ${o},`});if(t.length===0)return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig(format)",""].join(`
19
- `);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...t,"})",""].join(`
20
- `)}var b=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}],_e="0.46.0",d=_({assess:(e)=>De.gen(function*(){let t=yield*at.FileSystem,r=yield*ft.Path,n=yield*$(e);if(!Q(n).includes("format"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxfmt??n.dependencies?.oxfmt,a=r.join(e,b[0].path),u=r.join(e,b[1].path),y=r.join(e,b[2].path),f=yield*t.exists(a),s=yield*t.exists(u),l=yield*t.exists(y),h=f?"ts":l?"jsonc":s?"json":null,S=[],k=[];if(f&&(s||l))k.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!f&&s&&l)k.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(!i)S.push({description:`Install \`oxfmt@${_e}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:_e,type:"install_package"});else if(B(i)!==_e)S.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${_e}\`.`,package:"oxfmt",targetVersion:_e,type:"update_package"});if(h===null)S.push({description:`Create \`${b[0].path}\` for \`oxfmt\`.`,path:b[0].path,type:"create_config"});if(h==="json"||h==="jsonc")S.push({description:`Migrate legacy \`${h==="json"?b[1].path:b[2].path}\` to \`${b[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:k}}),config:b[0].path,create:(e)=>De.gen(function*(){let t=yield*at.FileSystem,n=(yield*ft.Path).join(e,b[0].path);yield*t.writeFileString(n,it()).pipe(De.mapError((o)=>new O({cause:o,path:n})))}),exists:(e)=>De.gen(function*(){let t=yield*at.FileSystem,r=yield*ft.Path,n=r.join(e,b[0].path),o=r.join(e,b[1].path),i=r.join(e,b[2].path),a=yield*t.exists(n),u=yield*t.exists(o),y=yield*t.exists(i),f=a?"ts":y?"jsonc":u?"json":null,s=[];if(a&&u)s.push({format:"json",path:o});if(a&&y)s.push({format:"jsonc",path:i});if(!a&&u&&y)s.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?n:f==="jsonc"?i:o},legacy:s}}),files:b,kind:"tooling",name:"oxfmt",version:_e});import*as un from"effect/Effect";var Ne="1.11.1",K=_({assess:(e)=>un.gen(function*(){let t=yield*$(e),r=Q(t);if(!r.includes("check:monorepo")&&!r.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let n=t.devDependencies?.sherif??t.dependencies?.sherif,o=[];if(!n)o.push({description:`Install \`sherif@${Ne}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:Ne,type:"install_package"});else if(B(n)!==Ne)o.push({currentVersion:n,description:`Update \`sherif\` from \`${n}\` to \`${Ne}\`.`,package:"sherif",targetVersion:Ne,type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:Ne});import*as cn from"effect/Effect";var ke="0.21.1",le=_({assess:(e)=>cn.gen(function*(){let t=yield*$(e),r=Q(t);if(!r.includes("check")&&!r.includes("fix"))return{applicable:!1,warnings:[]};let n=t.devDependencies?.["oxlint-tsgolint"]??t.dependencies?.["oxlint-tsgolint"],o=[];if(!n)o.push({description:`Install \`oxlint-tsgolint@${ke}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:ke,type:"install_package"});else if(B(n)!==ke)o.push({currentVersion:n,description:`Update \`oxlint-tsgolint\` from \`${n}\` to \`${ke}\`.`,package:"oxlint-tsgolint",targetVersion:ke,type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:ke});import*as z from"effect/Effect";import*as yn from"effect/Exit";import*as mn from"effect/FileSystem";import*as dn from"effect/Path";function pe(e){return e}function Qe(e,t,r){return z.gen(function*(){let n=yield*mn.FileSystem,o=yield*dn.Path,i=e.files??[],a=new Map;for(let y of i){let f=o.join(t.cwd,y);if(yield*n.exists(f)){let l=yield*n.readFileString(f);a.set(f,l)}else a.set(f,null)}let u=yield*z.exit(e.migrate(t).pipe(z.andThen(()=>e.validate?.(t)??z.void)));if(yn.isSuccess(u))return;if(r?.onRestore)yield*r.onRestore;for(let[y,f]of a){if(f!==null){yield*n.writeFileString(y,f).pipe(z.ignore);continue}if(!(yield*n.exists(y).pipe(z.orElseSucceed(()=>!1))))continue;yield*n.remove(y).pipe(z.ignore)}return yield*z.failCause(u.cause)})}import*as ee from"effect/Effect";import*as En from"effect/FileSystem";import*as jn from"effect/Path";import*as v from"@clack/prompts";import*as hn from"effect/Context";import*as q from"effect/Effect";import*as gn from"effect/Layer";class g extends hn.Service()("Prompter"){static layer=gn.succeed(this)({cancel:(e)=>q.sync(()=>{v.cancel(e)}),confirm:(e)=>q.promise(()=>v.confirm(e)).pipe(q.filterOrFail((t)=>!v.isCancel(t),()=>new Ce({}))),intro:(e)=>q.sync(()=>{v.intro(e)}),log:{error:(e)=>q.sync(()=>{v.log.error(e)}),info:(e)=>q.sync(()=>{v.log.info(e)}),success:(e)=>q.sync(()=>{v.log.success(e)}),warning:(e)=>q.sync(()=>{v.log.warning(e)})},multiselect:(e)=>q.promise(()=>v.multiselect(e)).pipe(q.filterOrFail((t)=>!v.isCancel(t),()=>new Ce({}))),outro:(e)=>q.sync(()=>{v.outro(e)}),spinner:()=>v.spinner()})}function On(){return[m.files[1].path,m.files[2].path]}function qr(e){let t=On();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function Jr(e){return ee.gen(function*(){let t=yield*En.FileSystem,r=yield*jn.Path,n=yield*m.exists(e);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(e,m.config),a=yield*t.readFileString(o).pipe(ee.mapError((l)=>new D({cause:l,path:o}))),u=yield*w(a,o);if(!N(u))return yield*new x({path:o});let{$schema:y,...f}=u;yield*t.writeFileString(i,Le(f)).pipe(ee.mapError((l)=>new O({cause:l,path:i}))),yield*t.remove(o).pipe(ee.mapError((l)=>new re({cause:l,path:o})));let s=n.legacy[0]?.path??null;if(s&&s!==o)yield*t.remove(s).pipe(ee.mapError((l)=>new re({cause:l,path:s})))})}var bt=pe({check:(e)=>ee.gen(function*(){let t=yield*m.exists(e.cwd),r=[];if(t.active?.format==="ts"&&t.legacy.length>0)r.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)r.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:qr(t.active.format),warnings:r};if(t.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[m.config,...On()],id:"legacy-knip-json",migrate:(e)=>ee.gen(function*(){let r=(yield*g).spinner(),o=(yield*m.exists(e.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;r.start(`Migrating \`${o}\` to \`${m.config}\`...`),yield*Jr(e.cwd),r.stop(`Knip config migrated to \`${m.config}\` successfully.`)}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>ee.gen(function*(){if((yield*m.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-knip-json",reason:`\`${m.config}\` is not the active Knip config.`})})});import*as te from"effect/Effect";import*as Sn from"effect/FileSystem";import*as Fn from"effect/Path";function $n(){return[d.files[1].path,d.files[2].path]}function xr(e){let t=$n();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${d.config}\`.`}function Wr(e){return te.gen(function*(){let t=yield*Sn.FileSystem,r=yield*Fn.Path,n=yield*d.exists(e);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(e,d.config),a=yield*t.readFileString(o).pipe(te.mapError((l)=>new D({cause:l,path:o}))),u=yield*w(a,o);if(!N(u))return yield*new x({path:o});let{$schema:y,...f}=u;yield*t.writeFileString(i,it(f)).pipe(te.mapError((l)=>new O({cause:l,path:i}))),yield*t.remove(o).pipe(te.mapError((l)=>new re({cause:l,path:o})));let s=n.legacy[0]?.path??null;if(s&&s!==o)yield*t.remove(s).pipe(te.mapError((l)=>new re({cause:l,path:s})))})}var qt=pe({check:(e)=>te.gen(function*(){let t=yield*d.exists(e.cwd),r=[];if(t.active?.format==="ts"&&t.legacy.length>0)r.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(t.active&&t.active.format!=="ts"&&t.legacy.length>0)r.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(t.active?.format==="json"||t.active?.format==="jsonc")return{applicable:!0,summary:xr(t.active.format),warnings:r};if(t.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[d.config,...$n()],id:"legacy-oxfmt-json",migrate:(e)=>te.gen(function*(){let r=(yield*g).spinner(),o=(yield*d.exists(e.cwd)).active?.path.endsWith(d.files[2].path)?d.files[2].path:d.files[1].path;r.start(`Migrating \`${o}\` to \`${d.config}\`...`),yield*Wr(e.cwd),r.stop(`Oxfmt config migrated to \`${d.config}\` successfully.`)}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>te.gen(function*(){if((yield*d.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxfmt-json",reason:`\`${d.config}\` is not the active oxfmt config.`})})});import*as oe from"effect/Effect";import*as Tn from"effect/FileSystem";import*as vn from"effect/Path";function Br(e){return oe.gen(function*(){let t=yield*Tn.FileSystem,r=yield*vn.Path,n=yield*c.exists(e);if(n.active?.format!=="json")return;let o=n.active.path,i=r.join(e,c.config),a=yield*t.readFileString(o).pipe(oe.mapError((P)=>new D({cause:P,path:o}))),u=yield*w(a,o);if(!N(u))return yield*new x({path:o});let{$schema:y,...f}=u,s=Array.isArray(f.extends)?f.extends.filter((P)=>typeof P==="string"):typeof f.extends==="string"?[f.extends]:[],l=new Set(rt()),h=new Set;for(let P of s){let J=P.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),p=P.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),F=J?.[1]??(p?p[1]??"core":null);if(F)l.add(F);else h.add(P)}let{extends:S,...k}=f;yield*t.writeFileString(i,ot(k,[...l],[...h])).pipe(oe.mapError((P)=>new O({cause:P,path:i}))),yield*t.remove(o).pipe(oe.mapError((P)=>new re({cause:P,path:o})))})}var Jt=pe({id:"legacy-oxlint-json",files:[c.config,c.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(e)=>oe.gen(function*(){let t=yield*c.exists(e.cwd),r=t.active?.format==="ts"&&t.legacy.length>0?[`Found both \`${c.config}\` and \`${c.files[1].path}\`. Adamantite will use \`${c.config}\`.`]:[];if(t.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${c.files[1].path}\` configuration to \`${c.config}\`.`,warnings:r};if(t.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),migrate:(e)=>oe.gen(function*(){let r=(yield*g).spinner();r.start(`Migrating \`${c.files[1].path}\` to \`${c.config}\`...`),yield*Br(e.cwd),r.stop(`Oxlint config migrated to \`${c.config}\` successfully.`)}),validate:(e)=>oe.gen(function*(){if((yield*c.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxlint-json",reason:`\`${c.config}\` is not the active oxlint config.`})})});import*as W from"effect/Effect";import*as xt from"effect/Exit";import*as de from"effect/Effect";import*as ut from"effect/FileSystem";import*as ct from"effect/Path";import*as st from"effect/Effect";import*as Pn from"effect/FileSystem";var _n=(e)=>st.gen(function*(){yield*(yield*Pn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(st.mapError((r)=>new me({cause:r,path:e})))});import{runScriptCommand as Qr}from"nypm";var Dn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Nn(e,t){let r=[];for(let n of Dn){if(!t.includes(n.script))continue;r.push({command:Qr(e,n.script,{args:n.args}),name:n.name})}return r}function lt(e){return Dn.some((t)=>e.includes(t.script))}var Zr={bun:` - name: Setup Node.js
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 vt({cause:r}),try:()=>$r(e,t)});funct
64
64
  cache: "yarn"
65
65
 
66
66
  - name: Install dependencies
67
- run: yarn install --frozen-lockfile`};function kn({packageManager:e,scripts:t}){let r=Nn(e,t);if(r.length===0)return null;return`${`name: adamantite
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
- ${Zr[e]}
100
+ ${Mr[t]}
101
101
 
102
102
  - name: Run \${{ matrix.name }}
103
103
  run: \${{ matrix.command }}`}
104
- `}var pt=[{path:".github/workflows/adamantite.yml",type:"ci"}],ie=_({create:(e,t)=>de.gen(function*(){let r=yield*ut.FileSystem,n=yield*ct.Path,o=n.join(e,pt[0].path);yield*_n(n.dirname(o));let i=kn(t);if(!i)return;yield*r.writeFileString(o,i).pipe(de.mapError((a)=>new O({cause:a,path:o})))}),exists:(e)=>de.gen(function*(){let t=yield*ut.FileSystem,r=yield*ct.Path;return yield*t.exists(r.join(e,pt[0].path))}),files:pt,kind:"ci",name:"github",update:(e,t)=>de.gen(function*(){let r=yield*ut.FileSystem,o=(yield*ct.Path).join(e,pt[0].path),i=kn(t);if(!i)return;yield*r.writeFileString(o,i).pipe(de.mapError((a)=>new O({cause:a,path:o})))})});import*as Rn from"effect/Context";import*as he from"effect/Effect";import*as An from"effect/Layer";import{addDevDependency as Xr,detectPackageManager as Yr}from"nypm";class Z extends Rn.Service()("DependencyInstaller"){static layer=An.succeed(this)({addDevDependencies:(e,t,r)=>he.tryPromise({catch:(n)=>new Tt({cause:n,packages:e}),try:()=>Xr(e,{...r,cwd:t})}).pipe(he.asVoid),detectPackageManager:(e)=>he.tryPromise({catch:(t)=>new xe({cause:t}),try:()=>Yr(e)}).pipe(he.map((t)=>t??null))})}import*as ue from"effect/Effect";import*as yt from"effect/FileSystem";import*as mt from"effect/Path";var Ze=[{path:"tsconfig.json",type:"config"}],In={extends:"adamantite/typescript"},V=_({config:Ze[0].path,create:(e)=>ue.gen(function*(){let t=yield*yt.FileSystem,n=(yield*mt.Path).join(e,Ze[0].path),o=JSON.stringify(In,null,2);yield*t.writeFileString(n,`${o}
105
- `).pipe(ue.mapError((i)=>new O({cause:i,path:n})))}),exists:(e)=>ue.gen(function*(){let t=yield*yt.FileSystem,r=yield*mt.Path;return yield*t.exists(r.join(e,Ze[0].path))}),files:Ze,kind:"workspace",name:"tsconfig",update:(e)=>ue.gen(function*(){let t=yield*yt.FileSystem,n=(yield*mt.Path).join(e,Ze[0].path),o=yield*t.readFileString(n).pipe(ue.mapError((u)=>new D({cause:u,path:n}))),i=yield*w(o,n);if(!N(i))return yield*new x({path:n});let a=yield*Ee(In,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
106
- `).pipe(ue.mapError((u)=>new O({cause:u,path:n})))})});var zn="adamantite typecheck";function Hr(){return c.files[1].path}function Kr(){return ie.files[0].path}function Vn(e){let t={...e.scripts};if(t.typecheck!==zn)return{migrated:!1,packageJson:e};return delete t.typecheck,t.check??=It.check,{migrated:!0,packageJson:{...e,scripts:t}}}var Mn=pe({check:(e)=>W.gen(function*(){let t=yield*$(e.cwd),{migrated:r}=Vn(t);if(!r)return{applicable:!1,warnings:[]};return{applicable:!0,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json",c.config,Hr(),V.config,Kr()],id:"legacy-typecheck-script",migrate:(e)=>W.gen(function*(){let t=yield*g,r=yield*Z,n=t.spinner(),o=W.gen(function*(){let i=yield*$(e.cwd),a=Vn(i);if(!a.migrated)return"noop";yield*Zt(e.cwd,a.packageJson);let u=yield*c.exists(e.cwd);if(u.active===null)yield*c.create(e.cwd);else if(u.active.format==="ts")yield*c.update(e.cwd);yield*(yield*V.exists(e.cwd))?V.update(e.cwd):V.create(e.cwd);let f=yield*ie.exists(e.cwd),s=Q(a.packageJson);if(f&&lt(s)){let l=yield*r.detectPackageManager(e.cwd);if(l){let h=t.spinner();h.start("Updating GitHub Actions workflow..."),yield*ie.update(e.cwd,{packageManager:l.name,scripts:s}).pipe(W.onExit((S)=>W.sync(()=>{h.stop(xt.match(S,{onFailure:()=>"Failed to update GitHub Actions workflow.",onSuccess:()=>"GitHub Actions workflow updated successfully"}))})))}else yield*t.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});n.start("Migrating `typecheck` script to unified `check` command..."),yield*o.pipe(W.onExit((i)=>W.sync(()=>{n.stop(xt.match(i,{onFailure:()=>"Legacy `typecheck` script migration failed.",onSuccess:(a)=>a==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}))})),W.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(e)=>W.gen(function*(){if((yield*$(e.cwd)).scripts?.typecheck===zn)return yield*new H({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*c.exists(e.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${c.config}\` is not the active oxlint config.`});if(!(yield*V.exists(e.cwd)))return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${V.config}\` is missing after the migration.`})})});var dt=[qt,bt,Jt,Mn],wn=Object.fromEntries(dt.map((e)=>[e.id,e])),Un={[bt.id]:m.name,[qt.id]:d.name,[Jt.id]:c.name};import*as bn from"effect/Console";import*as qn from"effect/Effect";import*as Jn from"effect/Terminal";var Re=()=>qn.gen(function*(){let t=yield*(yield*Jn.Terminal).columns,r=' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n '.split(`
107
- `).reduce((n,o)=>Math.max(n,o.trim().length),0);if(!t||t<r)return;yield*bn.info(' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n ')});var Cr=ht.boolean("fix").pipe(ht.withDescription("Automatically fix safe package install/update issues")),Lr=[m,d,c,K,le];function eo(e){return e.applicable&&Array.isArray(e.actions)}var xn={[m.name]:m,[d.name]:d,[c.name]:c},Wn={[c.name]:c};function Bn(e,t){return Object.hasOwn(e,t)}function Xe(e,t){switch(t.type){case"install_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"update_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"create_config":case"update_config":return`${e}:${t.type}:${t.path}`;case"manual_fix":return`${e}:${t.type}:${t.path??t.description}`;case"run_migration":return`${e}:${t.type}:${t.migrationId}`}}var Qn=Ie.make("doctor",{fix:Cr}).pipe(Ie.withDescription("Check Adamantite-managed integrations in the current project"),Ie.withHandler(({fix:e})=>Ae.gen(function*(){let t=Gr.cwd(),r=yield*g;yield*Re(),yield*r.intro("\uD83D\uDCA0 adamantite doctor");let n=yield*$(t);if(!n.devDependencies?.adamantite&&!n.dependencies?.adamantite)yield*r.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*r.outro("⚠️ Doctor found issues."),yield*new A({command:"doctor",exitCode:Wt.ExitCode(1)});let o=[];for(let y of Lr){let f=yield*y.assess(t);if(eo(f))o.push({assessment:f,integration:y})}for(let{assessment:y}of o)for(let f of y.warnings)yield*r.log.warning(f);if(o.length===0){yield*r.log.success("No applicable integrations found."),yield*r.outro("✅ Doctor completed successfully!");return}let i=o.flatMap(({assessment:y,integration:f})=>y.actions.map((s)=>({action:s,integration:f})));if(i.length===0){yield*r.log.success("No issues found."),yield*r.outro("✅ Doctor completed successfully!");return}let a=new Set;if(e)yield*Ae.gen(function*(){let y=i.filter(({action:f})=>f.type==="install_package"||f.type==="update_package");if(y.length>0){let f=yield*Z,s=[];for(let{action:l}of y)if(l.type==="install_package"||l.type==="update_package")s.push(`${l.package}@${l.targetVersion}`);yield*f.addDevDependencies(s,t,{silent:!0});for(let{action:l,integration:h}of y){if(l.type==="install_package")yield*r.log.success(`Fixed: installed \`${l.package}@${l.targetVersion}\`.`);if(l.type==="update_package")yield*r.log.success(`Fixed: updated \`${l.package}\` from \`${l.currentVersion}\` to \`${l.targetVersion}\`.`);a.add(Xe(h.name,l))}}for(let{action:f,integration:s}of i){if(f.type!=="create_config")continue;if(!Bn(xn,s.name))continue;yield*xn[s.name].create(t),yield*r.log.success(`Fixed: created \`${f.path}\`.`),a.add(Xe(s.name,f))}for(let{action:f,integration:s}of i){if(f.type!=="update_config")continue;if(!Bn(Wn,s.name))continue;yield*Wn[s.name].update(t),yield*r.log.success(`Fixed: updated \`${f.path}\`.`),a.add(Xe(s.name,f))}for(let{action:f,integration:s}of i){if(f.type!=="run_migration")continue;let l=wn[f.migrationId];if(!l)continue;yield*Qe(l,{cwd:t}),a.add(Xe(s.name,f))}}).pipe(Ae.tapError(()=>Ae.gen(function*(){yield*r.outro("❌ Doctor failed")})));let u=i.filter(({action:y,integration:f})=>!a.has(Xe(f.name,y)));if(e&&u.length===0){yield*r.outro("✅ Doctor completed successfully!");return}for(let{action:y}of e?u:i)yield*r.log.warning(`Needs attention: ${y.description}`);yield*r.outro("⚠️ Doctor found issues."),yield*new A({command:"doctor",exitCode:Wt.ExitCode(1)})})));import*as Zn from"effect/Effect";import*as Ve from"effect/unstable/cli/Argument";import*as ze from"effect/unstable/cli/Command";import*as ce from"effect/unstable/cli/Flag";import*as Xn from"effect/unstable/process/ChildProcessSpawner";var to=Ve.file("files",{mustExist:!0}).pipe(Ve.withDescription("Specific files to fix (optional)"),Ve.variadic()),no=ce.boolean("suggested").pipe(ce.withDescription("Apply suggested fixes")),ro=ce.boolean("dangerous").pipe(ce.withDescription("Apply dangerous fixes")),oo=ce.boolean("all").pipe(ce.withDescription("Apply all fixes, including suggested and dangerous fixes")),Yn=ze.make("fix",{all:oo,dangerous:ro,files:to,suggested:no}).pipe(ze.withDescription("Fix issues in code using oxlint"),ze.withHandler(({all:e,dangerous:t,files:r,suggested:n})=>Zn.gen(function*(){let o=yield*R,i=new Set(["--fix"]);if(n||e)i.add("--fix-suggestions");if(t||e)i.add("--fix-dangerously");for(let u of r)i.add(u);let a=yield*o.run({args:[...i],command:c.name});if(a!==Xn.ExitCode(0))yield*new A({command:c.name,exitCode:a})})));import*as Hn from"effect/Effect";import*as Me from"effect/unstable/cli/Argument";import*as we from"effect/unstable/cli/Command";import*as gt from"effect/unstable/cli/Flag";import*as Kn from"effect/unstable/process/ChildProcessSpawner";var io=Me.file("files",{mustExist:!0}).pipe(Me.withDescription("Specific files to format (optional)"),Me.variadic()),ao=gt.boolean("check").pipe(gt.withDescription("Check if files are formatted without writing")),Gn=we.make("format",{check:ao,files:io}).pipe(we.withDescription("Format files using oxfmt"),we.withHandler(({check:e,files:t})=>Hn.gen(function*(){let r=yield*R,n=[];if(e)n.push("--check");n.push(...t);let o=yield*r.run({args:n,command:d.name});if(o!==Kn.ExitCode(0))yield*new A({command:d.name,exitCode:o})})));import so from"node:process";import*as j from"effect/Effect";import*as or from"effect/FileSystem";import*as ir from"effect/Path";import*as Ue from"effect/unstable/cli/Command";import*as X from"effect/Effect";import*as Et from"effect/FileSystem";import*as jt from"effect/Path";import*as Ln from"effect/unstable/process/ChildProcessSpawner";var Ye=[{path:".vscode/settings.json",type:"config"}],Cn={"[css]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[graphql]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[json]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[jsonc]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"editor.codeActionsOnSave":{"source.fixAll.oxc":"explicit"},"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0},ne=_({config:Ye[0].path,create:(e)=>X.gen(function*(){let t=yield*Et.FileSystem,r=yield*jt.Path,n=r.join(e,Ye[0].path),o=r.dirname(n);yield*t.makeDirectory(o,{recursive:!0}).pipe(X.mapError((i)=>new me({cause:i,path:o}))),yield*t.writeFileString(n,`${JSON.stringify(Cn,null,2)}
108
- `).pipe(X.mapError((i)=>new O({cause:i,path:n})))}),exists:(e)=>X.gen(function*(){let t=yield*Et.FileSystem,r=yield*jt.Path;return yield*t.exists(r.join(e,Ye[0].path))}),extension:(e=[])=>X.gen(function*(){function t(n){return X.gen(function*(){let i=yield*(yield*R).run({args:["--install-extension",n],command:"code"}).pipe(X.mapError((a)=>a._tag==="CliNotFound"&&a.command==="code"?new kt({cause:a}):new Ge({cause:a,extension:n})));if(i!==Ln.ExitCode(0))return yield*new Ge({cause:i,extension:n})})}let r=[];if(e.includes("check")||e.includes("fix")||e.includes("format"))r.push("oxc.oxc-vscode");if(e.includes("analyze"))r.push("webpro.vscode-knip");for(let n of r)yield*t(n)}),files:Ye,kind:"editor",name:"vscode",update:(e)=>X.gen(function*(){let t=yield*Et.FileSystem,n=(yield*jt.Path).join(e,Ye[0].path),o=yield*t.readFileString(n).pipe(X.mapError((u)=>new D({cause:u,path:n}))),i=yield*w(o,n);if(!N(i))return yield*new x({path:n});let a=yield*Ee(Cn,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
109
- `).pipe(X.mapError((u)=>new O({cause:u,path:n})))})});import*as ae from"effect/Effect";import*as Ot from"effect/FileSystem";import*as St from"effect/Path";var He=[{path:".zed/settings.json",type:"config"}],er={languages:{CSS:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},HTML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSON:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSONC:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JavaScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},MDX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},Markdown:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},TSX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},YAML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}},fe=_({config:He[0].path,create:(e)=>ae.gen(function*(){let t=yield*Ot.FileSystem,r=yield*St.Path,n=r.join(e,He[0].path),o=r.dirname(n);yield*t.makeDirectory(o,{recursive:!0}).pipe(ae.mapError((i)=>new me({cause:i,path:o}))),yield*t.writeFileString(n,`${JSON.stringify(er,null,2)}
110
- `).pipe(ae.mapError((i)=>new O({cause:i,path:n})))}),exists:(e)=>ae.gen(function*(){let t=yield*Ot.FileSystem,r=yield*St.Path;return yield*t.exists(r.join(e,He[0].path))}),files:He,kind:"editor",name:"zed",update:(e)=>ae.gen(function*(){let t=yield*Ot.FileSystem,n=(yield*St.Path).join(e,He[0].path),o=yield*t.readFileString(n).pipe(ae.mapError((u)=>new D({cause:u,path:n}))),i=yield*w(o,n);if(!N(i))return yield*new x({path:n});let a=yield*Ee(er,i);yield*t.writeFileString(n,`${JSON.stringify(a,null,2)}
111
- `).pipe(ae.mapError((u)=>new O({cause:u,path:n})))})});import fo from"node:process";import*as tr from"effect/Effect";import*as nr from"effect/FileSystem";import*as rr from"effect/Path";var Bt=(e=fo.cwd())=>tr.gen(function*(){let t=yield*nr.FileSystem,r=yield*rr.Path;if(yield*t.exists(r.join(e,"pnpm-workspace.yaml")))return!0;return(yield*$(e)).workspaces!==void 0});var lo=(e,t)=>j.gen(function*(){let r=yield*Z,o=(yield*g).spinner();o.start("Installing dependencies...");let i=yield*Bt(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:i}).pipe(j.tapError(()=>j.sync(()=>{o.stop("Failed to install dependencies.")}))),o.stop("Dependencies installed.")});function Qt(e,t){return j.gen(function*(){yield*(yield*g).log.info(`Legacy \`${t}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${e} configs yet.`)})}var po=(e,t)=>j.gen(function*(){let r=yield*g,n=r.spinner();n.start("Setting up oxlint config...");let o=yield*c.exists(e),i=c.files[1].path;if(o.active?.format==="ts"&&o.legacy.length>0)yield*r.log.warning(`Found both \`${c.config}\` and \`${i}\`. Adamantite will use \`${c.config}\`.`);if(o.active?.format==="json")n.message(`Found \`${i}\`, keeping existing config.`),n.stop("oxlint config is ready."),yield*Qt("oxlint",i);else if(o.active?.format==="ts")n.message(`Found \`${c.config}\`, keeping existing config.`),n.stop("oxlint config is ready.");else n.message(`\`${c.config}\` not found, creating...`),yield*c.create(e,t),n.stop("oxlint config created successfully.")}),uo=(e)=>j.gen(function*(){let t=yield*g,r=t.spinner();r.start("Setting up oxfmt config...");let n=yield*d.exists(e);if(n.active?.format==="ts"&&n.legacy.length>0)yield*t.log.warning(`Found both \`${d.config}\` and \`.oxfmtrc.json(c)\`. Adamantite will use \`${d.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*t.log.warning("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(n.active?.format==="json"||n.active?.format==="jsonc"){let o=n.active.path.endsWith(d.files[1].path)?d.files[1].path:d.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("oxfmt config is ready."),yield*Qt("oxfmt",o)}else if(n.active?.format==="ts")r.message(`Found \`${d.config}\`, keeping existing config.`),r.stop("oxfmt config is ready.");else r.message(`\`${d.config}\` not found, creating...`),yield*d.create(e),r.stop("oxfmt config created successfully.")}),co=(e,t)=>j.gen(function*(){let r=yield*or.FileSystem,n=yield*ir.Path,o=yield*g,i=yield*$(e),a=o.spinner();a.start("Adding scripts to your `package.json`..."),i.scripts??={};for(let y of t)switch(y){case"check":i.scripts.check="adamantite check";break;case"fix":i.scripts.fix="adamantite fix";break;case"format":i.scripts.format="adamantite format";break;case"check:monorepo":i.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":i.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":i.scripts.analyze="adamantite analyze";break;default:return yield*new Nt({script:y})}let u=n.join(e,"package.json");yield*r.writeFileString(u,`${JSON.stringify(i,null,2)}
112
- `).pipe(j.mapError((y)=>new O({cause:y,path:u}))),a.stop("Scripts added to your `package.json`")}),yo=(e)=>j.gen(function*(){let t=yield*g,r=t.spinner();r.start("Setting up knip config...");let n=yield*m.exists(e);if(n.active?.format==="ts"&&n.legacy.length>0)yield*t.log.warning(`Found both \`${m.config}\` and \`knip.json(c)\`. Adamantite will use \`${m.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*t.log.warning("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(n.active?.format==="json"||n.active?.format==="jsonc"){let o=n.active.path.endsWith(m.files[1].path)?m.files[1].path:m.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("knip config is ready."),yield*Qt("knip",o)}else if(n.active?.format==="ts")r.message(`Found \`${m.config}\`, keeping existing config.`),r.stop("knip config is ready.");else r.message(`\`${m.config}\` not found, creating...`),yield*m.create(e),r.stop("knip config created successfully.")}),mo=(e)=>j.gen(function*(){let r=(yield*g).spinner();if(r.start("Setting up TypeScript config..."),yield*V.exists(e))r.message(`\`${V.config}\` found, updating...`),yield*V.update(e),r.stop(`\`${V.config}\` updated successfully`);else r.message(`\`${V.config}\` not found, creating...`),yield*V.create(e),r.stop(`\`${V.config}\` created successfully`)}),ho=(e,t)=>j.gen(function*(){let r=yield*g;if(t.includes("vscode")){let n=r.spinner();if(n.start(`Checking for \`${ne.config}\`...`),yield*ne.exists(e))n.message(`\`${ne.config}\` found, updating...`),yield*ne.update(e),n.stop(`\`${ne.config}\` updated with Adamantite preset.`);else n.message(`\`${ne.config}\` not found, creating...`),yield*ne.create(e),n.stop(`\`${ne.config}\` created with Adamantite preset.`)}if(t.includes("zed")){let n=r.spinner();if(n.start(`Checking for \`${fe.config}\`...`),yield*fe.exists(e))n.message(`\`${fe.config}\` found, updating...`),yield*fe.update(e),n.stop(`\`${fe.config}\` updated with Adamantite preset.`);else n.message(`\`${fe.config}\` not found, creating...`),yield*fe.create(e),n.stop(`\`${fe.config}\` created with Adamantite preset.`)}}),go=(e,t)=>j.gen(function*(){let r=yield*g,n=r.spinner();n.start("Installing editor extensions...");let o=e.includes("zed"),i=e.includes("vscode");if(yield*j.gen(function*(){if(e.includes("vscode"))n.message("Installing VS Code extension..."),yield*ne.extension(t);return!0}).pipe(j.tapError(()=>j.sync(()=>{n.stop()})),j.catchTag("FailedToInstallExtension",(u)=>j.gen(function*(){return yield*r.log.warning(`⚠️ Failed to install the \`${u.extension}\` extension.`),yield*r.log.warning("Please install it manually after setup completes."),!1})),j.catchTag("VscodeCliNotFound",()=>j.gen(function*(){return yield*r.log.error("VSCode CLI ('code' command) not found."),yield*r.log.info("To install it:"),yield*r.log.info(" 1. Open VS Code"),yield*r.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))))if(o&&!i)n.stop("Zed extensions require manual install.");else n.stop("Editor extensions installed successfully.");if(o)yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Eo=(e,t,r)=>j.gen(function*(){let o=(yield*g).spinner();o.start("Setting up GitHub Actions workflow...");let i=yield*ie.exists(e),a=ie.files[0].path;if(i)o.message(`\`${a}\` found, updating...`),yield*ie.update(e,{packageManager:t,scripts:r}),o.stop("GitHub Actions workflow updated successfully.");else o.message(`Creating \`${a}\`...`),yield*ie.create(e,{packageManager:t,scripts:r}),o.stop("GitHub Actions workflow created successfully.")}).pipe(j.option),ar=Ue.make("init").pipe(Ue.withDescription("Initialize Adamantite in the current directory"),Ue.withHandler(()=>j.gen(function*(){let e=so.cwd(),t=yield*g;yield*Re(),yield*t.intro("\uD83D\uDCA0 adamantite init");let n=yield*(yield*Z).detectPackageManager(e);if(!n)return yield*new xe({});if(n.warnings?.length)for(let p of n.warnings)yield*t.log.warning(p);yield*t.log.info(`Detected package manager: ${n.name}`);let o=yield*Bt(e);if(o)yield*t.log.info("We've detected a monorepo setup in your project.");let i=yield*t.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues and type errors using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{disabled:!o,hint:o?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!o,hint:o?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),a=i.includes("check")||i.includes("fix"),u=[];if(a)u=yield*t.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let y=!1;if(a)y=yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"});let f=yield*t.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),s=!1;if(f.length>0)s=yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let l=lt(i),h=!1;if(l)h=yield*t.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let S=i.includes("format"),k=i.includes("check:monorepo")||i.includes("fix:monorepo"),P=i.includes("analyze"),J=["adamantite"];if(a)J.push(`${c.name}@${c.version}`),J.push(`${le.name}@${le.version}`);if(S)J.push(`${d.name}@${d.version}`);if(k)J.push(`${K.name}@${K.version}`);if(P)J.push(`${m.name}@${m.version}`);if(yield*lo(e,J),S)yield*uo(e);if(a)yield*po(e,u);if(P)yield*yo(e);if(yield*co(e,i),y)yield*mo(e);if(yield*ho(e,f),s)yield*go(f,i);if(h)yield*Eo(e,n.name,i);yield*t.log.success("Your project is now configured"),yield*t.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(j.catchTags({OperationCancelled:()=>j.gen(function*(){yield*(yield*g).cancel("You've cancelled the initialization process.")})}))));import*as fr from"effect/Effect";import*as be from"effect/unstable/cli/Command";import*as Ft from"effect/unstable/cli/Flag";import*as sr from"effect/unstable/process/ChildProcessSpawner";var jo=Ft.boolean("fix").pipe(Ft.withDescription("Automatically fix issues")),lr=be.make("monorepo",{fix:jo}).pipe(be.withDescription("Find and fix monorepo-specific issues using Sherif"),be.withHandler(({fix:e})=>fr.gen(function*(){let t=yield*R,r=e?["--fix"]:[],n=yield*t.run({args:r,command:K.name,stdin:"inherit"});if(n!==sr.ExitCode(0))yield*new A({command:K.name,exitCode:n})})));import*as pr from"effect/Effect";import*as qe from"effect/unstable/cli/Command";import*as ur from"effect/unstable/process/ChildProcessSpawner";var cr=qe.make("typecheck").pipe(qe.withDescription("Deprecated alias for `check`"),qe.withHandler(()=>pr.gen(function*(){let e=yield*g,t=yield*R;yield*e.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*t.run({args:[],command:c.name});if(r!==ur.ExitCode(0))yield*new A({command:c.name,exitCode:r})})));import Oo from"node:process";import*as Y from"effect/Effect";import*as Je from"effect/unstable/cli/Command";var So=[c,le,d,K,m],Fo=[c,le,d,K,m];function $o(e){return e.applicable&&Array.isArray(e.actions)}function To(e,t){let r=[];for(let n of Fo){if(t.has(n.name))continue;let o=e.devDependencies?.[n.name]??e.dependencies?.[n.name];if(o&&B(o)!==n.version)r.push({currentVersion:o,name:n.name,targetVersion:n.version})}return r}var yr=Je.make("update").pipe(Je.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Je.withHandler(()=>Y.gen(function*(){let e=Oo.cwd(),t=yield*g,r=yield*Z,n={cwd:e};yield*Re(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>Y.gen(function*(){let p=[];for(let F of So){let Ke=yield*F.assess(e);if($o(Ke))p.push({assessment:Ke,integration:F})}return p}),i=yield*o();for(let{assessment:p}of i)for(let F of p.warnings)yield*t.log.warning(F);let a=new Set(i.map(({integration:p})=>p.name)),u=i.flatMap(({assessment:p})=>p.actions),y=new Set(u.filter((p)=>p.type==="run_migration").map((p)=>p.migrationId)),f=[];for(let p of dt.filter((F)=>F.tags.includes("update"))){let F=Un[p.id];if(a.has(F))continue;let Ke=yield*p.check(n);f.push({migration:p,result:Ke})}for(let p of f){for(let F of p.result.warnings)yield*t.log.warning(F);if(p.result.applicable&&p.result.summary)yield*t.log.info(p.result.summary)}let s=[];for(let p of dt){if(!y.has(p.id))continue;yield*Qe(p,n,{onRestore:t.log.warning(`Migration "${p.title}" failed, restoring files...`)}),s.push(p.id)}for(let{migration:p,result:F}of f){if(!F.applicable||!F.summary)continue;yield*Qe(p,n,{onRestore:t.log.warning(`Migration "${p.title}" failed, restoring files...`)}),s.push(p.id)}if(s.length>0)yield*t.log.success("Migrations ran successfully.");let l=yield*$(e),h=yield*o(),S=h.flatMap(({assessment:p})=>p.actions).filter((p)=>p.type==="create_config"||p.type==="update_config"||p.type==="manual_fix"),k=h.flatMap(({assessment:p})=>p.actions).filter((p)=>p.type==="install_package"||p.type==="update_package").map((p)=>p.type==="install_package"?{currentVersion:"not installed",name:p.package,targetVersion:p.targetVersion}:{currentVersion:p.currentVersion,name:p.package,targetVersion:p.targetVersion}),P=new Set(k.map((p)=>p.name)),J=[...k,...To(l,P)];if(J.length>0){yield*t.log.info("The following dependencies will be updated:");for(let F of J)yield*t.log.info(` ${F.name}: ${F.currentVersion} → ${F.targetVersion}`);let p=t.spinner();p.start("Updating dependencies..."),yield*r.addDevDependencies(J.map((F)=>`${F.name}@${F.targetVersion}`),e,{silent:!0}).pipe(Y.tapError(()=>Y.sync(()=>{p.stop("Failed to update dependencies")}))),p.stop("Dependencies updated successfully"),yield*t.log.success("Dependencies updated successfully.")}if(S.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let p of S)yield*t.log.warning(`Doctor follow-up: ${p.description}`)}if(s.length===0&&J.length===0&&S.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(Y.tapError(()=>Y.gen(function*(){yield*(yield*g).outro("❌ Update failed")})),Y.tap((e)=>Y.gen(function*(){let t=yield*g;switch(e){case"no-changes":yield*t.outro("✅ Adamantite is already up to date.");break;case"success":yield*t.outro("✅ Update completed successfully!");break;default:break}})))));var vo=ye.make("adamantite").pipe(ye.withDescription("Opinionated preset package for modern TypeScript applications"),ye.withSubcommands([Ct,pn,Qn,Yn,Gn,ar,lr,cr,yr])),Po=await"0.32.2",_o=ye.run(vo,{version:Po}).pipe(M.as(0),M.catchTag("CommandFailed",(e)=>M.succeed(e.exitCode)),M.catch((e)=>M.service(g).pipe(M.flatMap((t)=>t.log.error(e.message)),M.as(jr.ExitCode(1)))),M.provide(gr.mergeAll(dr.layer,g.layer,R.layer,Z.layer)));mr.runMain(_o,{teardown:(e,t)=>{if(hr.isSuccess(e)){t(Number(e.value));return}Er.defaultTeardown(e,t)}});
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.0"}).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)}});