adamantite 0.34.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6,18 +6,18 @@ ${n}`)}var De=(e,t)=>G.try({catch:(n)=>new _t({cause:n}),try:()=>Yr(e,t)});funct
6
6
  `);return` ${n}: ${Re(r)},`});if(t.length===0)return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = analyze","","export default config",""].join(`
7
7
  `);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...t,"}","","export default config",""].join(`
8
8
  `)}import Kr from"node:process";import*as Ve from"effect/Effect";import*as Jt from"effect/FileSystem";import*as Bt from"effect/Path";var xr=/^workspace:/,Lr=/^[\^~]/;function Y(e){return e.trim().replace(xr,"").replace(Lr,"")}var v=(e=Kr.cwd())=>Ve.gen(function*(){let t=yield*Jt.FileSystem,r=(yield*Bt.Path).join(e,"package.json"),o=yield*t.readFileString(r).pipe(Ve.mapError((s)=>new R({cause:s,path:r})));return yield*A(o,r)}),an=(e,t)=>Ve.gen(function*(){let n=yield*Jt.FileSystem,o=(yield*Bt.Path).join(e,"package.json");yield*n.writeFileString(o,`${JSON.stringify(t,null,2)}
9
- `).pipe(Ve.mapError((i)=>new j({cause:i,path:o})))});function Ye(e){return e==="bun"||e==="deno"||e==="npm"||e==="pnpm"||e==="yarn"}var He={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function H(e){let t=e.scripts??{},n=[];for(let[r,o]of Object.entries(He))if(t[r]===o)n.push(r);return n}var J=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}];var h=I({assess:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,n=yield*it.Path,r=yield*v(e);if(!H(r).includes("analyze"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.knip??r.dependencies?.knip,s=n.join(e,J[0].path),a=n.join(e,J[1].path),u=n.join(e,J[2].path),{hasConfig:f,hasLegacyJson:l,hasLegacyJsonc:p}=yield*re.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(u)},{concurrency:"unbounded"}),E=f?"ts":p?"jsonc":l?"json":null,S=[],T=[];if(f&&(l||p))T.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!f&&l&&p)T.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@${"6.30.0"}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:"6.30.0",type:"install_package"});else if(Y(i)!=="6.30.0")S.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${"6.30.0"}\`.`,package:"knip",targetVersion:"6.30.0",type:"update_package"});if(E===null)S.push({description:`Create \`${J[0].path}\` for \`knip\`.`,path:J[0].path,type:"create_config"});if(E==="json"||E==="jsonc")S.push({description:`Migrate legacy \`${E==="json"?J[1].path:J[2].path}\` to \`${J[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:T}}),config:J[0].path,create:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,r=(yield*it.Path).join(e,J[0].path);yield*t.writeFileString(r,rt()).pipe(re.mapError((o)=>new j({cause:o,path:r})))}),detect:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,n=yield*it.Path,r=n.join(e,J[0].path),o=n.join(e,J[1].path),i=n.join(e,J[2].path),{hasJson:s,hasJsonc:a,hasTs:u}=yield*re.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),f=u?"ts":a?"jsonc":s?"json":null,l=[];if(u&&s)l.push({format:"json",path:o});if(u&&a)l.push({format:"jsonc",path:i});if(!u&&s&&a)l.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?r:f==="jsonc"?i:o},legacy:l}}),files:J,kind:"tooling",name:"knip",version:"6.30.0"});import*as fn from"effect/Context";import*as Pe from"effect/Effect";import*as ln from"effect/Layer";import*as pn from"effect/unstable/process/ChildProcess";class _ extends fn.Service()("CommandRunner"){static layer=ln.succeed(this)({run:({args:e,command:t,cwd:n,stderr:r="inherit",stdin:o="ignore",stdout:i="inherit"})=>Pe.mapError(Pe.scoped(Pe.gen(function*(){return yield*(yield*pn.make(t,e,{cwd:n,stderr:r,stdin:o,stdout:i})).exitCode})),(s)=>s.reason._tag==="NotFound"?new Nt({command:t}):s)})}import*as un from"effect/Context";var B=un.Reference("adamantite/ForwardedArguments",{defaultValue:()=>[]});var wr=Ie.boolean("fix").pipe(Ie.withDescription("Automatically fix issues")),Mr=Ie.boolean("strict").pipe(Ie.withDescription("Enable strict mode")),Qt=fe.make("analyze",{fix:wr,strict:Mr}).pipe(fe.withDescription("Find unused dependencies, exports, and files using knip"),fe.withExamples([{command:"adamantite analyze -- --directory packages/app",description:"Run knip from a specific directory"}]),fe.withHandler(({fix:e,strict:t})=>cn.gen(function*(){let n=yield*B,r=yield*_,o=[];if(e)o.push("--fix","--allow-remove-files");if(t)o.push("--production","--strict");o.push(...n);let i=yield*r.run({args:o,command:h.name});if(i!==yn.ExitCode(0))yield*new b({command:h.name,exitCode:i})})));import*as $n from"effect/Effect";import*as Ne from"effect/unstable/cli/Argument";import*as Te from"effect/unstable/cli/Command";import*as Fn from"effect/unstable/process/ChildProcessSpawner";import*as X from"effect/Effect";import*as Ke from"effect/FileSystem";import*as xe from"effect/Path";import*as g from"effect/Option";import{print as Gr}from"esrap";import Cr from"esrap/languages/ts";import{parseSync as eo}from"oxc-parser";var On=["respectEslintDisableDirectives","typeAware","typeCheck"],hn="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",mn="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",dn="`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.",jn="Adamantite could not generate the required `options` patch.";function at(e=[]){return e.includes("core")?e:["core",...e]}function En(e){return e.replaceAll(/-([a-z])/g,(t,n)=>n.toUpperCase())}function ft(e,t,n=[]){let{options:r,...o}=e,i=['import { defineConfig } from "oxlint"',...t.map((E)=>`import ${En(E)} from "${E==="core"?"adamantite/lint":`adamantite/lint/${E}`}"`)],a=[...t.map((E)=>En(E)),...n.map((E)=>JSON.stringify(E))],u=JSON.stringify(N(r)?{...r,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),f=Object.entries(o).map(([E,S])=>[E,JSON.stringify(S,null,2)]),l=`[${a.join(", ")}]`,p=[["options",u],...f,["extends",l]].map(([E,S])=>` ${E}: ${S},`).join(`
9
+ `).pipe(Ve.mapError((i)=>new j({cause:i,path:o})))});function Ye(e){return e==="bun"||e==="deno"||e==="npm"||e==="pnpm"||e==="yarn"}var He={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function H(e){let t=e.scripts??{},n=[];for(let[r,o]of Object.entries(He))if(t[r]===o)n.push(r);return n}var J=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}];var h=I({assess:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,n=yield*it.Path,r=yield*v(e);if(!H(r).includes("analyze"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.knip??r.dependencies?.knip,s=n.join(e,J[0].path),a=n.join(e,J[1].path),u=n.join(e,J[2].path),{hasConfig:f,hasLegacyJson:l,hasLegacyJsonc:p}=yield*re.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(u)},{concurrency:"unbounded"}),E=f?"ts":p?"jsonc":l?"json":null,S=[],T=[];if(f&&(l||p))T.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!f&&l&&p)T.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@${"6.31.0"}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:"6.31.0",type:"install_package"});else if(Y(i)!=="6.31.0")S.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${"6.31.0"}\`.`,package:"knip",targetVersion:"6.31.0",type:"update_package"});if(E===null)S.push({description:`Create \`${J[0].path}\` for \`knip\`.`,path:J[0].path,type:"create_config"});if(E==="json"||E==="jsonc")S.push({description:`Migrate legacy \`${E==="json"?J[1].path:J[2].path}\` to \`${J[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:T}}),config:J[0].path,create:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,r=(yield*it.Path).join(e,J[0].path);yield*t.writeFileString(r,rt()).pipe(re.mapError((o)=>new j({cause:o,path:r})))}),detect:(e)=>re.gen(function*(){let t=yield*ot.FileSystem,n=yield*it.Path,r=n.join(e,J[0].path),o=n.join(e,J[1].path),i=n.join(e,J[2].path),{hasJson:s,hasJsonc:a,hasTs:u}=yield*re.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),f=u?"ts":a?"jsonc":s?"json":null,l=[];if(u&&s)l.push({format:"json",path:o});if(u&&a)l.push({format:"jsonc",path:i});if(!u&&s&&a)l.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?r:f==="jsonc"?i:o},legacy:l}}),files:J,kind:"tooling",name:"knip",version:"6.31.0"});import*as fn from"effect/Context";import*as Pe from"effect/Effect";import*as ln from"effect/Layer";import*as pn from"effect/unstable/process/ChildProcess";class _ extends fn.Service()("CommandRunner"){static layer=ln.succeed(this)({run:({args:e,command:t,cwd:n,stderr:r="inherit",stdin:o="ignore",stdout:i="inherit"})=>Pe.mapError(Pe.scoped(Pe.gen(function*(){return yield*(yield*pn.make(t,e,{cwd:n,stderr:r,stdin:o,stdout:i})).exitCode})),(s)=>s.reason._tag==="NotFound"?new Nt({command:t}):s)})}import*as un from"effect/Context";var B=un.Reference("adamantite/ForwardedArguments",{defaultValue:()=>[]});var wr=Ie.boolean("fix").pipe(Ie.withDescription("Automatically fix issues")),Mr=Ie.boolean("strict").pipe(Ie.withDescription("Enable strict mode")),Qt=fe.make("analyze",{fix:wr,strict:Mr}).pipe(fe.withDescription("Find unused dependencies, exports, and files using knip"),fe.withExamples([{command:"adamantite analyze -- --directory packages/app",description:"Run knip from a specific directory"}]),fe.withHandler(({fix:e,strict:t})=>cn.gen(function*(){let n=yield*B,r=yield*_,o=[];if(e)o.push("--fix","--allow-remove-files");if(t)o.push("--production","--strict");o.push(...n);let i=yield*r.run({args:o,command:h.name});if(i!==yn.ExitCode(0))yield*new b({command:h.name,exitCode:i})})));import*as $n from"effect/Effect";import*as Ne from"effect/unstable/cli/Argument";import*as Te from"effect/unstable/cli/Command";import*as Fn from"effect/unstable/process/ChildProcessSpawner";import*as X from"effect/Effect";import*as Ke from"effect/FileSystem";import*as xe from"effect/Path";import*as g from"effect/Option";import{print as Gr}from"esrap";import Cr from"esrap/languages/ts";import{parseSync as eo}from"oxc-parser";var On=["respectEslintDisableDirectives","typeAware","typeCheck"],hn="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",mn="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",dn="`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.",jn="Adamantite could not generate the required `options` patch.";function at(e=[]){return e.includes("core")?e:["core",...e]}function En(e){return e.replaceAll(/-([a-z])/g,(t,n)=>n.toUpperCase())}function ft(e,t,n=[]){let{options:r,...o}=e,i=['import { defineConfig } from "oxlint"',...t.map((E)=>`import ${En(E)} from "${E==="core"?"adamantite/lint":`adamantite/lint/${E}`}"`)],a=[...t.map((E)=>En(E)),...n.map((E)=>JSON.stringify(E))],u=JSON.stringify(N(r)?{...r,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),f=Object.entries(o).map(([E,S])=>[E,JSON.stringify(S,null,2)]),l=`[${a.join(", ")}]`,p=[["options",u],...f,["extends",l]].map(([E,S])=>` ${E}: ${S},`).join(`
10
10
  `);return[...i,"","export default defineConfig({",p,"})",""].join(`
11
11
  `)}function st(e){return N(e)&&e.type==="ObjectExpression"&&Array.isArray(e.properties)}function Wt(e){return N(e)&&e.type==="Property"}var to=g.liftThrowable((e)=>eo("oxlint.config.ts",e,{astType:"ts",lang:"ts",sourceType:"module"}));function Zt(e){return to(e).pipe(g.flatMap((t)=>t.errors.length===0?g.fromNullishOr(t.program):g.none()))}function Sn(e){let{code:t}=Gr(e,Cr({quotes:"double"}));return t.endsWith(`
12
12
  `)?t:`${t}
13
13
  `}function gn(e){if(e.type==="Identifier")return e.name;if(e.type==="Literal"&&typeof e.value==="string")return e.value;return null}function Xt(e){let t=e.body.filter((i)=>i.type==="ExportDefaultDeclaration");if(t.length!==1)return g.none();let[n]=t;if(!n)return g.none();let r=n.declaration;if(st(r))return g.fromNullishOr(r);if(r.type!=="CallExpression")return g.none();if(r.callee.type!=="Identifier"||r.callee.name!=="defineConfig")return g.none();if(r.arguments.length!==1)return g.none();let[o]=r.arguments;if(st(o))return g.fromNullishOr(o);return g.none()}function Yt(e,t){let n=null;for(let r of e.properties){if(r.type==="SpreadElement")return{status:"manual"};if(!Wt(r))return{status:"manual"};if(r.computed)return{status:"manual"};if(r.method||r.kind!=="init"){if(gn(r.key)===t)return{status:"manual"};continue}if(gn(r.key)!==t)continue;if(n)return{status:"manual"};n=r}if(!n)return{status:"missing"};return{property:n,status:"found"}}function no(e){let t=`export default { options: { ${e.map((s)=>`${s}: true`).join(", ")} } }
14
14
  `,n=Zt(t);if(g.isNone(n))return g.none();let r=Xt(n.value);if(g.isNone(r))return g.none();let o=Yt(r.value,"options");if(o.status!=="found")return g.none();if(!st(o.property.value))return g.none();let i=o.property.value.properties.filter(Wt);return i.length===o.property.value.properties.length?g.fromNullishOr(i):g.none()}function ro(){let e=`export default { options: { ${On.map((o)=>`${o}: true`).join(", ")} } }
15
- `,t=Zt(e);if(g.isNone(t))return g.none();let n=Xt(t.value);if(g.isNone(n)||n.value.properties.length!==1)return g.none();let[r]=n.value.properties;if(!r||!Wt(r)||r.computed||r.method||r.kind!=="init")return g.none();return g.fromNullishOr(r)}function oo(e,t){let n=[],r=!1;for(let o of On){let i=Yt(t,o);if(i.status==="manual")return{kind:"manual",reason:dn};if(i.status==="missing"){n.push(o);continue}let s=i.property.value;if(s.type!=="Literal"||typeof s.value!=="boolean")return{kind:"manual",reason:dn};if(s.value)continue;s.raw="true",s.value=!0,r=!0}if(n.length>0){let o=no(n);if(g.isNone(o))return{kind:"manual",reason:jn};t.properties.unshift(...o.value),r=!0}if(!r)return{kind:"configured"};return{kind:"patchable",updatedContent:Sn(e)}}function Ht(e){let t=Zt(e);if(g.isNone(t))return{kind:"manual",reason:hn};let n=Xt(t.value);if(g.isNone(n))return{kind:"manual",reason:hn};let r=Yt(n.value,"options");if(r.status==="manual")return{kind:"manual",reason:mn};if(r.status==="missing"){let o=ro();if(g.isNone(o))return{kind:"manual",reason:jn};return n.value.properties.unshift(o.value),{kind:"patchable",updatedContent:Sn(t.value)}}if(!st(r.property.value))return{kind:"manual",reason:mn};return oo(t.value,r.property.value)}var U=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}];var y=I({assess:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,n=yield*xe.Path,r=yield*v(e),o=H(r);if(!o.includes("check")&&!o.includes("fix"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxlint??r.dependencies?.oxlint,s=n.join(e,U[0].path),a=n.join(e,U[1].path),{hasJson:u,hasTs:f}=yield*X.all({hasJson:t.exists(a),hasTs:t.exists(s)},{concurrency:"unbounded"}),l={active:f?{format:"ts",path:s}:u?{format:"json",path:a}:null,legacy:f&&u?[{format:"json",path:a}]:[]},p=[],E=[];if(l.active?.format==="ts"&&l.legacy.length>0)E.push("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(!i)p.push({description:`Install \`oxlint@${"1.76.0"}\` for the managed lint scripts.`,package:"oxlint",targetVersion:"1.76.0",type:"install_package"});else if(Y(i)!=="1.76.0")p.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${"1.76.0"}\`.`,package:"oxlint",targetVersion:"1.76.0",type:"update_package"});if(l.active===null)p.push({description:`Create \`${U[0].path}\` for \`oxlint\`.`,path:U[0].path,type:"create_config"});if(l.active?.format==="json")p.push({description:`Migrate legacy \`${U[1].path}\` to \`${U[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(l.active?.format==="ts"){let S=yield*t.readFileString(s).pipe(X.mapError((P)=>new R({cause:P,path:s}))),T=Ht(S);if(T.kind==="patchable")p.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:U[0].path,type:"update_config"});if(T.kind==="manual")p.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:U[0].path,type:"manual_fix"})}return{actions:p,applicable:!0,warnings:E}}),config:U[0].path,create:(e,t=[])=>X.gen(function*(){let n=yield*Ke.FileSystem,o=(yield*xe.Path).join(e,U[0].path),i=ft({},at(t));yield*n.writeFileString(o,i).pipe(X.mapError((s)=>new j({cause:s,path:o})))}),detect:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,n=yield*xe.Path,r=n.join(e,U[0].path),o=n.join(e,U[1].path),{hasJson:i,hasTs:s}=yield*X.all({hasJson:t.exists(o),hasTs:t.exists(r)},{concurrency:"unbounded"}),a=s?"ts":i?"json":null,u=[];if(s&&i)u.push({format:"json",path:o});return{active:a===null?null:{format:a,path:a==="ts"?r:o},legacy:u}}),files:U,kind:"tooling",name:"oxlint",update:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,r=(yield*xe.Path).join(e,U[0].path);if(!(yield*t.exists(r)))return yield*new zt({path:U[0].path});let o=yield*t.readFileString(r).pipe(X.mapError((s)=>new R({cause:s,path:r}))),i=Ht(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new bt({path:U[0].path,reason:i.reason});yield*t.writeFileString(r,i.updatedContent).pipe(X.mapError((s)=>new j({cause:s,path:r})))}),version:"1.76.0"});var io=Ne.file("files",{mustExist:!0}).pipe(Ne.withDescription("Specific files to lint (optional)"),Ne.variadic()),Kt=Te.make("check",{files:io}).pipe(Te.withDescription("Find issues and type errors in code using oxlint"),Te.withHandler(({files:e})=>$n.gen(function*(){let t=yield*B,r=yield*(yield*_).run({args:[...e,...t],command:y.name});if(r!==Fn.ExitCode(0))yield*new b({command:y.name,exitCode:r})})));import $o from"node:process";import*as qe from"effect/Effect";import*as ze from"effect/unstable/cli/Command";import*as St from"effect/unstable/cli/Flag";import*as Mt from"effect/unstable/process/ChildProcessSpawner";import*as oe from"effect/Effect";import*as pt from"effect/FileSystem";import*as ut from"effect/Path";var so=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function ao(e){let t=e.split(`
15
+ `,t=Zt(e);if(g.isNone(t))return g.none();let n=Xt(t.value);if(g.isNone(n)||n.value.properties.length!==1)return g.none();let[r]=n.value.properties;if(!r||!Wt(r)||r.computed||r.method||r.kind!=="init")return g.none();return g.fromNullishOr(r)}function oo(e,t){let n=[],r=!1;for(let o of On){let i=Yt(t,o);if(i.status==="manual")return{kind:"manual",reason:dn};if(i.status==="missing"){n.push(o);continue}let s=i.property.value;if(s.type!=="Literal"||typeof s.value!=="boolean")return{kind:"manual",reason:dn};if(s.value)continue;s.raw="true",s.value=!0,r=!0}if(n.length>0){let o=no(n);if(g.isNone(o))return{kind:"manual",reason:jn};t.properties.unshift(...o.value),r=!0}if(!r)return{kind:"configured"};return{kind:"patchable",updatedContent:Sn(e)}}function Ht(e){let t=Zt(e);if(g.isNone(t))return{kind:"manual",reason:hn};let n=Xt(t.value);if(g.isNone(n))return{kind:"manual",reason:hn};let r=Yt(n.value,"options");if(r.status==="manual")return{kind:"manual",reason:mn};if(r.status==="missing"){let o=ro();if(g.isNone(o))return{kind:"manual",reason:jn};return n.value.properties.unshift(o.value),{kind:"patchable",updatedContent:Sn(t.value)}}if(!st(r.property.value))return{kind:"manual",reason:mn};return oo(t.value,r.property.value)}var U=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}];var y=I({assess:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,n=yield*xe.Path,r=yield*v(e),o=H(r);if(!o.includes("check")&&!o.includes("fix"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxlint??r.dependencies?.oxlint,s=n.join(e,U[0].path),a=n.join(e,U[1].path),{hasJson:u,hasTs:f}=yield*X.all({hasJson:t.exists(a),hasTs:t.exists(s)},{concurrency:"unbounded"}),l={active:f?{format:"ts",path:s}:u?{format:"json",path:a}:null,legacy:f&&u?[{format:"json",path:a}]:[]},p=[],E=[];if(l.active?.format==="ts"&&l.legacy.length>0)E.push("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(!i)p.push({description:`Install \`oxlint@${"1.77.0"}\` for the managed lint scripts.`,package:"oxlint",targetVersion:"1.77.0",type:"install_package"});else if(Y(i)!=="1.77.0")p.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${"1.77.0"}\`.`,package:"oxlint",targetVersion:"1.77.0",type:"update_package"});if(l.active===null)p.push({description:`Create \`${U[0].path}\` for \`oxlint\`.`,path:U[0].path,type:"create_config"});if(l.active?.format==="json")p.push({description:`Migrate legacy \`${U[1].path}\` to \`${U[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(l.active?.format==="ts"){let S=yield*t.readFileString(s).pipe(X.mapError((P)=>new R({cause:P,path:s}))),T=Ht(S);if(T.kind==="patchable")p.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:U[0].path,type:"update_config"});if(T.kind==="manual")p.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:U[0].path,type:"manual_fix"})}return{actions:p,applicable:!0,warnings:E}}),config:U[0].path,create:(e,t=[])=>X.gen(function*(){let n=yield*Ke.FileSystem,o=(yield*xe.Path).join(e,U[0].path),i=ft({},at(t));yield*n.writeFileString(o,i).pipe(X.mapError((s)=>new j({cause:s,path:o})))}),detect:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,n=yield*xe.Path,r=n.join(e,U[0].path),o=n.join(e,U[1].path),{hasJson:i,hasTs:s}=yield*X.all({hasJson:t.exists(o),hasTs:t.exists(r)},{concurrency:"unbounded"}),a=s?"ts":i?"json":null,u=[];if(s&&i)u.push({format:"json",path:o});return{active:a===null?null:{format:a,path:a==="ts"?r:o},legacy:u}}),files:U,kind:"tooling",name:"oxlint",update:(e)=>X.gen(function*(){let t=yield*Ke.FileSystem,r=(yield*xe.Path).join(e,U[0].path);if(!(yield*t.exists(r)))return yield*new zt({path:U[0].path});let o=yield*t.readFileString(r).pipe(X.mapError((s)=>new R({cause:s,path:r}))),i=Ht(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new bt({path:U[0].path,reason:i.reason});yield*t.writeFileString(r,i.updatedContent).pipe(X.mapError((s)=>new j({cause:s,path:r})))}),version:"1.77.0"});var io=Ne.file("files",{mustExist:!0}).pipe(Ne.withDescription("Specific files to lint (optional)"),Ne.variadic()),Kt=Te.make("check",{files:io}).pipe(Te.withDescription("Find issues and type errors in code using oxlint"),Te.withHandler(({files:e})=>$n.gen(function*(){let t=yield*B,r=yield*(yield*_).run({args:[...e,...t],command:y.name});if(r!==Fn.ExitCode(0))yield*new b({command:y.name,exitCode:r})})));import $o from"node:process";import*as qe from"effect/Effect";import*as ze from"effect/unstable/cli/Command";import*as St from"effect/unstable/cli/Flag";import*as Mt from"effect/unstable/process/ChildProcessSpawner";import*as oe from"effect/Effect";import*as pt from"effect/FileSystem";import*as ut from"effect/Path";var so=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function ao(e){let t=e.split(`
16
16
  `);if(t.length===1)return e.slice(1,-1).trim();return t.slice(1,-1).map((n)=>` ${n.trimStart()}`).join(`
17
17
  `)}function fo(e,t){let n=Re(t),r=ao(n);return[` ${e}: {`,` ...format.${e},`,...r===""?[]:[r]," },"].join(`
18
18
  `)}function lt(e={}){let t=Object.entries(e).map(([n,r])=>{if(so.has(n)&&N(r))return fo(n,r);let o=Re(r,{continuationIndent:" "});return` ${n}: ${o},`});if(t.length===0)return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig(format)",""].join(`
19
19
  `);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...t,"})",""].join(`
20
- `)}var Q=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var m=I({assess:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,n=yield*ut.Path,r=yield*v(e);if(!H(r).includes("format"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxfmt??r.dependencies?.oxfmt,s=n.join(e,Q[0].path),a=n.join(e,Q[1].path),u=n.join(e,Q[2].path),{hasConfig:f,hasLegacyJson:l,hasLegacyJsonc:p}=yield*oe.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(u)},{concurrency:"unbounded"}),E=f?"ts":p?"jsonc":l?"json":null,S=[],T=[];if(f&&(l||p))T.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!f&&l&&p)T.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@${"0.61.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.61.0",type:"install_package"});else if(Y(i)!=="0.61.0")S.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.61.0"}\`.`,package:"oxfmt",targetVersion:"0.61.0",type:"update_package"});if(E===null)S.push({description:`Create \`${Q[0].path}\` for \`oxfmt\`.`,path:Q[0].path,type:"create_config"});if(E==="json"||E==="jsonc")S.push({description:`Migrate legacy \`${E==="json"?Q[1].path:Q[2].path}\` to \`${Q[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:T}}),config:Q[0].path,create:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,r=(yield*ut.Path).join(e,Q[0].path);yield*t.writeFileString(r,lt()).pipe(oe.mapError((o)=>new j({cause:o,path:r})))}),detect:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,n=yield*ut.Path,r=n.join(e,Q[0].path),o=n.join(e,Q[1].path),i=n.join(e,Q[2].path),{hasJson:s,hasJsonc:a,hasTs:u}=yield*oe.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),f=u?"ts":a?"jsonc":s?"json":null,l=[];if(u&&s)l.push({format:"json",path:o});if(u&&a)l.push({format:"jsonc",path:i});if(!u&&s&&a)l.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?r:f==="jsonc"?i:o},legacy:l}}),files:Q,kind:"tooling",name:"oxfmt",version:"0.61.0"});import*as vn from"effect/Effect";var L=I({assess:(e)=>vn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check:monorepo")&&!n.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.sherif??t.dependencies?.sherif,o=[];if(!r)o.push({description:`Install \`sherif@${"1.13.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.13.0",type:"install_package"});else if(Y(r)!=="1.13.0")o.push({currentVersion:r,description:`Update \`sherif\` from \`${r}\` 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 Rn from"effect/Effect";var le=I({assess:(e)=>Rn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check")&&!n.includes("fix"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.["oxlint-tsgolint"]??t.dependencies?.["oxlint-tsgolint"],o=[];if(!r)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(Y(r)!=="7.0.2001")o.push({currentVersion:r,description:`Update \`oxlint-tsgolint\` from \`${r}\` 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 W from"effect/Effect";import*as Dn from"effect/FileSystem";import*as Vn from"effect/Path";function pe(e){return e}function Le(e,t,n){return W.gen(function*(){let r=yield*Dn.FileSystem,o=yield*Vn.Path,i=e.files??[],s=new Map;for(let a of i){let u=o.join(t.cwd,a);if(yield*r.exists(u)){let l=yield*r.readFileString(u);s.set(u,l)}else s.set(u,null)}yield*e.migrate(t).pipe(W.andThen(()=>e.validate?.(t)??W.void),W.onError(()=>W.gen(function*(){if(n?.onRestore)yield*n.onRestore;for(let[a,u]of s){if(u!==null){yield*r.writeFileString(a,u).pipe(W.ignore);continue}if(!(yield*r.exists(a).pipe(W.orElseSucceed(()=>!1))))continue;yield*r.remove(a).pipe(W.ignore)}})))})}import*as C from"effect/Effect";import*as Tn from"effect/FileSystem";import*as _n from"effect/Path";import*as D from"@clack/prompts";import*as Pn from"effect/Context";import*as V from"effect/Effect";import*as In from"effect/Exit";import*as Nn from"effect/Layer";class O extends Pn.Service()("Prompter"){static layer=Nn.succeed(this)({cancel:(e)=>V.sync(()=>{D.cancel(e)}),confirm:(e)=>V.promise(()=>D.confirm(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),intro:(e)=>V.sync(()=>{D.intro(e)}),log:{error:(e)=>V.sync(()=>{D.log.error(e)}),info:(e)=>V.sync(()=>{D.log.info(e)}),success:(e)=>V.sync(()=>{D.log.success(e)}),warning:(e)=>V.sync(()=>{D.log.warning(e)})},multiselect:(e)=>V.promise(()=>D.multiselect(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),outro:(e)=>V.sync(()=>{D.outro(e)}),withSpinner:(e,t)=>V.acquireUseRelease(V.sync(()=>{let n=D.spinner();return n.start(t.start),n}),(n)=>e({message:(r)=>V.sync(()=>{n.message(r)})}),(n,r)=>V.sync(()=>{n.stop(In.match(r,{onFailure:()=>t.failure,onSuccess:(o)=>typeof t.success==="function"?t.success(o):t.success}))}))})}function qn(){return[h.files[1].path,h.files[2].path]}function lo(e){let t=qn();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${h.config}\`.`}function po(e){return C.gen(function*(){let t=yield*Tn.FileSystem,n=yield*_n.Path,r=yield*h.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,h.config),s=yield*t.readFileString(o).pipe(C.mapError((p)=>new R({cause:p,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a;yield*t.writeFileString(i,rt(f)).pipe(C.mapError((p)=>new j({cause:p,path:i}))),yield*t.remove(o).pipe(C.mapError((p)=>new ne({cause:p,path:o})));let l=r.legacy[0]?.path??null;if(l&&l!==o)yield*t.remove(l).pipe(C.mapError((p)=>new ne({cause:p,path:l})))})}var xt=pe({check:(e)=>C.gen(function*(){let t=yield*h.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.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)n.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:lo(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[h.config,...qn()],id:"legacy-knip-json",migrate:(e)=>C.gen(function*(){let t=yield*O,r=(yield*h.detect(e.cwd)).active?.path.endsWith(h.files[2].path)?h.files[2].path:h.files[1].path;yield*t.withSpinner(()=>po(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${h.config}\`...`,success:`Knip config migrated to \`${h.config}\` successfully.`})}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>C.gen(function*(){if((yield*h.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-knip-json",reason:`\`${h.config}\` is not the active Knip config.`})})});import*as ee from"effect/Effect";import*as zn from"effect/FileSystem";import*as bn from"effect/Path";function Un(){return[m.files[1].path,m.files[2].path]}function uo(e){let t=Un();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function co(e){return ee.gen(function*(){let t=yield*zn.FileSystem,n=yield*bn.Path,r=yield*m.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,m.config),s=yield*t.readFileString(o).pipe(ee.mapError((p)=>new R({cause:p,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a;yield*t.writeFileString(i,lt(f)).pipe(ee.mapError((p)=>new j({cause:p,path:i}))),yield*t.remove(o).pipe(ee.mapError((p)=>new ne({cause:p,path:o})));let l=r.legacy[0]?.path??null;if(l&&l!==o)yield*t.remove(l).pipe(ee.mapError((p)=>new ne({cause:p,path:l})))})}var Lt=pe({check:(e)=>ee.gen(function*(){let t=yield*m.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.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)n.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:uo(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[m.config,...Un()],id:"legacy-oxfmt-json",migrate:(e)=>ee.gen(function*(){let t=yield*O,r=(yield*m.detect(e.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;yield*t.withSpinner(()=>co(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${m.config}\`...`,success:`Oxfmt config migrated to \`${m.config}\` successfully.`})}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>ee.gen(function*(){if((yield*m.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxfmt-json",reason:`\`${m.config}\` is not the active oxfmt config.`})})});import*as ie from"effect/Effect";import*as kn from"effect/FileSystem";import*as An from"effect/Path";function yo(e){return ie.gen(function*(){let t=yield*kn.FileSystem,n=yield*An.Path,r=yield*y.detect(e);if(r.active?.format!=="json")return;let o=r.active.path,i=n.join(e,y.config),s=yield*t.readFileString(o).pipe(ie.mapError((P)=>new R({cause:P,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a,l=Array.isArray(f.extends)?f.extends.filter((P)=>typeof P==="string"):typeof f.extends==="string"?[f.extends]:[],p=new Set(at()),E=new Set;for(let P of l){let te=P.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),c=P.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),z=te?.[1]??(c?c[1]??"core":null);if(z)p.add(z);else E.add(P)}let{extends:S,...T}=f;yield*t.writeFileString(i,ft(T,[...p],[...E])).pipe(ie.mapError((P)=>new j({cause:P,path:i}))),yield*t.remove(o).pipe(ie.mapError((P)=>new ne({cause:P,path:o})))})}var wt=pe({id:"legacy-oxlint-json",files:[y.config,y.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(e)=>ie.gen(function*(){let t=yield*y.detect(e.cwd),n=t.active?.format==="ts"&&t.legacy.length>0?[`Found both \`${y.config}\` and \`${y.files[1].path}\`. Adamantite will use \`${y.config}\`.`]:[];if(t.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${y.files[1].path}\` configuration to \`${y.config}\`.`,warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),migrate:(e)=>ie.gen(function*(){yield*(yield*O).withSpinner(()=>yo(e.cwd),{failure:`Failed to migrate ${y.files[1].path}.`,start:`Migrating \`${y.files[1].path}\` to \`${y.config}\`...`,success:`Oxlint config migrated to \`${y.config}\` successfully.`})}),validate:(e)=>ie.gen(function*(){if((yield*y.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxlint-json",reason:`\`${y.config}\` is not the active oxlint config.`})})});import*as Se from"effect/Effect";import*as Oe from"effect/Effect";import*as ht from"effect/FileSystem";import*as mt from"effect/Path";import*as ct from"effect/Effect";import*as Jn from"effect/FileSystem";var Bn=(e)=>ct.gen(function*(){yield*(yield*Jn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(ct.mapError((n)=>new ge({cause:n,path:e})))});import{runScriptCommand as ho}from"nypm";var Qn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Wn(e,t){let n=[];for(let r of Qn){if(!t.includes(r.script))continue;n.push({command:ho(e,r.script,{args:r.args}),name:r.name})}return n}function we(e){return Qn.some((t)=>e.includes(t.script))}var mo={bun:` - name: Setup Node.js
20
+ `)}var Q=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var m=I({assess:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,n=yield*ut.Path,r=yield*v(e);if(!H(r).includes("format"))return{applicable:!1,warnings:[]};let i=r.devDependencies?.oxfmt??r.dependencies?.oxfmt,s=n.join(e,Q[0].path),a=n.join(e,Q[1].path),u=n.join(e,Q[2].path),{hasConfig:f,hasLegacyJson:l,hasLegacyJsonc:p}=yield*oe.all({hasConfig:t.exists(s),hasLegacyJson:t.exists(a),hasLegacyJsonc:t.exists(u)},{concurrency:"unbounded"}),E=f?"ts":p?"jsonc":l?"json":null,S=[],T=[];if(f&&(l||p))T.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!f&&l&&p)T.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@${"0.62.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.62.0",type:"install_package"});else if(Y(i)!=="0.62.0")S.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.62.0"}\`.`,package:"oxfmt",targetVersion:"0.62.0",type:"update_package"});if(E===null)S.push({description:`Create \`${Q[0].path}\` for \`oxfmt\`.`,path:Q[0].path,type:"create_config"});if(E==="json"||E==="jsonc")S.push({description:`Migrate legacy \`${E==="json"?Q[1].path:Q[2].path}\` to \`${Q[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:S,applicable:!0,warnings:T}}),config:Q[0].path,create:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,r=(yield*ut.Path).join(e,Q[0].path);yield*t.writeFileString(r,lt()).pipe(oe.mapError((o)=>new j({cause:o,path:r})))}),detect:(e)=>oe.gen(function*(){let t=yield*pt.FileSystem,n=yield*ut.Path,r=n.join(e,Q[0].path),o=n.join(e,Q[1].path),i=n.join(e,Q[2].path),{hasJson:s,hasJsonc:a,hasTs:u}=yield*oe.all({hasJson:t.exists(o),hasJsonc:t.exists(i),hasTs:t.exists(r)},{concurrency:"unbounded"}),f=u?"ts":a?"jsonc":s?"json":null,l=[];if(u&&s)l.push({format:"json",path:o});if(u&&a)l.push({format:"jsonc",path:i});if(!u&&s&&a)l.push({format:"json",path:o});return{active:f===null?null:{format:f,path:f==="ts"?r:f==="jsonc"?i:o},legacy:l}}),files:Q,kind:"tooling",name:"oxfmt",version:"0.62.0"});import*as vn from"effect/Effect";var L=I({assess:(e)=>vn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check:monorepo")&&!n.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.sherif??t.dependencies?.sherif,o=[];if(!r)o.push({description:`Install \`sherif@${"1.13.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.13.0",type:"install_package"});else if(Y(r)!=="1.13.0")o.push({currentVersion:r,description:`Update \`sherif\` from \`${r}\` 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 Rn from"effect/Effect";var le=I({assess:(e)=>Rn.gen(function*(){let t=yield*v(e),n=H(t);if(!n.includes("check")&&!n.includes("fix"))return{applicable:!1,warnings:[]};let r=t.devDependencies?.["oxlint-tsgolint"]??t.dependencies?.["oxlint-tsgolint"],o=[];if(!r)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(Y(r)!=="7.0.2001")o.push({currentVersion:r,description:`Update \`oxlint-tsgolint\` from \`${r}\` 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 W from"effect/Effect";import*as Dn from"effect/FileSystem";import*as Vn from"effect/Path";function pe(e){return e}function Le(e,t,n){return W.gen(function*(){let r=yield*Dn.FileSystem,o=yield*Vn.Path,i=e.files??[],s=new Map;for(let a of i){let u=o.join(t.cwd,a);if(yield*r.exists(u)){let l=yield*r.readFileString(u);s.set(u,l)}else s.set(u,null)}yield*e.migrate(t).pipe(W.andThen(()=>e.validate?.(t)??W.void),W.onError(()=>W.gen(function*(){if(n?.onRestore)yield*n.onRestore;for(let[a,u]of s){if(u!==null){yield*r.writeFileString(a,u).pipe(W.ignore);continue}if(!(yield*r.exists(a).pipe(W.orElseSucceed(()=>!1))))continue;yield*r.remove(a).pipe(W.ignore)}})))})}import*as C from"effect/Effect";import*as Tn from"effect/FileSystem";import*as _n from"effect/Path";import*as D from"@clack/prompts";import*as Pn from"effect/Context";import*as V from"effect/Effect";import*as In from"effect/Exit";import*as Nn from"effect/Layer";class O extends Pn.Service()("Prompter"){static layer=Nn.succeed(this)({cancel:(e)=>V.sync(()=>{D.cancel(e)}),confirm:(e)=>V.promise(()=>D.confirm(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),intro:(e)=>V.sync(()=>{D.intro(e)}),log:{error:(e)=>V.sync(()=>{D.log.error(e)}),info:(e)=>V.sync(()=>{D.log.info(e)}),success:(e)=>V.sync(()=>{D.log.success(e)}),warning:(e)=>V.sync(()=>{D.log.warning(e)})},multiselect:(e)=>V.promise(()=>D.multiselect(e)).pipe(V.filterOrFail((t)=>!D.isCancel(t),()=>new nt({}))),outro:(e)=>V.sync(()=>{D.outro(e)}),withSpinner:(e,t)=>V.acquireUseRelease(V.sync(()=>{let n=D.spinner();return n.start(t.start),n}),(n)=>e({message:(r)=>V.sync(()=>{n.message(r)})}),(n,r)=>V.sync(()=>{n.stop(In.match(r,{onFailure:()=>t.failure,onSuccess:(o)=>typeof t.success==="function"?t.success(o):t.success}))}))})}function qn(){return[h.files[1].path,h.files[2].path]}function lo(e){let t=qn();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${h.config}\`.`}function po(e){return C.gen(function*(){let t=yield*Tn.FileSystem,n=yield*_n.Path,r=yield*h.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,h.config),s=yield*t.readFileString(o).pipe(C.mapError((p)=>new R({cause:p,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a;yield*t.writeFileString(i,rt(f)).pipe(C.mapError((p)=>new j({cause:p,path:i}))),yield*t.remove(o).pipe(C.mapError((p)=>new ne({cause:p,path:o})));let l=r.legacy[0]?.path??null;if(l&&l!==o)yield*t.remove(l).pipe(C.mapError((p)=>new ne({cause:p,path:l})))})}var xt=pe({check:(e)=>C.gen(function*(){let t=yield*h.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.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)n.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:lo(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[h.config,...qn()],id:"legacy-knip-json",migrate:(e)=>C.gen(function*(){let t=yield*O,r=(yield*h.detect(e.cwd)).active?.path.endsWith(h.files[2].path)?h.files[2].path:h.files[1].path;yield*t.withSpinner(()=>po(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${h.config}\`...`,success:`Knip config migrated to \`${h.config}\` successfully.`})}),tags:["update"],title:"Legacy Knip JSON config",validate:(e)=>C.gen(function*(){if((yield*h.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-knip-json",reason:`\`${h.config}\` is not the active Knip config.`})})});import*as ee from"effect/Effect";import*as zn from"effect/FileSystem";import*as bn from"effect/Path";function Un(){return[m.files[1].path,m.files[2].path]}function uo(e){let t=Un();return`Migrating legacy \`${e==="json"?t[0]:t[1]}\` configuration to \`${m.config}\`.`}function co(e){return ee.gen(function*(){let t=yield*zn.FileSystem,n=yield*bn.Path,r=yield*m.detect(e);if(r.active?.format!=="json"&&r.active?.format!=="jsonc")return;let o=r.active.path,i=n.join(e,m.config),s=yield*t.readFileString(o).pipe(ee.mapError((p)=>new R({cause:p,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a;yield*t.writeFileString(i,lt(f)).pipe(ee.mapError((p)=>new j({cause:p,path:i}))),yield*t.remove(o).pipe(ee.mapError((p)=>new ne({cause:p,path:o})));let l=r.legacy[0]?.path??null;if(l&&l!==o)yield*t.remove(l).pipe(ee.mapError((p)=>new ne({cause:p,path:l})))})}var Lt=pe({check:(e)=>ee.gen(function*(){let t=yield*m.detect(e.cwd),n=[];if(t.active?.format==="ts"&&t.legacy.length>0)n.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)n.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:uo(t.active.format),warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),files:[m.config,...Un()],id:"legacy-oxfmt-json",migrate:(e)=>ee.gen(function*(){let t=yield*O,r=(yield*m.detect(e.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;yield*t.withSpinner(()=>co(e.cwd),{failure:`Failed to migrate ${r}.`,start:`Migrating \`${r}\` to \`${m.config}\`...`,success:`Oxfmt config migrated to \`${m.config}\` successfully.`})}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(e)=>ee.gen(function*(){if((yield*m.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxfmt-json",reason:`\`${m.config}\` is not the active oxfmt config.`})})});import*as ie from"effect/Effect";import*as kn from"effect/FileSystem";import*as An from"effect/Path";function yo(e){return ie.gen(function*(){let t=yield*kn.FileSystem,n=yield*An.Path,r=yield*y.detect(e);if(r.active?.format!=="json")return;let o=r.active.path,i=n.join(e,y.config),s=yield*t.readFileString(o).pipe(ie.mapError((P)=>new R({cause:P,path:o}))),a=yield*A(s,o);if(!N(a))return yield*new Z({path:o});let{$schema:u,...f}=a,l=Array.isArray(f.extends)?f.extends.filter((P)=>typeof P==="string"):typeof f.extends==="string"?[f.extends]:[],p=new Set(at()),E=new Set;for(let P of l){let te=P.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),c=P.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),z=te?.[1]??(c?c[1]??"core":null);if(z)p.add(z);else E.add(P)}let{extends:S,...T}=f;yield*t.writeFileString(i,ft(T,[...p],[...E])).pipe(ie.mapError((P)=>new j({cause:P,path:i}))),yield*t.remove(o).pipe(ie.mapError((P)=>new ne({cause:P,path:o})))})}var wt=pe({id:"legacy-oxlint-json",files:[y.config,y.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(e)=>ie.gen(function*(){let t=yield*y.detect(e.cwd),n=t.active?.format==="ts"&&t.legacy.length>0?[`Found both \`${y.config}\` and \`${y.files[1].path}\`. Adamantite will use \`${y.config}\`.`]:[];if(t.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${y.files[1].path}\` configuration to \`${y.config}\`.`,warnings:n};if(t.active?.format==="ts")return{applicable:!0,warnings:n};return{applicable:!1,warnings:n}}),migrate:(e)=>ie.gen(function*(){yield*(yield*O).withSpinner(()=>yo(e.cwd),{failure:`Failed to migrate ${y.files[1].path}.`,start:`Migrating \`${y.files[1].path}\` to \`${y.config}\`...`,success:`Oxlint config migrated to \`${y.config}\` successfully.`})}),validate:(e)=>ie.gen(function*(){if((yield*y.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-oxlint-json",reason:`\`${y.config}\` is not the active oxlint config.`})})});import*as Se from"effect/Effect";import*as Oe from"effect/Effect";import*as ht from"effect/FileSystem";import*as mt from"effect/Path";import*as ct from"effect/Effect";import*as Jn from"effect/FileSystem";var Bn=(e)=>ct.gen(function*(){yield*(yield*Jn.FileSystem).makeDirectory(e,{recursive:!0}).pipe(ct.mapError((n)=>new ge({cause:n,path:e})))});import{runScriptCommand as ho}from"nypm";var Qn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Wn(e,t){let n=[];for(let r of Qn){if(!t.includes(r.script))continue;n.push({command:ho(e,r.script,{args:r.args}),name:r.name})}return n}function we(e){return Qn.some((t)=>e.includes(t.script))}var mo={bun:` - name: Setup Node.js
21
21
  uses: actions/setup-node@v6
22
22
  with:
23
23
  node-version: "22"
@@ -119,4 +119,4 @@ ${mo[e]}
119
119
  `:`
120
120
 
121
121
  `;return yield*n.writeFileString(o,`${s}${l}${f}`).pipe(ve.mapError((p)=>new j({cause:p,path:o}))),"updated"});import bo from"node:process";import*as gr from"effect/Effect";import*as Or from"effect/FileSystem";import*as jr from"effect/Path";var tn=(e=bo.cwd())=>gr.gen(function*(){let t=yield*Or.FileSystem,n=yield*jr.Path;if(yield*t.exists(n.join(e,"pnpm-workspace.yaml")))return!0;return(yield*v(e)).workspaces!==void 0});var ko=(e,t)=>d.gen(function*(){let n=yield*K;yield*(yield*O).withSpinner(()=>d.gen(function*(){let o=yield*tn(e);yield*n.addDevDependencies(t,e,{silent:!0,workspace:o})}),{failure:"Failed to install dependencies.",start:"Installing dependencies...",success:"Dependencies installed."})});function nn(e,t){return d.gen(function*(){yield*(yield*O).log.info(`Legacy \`${t}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${e} configs yet.`)})}var Ao=(e,t)=>d.gen(function*(){let n=yield*O,r=yield*n.withSpinner((o)=>d.gen(function*(){let i=yield*y.detect(e),s=y.files[1].path;if(i.active?.format==="ts"&&i.legacy.length>0)yield*n.log.warning(`Found both \`${y.config}\` and \`${s}\`. Adamantite will use \`${y.config}\`.`);if(i.active?.format==="json")return yield*o.message(`Found \`${s}\`, keeping existing config.`),{created:!1,legacyConfig:s};if(i.active?.format==="ts")return yield*o.message(`Found \`${y.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*o.message(`\`${y.config}\` not found, creating...`),yield*y.create(e,t),{created:!0,legacyConfig:null}}),{failure:"Failed to set up oxlint config.",start:"Setting up oxlint config...",success:(o)=>o.created?"oxlint config created successfully.":"oxlint config is ready."});if(r.legacyConfig)yield*nn("oxlint",r.legacyConfig)}),Jo=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*m.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${m.config}\` and \`.oxfmtrc.json(c)\`. Adamantite will use \`${m.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.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(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(m.files[1].path)?m.files[1].path:m.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${m.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${m.config}\` not found, creating...`),yield*m.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up oxfmt config.",start:"Setting up oxfmt config...",success:(r)=>r.created?"oxfmt config created successfully.":"oxfmt config is ready."});if(n.legacyConfig)yield*nn("oxfmt",n.legacyConfig)}),Bo=(e,t)=>d.gen(function*(){let n=yield*vr.FileSystem,r=yield*Rr.Path,o=yield*O,i=yield*v(e);yield*o.withSpinner(()=>d.gen(function*(){i.scripts??={};for(let a of t)switch(a){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 kt({script:a})}let s=r.join(e,"package.json");yield*n.writeFileString(s,`${JSON.stringify(i,null,2)}
122
- `).pipe(d.mapError((a)=>new j({cause:a,path:s})))}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:"Scripts added to your `package.json`"})}),Qo=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*h.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${h.config}\` and \`knip.json(c)\`. Adamantite will use \`${h.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.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(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(h.files[1].path)?h.files[1].path:h.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${h.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${h.config}\` not found, creating...`),yield*h.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up knip config.",start:"Setting up knip config...",success:(r)=>r.created?"knip config created successfully.":"knip config is ready."});if(n.legacyConfig)yield*nn("knip",n.legacyConfig)}),Wo=(e)=>d.gen(function*(){yield*(yield*O).withSpinner((n)=>d.gen(function*(){if(yield*k.detect(e))return yield*n.message(`\`${k.config}\` found, updating...`),yield*k.update(e),!1;return yield*n.message(`\`${k.config}\` not found, creating...`),yield*k.create(e),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(n)=>n?`\`${k.config}\` created successfully`:`\`${k.config}\` updated successfully`})}),Zo=(e,t)=>d.gen(function*(){let n=yield*O;if(t.includes("vscode"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*ye.detect(e);return yield*r.message(`\`${ye.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?ye.update(e):ye.create(e),!o}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${ye.config}\`...`,success:(r)=>`\`${ye.config}\` ${r?"created":"updated"} with Adamantite preset.`});if(t.includes("zed"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*Fe.detect(e);return yield*r.message(`\`${Fe.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?Fe.update(e):Fe.create(e),!o}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Fe.config}\`...`,success:(r)=>`\`${Fe.config}\` ${r?"created":"updated"} with Adamantite preset.`})}),Xo=(e,t)=>d.gen(function*(){let n=yield*O,r=e.includes("zed"),o=e.includes("vscode");if(yield*n.withSpinner((i)=>d.gen(function*(){if(o)yield*i.message("Installing VS Code extension..."),yield*ye.extension(t);return!0}),{start:"Installing editor extensions...",success:r&&!o?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe(d.catchTag("FailedToInstallExtension",(i)=>d.gen(function*(){return yield*n.log.warning(`⚠️ Failed to install the \`${i.extension}\` extension.`),yield*n.log.warning("Please install it manually after setup completes."),!1})),d.catchTag("VscodeCliNotFound",()=>d.gen(function*(){return yield*n.log.error("VSCode CLI ('code' command) not found."),yield*n.log.info("To install it:"),yield*n.log.info(" 1. Open VS Code"),yield*n.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*n.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),r)yield*n.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Yo=(e,t,n)=>d.gen(function*(){let r=yield*O,o=se.files[0].path;yield*r.withSpinner((i)=>d.gen(function*(){let s=yield*se.detect(e);return yield*i.message(s?`\`${o}\` found, updating...`:`Creating \`${o}\`...`),yield*s?se.update(e,{packageManager:t,scripts:n}):se.create(e,{packageManager:t,scripts:n}),!s}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(i)=>`GitHub Actions workflow ${i?"created":"updated"} successfully.`})}).pipe(d.option),Ho=(e,t,n)=>d.gen(function*(){let r=yield*O,o=yield*r.withSpinner(()=>Er(e,{packageManager:t,scripts:n}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe(d.catchTag(["FailedToReadFile","FailedToWriteFile"],(i)=>d.gen(function*(){return yield*r.log.warning(`Could not update AGENTS.md. ${i.message} Adamantite will continue initialization.`),"failed"})));if(o==="failed")return;if(o==="malformed")yield*r.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),Sr=["check","fix","format","check:monorepo","fix:monorepo","analyze"],$r=["react","nextjs","vue","jest","vitest","node"],Fr=["vscode","zed"],Ko=d.fn("validateInitOptions")(function*(e,t){let n={agents:e.agents,editors:Je.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,presets:Je.dedupe(e.presets),scripts:Je.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new M({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes("check")||n.scripts.includes("fix");if((n.scripts.includes("check:monorepo")||n.scripts.includes("fix:monorepo"))&&!t.isMonorepo)return yield*new M({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(n.presets.length>0&&!r)return yield*new M({reason:"`--preset` requires the `check` or `fix` script."});if(n.typescript&&!r)return yield*new M({reason:"`--typescript` requires the `check` or `fix` script."});if(n.installExtensions&&n.editors.length===0)return yield*new M({reason:"`--install-extensions` requires at least one `--editor`."});if(n.githubActions&&!we(n.scripts))return yield*new M({reason:"`--github-actions` requires a CI-compatible script."});if(n.githubActions&&t.nonInteractive&&!Ye(t.packageManager))return yield*new M({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return n}),xo=$.boolean("non-interactive").pipe($.withDescription("Configure without prompts; requires at least one --script")),Lo=$.choice("script",Sr).pipe($.atMost(Sr.length),$.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),wo=$.choice("preset",$r).pipe($.atMost($r.length),$.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),Mo=$.choice("editor",Fr).pipe($.atMost(Fr.length),$.withDescription("Editor to configure; may be specified multiple times")),Go=$.boolean("typescript").pipe($.withDescription("Configure the TypeScript preset; requires --script check or fix")),Co=$.boolean("install-extensions").pipe($.withDescription("Install recommended extensions; requires at least one --editor")),ei=$.boolean("github-actions").pipe($.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),ti=$.boolean("agents").pipe($.withDescription("Add Adamantite guidance to AGENTS.md")),ni=d.fn("collectInteractiveInitOptions")(function*(e){let t=yield*O,n=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:!e,hint:e?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!e,hint:e?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"}]}),r=n.includes("check")||n.includes("fix"),o=[];if(r)o=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 i=r?yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,s=yield*t.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),a=s.length>0?yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,u=we(n)?yield*t.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*t.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:s,githubActions:u,installExtensions:a,presets:o,scripts:n,typescript:i}}),Vr=he.make("init",{agents:ti,editors:Mo,githubActions:ei,installExtensions:Co,nonInteractive:xo,presets:wo,scripts:Lo,typescript:Go}).pipe(he.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),he.withExamples([{command:"adamantite init --non-interactive --script check",description:"Configure linting without prompts"},{command:"adamantite init --non-interactive --script check --script format --preset react --editor vscode --typescript --install-extensions --github-actions --agents",description:"Configure a React project with VS Code, TypeScript, CI, and agent guidance"},{command:"adamantite init --non-interactive --script check:monorepo",description:"Configure monorepo checks in a detected monorepo"}]),he.withHandler((e)=>d.gen(function*(){let t=Uo.cwd(),n=yield*O;yield*_e(),yield*n.intro("\uD83D\uDCA0 adamantite init");let o=yield*(yield*K).detectPackageManager(t);if(!o)return yield*new Xe({});if(o.warnings?.length)for(let Ze of o.warnings)yield*n.log.warning(Ze);yield*n.log.info(`Detected package manager: ${o.name}`);let i=yield*tn(t);if(i)yield*n.log.info("We've detected a monorepo setup in your project.");if(!e.nonInteractive&&Je.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents],Dr.isTruthy))return yield*new M({reason:"Setup flags require `--non-interactive`."});let s=e.nonInteractive?e:yield*ni(i),a=yield*Ko(s,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:o.name}),u=a.scripts,f=a.presets,l=a.editors,p=a.typescript,E=a.installExtensions,S=a.githubActions,T=a.agents,P=u.includes("check")||u.includes("fix"),te=u.includes("format"),c=u.includes("check:monorepo")||u.includes("fix:monorepo"),z=u.includes("analyze"),Ee=["adamantite"];if(P)Ee.push(`${y.name}@${y.version}`,`${le.name}@${le.version}`);if(te)Ee.push(`${m.name}@${m.version}`);if(c)Ee.push(`${L.name}@${L.version}`);if(z)Ee.push(`${h.name}@${h.version}`);if(yield*ko(t,Ee),te)yield*Jo(t);if(P)yield*Ao(t,f);if(z)yield*Qo(t);if(yield*Bo(t,u),T)yield*Ho(t,o.name,u);if(p)yield*Wo(t);if(yield*Zo(t,l),E)yield*Xo(l,u);if(S){let Ze=o.name;if(Ye(Ze))yield*Yo(t,Ze,u);else yield*n.log.warning(`Skipping GitHub Actions setup: \`${Ze}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success("Your project is now configured"),yield*n.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(d.catchTags({OperationCancelled:()=>d.gen(function*(){yield*(yield*O).cancel("You've cancelled the initialization process.")})}))));import*as Pr from"effect/Effect";import*as Be from"effect/unstable/cli/Command";import*as Vt from"effect/unstable/cli/Flag";import*as Ir from"effect/unstable/process/ChildProcessSpawner";var ri=Vt.boolean("fix").pipe(Vt.withDescription("Automatically fix issues")),rn=Be.make("monorepo",{fix:ri}).pipe(Be.withDescription("Find and fix monorepo-specific issues using Sherif"),Be.withHandler(({fix:e})=>Pr.gen(function*(){let t=yield*B,n=yield*_,r=e?["--fix",...t]:[...t],o=yield*n.run({args:r,command:L.name,stdin:"inherit"});if(o!==Ir.ExitCode(0))yield*new b({command:L.name,exitCode:o})})));import*as Nr from"effect/Effect";import*as Qe from"effect/unstable/cli/Command";import*as Tr from"effect/unstable/process/ChildProcessSpawner";var on=Qe.make("typecheck").pipe(Qe.withDescription("Deprecated alias for `check`"),Qe.withHandler(()=>Nr.gen(function*(){let e=yield*B,t=yield*O,n=yield*_;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:y.name});if(r!==Tr.ExitCode(0))yield*new b({command:y.name,exitCode:r})})));import oi from"node:process";import*as me from"effect/Effect";import*as We from"effect/unstable/cli/Command";var ii=[y,le,m,L,h],si=[y,le,m,L,h];function ai(e,t){let n=[];for(let r of si){if(t.has(r.name))continue;let o=e.devDependencies?.[r.name]??e.dependencies?.[r.name];if(o&&Y(o)!==r.version)n.push({currentVersion:o,name:r.name,targetVersion:r.version})}return n}var _r=We.make("update").pipe(We.withDescription("Run applicable Adamantite migrations and update managed dependencies"),We.withHandler(()=>me.gen(function*(){let e=oi.cwd(),t=yield*O,n=yield*K,r={cwd:e};yield*_e(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>jt(ii,e),i=yield*o();for(let{assessment:c}of i)for(let z of c.warnings)yield*t.log.warning(z);let s=new Set(i.map(({integration:c})=>c.name)),a=i.flatMap(({assessment:c})=>c.actions),u=new Set(a.filter((c)=>c.type==="run_migration").map((c)=>c.migrationId)),f=[];for(let c of gt.filter((z)=>z.tags.includes("update"))){let z=Mn[c.id];if(s.has(z))continue;let Ee=yield*c.check(r);f.push({migration:c,result:Ee})}for(let c of f){for(let z of c.result.warnings)yield*t.log.warning(z);if(c.result.applicable&&c.result.summary)yield*t.log.info(c.result.summary)}let l=[];for(let c of gt){if(!u.has(c.id))continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),l.push(c.id)}for(let{migration:c,result:z}of f){if(!z.applicable||!z.summary)continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),l.push(c.id)}if(l.length>0)yield*t.log.success("Migrations ran successfully.");let p=yield*v(e),E=yield*o(),S=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="create_config"||c.type==="update_config"||c.type==="manual_fix"),T=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="install_package"||c.type==="update_package").map((c)=>c.type==="install_package"?{currentVersion:"not installed",name:c.package,targetVersion:c.targetVersion}:{currentVersion:c.currentVersion,name:c.package,targetVersion:c.targetVersion}),P=new Set(T.map((c)=>c.name)),te=[...T,...ai(p,P)];if(te.length>0){yield*t.log.info("The following dependencies will be updated:");for(let c of te)yield*t.log.info(` ${c.name}: ${c.currentVersion} → ${c.targetVersion}`);yield*t.withSpinner(()=>n.addDevDependencies(te.map((c)=>`${c.name}@${c.targetVersion}`),e,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"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 c of S)yield*t.log.warning(`Doctor follow-up: ${c.description}`)}if(l.length===0&&te.length===0&&S.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(me.tapError(()=>me.gen(function*(){yield*(yield*O).outro("❌ Update failed")})),me.tap((e)=>me.gen(function*(){let t=yield*O;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 fi=[Qt,Kt,Gt,Ct,rn,on],qr=[Qt,Kt,ir,Gt,Ct,Vr,rn,on,_r],li=new Set(qr.map((e)=>e.name)),pi=new Set(fi.map((e)=>e.name)),ui=de.make("adamantite").pipe(de.withDescription("Opinionated preset package for modern TypeScript applications"),de.withSubcommands(qr)),zr=It.fn("runCli")(function*(e,t){let[n,r]=Pt.splitWhere(e,(s)=>s==="--"),o=Pt.drop(r,1),i=n.find((s)=>li.has(s));if(o.length>0&&i!==void 0&&!pi.has(i))return yield*new Ut({command:i});yield*de.runWith(ui,{version:t})(n).pipe(It.provideService(B,o))});var ci=q.gen(function*(){let t=yield*(yield*Br.Stdio).args;yield*zr(t,"0.34.0")}).pipe(q.as(0),q.catchTag("CommandFailed",(e)=>q.succeed(e.exitCode)),q.catch((e)=>q.service(O).pipe(q.flatMap((t)=>t.log.error(e.message)),q.as(Qr.ExitCode(1)))),q.provide(Ar.mergeAll(Ur.layer,O.layer,_.layer,K.layer)));br.runMain(ci,{teardown:(e,t)=>{if(kr.isSuccess(e)){t(Number(e.value));return}Jr.defaultTeardown(e,t)}});
122
+ `).pipe(d.mapError((a)=>new j({cause:a,path:s})))}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:"Scripts added to your `package.json`"})}),Qo=(e)=>d.gen(function*(){let t=yield*O,n=yield*t.withSpinner((r)=>d.gen(function*(){let o=yield*h.detect(e);if(o.active?.format==="ts"&&o.legacy.length>0)yield*t.log.warning(`Found both \`${h.config}\` and \`knip.json(c)\`. Adamantite will use \`${h.config}\`.`);if(o.active&&o.active.format!=="ts"&&o.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(o.active?.format==="json"||o.active?.format==="jsonc"){let i=o.active.path.endsWith(h.files[1].path)?h.files[1].path:h.files[2].path;return yield*r.message(`Found \`${i}\`, keeping existing config.`),{created:!1,legacyConfig:i}}if(o.active?.format==="ts")return yield*r.message(`Found \`${h.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*r.message(`\`${h.config}\` not found, creating...`),yield*h.create(e),{created:!0,legacyConfig:null}}),{failure:"Failed to set up knip config.",start:"Setting up knip config...",success:(r)=>r.created?"knip config created successfully.":"knip config is ready."});if(n.legacyConfig)yield*nn("knip",n.legacyConfig)}),Wo=(e)=>d.gen(function*(){yield*(yield*O).withSpinner((n)=>d.gen(function*(){if(yield*k.detect(e))return yield*n.message(`\`${k.config}\` found, updating...`),yield*k.update(e),!1;return yield*n.message(`\`${k.config}\` not found, creating...`),yield*k.create(e),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(n)=>n?`\`${k.config}\` created successfully`:`\`${k.config}\` updated successfully`})}),Zo=(e,t)=>d.gen(function*(){let n=yield*O;if(t.includes("vscode"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*ye.detect(e);return yield*r.message(`\`${ye.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?ye.update(e):ye.create(e),!o}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${ye.config}\`...`,success:(r)=>`\`${ye.config}\` ${r?"created":"updated"} with Adamantite preset.`});if(t.includes("zed"))yield*n.withSpinner((r)=>d.gen(function*(){let o=yield*Fe.detect(e);return yield*r.message(`\`${Fe.config}\` ${o?"found, updating":"not found, creating"}...`),yield*o?Fe.update(e):Fe.create(e),!o}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Fe.config}\`...`,success:(r)=>`\`${Fe.config}\` ${r?"created":"updated"} with Adamantite preset.`})}),Xo=(e,t)=>d.gen(function*(){let n=yield*O,r=e.includes("zed"),o=e.includes("vscode");if(yield*n.withSpinner((i)=>d.gen(function*(){if(o)yield*i.message("Installing VS Code extension..."),yield*ye.extension(t);return!0}),{start:"Installing editor extensions...",success:r&&!o?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe(d.catchTag("FailedToInstallExtension",(i)=>d.gen(function*(){return yield*n.log.warning(`⚠️ Failed to install the \`${i.extension}\` extension.`),yield*n.log.warning("Please install it manually after setup completes."),!1})),d.catchTag("VscodeCliNotFound",()=>d.gen(function*(){return yield*n.log.error("VSCode CLI ('code' command) not found."),yield*n.log.info("To install it:"),yield*n.log.info(" 1. Open VS Code"),yield*n.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*n.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),r)yield*n.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),Yo=(e,t,n)=>d.gen(function*(){let r=yield*O,o=se.files[0].path;yield*r.withSpinner((i)=>d.gen(function*(){let s=yield*se.detect(e);return yield*i.message(s?`\`${o}\` found, updating...`:`Creating \`${o}\`...`),yield*s?se.update(e,{packageManager:t,scripts:n}):se.create(e,{packageManager:t,scripts:n}),!s}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(i)=>`GitHub Actions workflow ${i?"created":"updated"} successfully.`})}).pipe(d.option),Ho=(e,t,n)=>d.gen(function*(){let r=yield*O,o=yield*r.withSpinner(()=>Er(e,{packageManager:t,scripts:n}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe(d.catchTag(["FailedToReadFile","FailedToWriteFile"],(i)=>d.gen(function*(){return yield*r.log.warning(`Could not update AGENTS.md. ${i.message} Adamantite will continue initialization.`),"failed"})));if(o==="failed")return;if(o==="malformed")yield*r.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),Sr=["check","fix","format","check:monorepo","fix:monorepo","analyze"],$r=["react","nextjs","vue","jest","vitest","node"],Fr=["vscode","zed"],Ko=d.fn("validateInitOptions")(function*(e,t){let n={agents:e.agents,editors:Je.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,presets:Je.dedupe(e.presets),scripts:Je.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new M({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes("check")||n.scripts.includes("fix");if((n.scripts.includes("check:monorepo")||n.scripts.includes("fix:monorepo"))&&!t.isMonorepo)return yield*new M({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(n.presets.length>0&&!r)return yield*new M({reason:"`--preset` requires the `check` or `fix` script."});if(n.typescript&&!r)return yield*new M({reason:"`--typescript` requires the `check` or `fix` script."});if(n.installExtensions&&n.editors.length===0)return yield*new M({reason:"`--install-extensions` requires at least one `--editor`."});if(n.githubActions&&!we(n.scripts))return yield*new M({reason:"`--github-actions` requires a CI-compatible script."});if(n.githubActions&&t.nonInteractive&&!Ye(t.packageManager))return yield*new M({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return n}),xo=$.boolean("non-interactive").pipe($.withDescription("Configure without prompts; requires at least one --script")),Lo=$.choice("script",Sr).pipe($.atMost(Sr.length),$.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),wo=$.choice("preset",$r).pipe($.atMost($r.length),$.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),Mo=$.choice("editor",Fr).pipe($.atMost(Fr.length),$.withDescription("Editor to configure; may be specified multiple times")),Go=$.boolean("typescript").pipe($.withDescription("Configure the TypeScript preset; requires --script check or fix")),Co=$.boolean("install-extensions").pipe($.withDescription("Install recommended extensions; requires at least one --editor")),ei=$.boolean("github-actions").pipe($.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),ti=$.boolean("agents").pipe($.withDescription("Add Adamantite guidance to AGENTS.md")),ni=d.fn("collectInteractiveInitOptions")(function*(e){let t=yield*O,n=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:!e,hint:e?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!e,hint:e?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"}]}),r=n.includes("check")||n.includes("fix"),o=[];if(r)o=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 i=r?yield*t.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,s=yield*t.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),a=s.length>0?yield*t.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,u=we(n)?yield*t.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*t.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:s,githubActions:u,installExtensions:a,presets:o,scripts:n,typescript:i}}),Vr=he.make("init",{agents:ti,editors:Mo,githubActions:ei,installExtensions:Co,nonInteractive:xo,presets:wo,scripts:Lo,typescript:Go}).pipe(he.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),he.withExamples([{command:"adamantite init --non-interactive --script check",description:"Configure linting without prompts"},{command:"adamantite init --non-interactive --script check --script format --preset react --editor vscode --typescript --install-extensions --github-actions --agents",description:"Configure a React project with VS Code, TypeScript, CI, and agent guidance"},{command:"adamantite init --non-interactive --script check:monorepo",description:"Configure monorepo checks in a detected monorepo"}]),he.withHandler((e)=>d.gen(function*(){let t=Uo.cwd(),n=yield*O;yield*_e(),yield*n.intro("\uD83D\uDCA0 adamantite init");let o=yield*(yield*K).detectPackageManager(t);if(!o)return yield*new Xe({});if(o.warnings?.length)for(let Ze of o.warnings)yield*n.log.warning(Ze);yield*n.log.info(`Detected package manager: ${o.name}`);let i=yield*tn(t);if(i)yield*n.log.info("We've detected a monorepo setup in your project.");if(!e.nonInteractive&&Je.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents],Dr.isTruthy))return yield*new M({reason:"Setup flags require `--non-interactive`."});let s=e.nonInteractive?e:yield*ni(i),a=yield*Ko(s,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:o.name}),u=a.scripts,f=a.presets,l=a.editors,p=a.typescript,E=a.installExtensions,S=a.githubActions,T=a.agents,P=u.includes("check")||u.includes("fix"),te=u.includes("format"),c=u.includes("check:monorepo")||u.includes("fix:monorepo"),z=u.includes("analyze"),Ee=["adamantite"];if(P)Ee.push(`${y.name}@${y.version}`,`${le.name}@${le.version}`);if(te)Ee.push(`${m.name}@${m.version}`);if(c)Ee.push(`${L.name}@${L.version}`);if(z)Ee.push(`${h.name}@${h.version}`);if(yield*ko(t,Ee),te)yield*Jo(t);if(P)yield*Ao(t,f);if(z)yield*Qo(t);if(yield*Bo(t,u),T)yield*Ho(t,o.name,u);if(p)yield*Wo(t);if(yield*Zo(t,l),E)yield*Xo(l,u);if(S){let Ze=o.name;if(Ye(Ze))yield*Yo(t,Ze,u);else yield*n.log.warning(`Skipping GitHub Actions setup: \`${Ze}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success("Your project is now configured"),yield*n.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(d.catchTags({OperationCancelled:()=>d.gen(function*(){yield*(yield*O).cancel("You've cancelled the initialization process.")})}))));import*as Pr from"effect/Effect";import*as Be from"effect/unstable/cli/Command";import*as Vt from"effect/unstable/cli/Flag";import*as Ir from"effect/unstable/process/ChildProcessSpawner";var ri=Vt.boolean("fix").pipe(Vt.withDescription("Automatically fix issues")),rn=Be.make("monorepo",{fix:ri}).pipe(Be.withDescription("Find and fix monorepo-specific issues using Sherif"),Be.withHandler(({fix:e})=>Pr.gen(function*(){let t=yield*B,n=yield*_,r=e?["--fix",...t]:[...t],o=yield*n.run({args:r,command:L.name,stdin:"inherit"});if(o!==Ir.ExitCode(0))yield*new b({command:L.name,exitCode:o})})));import*as Nr from"effect/Effect";import*as Qe from"effect/unstable/cli/Command";import*as Tr from"effect/unstable/process/ChildProcessSpawner";var on=Qe.make("typecheck").pipe(Qe.withDescription("Deprecated alias for `check`"),Qe.withHandler(()=>Nr.gen(function*(){let e=yield*B,t=yield*O,n=yield*_;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:y.name});if(r!==Tr.ExitCode(0))yield*new b({command:y.name,exitCode:r})})));import oi from"node:process";import*as me from"effect/Effect";import*as We from"effect/unstable/cli/Command";var ii=[y,le,m,L,h],si=[y,le,m,L,h];function ai(e,t){let n=[];for(let r of si){if(t.has(r.name))continue;let o=e.devDependencies?.[r.name]??e.dependencies?.[r.name];if(o&&Y(o)!==r.version)n.push({currentVersion:o,name:r.name,targetVersion:r.version})}return n}var _r=We.make("update").pipe(We.withDescription("Run applicable Adamantite migrations and update managed dependencies"),We.withHandler(()=>me.gen(function*(){let e=oi.cwd(),t=yield*O,n=yield*K,r={cwd:e};yield*_e(),yield*t.intro("\uD83D\uDCA0 adamantite update");let o=()=>jt(ii,e),i=yield*o();for(let{assessment:c}of i)for(let z of c.warnings)yield*t.log.warning(z);let s=new Set(i.map(({integration:c})=>c.name)),a=i.flatMap(({assessment:c})=>c.actions),u=new Set(a.filter((c)=>c.type==="run_migration").map((c)=>c.migrationId)),f=[];for(let c of gt.filter((z)=>z.tags.includes("update"))){let z=Mn[c.id];if(s.has(z))continue;let Ee=yield*c.check(r);f.push({migration:c,result:Ee})}for(let c of f){for(let z of c.result.warnings)yield*t.log.warning(z);if(c.result.applicable&&c.result.summary)yield*t.log.info(c.result.summary)}let l=[];for(let c of gt){if(!u.has(c.id))continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),l.push(c.id)}for(let{migration:c,result:z}of f){if(!z.applicable||!z.summary)continue;yield*Le(c,r,{onRestore:t.log.warning(`Migration "${c.title}" failed, restoring files...`)}),l.push(c.id)}if(l.length>0)yield*t.log.success("Migrations ran successfully.");let p=yield*v(e),E=yield*o(),S=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="create_config"||c.type==="update_config"||c.type==="manual_fix"),T=E.flatMap(({assessment:c})=>c.actions).filter((c)=>c.type==="install_package"||c.type==="update_package").map((c)=>c.type==="install_package"?{currentVersion:"not installed",name:c.package,targetVersion:c.targetVersion}:{currentVersion:c.currentVersion,name:c.package,targetVersion:c.targetVersion}),P=new Set(T.map((c)=>c.name)),te=[...T,...ai(p,P)];if(te.length>0){yield*t.log.info("The following dependencies will be updated:");for(let c of te)yield*t.log.info(` ${c.name}: ${c.currentVersion} → ${c.targetVersion}`);yield*t.withSpinner(()=>n.addDevDependencies(te.map((c)=>`${c.name}@${c.targetVersion}`),e,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"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 c of S)yield*t.log.warning(`Doctor follow-up: ${c.description}`)}if(l.length===0&&te.length===0&&S.length===0)return yield*t.log.success("No changes needed."),"no-changes";return"success"}).pipe(me.tapError(()=>me.gen(function*(){yield*(yield*O).outro("❌ Update failed")})),me.tap((e)=>me.gen(function*(){let t=yield*O;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 fi=[Qt,Kt,Gt,Ct,rn,on],qr=[Qt,Kt,ir,Gt,Ct,Vr,rn,on,_r],li=new Set(qr.map((e)=>e.name)),pi=new Set(fi.map((e)=>e.name)),ui=de.make("adamantite").pipe(de.withDescription("Opinionated preset package for modern TypeScript applications"),de.withSubcommands(qr)),zr=It.fn("runCli")(function*(e,t){let[n,r]=Pt.splitWhere(e,(s)=>s==="--"),o=Pt.drop(r,1),i=n.find((s)=>li.has(s));if(o.length>0&&i!==void 0&&!pi.has(i))return yield*new Ut({command:i});yield*de.runWith(ui,{version:t})(n).pipe(It.provideService(B,o))});var ci=q.gen(function*(){let t=yield*(yield*Br.Stdio).args;yield*zr(t,"0.34.1")}).pipe(q.as(0),q.catchTag("CommandFailed",(e)=>q.succeed(e.exitCode)),q.catch((e)=>q.service(O).pipe(q.flatMap((t)=>t.log.error(e.message)),q.as(Qr.ExitCode(1)))),q.provide(Ar.mergeAll(Ur.layer,O.layer,_.layer,K.layer)));br.runMain(ci,{teardown:(e,t)=>{if(kr.isSuccess(e)){t(Number(e.value));return}Jr.defaultTeardown(e,t)}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adamantite",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "An strict and opinionated set of presets for modern TypeScript applications",
5
5
  "keywords": [
6
6
  "adamantite",
@@ -9,6 +9,7 @@
9
9
  "oxfmt",
10
10
  "oxlint",
11
11
  "preset",
12
+ "tanstack-intent",
12
13
  "typescript"
13
14
  ],
14
15
  "homepage": "https://github.com/adelrodriguez/adamantite",
@@ -27,7 +28,9 @@
27
28
  "files": [
28
29
  "bin",
29
30
  "dist",
30
- "presets"
31
+ "presets",
32
+ "skills",
33
+ "!skills/_artifacts"
31
34
  ],
32
35
  "type": "module",
33
36
  "main": "dist/presets/lint/core.js",
@@ -73,21 +76,22 @@
73
76
  "@effect/platform-node": "4.0.0-beta.102",
74
77
  "defu": "6.1.7",
75
78
  "effect": "4.0.0-beta.102",
76
- "esrap": "2.3.0",
79
+ "esrap": "2.3.1",
77
80
  "jsonc-parser": "3.3.1",
78
81
  "nypm": "0.6.9",
79
- "oxc-parser": "^0.142.0"
82
+ "oxc-parser": "^0.143.0"
80
83
  },
81
84
  "devDependencies": {
82
85
  "@changesets/changelog-github": "0.7.0",
83
86
  "@changesets/cli": "2.31.1",
87
+ "@tanstack/intent": "0.3.6",
84
88
  "@types/bun": "1.3.14",
85
89
  "@types/figlet": "1.7.0",
86
90
  "bunup": "0.16.32",
87
91
  "figlet": "1.11.4",
88
- "knip": "6.30.0",
89
- "oxfmt": "0.61.0",
90
- "oxlint": "1.76.0",
92
+ "knip": "6.31.0",
93
+ "oxfmt": "0.62.0",
94
+ "oxlint": "1.77.0",
91
95
  "oxlint-tsgolint": "7.0.2001",
92
96
  "sherif": "1.13.0",
93
97
  "type-fest": "5.8.0",
@@ -0,0 +1,108 @@
1
+ ---
2
+ name: adamantite
3
+ description: Configures and maintains Adamantite linting, formatting, type-safety, analysis, editor, and CI tooling in TypeScript projects. Use when initializing Adamantite, running its checks, repairing a broken or drifted setup, or updating and migrating an existing installation.
4
+ metadata:
5
+ type: core
6
+ library: adamantite
7
+ library_version: "0.34.0"
8
+ sources:
9
+ - "adelrodriguez/adamantite:src/cli.ts"
10
+ - "adelrodriguez/adamantite:src/commands/*.ts"
11
+ ---
12
+
13
+ # Adamantite
14
+
15
+ Adamantite is an opinionated preset package and CLI for modern TypeScript projects. Run
16
+ commands from the target project's root and use its detected package manager.
17
+
18
+ ## Quick start
19
+
20
+ For a human-driven setup, run `npx adamantite init`. For an agent, prefer explicit
21
+ non-interactive setup. Setup flags require `--non-interactive`, and at least one
22
+ `--script` is required:
23
+
24
+ ```shell
25
+ npx adamantite init --non-interactive --script check --script fix --script format --typescript --agents
26
+ ```
27
+
28
+ Repeat `--script`, `--preset`, and `--editor` for multiple values. Available values are:
29
+
30
+ - Scripts: `check`, `fix`, `format`, `analyze`, `check:monorepo`, `fix:monorepo`
31
+ - Presets: `react`, `nextjs`, `vue`, `jest`, `vitest`, `node`; editors: `vscode`, `zed`
32
+ - Optional flags: `--typescript`, `--install-extensions`, `--github-actions`, `--agents`
33
+
34
+ Only select options supported by the project. Presets and TypeScript require `check` or
35
+ `fix`; extension installation requires an editor; monorepo scripts require a detected
36
+ monorepo; `--github-actions` requires a CI-compatible script and a supported package
37
+ manager (bun, deno, npm, pnpm, or yarn). Omitted boolean flags are disabled.
38
+
39
+ ## Daily workflow
40
+
41
+ Use the scripts written by `init` when available. Otherwise invoke the CLI directly:
42
+
43
+ ```shell
44
+ adamantite check
45
+ adamantite fix
46
+ adamantite format
47
+ adamantite format --check
48
+ adamantite analyze
49
+ adamantite monorepo
50
+ ```
51
+
52
+ - Use `check` for read-only lint and type-error validation.
53
+ - Use `fix` for automatic oxlint fixes. Add `--suggested`, `--dangerous`, or `--all` only
54
+ with explicit permission after reviewing their impact.
55
+ - Use `format` to write formatting changes and `format --check` for read-only CI checks.
56
+ - Use `analyze` for unused dependencies, exports, and files. `analyze --fix` may remove
57
+ files, so inspect findings before using it.
58
+ - Use `monorepo` to inspect workspace dependency consistency and `monorepo --fix` to fix it.
59
+
60
+ To pass arguments to Knip, Oxlint, Oxfmt, or Sherif, place them after `--`:
61
+
62
+ ```shell
63
+ adamantite check src -- --deny-warnings
64
+ bun run analyze -- -- --directory packages/app
65
+ ```
66
+
67
+ ## Diagnose and repair
68
+
69
+ Start with the read-only assessment:
70
+
71
+ ```shell
72
+ adamantite doctor
73
+ ```
74
+
75
+ If it reports safe automatic actions, apply them and reassess:
76
+
77
+ ```shell
78
+ adamantite doctor --fix
79
+ adamantite doctor
80
+ ```
81
+
82
+ `doctor --fix` is the mutating repair dispatcher. It installs or updates managed packages,
83
+ creates or updates supported configs, and runs known migrations. Manual-fix findings remain
84
+ report-only; follow their instructions instead of overwriting custom configuration.
85
+
86
+ ## Update and migrate
87
+
88
+ For an existing installation, run:
89
+
90
+ ```shell
91
+ adamantite update
92
+ adamantite doctor --fix
93
+ adamantite doctor
94
+ ```
95
+
96
+ `update` runs applicable legacy migrations and updates Adamantite-managed dependencies. It
97
+ may leave supported config creation, config updates, or manual work to `doctor --fix`.
98
+ Migrations restore affected files if they fail; still review the resulting diff and run the
99
+ project's tests after any mutation.
100
+
101
+ ## Decision guide
102
+
103
+ - New target project: `init`, then run the configured checks.
104
+ - Suspected drift or broken setup: `doctor`, then `doctor --fix` if appropriate.
105
+ - Existing project upgrading Adamantite: `update`, then the doctor sequence.
106
+ - Code-quality failure: choose `check`, `format --check`, `analyze`, or `monorepo` based on
107
+ the failing subsystem; do not reinitialize the project.
108
+ - Unknown option or behavior: run `adamantite <command> --help` before guessing.