adamantite 0.33.2 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +77 -0
  2. package/dist/index.js +38 -38
  3. package/package.json +10 -10
package/README.md CHANGED
@@ -73,8 +73,61 @@ This interactive command will:
73
73
  - Also adds monorepo-specific scripts if running a monorepo
74
74
  - Configure editor settings
75
75
 
76
+ ### Non-interactive setup for agents
77
+
78
+ Use `--non-interactive` to configure a project entirely from flags. At least one
79
+ `--script` is required, repeat `--script`, `--preset`, and `--editor` to select multiple
80
+ values, and add boolean flags only when that setup should be enabled.
81
+
82
+ ```shell
83
+ # Minimal unattended setup
84
+ npx adamantite init --non-interactive --script check
85
+
86
+ # Fully specified unattended setup
87
+ npx adamantite init \
88
+ --non-interactive \
89
+ --script check \
90
+ --script fix \
91
+ --script format \
92
+ --script analyze \
93
+ --preset react \
94
+ --preset node \
95
+ --editor vscode \
96
+ --typescript \
97
+ --install-extensions \
98
+ --github-actions \
99
+ --agents
100
+ ```
101
+
102
+ The available values are:
103
+
104
+ - Scripts: `check`, `fix`, `format`, `analyze`, `check:monorepo`, and `fix:monorepo`
105
+ - Presets: `react`, `nextjs`, `vue`, `jest`, `vitest`, and `node`
106
+ - Editors: `vscode` and `zed`
107
+
108
+ Omitted boolean flags are disabled. Setup flags require `--non-interactive`; without it,
109
+ `adamantite init` keeps the interactive setup flow.
110
+
76
111
  ## 📋 Commands
77
112
 
113
+ ### `adamantite analyze`
114
+
115
+ Find unused dependencies, exports, and files using Knip:
116
+
117
+ ```shell
118
+ # Analyze the current project
119
+ adamantite analyze
120
+
121
+ # Automatically fix issues, including removing unused files
122
+ adamantite analyze --fix
123
+
124
+ # Enable production and strict analysis
125
+ adamantite analyze --strict
126
+
127
+ # Forward additional arguments to Knip
128
+ adamantite analyze -- --directory packages/app
129
+ ```
130
+
78
131
  ### `adamantite check`
79
132
 
80
133
  Check your code for issues and type errors without automatically fixing them using oxlint:
@@ -142,6 +195,30 @@ Automatically detects and fixes:
142
195
  - Unused dependencies
143
196
  - Package.json formatting issues
144
197
 
198
+ ### Passing arguments to underlying tools
199
+
200
+ Commands that invoke Knip, Oxlint, Oxfmt, or Sherif can forward additional arguments to
201
+ the underlying CLI. Place Adamantite arguments before `--` and underlying CLI arguments
202
+ after it:
203
+
204
+ ```shell
205
+ adamantite analyze --strict -- --directory packages/app
206
+ adamantite check src -- --deny-warnings
207
+ adamantite format -- --ignore-path .formatignore
208
+ adamantite monorepo -- --ignore-package package-a
209
+ ```
210
+
211
+ When invoking a package script, the package manager consumes its own `--`, so add a
212
+ second separator for Adamantite:
213
+
214
+ ```shell
215
+ bun run analyze -- -- --directory packages/app
216
+ npm run analyze -- -- --directory packages/app
217
+ ```
218
+
219
+ Passthrough arguments are not supported by `init`, `doctor`, or `update`, because those
220
+ commands do not invoke a single underlying CLI.
221
+
145
222
  ### `adamantite update`
146
223
 
147
224
  Run applicable migrations and update Adamantite-managed dependencies:
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import*as hr from"@effect/platform-node/NodeRuntime";import*as Er from"@effect/platform-node/NodeServices";import*as U from"effect/Effect";import*as gr from"effect/Exit";import*as Or from"effect/Layer";import*as jr from"effect/Runtime";import*as ct from"effect/unstable/cli/Command";import*as Sr from"effect/unstable/process/ChildProcessSpawner";import*as Me from"effect/Effect";import*as $t from"effect/unstable/cli/Command";import*as Ft from"effect/unstable/cli/Flag";import*as Ke from"effect/unstable/process/ChildProcessSpawner";import*as jt from"effect/Effect";import*as Gt from"effect/FileSystem";import*as Ct from"effect/Path";function P(t){return t}import*as D from"effect/Data";import{printParseErrorCode as $r}from"jsonc-parser";function Fr(t=[]){if(t.length===0)return"- Unknown JSON/JSONC parsing error";return t.slice(0,3).map((e)=>`- ${$r(e.error)} (offset: ${e.offset})`).join(`
2
- `)}class Se extends D.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class T extends D.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class yt extends D.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class $e extends D.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class Mt extends D.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class Fe extends D.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class ve extends D.TaggedError("FailedToParseFile"){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:"the target file"}.`,"Please fix the JSON/JSONC syntax and run the command again.","","Parse details:",Fr(this.errors)].join(`
3
- `)}}class v extends D.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class rt extends D.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class O extends D.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class Re extends D.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class W extends D.TaggedError("InvalidConfigFormat"){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:"the target config file"}. The config must be a JSON object (for example: {}).`}}class De extends D.TaggedError("UnsupportedConfigState"){get message(){let t=this.path?`\`${this.path}\``:"the target config file",e=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${t}.${e}`}}class bt extends D.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class vr extends D.TaggedError("MissingPackageVersion"){get message(){let t=this.path?`\`${this.path}\``:"package.json";if(this.dependency)return`Missing \`${this.dependency}\` in ${t} dependencies or devDependencies.`;return`Missing version field in ${t}.`}}class H extends D.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class Kt extends D.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class Ve extends D.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class Pe extends D.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}import{defu as Rr}from"defu";import*as L from"effect/Effect";import{parse as Dr}from"jsonc-parser";var J=(t,e)=>L.sync(()=>{let r=[],n=Dr(t,r,{allowTrailingComma:!0});return{errors:r,parsed:n}}).pipe(L.flatMap(({errors:r,parsed:n})=>r.length>0?L.fail(new ve({errors:r,path:e})):L.succeed(n)));function N(t){return t!==null&&typeof t==="object"&&!Array.isArray(t)}function Et(t,e={}){let{continuationIndent:r,indentation:n=2}=e,o=JSON.stringify(t,null,n).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!r)return o;return o.replaceAll(`
1
+ import*as br from"@effect/platform-node/NodeRuntime";import*as Ur from"@effect/platform-node/NodeServices";import*as q from"effect/Effect";import*as kr from"effect/Exit";import*as Ar from"effect/Layer";import*as Jr from"effect/Runtime";import*as Br from"effect/Stdio";import*as Qr from"effect/unstable/process/ChildProcessSpawner";import*as Pt from"effect/Array";import*as It from"effect/Effect";import*as de from"effect/unstable/cli/Command";import*as cn from"effect/Effect";import*as fe from"effect/unstable/cli/Command";import*as Ie from"effect/unstable/cli/Flag";import*as yn from"effect/unstable/process/ChildProcessSpawner";import*as re from"effect/Effect";import*as ot from"effect/FileSystem";import*as it from"effect/Path";function I(e,...t){return e}import*as F from"effect/Data";import{printParseErrorCode as Wr}from"jsonc-parser";function Zr(e=[]){if(e.length===0)return"- Unknown JSON/JSONC parsing error";return e.slice(0,3).map((t)=>`- ${Wr(t.error)} (offset: ${t.offset})`).join(`
2
+ `)}class Nt extends F.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class b extends F.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class ge extends F.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.`}}class Tt extends F.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.`}}class tt extends F.TaggedError("FailedToInstallExtension"){get message(){return`Failed to install ${this.extension?`\`${this.extension}\``:"the target extension"}.`}}class _t extends F.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class qt extends F.TaggedError("FailedToParseFile"){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:"the target file"}.`,"Please fix the JSON/JSONC syntax and run the command again.","","Parse details:",Zr(this.errors)].join(`
3
+ `)}}class R extends F.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.`}}class ne extends F.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.`}}class j extends F.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.`}}class zt extends F.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class Z extends F.TaggedError("InvalidConfigFormat"){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:"the target config file"}. The config must be a JSON object (for example: {}).`}}class M extends F.TaggedError("InvalidInitOptions"){get message(){return`Invalid init options. ${this.reason}`}}class bt extends F.TaggedError("UnsupportedConfigState"){get message(){let e=this.path?`\`${this.path}\``:"the target config file",t=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${e}.${t}`}}class Xe extends F.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}class Xr extends F.TaggedError("MissingPackageVersion"){get message(){let e=this.path?`\`${this.path}\``:"package.json";if(this.dependency)return`Missing \`${this.dependency}\` in ${e} dependencies or devDependencies.`;return`Missing version field in ${e}.`}}class x extends F.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class nt extends F.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class Ut extends F.TaggedError("PassthroughNotSupported"){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}}class kt extends F.TaggedError("UnknownScript"){get message(){return`Unknown script: \`${this.script}\`.`}}class At extends F.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${this.cause instanceof Error?` Cause: ${this.cause.message}`:""}`}}import{defu as Yr}from"defu";import*as G from"effect/Effect";import*as sn from"effect/Predicate";import{parse as Hr}from"jsonc-parser";var A=(e,t)=>G.sync(()=>{let n=[],r=Hr(e,n,{allowTrailingComma:!0});return{errors:n,parsed:r}}).pipe(G.flatMap(({errors:n,parsed:r})=>n.length>0?G.fail(new qt({errors:n,path:t})):G.succeed(r))),N=sn.isObject;function Re(e,t={}){let{continuationIndent:n,indentation:r=2}=t,o=JSON.stringify(e,null,r).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!n)return o;return o.replaceAll(`
4
4
  `,`
5
- ${r}`)}var gt=(t,e)=>L.try({catch:(r)=>new Fe({cause:r}),try:()=>Rr(t,e)});function Lt(t={}){let e=Object.entries(t).map(([r,n])=>{if(r==="rules"&&typeof n==="object"&&n!==null&&!Array.isArray(n))return[" rules: {"," ...analyze.rules,",...Object.entries(n).map(([i,f])=>` ${i}: ${Et(f,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
6
- `);return` ${r}: ${Et(n)},`});if(e.length===0)return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = analyze","","export default config",""].join(`
7
- `);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...e,"}","","export default config",""].join(`
8
- `)}import Vr from"node:process";import*as Ot from"effect/Effect";import*as Ne from"effect/FileSystem";import*as _e from"effect/Path";var Pr=/^workspace:/,Nr=/^[\^~]/;function x(t){return t.trim().replace(Pr,"").replace(Nr,"")}var F=(t=Vr.cwd())=>Ot.gen(function*(){let e=yield*Ne.FileSystem,n=(yield*_e.Path).join(t,"package.json"),o=yield*e.readFileString(n).pipe(Ot.mapError((f)=>new v({cause:f,path:n})));return yield*J(o,n)}),Xe=(t,e)=>Ot.gen(function*(){let r=yield*Ne.FileSystem,o=(yield*_e.Path).join(t,"package.json");yield*r.writeFileString(o,`${JSON.stringify(e,null,2)}
9
- `).pipe(Ot.mapError((i)=>new O({cause:i,path:o})))});function At(t){return t==="bun"||t==="deno"||t==="npm"||t==="pnpm"||t==="yarn"}var Bt={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function X(t){let e=t.scripts??{},r=[];for(let[n,o]of Object.entries(Bt))if(e[n]===o)r.push(n);return r}var b=[{path:"knip.config.ts",type:"config"},{path:"knip.json",type:"legacy_config"},{path:"knip.jsonc",type:"legacy_config"}];var d=P({assess:(t)=>jt.gen(function*(){let e=yield*Gt.FileSystem,r=yield*Ct.Path,n=yield*F(t);if(!X(n).includes("analyze"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.knip??n.dependencies?.knip,f=r.join(t,b[0].path),s=r.join(t,b[1].path),c=r.join(t,b[2].path),a=yield*e.exists(f),p=yield*e.exists(s),l=yield*e.exists(c),h=a?"ts":l?"jsonc":p?"json":null,$=[],R=[];if(a&&(p||l))R.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(!a&&p&&l)R.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(!i)$.push({description:`Install \`knip@${"6.29.0"}\` for the managed \`analyze\` script.`,package:"knip",targetVersion:"6.29.0",type:"install_package"});else if(x(i)!=="6.29.0")$.push({currentVersion:i,description:`Update \`knip\` from \`${i}\` to \`${"6.29.0"}\`.`,package:"knip",targetVersion:"6.29.0",type:"update_package"});if(h===null)$.push({description:`Create \`${b[0].path}\` for \`knip\`.`,path:b[0].path,type:"create_config"});if(h==="json"||h==="jsonc")$.push({description:`Migrate legacy \`${h==="json"?b[1].path:b[2].path}\` to \`${b[0].path}\`.`,migrationId:"legacy-knip-json",type:"run_migration"});return{actions:$,applicable:!0,warnings:R}}),config:b[0].path,create:(t)=>jt.gen(function*(){let e=yield*Gt.FileSystem,n=(yield*Ct.Path).join(t,b[0].path);yield*e.writeFileString(n,Lt()).pipe(jt.mapError((o)=>new O({cause:o,path:n})))}),exists:(t)=>jt.gen(function*(){let e=yield*Gt.FileSystem,r=yield*Ct.Path,n=r.join(t,b[0].path),o=r.join(t,b[1].path),i=r.join(t,b[2].path),f=yield*e.exists(n),s=yield*e.exists(o),c=yield*e.exists(i),a=f?"ts":c?"jsonc":s?"json":null,p=[];if(f&&s)p.push({format:"json",path:o});if(f&&c)p.push({format:"jsonc",path:i});if(!f&&s&&c)p.push({format:"json",path:o});return{active:a===null?null:{format:a,path:a==="ts"?n:a==="jsonc"?i:o},legacy:p}}),files:b,kind:"tooling",name:"knip",version:"6.29.0"});import*as Ye from"effect/Context";import*as St from"effect/Effect";import*as we from"effect/Layer";import*as He from"effect/unstable/process/ChildProcess";class I extends Ye.Service()("CommandRunner"){static layer=we.succeed(this)({run:({args:t,command:e,cwd:r,stderr:n="inherit",stdin:o="ignore",stdout:i="inherit"})=>St.mapError(St.scoped(St.gen(function*(){return yield*(yield*He.make(e,t,{cwd:r,stderr:n,stdin:o,stdout:i})).exitCode})),(f)=>f.reason._tag==="NotFound"?new Se({command:e}):f)})}var _r=Ft.boolean("fix").pipe(Ft.withDescription("Automatically fix issues")),Ir=Ft.boolean("strict").pipe(Ft.withDescription("Enable strict mode")),Le=$t.make("analyze",{fix:_r,strict:Ir}).pipe($t.withDescription("Find unused dependencies, exports, and files using knip"),$t.withHandler(({fix:t,strict:e})=>Me.gen(function*(){let r=yield*I,n=[];if(t)n.push("--fix","--allow-remove-files");if(e)n.push("--production","--strict");let o=yield*r.run({args:n,command:d.name});if(o!==Ke.ExitCode(0))yield*new T({command:d.name,exitCode:o})})));import*as fn from"effect/Effect";import*as vt from"effect/unstable/cli/Argument";import*as Rt from"effect/unstable/cli/Command";import*as an from"effect/unstable/process/ChildProcessSpawner";import*as G from"effect/Effect";import*as Qt from"effect/FileSystem";import*as Wt from"effect/Path";import*as A from"effect/Effect";import*as S from"effect/Option";import{print as Tr}from"esrap";import qr from"esrap/languages/ts";import{parseSync as zr}from"oxc-parser";var nn=["respectEslintDisableDirectives","typeAware","typeCheck"],Ae="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",Ge="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",Ce="`oxlint.config.ts` has an `options` object Adamantite cannot patch safely. Make sure each required option is a plain `key: true | false` property—avoid spreads (`...rest`), computed keys (`[name]: ...`), duplicate keys, methods/getters/setters, and non-boolean-literal values.",rn="Adamantite could not generate the required `options` patch.";function ee(t=[]){return t.includes("core")?t:["core",...t]}function tn(t){return t.replaceAll(/-([a-z])/g,(e,r)=>r.toUpperCase())}function ne(t,e,r=[]){let{options:n,...o}=t,i=['import { defineConfig } from "oxlint"',...e.map((h)=>`import ${tn(h)} from "${h==="core"?"adamantite/lint":`adamantite/lint/${h}`}"`)],s=[...e.map((h)=>tn(h)),...r.map((h)=>JSON.stringify(h))],c=JSON.stringify(N(n)?{...n,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),a=Object.entries(o).map(([h,$])=>[h,JSON.stringify($,null,2)]),p=`[${s.join(", ")}]`,l=[["options",c],...a,["extends",p]].map(([h,$])=>` ${h}: ${$},`).join(`
10
- `);return[...i,"","export default defineConfig({",l,"})",""].join(`
11
- `)}function te(t){return N(t)&&t.type==="ObjectExpression"&&Array.isArray(t.properties)}function Ie(t){return N(t)&&t.type==="Property"}function Te(t){return A.try({catch:()=>null,try:()=>zr("oxlint.config.ts",t,{astType:"ts",lang:"ts",sourceType:"module"})}).pipe(A.match({onFailure:()=>S.none(),onSuccess:(e)=>e.errors.length===0?S.fromNullishOr(e.program):S.none()}))}function on(t){let{code:e}=Tr(t,qr({quotes:"double"}));return e.endsWith(`
12
- `)?e:`${e}
13
- `}function en(t){if(t.type==="Identifier")return t.name;if(t.type==="Literal"&&typeof t.value==="string")return t.value;return null}function qe(t){let e=t.body.filter((i)=>i.type==="ExportDefaultDeclaration");if(e.length!==1)return S.none();let[r]=e;if(!r)return S.none();let n=r.declaration;if(te(n))return S.fromNullishOr(n);if(n.type!=="CallExpression")return S.none();if(n.callee.type!=="Identifier"||n.callee.name!=="defineConfig")return S.none();if(n.arguments.length!==1)return S.none();let[o]=n.arguments;if(te(o))return S.fromNullishOr(o);return S.none()}function ze(t,e){let r=null;for(let n of t.properties){if(n.type==="SpreadElement")return{status:"manual"};if(!Ie(n))return{status:"manual"};if(n.computed)return{status:"manual"};if(n.method||n.kind!=="init"){if(en(n.key)===e)return{status:"manual"};continue}if(en(n.key)!==e)continue;if(r)return{status:"manual"};r=n}if(!r)return{status:"missing"};return{property:r,status:"found"}}function kr(t){let e=`export default { options: { ${t.map((r)=>`${r}: true`).join(", ")} } }
14
- `;return Te(e).pipe(A.map((r)=>{if(S.isNone(r))return S.none();let n=qe(r.value);if(S.isNone(n))return S.none();let o=ze(n.value,"options");if(o.status!=="found")return S.none();if(!te(o.property.value))return S.none();let i=o.property.value.properties.filter(Ie);return i.length===o.property.value.properties.length?S.fromNullishOr(i):S.none()}))}function Ur(){let t=`export default { options: { ${nn.map((e)=>`${e}: true`).join(", ")} } }
15
- `;return Te(t).pipe(A.map((e)=>{if(S.isNone(e))return S.none();let r=qe(e.value);if(S.isNone(r)||r.value.properties.length!==1)return S.none();let[n]=r.value.properties;if(!n||!Ie(n)||n.computed||n.method||n.kind!=="init")return S.none();return S.fromNullishOr(n)}))}function Jr(t,e){return A.gen(function*(){let r=[],n=!1;for(let o of nn){let i=ze(e,o);if(i.status==="manual")return{kind:"manual",reason:Ce};if(i.status==="missing"){r.push(o);continue}let f=i.property.value;if(f.type!=="Literal"||typeof f.value!=="boolean")return{kind:"manual",reason:Ce};if(f.value)continue;f.raw="true",f.value=!0,n=!0}if(r.length>0){let o=yield*kr(r);if(S.isNone(o))return{kind:"manual",reason:rn};e.properties.unshift(...o.value),n=!0}if(!n)return{kind:"configured"};return{kind:"patchable",updatedContent:on(t)}})}function ke(t){return A.gen(function*(){let e=yield*Te(t);if(S.isNone(e))return{kind:"manual",reason:Ae};let r=qe(e.value);if(S.isNone(r))return{kind:"manual",reason:Ae};let n=ze(r.value,"options");if(n.status==="manual")return{kind:"manual",reason:Ge};if(n.status==="missing"){let o=yield*Ur();if(S.isNone(o))return{kind:"manual",reason:rn};return r.value.properties.unshift(o.value),{kind:"patchable",updatedContent:on(e.value)}}if(!te(n.property.value))return{kind:"manual",reason:Ge};return yield*Jr(e.value,n.property.value)})}var q=[{path:"oxlint.config.ts",type:"config"},{path:".oxlintrc.json",type:"legacy_config"}];var y=P({assess:(t)=>G.gen(function*(){let e=yield*Qt.FileSystem,r=yield*Wt.Path,n=yield*F(t),o=X(n);if(!o.includes("check")&&!o.includes("fix"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxlint??n.dependencies?.oxlint,f=r.join(t,q[0].path),s=r.join(t,q[1].path),c=yield*e.exists(f),a=yield*e.exists(s),p={active:c?{format:"ts",path:f}:a?{format:"json",path:s}:null,legacy:c&&a?[{format:"json",path:s}]:[]},l=[],h=[];if(p.active?.format==="ts"&&p.legacy.length>0)h.push("Found both `oxlint.config.ts` and `.oxlintrc.json`. Adamantite will use `oxlint.config.ts`.");if(!i)l.push({description:`Install \`oxlint@${"1.75.0"}\` for the managed lint scripts.`,package:"oxlint",targetVersion:"1.75.0",type:"install_package"});else if(x(i)!=="1.75.0")l.push({currentVersion:i,description:`Update \`oxlint\` from \`${i}\` to \`${"1.75.0"}\`.`,package:"oxlint",targetVersion:"1.75.0",type:"update_package"});if(p.active===null)l.push({description:`Create \`${q[0].path}\` for \`oxlint\`.`,path:q[0].path,type:"create_config"});if(p.active?.format==="json")l.push({description:`Migrate legacy \`${q[1].path}\` to \`${q[0].path}\`.`,migrationId:"legacy-oxlint-json",type:"run_migration"});if(p.active?.format==="ts"){let $=yield*e.readFileString(f).pipe(G.mapError((_)=>new v({cause:_,path:f}))),R=yield*ke($);if(R.kind==="patchable")l.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:q[0].path,type:"update_config"});if(R.kind==="manual")l.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:q[0].path,type:"manual_fix"})}return{actions:l,applicable:!0,warnings:h}}),config:q[0].path,create:(t,e=[])=>G.gen(function*(){let r=yield*Qt.FileSystem,o=(yield*Wt.Path).join(t,q[0].path),i=ne({},ee(e));yield*r.writeFileString(o,i).pipe(G.mapError((f)=>new O({cause:f,path:o})))}),exists:(t)=>G.gen(function*(){let e=yield*Qt.FileSystem,r=yield*Wt.Path,n=r.join(t,q[0].path),o=r.join(t,q[1].path),i=yield*e.exists(n),f=yield*e.exists(o),s=i?"ts":f?"json":null,c=[];if(i&&f)c.push({format:"json",path:o});return{active:s===null?null:{format:s,path:s==="ts"?n:o},legacy:c}}),files:q,kind:"tooling",name:"oxlint",update:(t)=>G.gen(function*(){let e=yield*Qt.FileSystem,n=(yield*Wt.Path).join(t,q[0].path);if(!(yield*e.exists(n)))return yield*new Re({path:q[0].path});let o=yield*e.readFileString(n).pipe(G.mapError((f)=>new v({cause:f,path:n}))),i=yield*ke(o);if(i.kind==="configured")return;if(i.kind==="manual")return yield*new De({path:q[0].path,reason:i.reason});yield*e.writeFileString(n,i.updatedContent).pipe(G.mapError((f)=>new O({cause:f,path:n})))}),version:"1.75.0"});var br=vt.file("files",{mustExist:!0}).pipe(vt.withDescription("Specific files to lint (optional)"),vt.variadic()),ln=Rt.make("check",{files:br}).pipe(Rt.withDescription("Find issues and type errors in code using oxlint"),Rt.withHandler(({files:t})=>fn.gen(function*(){let r=yield*(yield*I).run({args:[...t],command:y.name});if(r!==an.ExitCode(0))yield*new T({command:y.name,exitCode:r})})));import Cr from"node:process";import*as Pt from"effect/Effect";import*as Nt from"effect/unstable/cli/Command";import*as de from"effect/unstable/cli/Flag";import*as Qe from"effect/unstable/process/ChildProcessSpawner";import*as Dt from"effect/Effect";import*as oe from"effect/FileSystem";import*as ie from"effect/Path";var Br=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function Qr(t){let e=t.split(`
16
- `);if(e.length===1)return t.slice(1,-1).trim();return e.slice(1,-1).map((r)=>` ${r.trimStart()}`).join(`
17
- `)}function Wr(t,e){let r=Et(e),n=Qr(r);return[` ${t}: {`,` ...format.${t},`,...n===""?[]:[n]," },"].join(`
18
- `)}function re(t={}){let e=Object.entries(t).map(([r,n])=>{if(Br.has(r)&&N(n))return Wr(r,n);let o=Et(n,{continuationIndent:" "});return` ${r}: ${o},`});if(e.length===0)return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig(format)",""].join(`
19
- `);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...e,"})",""].join(`
20
- `)}var B=[{path:"oxfmt.config.ts",type:"config"},{path:".oxfmtrc.json",type:"legacy_config"},{path:".oxfmtrc.jsonc",type:"legacy_config"}];var m=P({assess:(t)=>Dt.gen(function*(){let e=yield*oe.FileSystem,r=yield*ie.Path,n=yield*F(t);if(!X(n).includes("format"))return{applicable:!1,warnings:[]};let i=n.devDependencies?.oxfmt??n.dependencies?.oxfmt,f=r.join(t,B[0].path),s=r.join(t,B[1].path),c=r.join(t,B[2].path),a=yield*e.exists(f),p=yield*e.exists(s),l=yield*e.exists(c),h=a?"ts":l?"jsonc":p?"json":null,$=[],R=[];if(a&&(p||l))R.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(!a&&p&&l)R.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(!i)$.push({description:`Install \`oxfmt@${"0.60.0"}\` for the managed \`format\` script.`,package:"oxfmt",targetVersion:"0.60.0",type:"install_package"});else if(x(i)!=="0.60.0")$.push({currentVersion:i,description:`Update \`oxfmt\` from \`${i}\` to \`${"0.60.0"}\`.`,package:"oxfmt",targetVersion:"0.60.0",type:"update_package"});if(h===null)$.push({description:`Create \`${B[0].path}\` for \`oxfmt\`.`,path:B[0].path,type:"create_config"});if(h==="json"||h==="jsonc")$.push({description:`Migrate legacy \`${h==="json"?B[1].path:B[2].path}\` to \`${B[0].path}\`.`,migrationId:"legacy-oxfmt-json",type:"run_migration"});return{actions:$,applicable:!0,warnings:R}}),config:B[0].path,create:(t)=>Dt.gen(function*(){let e=yield*oe.FileSystem,n=(yield*ie.Path).join(t,B[0].path);yield*e.writeFileString(n,re()).pipe(Dt.mapError((o)=>new O({cause:o,path:n})))}),exists:(t)=>Dt.gen(function*(){let e=yield*oe.FileSystem,r=yield*ie.Path,n=r.join(t,B[0].path),o=r.join(t,B[1].path),i=r.join(t,B[2].path),f=yield*e.exists(n),s=yield*e.exists(o),c=yield*e.exists(i),a=f?"ts":c?"jsonc":s?"json":null,p=[];if(f&&s)p.push({format:"json",path:o});if(f&&c)p.push({format:"jsonc",path:i});if(!f&&s&&c)p.push({format:"json",path:o});return{active:a===null?null:{format:a,path:a==="ts"?n:a==="jsonc"?i:o},legacy:p}}),files:B,kind:"tooling",name:"oxfmt",version:"0.60.0"});import*as sn from"effect/Effect";var M=P({assess:(t)=>sn.gen(function*(){let e=yield*F(t),r=X(e);if(!r.includes("check:monorepo")&&!r.includes("fix:monorepo"))return{applicable:!1,warnings:[]};let n=e.devDependencies?.sherif??e.dependencies?.sherif,o=[];if(!n)o.push({description:`Install \`sherif@${"1.13.0"}\` for the managed monorepo scripts.`,package:"sherif",targetVersion:"1.13.0",type:"install_package"});else if(x(n)!=="1.13.0")o.push({currentVersion:n,description:`Update \`sherif\` from \`${n}\` to \`${"1.13.0"}\`.`,package:"sherif",targetVersion:"1.13.0",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"sherif",version:"1.13.0"});import*as pn from"effect/Effect";var lt=P({assess:(t)=>pn.gen(function*(){let e=yield*F(t),r=X(e);if(!r.includes("check")&&!r.includes("fix"))return{applicable:!1,warnings:[]};let n=e.devDependencies?.["oxlint-tsgolint"]??e.dependencies?.["oxlint-tsgolint"],o=[];if(!n)o.push({description:`Install \`oxlint-tsgolint@${"7.0.2001"}\` for the managed lint scripts.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"install_package"});else if(x(n)!=="7.0.2001")o.push({currentVersion:n,description:`Update \`oxlint-tsgolint\` from \`${n}\` to \`${"7.0.2001"}\`.`,package:"oxlint-tsgolint",targetVersion:"7.0.2001",type:"update_package"});return{actions:o,applicable:!0,warnings:[]}}),kind:"tooling",name:"oxlint-tsgolint",version:"7.0.2001"});import*as k from"effect/Effect";import*as un from"effect/Exit";import*as cn from"effect/FileSystem";import*as yn from"effect/Path";function st(t){return t}function Zt(t,e,r){return k.gen(function*(){let n=yield*cn.FileSystem,o=yield*yn.Path,i=t.files??[],f=new Map;for(let c of i){let a=o.join(e.cwd,c);if(yield*n.exists(a)){let l=yield*n.readFileString(a);f.set(a,l)}else f.set(a,null)}let s=yield*k.exit(t.migrate(e).pipe(k.andThen(()=>t.validate?.(e)??k.void)));if(un.isSuccess(s))return;if(r?.onRestore)yield*r.onRestore;for(let[c,a]of f){if(a!==null){yield*n.writeFileString(c,a).pipe(k.ignore);continue}if(!(yield*n.exists(c).pipe(k.orElseSucceed(()=>!1))))continue;yield*n.remove(c).pipe(k.ignore)}return yield*k.failCause(s.cause)})}import*as C from"effect/Effect";import*as hn from"effect/FileSystem";import*as En from"effect/Path";import*as V from"@clack/prompts";import*as dn from"effect/Context";import*as Q from"effect/Effect";import*as mn from"effect/Layer";class E extends dn.Service()("Prompter"){static layer=mn.succeed(this)({cancel:(t)=>Q.sync(()=>{V.cancel(t)}),confirm:(t)=>Q.promise(()=>V.confirm(t)).pipe(Q.filterOrFail((e)=>!V.isCancel(e),()=>new Kt({}))),intro:(t)=>Q.sync(()=>{V.intro(t)}),log:{error:(t)=>Q.sync(()=>{V.log.error(t)}),info:(t)=>Q.sync(()=>{V.log.info(t)}),success:(t)=>Q.sync(()=>{V.log.success(t)}),warning:(t)=>Q.sync(()=>{V.log.warning(t)})},multiselect:(t)=>Q.promise(()=>V.multiselect(t)).pipe(Q.filterOrFail((e)=>!V.isCancel(e),()=>new Kt({}))),outro:(t)=>Q.sync(()=>{V.outro(t)}),spinner:()=>V.spinner()})}function gn(){return[d.files[1].path,d.files[2].path]}function Zr(t){let e=gn();return`Migrating legacy \`${t==="json"?e[0]:e[1]}\` configuration to \`${d.config}\`.`}function xr(t){return C.gen(function*(){let e=yield*hn.FileSystem,r=yield*En.Path,n=yield*d.exists(t);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(t,d.config),f=yield*e.readFileString(o).pipe(C.mapError((l)=>new v({cause:l,path:o}))),s=yield*J(f,o);if(!N(s))return yield*new W({path:o});let{$schema:c,...a}=s;yield*e.writeFileString(i,Lt(a)).pipe(C.mapError((l)=>new O({cause:l,path:i}))),yield*e.remove(o).pipe(C.mapError((l)=>new rt({cause:l,path:o})));let p=n.legacy[0]?.path??null;if(p&&p!==o)yield*e.remove(p).pipe(C.mapError((l)=>new rt({cause:l,path:p})))})}var Ue=st({check:(t)=>C.gen(function*(){let e=yield*d.exists(t.cwd),r=[];if(e.active?.format==="ts"&&e.legacy.length>0)r.push("Found both `knip.config.ts` and `knip.json(c)`. Adamantite will use `knip.config.ts`.");if(e.active&&e.active.format!=="ts"&&e.legacy.length>0)r.push("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(e.active?.format==="json"||e.active?.format==="jsonc")return{applicable:!0,summary:Zr(e.active.format),warnings:r};if(e.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[d.config,...gn()],id:"legacy-knip-json",migrate:(t)=>C.gen(function*(){let r=(yield*E).spinner(),o=(yield*d.exists(t.cwd)).active?.path.endsWith(d.files[2].path)?d.files[2].path:d.files[1].path;r.start(`Migrating \`${o}\` to \`${d.config}\`...`),yield*xr(t.cwd),r.stop(`Knip config migrated to \`${d.config}\` successfully.`)}),tags:["update"],title:"Legacy Knip JSON config",validate:(t)=>C.gen(function*(){if((yield*d.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-knip-json",reason:`\`${d.config}\` is not the active Knip config.`})})});import*as tt from"effect/Effect";import*as On from"effect/FileSystem";import*as jn from"effect/Path";function Sn(){return[m.files[1].path,m.files[2].path]}function Xr(t){let e=Sn();return`Migrating legacy \`${t==="json"?e[0]:e[1]}\` configuration to \`${m.config}\`.`}function Yr(t){return tt.gen(function*(){let e=yield*On.FileSystem,r=yield*jn.Path,n=yield*m.exists(t);if(n.active?.format!=="json"&&n.active?.format!=="jsonc")return;let o=n.active.path,i=r.join(t,m.config),f=yield*e.readFileString(o).pipe(tt.mapError((l)=>new v({cause:l,path:o}))),s=yield*J(f,o);if(!N(s))return yield*new W({path:o});let{$schema:c,...a}=s;yield*e.writeFileString(i,re(a)).pipe(tt.mapError((l)=>new O({cause:l,path:i}))),yield*e.remove(o).pipe(tt.mapError((l)=>new rt({cause:l,path:o})));let p=n.legacy[0]?.path??null;if(p&&p!==o)yield*e.remove(p).pipe(tt.mapError((l)=>new rt({cause:l,path:p})))})}var Je=st({check:(t)=>tt.gen(function*(){let e=yield*m.exists(t.cwd),r=[];if(e.active?.format==="ts"&&e.legacy.length>0)r.push("Found both `oxfmt.config.ts` and `.oxfmtrc.json(c)`. Adamantite will use `oxfmt.config.ts`.");if(e.active&&e.active.format!=="ts"&&e.legacy.length>0)r.push("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(e.active?.format==="json"||e.active?.format==="jsonc")return{applicable:!0,summary:Xr(e.active.format),warnings:r};if(e.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),files:[m.config,...Sn()],id:"legacy-oxfmt-json",migrate:(t)=>tt.gen(function*(){let r=(yield*E).spinner(),o=(yield*m.exists(t.cwd)).active?.path.endsWith(m.files[2].path)?m.files[2].path:m.files[1].path;r.start(`Migrating \`${o}\` to \`${m.config}\`...`),yield*Yr(t.cwd),r.stop(`Oxfmt config migrated to \`${m.config}\` successfully.`)}),tags:["update"],title:"Legacy oxfmt JSON config",validate:(t)=>tt.gen(function*(){if((yield*m.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxfmt-json",reason:`\`${m.config}\` is not the active oxfmt config.`})})});import*as ot from"effect/Effect";import*as $n from"effect/FileSystem";import*as Fn from"effect/Path";function wr(t){return ot.gen(function*(){let e=yield*$n.FileSystem,r=yield*Fn.Path,n=yield*y.exists(t);if(n.active?.format!=="json")return;let o=n.active.path,i=r.join(t,y.config),f=yield*e.readFileString(o).pipe(ot.mapError((_)=>new v({cause:_,path:o}))),s=yield*J(f,o);if(!N(s))return yield*new W({path:o});let{$schema:c,...a}=s,p=Array.isArray(a.extends)?a.extends.filter((_)=>typeof _==="string"):typeof a.extends==="string"?[a.extends]:[],l=new Set(ee()),h=new Set;for(let _ of p){let nt=_.match(/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/),u=_.match(/^adamantite\/lint(?:\/([a-z0-9-]+))?$/),j=nt?.[1]??(u?u[1]??"core":null);if(j)l.add(j);else h.add(_)}let{extends:$,...R}=a;yield*e.writeFileString(i,ne(R,[...l],[...h])).pipe(ot.mapError((_)=>new O({cause:_,path:i}))),yield*e.remove(o).pipe(ot.mapError((_)=>new rt({cause:_,path:o})))})}var be=st({id:"legacy-oxlint-json",files:[y.config,y.files[1].path],tags:["update"],title:"Legacy oxlint JSON config",check:(t)=>ot.gen(function*(){let e=yield*y.exists(t.cwd),r=e.active?.format==="ts"&&e.legacy.length>0?[`Found both \`${y.config}\` and \`${y.files[1].path}\`. Adamantite will use \`${y.config}\`.`]:[];if(e.active?.format==="json")return{applicable:!0,summary:`Migrating legacy \`${y.files[1].path}\` configuration to \`${y.config}\`.`,warnings:r};if(e.active?.format==="ts")return{applicable:!0,warnings:r};return{applicable:!1,warnings:r}}),migrate:(t)=>ot.gen(function*(){let r=(yield*E).spinner();r.start(`Migrating \`${y.files[1].path}\` to \`${y.config}\`...`),yield*wr(t.cwd),r.stop(`Oxlint config migrated to \`${y.config}\` successfully.`)}),validate:(t)=>ot.gen(function*(){if((yield*y.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-oxlint-json",reason:`\`${y.config}\` is not the active oxlint config.`})})});import*as Z from"effect/Effect";import*as Be from"effect/Exit";import*as dt from"effect/Effect";import*as se from"effect/FileSystem";import*as pe from"effect/Path";import*as fe from"effect/Effect";import*as vn from"effect/FileSystem";var Rn=(t)=>fe.gen(function*(){yield*(yield*vn.FileSystem).makeDirectory(t,{recursive:!0}).pipe(fe.mapError((r)=>new yt({cause:r,path:t})))});import{runScriptCommand as Hr}from"nypm";var Dn=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function Vn(t,e){let r=[];for(let n of Dn){if(!e.includes(n.script))continue;r.push({command:Hr(t,n.script,{args:n.args}),name:n.name})}return r}function ae(t){return Dn.some((e)=>t.includes(e.script))}var Mr={bun:` - name: Setup Node.js
5
+ ${n}`)}var De=(e,t)=>G.try({catch:(n)=>new _t({cause:n}),try:()=>Yr(e,t)});function rt(e={}){let t=Object.entries(e).map(([n,r])=>{if(n==="rules"&&typeof r==="object"&&r!==null&&!Array.isArray(r))return[" rules: {"," ...analyze.rules,",...Object.entries(r).map(([i,s])=>` ${i}: ${Re(s,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
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
+ `);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...t,"}","","export default config",""].join(`
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(`
10
+ `);return[...i,"","export default defineConfig({",p,"})",""].join(`
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
+ `)?t:`${t}
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
+ `,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(`
16
+ `);if(t.length===1)return e.slice(1,-1).trim();return t.slice(1,-1).map((n)=>` ${n.trimStart()}`).join(`
17
+ `)}function fo(e,t){let n=Re(t),r=ao(n);return[` ${e}: {`,` ...format.${e},`,...r===""?[]:[r]," },"].join(`
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
+ `);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
21
21
  uses: actions/setup-node@v6
22
22
  with:
23
23
  node-version: "22"
@@ -64,7 +64,7 @@ ${r}`)}var gt=(t,e)=>L.try({catch:(r)=>new Fe({cause:r}),try:()=>Rr(t,e)});funct
64
64
  cache: "yarn"
65
65
 
66
66
  - name: Install dependencies
67
- run: yarn install --frozen-lockfile`};function Pn({packageManager:t,scripts:e}){let r=Vn(t,e);if(r.length===0)return null;return`${`name: adamantite
67
+ run: yarn install --frozen-lockfile`};function Zn({packageManager:e,scripts:t}){let n=Wn(e,t);if(n.length===0)return null;return`${`name: adamantite
68
68
 
69
69
  on:
70
70
  push:
@@ -89,7 +89,7 @@ jobs:
89
89
  fail-fast: false
90
90
  matrix:
91
91
  include:
92
- ${r.map((i)=>` - name: ${i.name}
92
+ ${n.map((i)=>` - name: ${i.name}
93
93
  command: ${i.command}`).join(`
94
94
  `)}
95
95
 
@@ -97,26 +97,26 @@ ${r.map((i)=>` - name: ${i.name}
97
97
  - name: Checkout
98
98
  uses: actions/checkout@v4
99
99
 
100
- ${Mr[t]}
100
+ ${mo[e]}
101
101
 
102
102
  - name: Run \${{ matrix.name }}
103
103
  run: \${{ matrix.command }}`}
104
- `}var le=[{path:".github/workflows/adamantite.yml",type:"ci"}],it=P({create:(t,e)=>dt.gen(function*(){let r=yield*se.FileSystem,n=yield*pe.Path,o=n.join(t,le[0].path);yield*Rn(n.dirname(o));let i=Pn(e);if(!i)return;yield*r.writeFileString(o,i).pipe(dt.mapError((f)=>new O({cause:f,path:o})))}),exists:(t)=>dt.gen(function*(){let e=yield*se.FileSystem,r=yield*pe.Path;return yield*e.exists(r.join(t,le[0].path))}),files:le,kind:"ci",name:"github",update:(t,e)=>dt.gen(function*(){let r=yield*se.FileSystem,o=(yield*pe.Path).join(t,le[0].path),i=Pn(e);if(!i)return;yield*r.writeFileString(o,i).pipe(dt.mapError((f)=>new O({cause:f,path:o})))})});import*as Nn from"effect/Context";import*as mt from"effect/Effect";import*as _n from"effect/Layer";import{addDevDependency as Kr,detectPackageManager as Lr}from"nypm";class Y extends Nn.Service()("DependencyInstaller"){static layer=_n.succeed(this)({addDevDependencies:(t,e,r)=>mt.tryPromise({catch:(n)=>new $e({cause:n,packages:t}),try:()=>Kr(t,{...r,cwd:e})}).pipe(mt.asVoid),detectPackageManager:(t)=>mt.tryPromise({catch:(e)=>new bt({cause:e}),try:()=>Lr(t)}).pipe(mt.map((e)=>e??null))})}import*as pt from"effect/Effect";import*as ue from"effect/FileSystem";import*as ce from"effect/Path";var xt=[{path:"tsconfig.json",type:"config"}],In={extends:"adamantite/typescript"},z=P({config:xt[0].path,create:(t)=>pt.gen(function*(){let e=yield*ue.FileSystem,n=(yield*ce.Path).join(t,xt[0].path),o=JSON.stringify(In,null,2);yield*e.writeFileString(n,`${o}
105
- `).pipe(pt.mapError((i)=>new O({cause:i,path:n})))}),exists:(t)=>pt.gen(function*(){let e=yield*ue.FileSystem,r=yield*ce.Path;return yield*e.exists(r.join(t,xt[0].path))}),files:xt,kind:"workspace",name:"tsconfig",update:(t)=>pt.gen(function*(){let e=yield*ue.FileSystem,n=(yield*ce.Path).join(t,xt[0].path),o=yield*e.readFileString(n).pipe(pt.mapError((s)=>new v({cause:s,path:n}))),i=yield*J(o,n);if(!N(i))return yield*new W({path:n});let f=yield*gt(In,i);yield*e.writeFileString(n,`${JSON.stringify(f,null,2)}
106
- `).pipe(pt.mapError((s)=>new O({cause:s,path:n})))})});var qn="adamantite typecheck";function Ar(){return y.files[1].path}function Gr(){return it.files[0].path}function Tn(t){let e={...t.scripts};if(e.typecheck!==qn)return{migrated:!1,packageJson:t};return delete e.typecheck,e.check??=Bt.check,{migrated:!0,packageJson:{...t,scripts:e}}}var zn=st({check:(t)=>Z.gen(function*(){let e=yield*F(t.cwd),{migrated:r}=Tn(e);if(!r)return{applicable:!1,warnings:[]};return{applicable:!0,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json",y.config,Ar(),z.config,Gr()],id:"legacy-typecheck-script",migrate:(t)=>Z.gen(function*(){let e=yield*E,r=yield*Y,n=e.spinner(),o=Z.gen(function*(){let i=yield*F(t.cwd),f=Tn(i);if(!f.migrated)return"noop";yield*Xe(t.cwd,f.packageJson);let s=yield*y.exists(t.cwd);if(s.active===null)yield*y.create(t.cwd);else if(s.active.format==="ts")yield*y.update(t.cwd);yield*(yield*z.exists(t.cwd))?z.update(t.cwd):z.create(t.cwd);let a=yield*it.exists(t.cwd),p=X(f.packageJson);if(a&&ae(p)){let l=yield*r.detectPackageManager(t.cwd);if(l&&At(l.name)){let h=l.name,$=e.spinner();$.start("Updating GitHub Actions workflow..."),yield*it.update(t.cwd,{packageManager:h,scripts:p}).pipe(Z.onExit((R)=>Z.sync(()=>{$.stop(Be.match(R,{onFailure:()=>"Failed to update GitHub Actions workflow.",onSuccess:()=>"GitHub Actions workflow updated successfully"}))})))}else if(l)yield*e.log.warning(`\`${l.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`);else yield*e.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});n.start("Migrating `typecheck` script to unified `check` command..."),yield*o.pipe(Z.onExit((i)=>Z.sync(()=>{n.stop(Be.match(i,{onFailure:()=>"Legacy `typecheck` script migration failed.",onSuccess:(f)=>f==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}))})),Z.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(t)=>Z.gen(function*(){if((yield*F(t.cwd)).scripts?.typecheck===qn)return yield*new H({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*y.exists(t.cwd)).active?.format!=="ts")return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${y.config}\` is not the active oxlint config.`});if(!(yield*z.exists(t.cwd)))return yield*new H({migrationId:"legacy-typecheck-script",reason:`\`${z.config}\` is missing after the migration.`})})});var ye=[Je,Ue,be,zn],kn=Object.fromEntries(ye.map((t)=>[t.id,t])),Un={[Ue.id]:d.name,[Je.id]:m.name,[be.id]:y.name};import*as Jn from"effect/Console";import*as bn from"effect/Effect";import*as Bn from"effect/Terminal";var Vt=()=>bn.gen(function*(){let e=yield*(yield*Bn.Terminal).columns,r=' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n '.split(`
107
- `).reduce((n,o)=>Math.max(n,o.trim().length),0);if(!e||e<r)return;yield*Jn.info(' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n ')});var to=de.boolean("fix").pipe(de.withDescription("Automatically fix safe package install/update issues")),eo=[d,m,y,M,lt];function no(t){return t.applicable&&Array.isArray(t.actions)}var Qn={[d.name]:d,[m.name]:m,[y.name]:y},Wn={[y.name]:y};function Zn(t,e){return Object.hasOwn(t,e)}function Xt(t,e){switch(e.type){case"install_package":return`${t}:${e.type}:${e.package}:${e.targetVersion}`;case"update_package":return`${t}:${e.type}:${e.package}:${e.targetVersion}`;case"create_config":case"update_config":return`${t}:${e.type}:${e.path}`;case"manual_fix":return`${t}:${e.type}:${e.path??e.description}`;case"run_migration":return`${t}:${e.type}:${e.migrationId}`}}var xn=Nt.make("doctor",{fix:to}).pipe(Nt.withDescription("Check Adamantite-managed integrations in the current project"),Nt.withHandler(({fix:t})=>Pt.gen(function*(){let e=Cr.cwd(),r=yield*E;yield*Vt(),yield*r.intro("\uD83D\uDCA0 adamantite doctor");let n=yield*F(e);if(!n.devDependencies?.adamantite&&!n.dependencies?.adamantite)yield*r.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*r.outro("⚠️ Doctor found issues."),yield*new T({command:"doctor",exitCode:Qe.ExitCode(1)});let o=[];for(let c of eo){let a=yield*c.assess(e);if(no(a))o.push({assessment:a,integration:c})}for(let{assessment:c}of o)for(let a of c.warnings)yield*r.log.warning(a);if(o.length===0){yield*r.log.success("No applicable integrations found."),yield*r.outro("✅ Doctor completed successfully!");return}let i=o.flatMap(({assessment:c,integration:a})=>c.actions.map((p)=>({action:p,integration:a})));if(i.length===0){yield*r.log.success("No issues found."),yield*r.outro("✅ Doctor completed successfully!");return}let f=new Set;if(t)yield*Pt.gen(function*(){let c=i.filter(({action:a})=>a.type==="install_package"||a.type==="update_package");if(c.length>0){let a=yield*Y,p=[];for(let{action:l}of c)if(l.type==="install_package"||l.type==="update_package")p.push(`${l.package}@${l.targetVersion}`);yield*a.addDevDependencies(p,e,{silent:!0});for(let{action:l,integration:h}of c){if(l.type==="install_package")yield*r.log.success(`Fixed: installed \`${l.package}@${l.targetVersion}\`.`);if(l.type==="update_package")yield*r.log.success(`Fixed: updated \`${l.package}\` from \`${l.currentVersion}\` to \`${l.targetVersion}\`.`);f.add(Xt(h.name,l))}}for(let{action:a,integration:p}of i){if(a.type!=="create_config")continue;if(!Zn(Qn,p.name))continue;yield*Qn[p.name].create(e),yield*r.log.success(`Fixed: created \`${a.path}\`.`),f.add(Xt(p.name,a))}for(let{action:a,integration:p}of i){if(a.type!=="update_config")continue;if(!Zn(Wn,p.name))continue;yield*Wn[p.name].update(e),yield*r.log.success(`Fixed: updated \`${a.path}\`.`),f.add(Xt(p.name,a))}for(let{action:a,integration:p}of i){if(a.type!=="run_migration")continue;let l=kn[a.migrationId];if(!l)continue;yield*Zt(l,{cwd:e}),f.add(Xt(p.name,a))}}).pipe(Pt.tapError(()=>Pt.gen(function*(){yield*r.outro("❌ Doctor failed")})));let s=i.filter(({action:c,integration:a})=>!f.has(Xt(a.name,c)));if(t&&s.length===0){yield*r.outro("✅ Doctor completed successfully!");return}for(let{action:c}of t?s:i)yield*r.log.warning(`Needs attention: ${c.description}`);yield*r.outro("⚠️ Doctor found issues."),yield*new T({command:"doctor",exitCode:Qe.ExitCode(1)})})));import*as Xn from"effect/Effect";import*as _t from"effect/unstable/cli/Argument";import*as It from"effect/unstable/cli/Command";import*as ut from"effect/unstable/cli/Flag";import*as Yn from"effect/unstable/process/ChildProcessSpawner";var ro=_t.file("files",{mustExist:!0}).pipe(_t.withDescription("Specific files to fix (optional)"),_t.variadic()),oo=ut.boolean("suggested").pipe(ut.withDescription("Apply suggested fixes")),io=ut.boolean("dangerous").pipe(ut.withDescription("Apply dangerous fixes")),fo=ut.boolean("all").pipe(ut.withDescription("Apply all fixes, including suggested and dangerous fixes")),wn=It.make("fix",{all:fo,dangerous:io,files:ro,suggested:oo}).pipe(It.withDescription("Fix issues in code using oxlint"),It.withHandler(({all:t,dangerous:e,files:r,suggested:n})=>Xn.gen(function*(){let o=yield*I,i=new Set(["--fix"]);if(n||t)i.add("--fix-suggestions");if(e||t)i.add("--fix-dangerously");for(let s of r)i.add(s);let f=yield*o.run({args:[...i],command:y.name});if(f!==Yn.ExitCode(0))yield*new T({command:y.name,exitCode:f})})));import*as Hn from"effect/Effect";import*as Tt from"effect/unstable/cli/Argument";import*as qt from"effect/unstable/cli/Command";import*as me from"effect/unstable/cli/Flag";import*as Mn from"effect/unstable/process/ChildProcessSpawner";var ao=Tt.file("files",{mustExist:!0}).pipe(Tt.withDescription("Specific files to format (optional)"),Tt.variadic()),lo=me.boolean("check").pipe(me.withDescription("Check if files are formatted without writing")),Kn=qt.make("format",{check:lo,files:ao}).pipe(qt.withDescription("Format files using oxfmt"),qt.withHandler(({check:t,files:e})=>Hn.gen(function*(){let r=yield*I,n=[];if(t)n.push("--check");n.push(...e);let o=yield*r.run({args:n,command:m.name});if(o!==Mn.ExitCode(0))yield*new T({command:m.name,exitCode:o})})));import mo from"node:process";import*as g from"effect/Effect";import*as fr from"effect/FileSystem";import*as ar from"effect/Path";import*as zt from"effect/unstable/cli/Command";import*as K from"effect/Effect";import*as he from"effect/FileSystem";import*as Ee from"effect/Path";import*as An from"effect/unstable/process/ChildProcessSpawner";var Yt=[{path:".vscode/settings.json",type:"config"}],Ln={"[css]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[graphql]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[json]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[jsonc]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"editor.codeActionsOnSave":{"source.fixAll.oxc":"explicit"},"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0},et=P({config:Yt[0].path,create:(t)=>K.gen(function*(){let e=yield*he.FileSystem,r=yield*Ee.Path,n=r.join(t,Yt[0].path),o=r.dirname(n);yield*e.makeDirectory(o,{recursive:!0}).pipe(K.mapError((i)=>new yt({cause:i,path:o}))),yield*e.writeFileString(n,`${JSON.stringify(Ln,null,2)}
108
- `).pipe(K.mapError((i)=>new O({cause:i,path:n})))}),exists:(t)=>K.gen(function*(){let e=yield*he.FileSystem,r=yield*Ee.Path;return yield*e.exists(r.join(t,Yt[0].path))}),extension:(t=[])=>K.gen(function*(){let e=[];if(t.includes("check")||t.includes("fix")||t.includes("format"))e.push("oxc.oxc-vscode");if(t.includes("analyze"))e.push("webpro.vscode-knip");for(let r of e){let o=yield*(yield*I).run({args:["--install-extension",r],command:"code"}).pipe(K.mapError((i)=>i._tag==="CliNotFound"&&i.command==="code"?new Pe({cause:i}):new Mt({cause:i,extension:r})));if(o!==An.ExitCode(0))return yield*new Mt({cause:o,extension:r})}}),files:Yt,kind:"editor",name:"vscode",update:(t)=>K.gen(function*(){let e=yield*he.FileSystem,n=(yield*Ee.Path).join(t,Yt[0].path),o=yield*e.readFileString(n).pipe(K.mapError((s)=>new v({cause:s,path:n}))),i=yield*J(o,n);if(!N(i))return yield*new W({path:n});let f=yield*gt(Ln,i);yield*e.writeFileString(n,`${JSON.stringify(f,null,2)}
109
- `).pipe(K.mapError((s)=>new O({cause:s,path:n})))})});import*as ft from"effect/Effect";import*as ge from"effect/FileSystem";import*as Oe from"effect/Path";var wt=[{path:".zed/settings.json",type:"config"}],Gn={languages:{CSS:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},HTML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSON:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSONC:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JavaScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},MDX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},Markdown:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},TSX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},YAML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}},at=P({config:wt[0].path,create:(t)=>ft.gen(function*(){let e=yield*ge.FileSystem,r=yield*Oe.Path,n=r.join(t,wt[0].path),o=r.dirname(n);yield*e.makeDirectory(o,{recursive:!0}).pipe(ft.mapError((i)=>new yt({cause:i,path:o}))),yield*e.writeFileString(n,`${JSON.stringify(Gn,null,2)}
110
- `).pipe(ft.mapError((i)=>new O({cause:i,path:n})))}),exists:(t)=>ft.gen(function*(){let e=yield*ge.FileSystem,r=yield*Oe.Path;return yield*e.exists(r.join(t,wt[0].path))}),files:wt,kind:"editor",name:"zed",update:(t)=>ft.gen(function*(){let e=yield*ge.FileSystem,n=(yield*Oe.Path).join(t,wt[0].path),o=yield*e.readFileString(n).pipe(ft.mapError((s)=>new v({cause:s,path:n}))),i=yield*J(o,n);if(!N(i))return yield*new W({path:n});let f=yield*gt(Gn,i);yield*e.writeFileString(n,`${JSON.stringify(f,null,2)}
111
- `).pipe(ft.mapError((s)=>new O({cause:s,path:n})))})});import*as ht from"effect/Effect";import*as Cn from"effect/FileSystem";import*as tr from"effect/Path";import{runScriptCommand as so}from"nypm";var po="AGENTS.md",er="<!-- ADAMANTITE:START -->",We="<!-- ADAMANTITE:END -->";function uo(t,e){let r=so(t,e),n=Bt[e];switch(e){case"analyze":return`- Run \`${r}\` after changing dependencies, imports, or exports. Direct command: \`${n}\`.`;case"check":return`- Run \`${r}\` to catch lint and type issues. Direct command: \`${n}\`.`;case"check:monorepo":return`- Run \`${r}\` to check monorepo package consistency. Direct command: \`${n}\`.`;case"fix":return`- Run \`${r}\` to apply safe lint fixes. Direct command: \`${n}\`.`;case"fix:monorepo":return`- Run \`${r}\` to fix monorepo package consistency. Direct command: \`${n}\`.`;case"format":return`- Run \`${r}\` after editing files. Direct command: \`${n}\`.`}}function co({packageManager:t,scripts:e}){let n=["format","check","fix","analyze","check:monorepo","fix:monorepo"].filter((i)=>e.includes(i)).map((i)=>uo(t,i)),o=["## Adamantite","","This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.","",...n.length>0?["- Prefer the package scripts Adamantite added for this workspace.",...n]:[],"- Use `adamantite doctor` to inspect managed setup and `adamantite doctor --fix` for safe local fixes."].join(`
112
- `);return[er,"",o,"",We,""].join(`
113
- `)}var nr=(t,e)=>ht.gen(function*(){let r=yield*Cn.FileSystem,o=(yield*tr.Path).join(t,po),f=(yield*r.exists(o).pipe(ht.mapError((l)=>new v({cause:l,path:o}))))?yield*r.readFileString(o).pipe(ht.mapError((l)=>new v({cause:l,path:o}))):"",s=f.indexOf(er),c=f.indexOf(We),a=co(e);if(s!==-1&&c!==-1&&s<c){let l=c+We.length,h=`${f.slice(0,s)}${a.trimEnd()}${f.slice(l)}`;return yield*r.writeFileString(o,h.endsWith(`
114
- `)?h:`${h}
115
- `).pipe(ht.mapError(($)=>new O({cause:$,path:o}))),"updated"}if(s!==-1||c!==-1)return"malformed";let p=f.length===0||f.endsWith(`
116
-
117
- `)?"":f.endsWith(`
104
+ `}var yt=[{path:".github/workflows/adamantite.yml",type:"ci"}],se=I({create:(e,t)=>Oe.gen(function*(){let n=yield*ht.FileSystem,r=yield*mt.Path,o=r.join(e,yt[0].path);yield*Bn(r.dirname(o));let i=Zn(t);if(!i)return;yield*n.writeFileString(o,i).pipe(Oe.mapError((s)=>new j({cause:s,path:o})))}),detect:(e)=>Oe.gen(function*(){let t=yield*ht.FileSystem,n=yield*mt.Path;return yield*t.exists(n.join(e,yt[0].path))}),files:yt,kind:"ci",name:"github",update:(e,t)=>Oe.gen(function*(){let n=yield*ht.FileSystem,o=(yield*mt.Path).join(e,yt[0].path),i=Zn(t);if(!i)return;yield*n.writeFileString(o,i).pipe(Oe.mapError((s)=>new j({cause:s,path:o})))})});import*as Xn from"effect/Context";import*as je from"effect/Effect";import*as Yn from"effect/Layer";import{addDevDependency as Eo,detectPackageManager as go}from"nypm";class K extends Xn.Service()("DependencyInstaller"){static layer=Yn.succeed(this)({addDevDependencies:(e,t,n)=>je.tryPromise({catch:(r)=>new Tt({cause:r,packages:e}),try:()=>Eo(e,{...n,cwd:t})}).pipe(je.asVoid),detectPackageManager:(e)=>je.tryPromise({catch:(t)=>new Xe({cause:t}),try:()=>go(e)}).pipe(je.map((t)=>t??null))})}import*as ue from"effect/Effect";import*as dt from"effect/FileSystem";import*as Et from"effect/Path";var Me=[{path:"tsconfig.json",type:"config"}],Hn={extends:"adamantite/typescript"},k=I({config:Me[0].path,create:(e)=>ue.gen(function*(){let t=yield*dt.FileSystem,r=(yield*Et.Path).join(e,Me[0].path),o=JSON.stringify(Hn,null,2);yield*t.writeFileString(r,`${o}
105
+ `).pipe(ue.mapError((i)=>new j({cause:i,path:r})))}),detect:(e)=>ue.gen(function*(){let t=yield*dt.FileSystem,n=yield*Et.Path;return yield*t.exists(n.join(e,Me[0].path))}),files:Me,kind:"workspace",name:"tsconfig",update:(e)=>ue.gen(function*(){let t=yield*dt.FileSystem,r=(yield*Et.Path).join(e,Me[0].path),o=yield*t.readFileString(r).pipe(ue.mapError((a)=>new R({cause:a,path:r}))),i=yield*A(o,r);if(!N(i))return yield*new Z({path:r});let s=yield*De(Hn,i);yield*t.writeFileString(r,`${JSON.stringify(s,null,2)}
106
+ `).pipe(ue.mapError((a)=>new j({cause:a,path:r})))})});var xn="adamantite typecheck";function Oo(){return y.files[1].path}function jo(){return se.files[0].path}function Kn(e){let t={...e.scripts};if(t.typecheck!==xn)return{migrated:!1,packageJson:e};return delete t.typecheck,t.check??=He.check,{migrated:!0,packageJson:{...e,scripts:t}}}var Ln=pe({check:(e)=>Se.gen(function*(){let t=yield*v(e.cwd),{migrated:n}=Kn(t);if(!n)return{applicable:!1,warnings:[]};return{applicable:!0,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json",y.config,Oo(),k.config,jo()],id:"legacy-typecheck-script",migrate:(e)=>Se.gen(function*(){let t=yield*O,n=yield*K,r=Se.gen(function*(){let o=yield*v(e.cwd),i=Kn(o);if(!i.migrated)return"noop";yield*an(e.cwd,i.packageJson);let s=yield*y.detect(e.cwd);if(s.active===null)yield*y.create(e.cwd);else if(s.active.format==="ts")yield*y.update(e.cwd);yield*(yield*k.detect(e.cwd))?k.update(e.cwd):k.create(e.cwd);let u=yield*se.detect(e.cwd),f=H(i.packageJson);if(u&&we(f)){let l=yield*n.detectPackageManager(e.cwd);if(l&&Ye(l.name)){let p=l.name;yield*t.withSpinner(()=>se.update(e.cwd,{packageManager:p,scripts:f}),{failure:"Failed to update GitHub Actions workflow.",start:"Updating GitHub Actions workflow...",success:"GitHub Actions workflow updated successfully"})}else if(l)yield*t.log.warning(`\`${l.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`);else yield*t.log.warning("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return"migrated"});yield*t.withSpinner(()=>r,{failure:"Legacy `typecheck` script migration failed.",start:"Migrating `typecheck` script to unified `check` command...",success:(o)=>o==="noop"?"No migration needed.":"Legacy `typecheck` script migrated to `check` successfully."}).pipe(Se.asVoid)}),tags:["update"],title:"Legacy typecheck script",validate:(e)=>Se.gen(function*(){if((yield*v(e.cwd)).scripts?.typecheck===xn)return yield*new x({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*y.detect(e.cwd)).active?.format!=="ts")return yield*new x({migrationId:"legacy-typecheck-script",reason:`\`${y.config}\` is not the active oxlint config.`});if(!(yield*k.detect(e.cwd)))return yield*new x({migrationId:"legacy-typecheck-script",reason:`\`${k.config}\` is missing after the migration.`})})});var gt=[Lt,xt,wt,Ln],wn=Object.fromEntries(gt.map((e)=>[e.id,e])),Mn={[xt.id]:h.name,[Lt.id]:m.name,[wt.id]:y.name};import*as Gn from"effect/Array";import*as $e from"effect/Effect";import*as Ot from"effect/Option";var So=$e.fn("collectApplicableAssessments")((e,t)=>$e.forEach((n)=>n.assess(t).pipe($e.map((r)=>r.applicable?Ot.some({assessment:r,integration:n}):Ot.none())))(e).pipe($e.map((n)=>Gn.getSomes(n))));function jt(e,t){return So(e,t)}import*as Cn from"effect/Console";import*as er from"effect/Effect";import*as tr from"effect/Terminal";var _e=()=>er.gen(function*(){let t=yield*(yield*tr.Terminal).columns,n=' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n '.split(`
107
+ `).reduce((r,o)=>Math.max(r,o.trim().length),0);if(!t||t<n)return;yield*Cn.info(' .o8 . o8o . \n "888 .o8 `"\' .o8 \n .oooo. .oooo888 .oooo. ooo. .oo. .oo. .oooo. ooo. .oo. .o888oo oooo .o888oo .ooooo. \n`P )88b d88\' `888 `P )88b `888P"Y88bP"Y88b `P )88b `888P"Y88b 888 `888 888 d88\' `88b \n .oP"888 888 888 .oP"888 888 888 888 .oP"888 888 888 888 888 888 888ooo888 \nd8( 888 888 888 d8( 888 888 888 888 d8( 888 888 888 888 . 888 888 . 888 .o \n`Y888""8o `Y8bod88P" `Y888""8o o888o o888o o888o `Y888""8o o888o o888o "888" o888o "888" `Y8bod8P\' \n \n \n ')});var Fo=St.boolean("fix").pipe(St.withDescription("Automatically fix safe package install/update issues")),vo=[h,m,y,L,le],nr={[h.name]:h,[m.name]:m,[y.name]:y},rr={[y.name]:y};function or(e,t){return Object.hasOwn(e,t)}function Ge(e,t){switch(t.type){case"install_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"update_package":return`${e}:${t.type}:${t.package}:${t.targetVersion}`;case"create_config":case"update_config":return`${e}:${t.type}:${t.path}`;case"manual_fix":return`${e}:${t.type}:${t.path??t.description}`;case"run_migration":return`${e}:${t.type}:${t.migrationId}`}}var ir=ze.make("doctor",{fix:Fo}).pipe(ze.withDescription("Check Adamantite-managed integrations in the current project"),ze.withHandler(({fix:e})=>qe.gen(function*(){let t=$o.cwd(),n=yield*O;yield*_e(),yield*n.intro("\uD83D\uDCA0 adamantite doctor");let r=yield*v(t);if(!r.devDependencies?.adamantite&&!r.dependencies?.adamantite)yield*n.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*n.outro("⚠️ Doctor found issues."),yield*new b({command:"doctor",exitCode:Mt.ExitCode(1)});let o=yield*jt(vo,t);for(let{assessment:u}of o)for(let f of u.warnings)yield*n.log.warning(f);if(o.length===0){yield*n.log.success("No applicable integrations found."),yield*n.outro("✅ Doctor completed successfully!");return}let i=o.flatMap(({assessment:u,integration:f})=>u.actions.map((l)=>({action:l,integration:f})));if(i.length===0){yield*n.log.success("No issues found."),yield*n.outro("✅ Doctor completed successfully!");return}let s=new Set;if(e)yield*qe.gen(function*(){let u=i.filter(({action:f})=>f.type==="install_package"||f.type==="update_package");if(u.length>0){let f=yield*K,l=[];for(let{action:p}of u)if(p.type==="install_package"||p.type==="update_package")l.push(`${p.package}@${p.targetVersion}`);yield*f.addDevDependencies(l,t,{silent:!0});for(let{action:p,integration:E}of u){if(p.type==="install_package")yield*n.log.success(`Fixed: installed \`${p.package}@${p.targetVersion}\`.`);if(p.type==="update_package")yield*n.log.success(`Fixed: updated \`${p.package}\` from \`${p.currentVersion}\` to \`${p.targetVersion}\`.`);s.add(Ge(E.name,p))}}for(let{action:f,integration:l}of i){if(f.type!=="create_config")continue;if(!or(nr,l.name))continue;yield*nr[l.name].create(t),yield*n.log.success(`Fixed: created \`${f.path}\`.`),s.add(Ge(l.name,f))}for(let{action:f,integration:l}of i){if(f.type!=="update_config")continue;if(!or(rr,l.name))continue;yield*rr[l.name].update(t),yield*n.log.success(`Fixed: updated \`${f.path}\`.`),s.add(Ge(l.name,f))}for(let{action:f,integration:l}of i){if(f.type!=="run_migration")continue;let p=wn[f.migrationId];if(!p)continue;yield*Le(p,{cwd:t}),s.add(Ge(l.name,f))}}).pipe(qe.tapError(()=>qe.gen(function*(){yield*n.outro("❌ Doctor failed")})));let a=i.filter(({action:u,integration:f})=>!s.has(Ge(f.name,u)));if(e&&a.length===0){yield*n.outro("✅ Doctor completed successfully!");return}for(let{action:u}of e?a:i)yield*n.log.warning(`Needs attention: ${u.description}`);yield*n.outro("⚠️ Doctor found issues."),yield*new b({command:"doctor",exitCode:Mt.ExitCode(1)})})));import*as sr from"effect/Array";import*as ar from"effect/Effect";import*as be from"effect/unstable/cli/Argument";import*as Ue from"effect/unstable/cli/Command";import*as ce from"effect/unstable/cli/Flag";import*as fr from"effect/unstable/process/ChildProcessSpawner";var Ro=be.file("files",{mustExist:!0}).pipe(be.withDescription("Specific files to fix (optional)"),be.variadic()),Do=ce.boolean("suggested").pipe(ce.withDescription("Apply suggested fixes")),Vo=ce.boolean("dangerous").pipe(ce.withDescription("Apply dangerous fixes")),Po=ce.boolean("all").pipe(ce.withDescription("Apply all fixes, including suggested and dangerous fixes")),Gt=Ue.make("fix",{all:Po,dangerous:Vo,files:Ro,suggested:Do}).pipe(Ue.withDescription("Fix issues in code using oxlint"),Ue.withHandler(({all:e,dangerous:t,files:n,suggested:r})=>ar.gen(function*(){let o=yield*B,i=yield*_,s=sr.dedupe(["--fix",...r||e?["--fix-suggestions"]:[],...t||e?["--fix-dangerously"]:[],...n]),a=yield*i.run({args:[...s,...o],command:y.name});if(a!==fr.ExitCode(0))yield*new b({command:y.name,exitCode:a})})));import*as lr from"effect/Effect";import*as ke from"effect/unstable/cli/Argument";import*as Ae from"effect/unstable/cli/Command";import*as $t from"effect/unstable/cli/Flag";import*as pr from"effect/unstable/process/ChildProcessSpawner";var Io=ke.file("files",{mustExist:!0}).pipe(ke.withDescription("Specific files to format (optional)"),ke.variadic()),No=$t.boolean("check").pipe($t.withDescription("Check if files are formatted without writing")),Ct=Ae.make("format",{check:No,files:Io}).pipe(Ae.withDescription("Format files using oxfmt"),Ae.withHandler(({check:e,files:t})=>lr.gen(function*(){let n=yield*B,r=yield*_,o=[];if(e)o.push("--check");o.push(...t,...n);let i=yield*r.run({args:o,command:m.name});if(i!==pr.ExitCode(0))yield*new b({command:m.name,exitCode:i})})));import Uo from"node:process";import*as Je from"effect/Array";import*as d from"effect/Effect";import*as vr from"effect/FileSystem";import*as Rr from"effect/Path";import*as Dr from"effect/Predicate";import*as he from"effect/unstable/cli/Command";import*as $ from"effect/unstable/cli/Flag";import*as w from"effect/Effect";import*as Ft from"effect/FileSystem";import*as vt from"effect/Path";import*as cr from"effect/unstable/process/ChildProcessSpawner";var Ce=[{path:".vscode/settings.json",type:"config"}],ur={"[css]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[graphql]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[javascriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[json]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[jsonc]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescript]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"[typescriptreact]":{"editor.defaultFormatter":"oxc.oxc-vscode"},"editor.codeActionsOnSave":{"source.fixAll.oxc":"explicit"},"editor.defaultFormatter":"oxc.oxc-vscode","editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0},ye=I({config:Ce[0].path,create:(e)=>w.gen(function*(){let t=yield*Ft.FileSystem,n=yield*vt.Path,r=n.join(e,Ce[0].path),o=n.dirname(r);yield*t.makeDirectory(o,{recursive:!0}).pipe(w.mapError((i)=>new ge({cause:i,path:o}))),yield*t.writeFileString(r,`${JSON.stringify(ur,null,2)}
108
+ `).pipe(w.mapError((i)=>new j({cause:i,path:r})))}),detect:(e)=>w.gen(function*(){let t=yield*Ft.FileSystem,n=yield*vt.Path;return yield*t.exists(n.join(e,Ce[0].path))}),extension:(e=[])=>w.gen(function*(){let t=[];if(e.includes("check")||e.includes("fix")||e.includes("format"))t.push("oxc.oxc-vscode");if(e.includes("analyze"))t.push("webpro.vscode-knip");for(let n of t){let o=yield*(yield*_).run({args:["--install-extension",n],command:"code"}).pipe(w.mapError((i)=>i._tag==="CliNotFound"&&i.command==="code"?new At({cause:i}):new tt({cause:i,extension:n})));if(o!==cr.ExitCode(0))return yield*new tt({cause:o,extension:n})}}),files:Ce,kind:"editor",name:"vscode",update:(e)=>w.gen(function*(){let t=yield*Ft.FileSystem,r=(yield*vt.Path).join(e,Ce[0].path),o=yield*t.readFileString(r).pipe(w.mapError((a)=>new R({cause:a,path:r}))),i=yield*A(o,r);if(!N(i))return yield*new Z({path:r});let s=yield*De(ur,i);yield*t.writeFileString(r,`${JSON.stringify(s,null,2)}
109
+ `).pipe(w.mapError((a)=>new j({cause:a,path:r})))})});import*as ae from"effect/Effect";import*as Rt from"effect/FileSystem";import*as Dt from"effect/Path";var et=[{path:".zed/settings.json",type:"config"}],yr={languages:{CSS:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},HTML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSON:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JSONC:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},JavaScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},MDX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},Markdown:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]},TSX:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},TypeScript:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}},{code_action:"source.fixAll.oxc"}]},YAML:{format_on_save:"on",formatter:[{language_server:{name:"oxfmt"}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:"onSave",typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:"safe_fix",run:"onType",typeAware:!0,unusedDisableDirectives:"deny"}}}}},Fe=I({config:et[0].path,create:(e)=>ae.gen(function*(){let t=yield*Rt.FileSystem,n=yield*Dt.Path,r=n.join(e,et[0].path),o=n.dirname(r);yield*t.makeDirectory(o,{recursive:!0}).pipe(ae.mapError((i)=>new ge({cause:i,path:o}))),yield*t.writeFileString(r,`${JSON.stringify(yr,null,2)}
110
+ `).pipe(ae.mapError((i)=>new j({cause:i,path:r})))}),detect:(e)=>ae.gen(function*(){let t=yield*Rt.FileSystem,n=yield*Dt.Path;return yield*t.exists(n.join(e,et[0].path))}),files:et,kind:"editor",name:"zed",update:(e)=>ae.gen(function*(){let t=yield*Rt.FileSystem,r=(yield*Dt.Path).join(e,et[0].path),o=yield*t.readFileString(r).pipe(ae.mapError((a)=>new R({cause:a,path:r}))),i=yield*A(o,r);if(!N(i))return yield*new Z({path:r});let s=yield*De(yr,i);yield*t.writeFileString(r,`${JSON.stringify(s,null,2)}
111
+ `).pipe(ae.mapError((a)=>new j({cause:a,path:r})))})});import*as ve from"effect/Effect";import*as hr from"effect/FileSystem";import*as mr from"effect/Path";import{runScriptCommand as To}from"nypm";var _o="AGENTS.md",dr="<!-- ADAMANTITE:START -->",en="<!-- ADAMANTITE:END -->";function qo(e,t){let n=To(e,t),r=He[t];switch(t){case"analyze":return`- Run \`${n}\` after changing dependencies, imports, or exports. Direct command: \`${r}\`.`;case"check":return`- Run \`${n}\` to catch lint and type issues. Direct command: \`${r}\`.`;case"check:monorepo":return`- Run \`${n}\` to check monorepo package consistency. Direct command: \`${r}\`.`;case"fix":return`- Run \`${n}\` to apply safe lint fixes. Direct command: \`${r}\`.`;case"fix:monorepo":return`- Run \`${n}\` to fix monorepo package consistency. Direct command: \`${r}\`.`;case"format":return`- Run \`${n}\` after editing files. Direct command: \`${r}\`.`}}function zo({packageManager:e,scripts:t}){let r=["format","check","fix","analyze","check:monorepo","fix:monorepo"].filter((i)=>t.includes(i)).map((i)=>qo(e,i)),o=["## Adamantite","","This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.","",...r.length>0?["- Prefer the package scripts Adamantite added for this workspace.",...r]:[],"- Use `adamantite doctor` to inspect managed setup and `adamantite doctor --fix` for safe local fixes."].join(`
112
+ `);return[dr,"",o,"",en,""].join(`
113
+ `)}var Er=(e,t)=>ve.gen(function*(){let n=yield*hr.FileSystem,o=(yield*mr.Path).join(e,_o),s=(yield*n.exists(o).pipe(ve.mapError((p)=>new R({cause:p,path:o}))))?yield*n.readFileString(o).pipe(ve.mapError((p)=>new R({cause:p,path:o}))):"",a=s.indexOf(dr),u=s.indexOf(en),f=zo(t);if(a!==-1&&u!==-1&&a<u){let p=u+en.length,E=`${s.slice(0,a)}${f.trimEnd()}${s.slice(p)}`;return yield*n.writeFileString(o,E.endsWith(`
114
+ `)?E:`${E}
115
+ `).pipe(ve.mapError((S)=>new j({cause:S,path:o}))),"updated"}if(a!==-1||u!==-1)return"malformed";let l=s.length===0||s.endsWith(`
116
+
117
+ `)?"":s.endsWith(`
118
118
  `)?`
119
119
  `:`
120
120
 
121
- `;return yield*r.writeFileString(o,`${f}${p}${a}`).pipe(ht.mapError((l)=>new O({cause:l,path:o}))),"updated"});import yo from"node:process";import*as rr from"effect/Effect";import*as or from"effect/FileSystem";import*as ir from"effect/Path";var Ze=(t=yo.cwd())=>rr.gen(function*(){let e=yield*or.FileSystem,r=yield*ir.Path;if(yield*e.exists(r.join(t,"pnpm-workspace.yaml")))return!0;return(yield*F(t)).workspaces!==void 0});var ho=(t,e)=>g.gen(function*(){let r=yield*Y,o=(yield*E).spinner();o.start("Installing dependencies...");let i=yield*Ze(t);yield*r.addDevDependencies(e,t,{silent:!0,workspace:i}).pipe(g.tapError(()=>g.sync(()=>{o.stop("Failed to install dependencies.")}))),o.stop("Dependencies installed.")});function xe(t,e){return g.gen(function*(){yield*(yield*E).log.info(`Legacy \`${e}\` was preserved during \`adamantite init\`. \`adamantite init\` does not migrate legacy ${t} configs yet.`)})}var Eo=(t,e)=>g.gen(function*(){let r=yield*E,n=r.spinner();n.start("Setting up oxlint config...");let o=yield*y.exists(t),i=y.files[1].path;if(o.active?.format==="ts"&&o.legacy.length>0)yield*r.log.warning(`Found both \`${y.config}\` and \`${i}\`. Adamantite will use \`${y.config}\`.`);if(o.active?.format==="json")n.message(`Found \`${i}\`, keeping existing config.`),n.stop("oxlint config is ready."),yield*xe("oxlint",i);else if(o.active?.format==="ts")n.message(`Found \`${y.config}\`, keeping existing config.`),n.stop("oxlint config is ready.");else n.message(`\`${y.config}\` not found, creating...`),yield*y.create(t,e),n.stop("oxlint config created successfully.")}),go=(t)=>g.gen(function*(){let e=yield*E,r=e.spinner();r.start("Setting up oxfmt config...");let n=yield*m.exists(t);if(n.active?.format==="ts"&&n.legacy.length>0)yield*e.log.warning(`Found both \`${m.config}\` and \`.oxfmtrc.json(c)\`. Adamantite will use \`${m.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*e.log.warning("Found both `.oxfmtrc.json` and `.oxfmtrc.jsonc`. Multiple legacy oxfmt configs exist; Adamantite will treat `.oxfmtrc.jsonc` as the source of truth when migration is needed.");if(n.active?.format==="json"||n.active?.format==="jsonc"){let o=n.active.path.endsWith(m.files[1].path)?m.files[1].path:m.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("oxfmt config is ready."),yield*xe("oxfmt",o)}else if(n.active?.format==="ts")r.message(`Found \`${m.config}\`, keeping existing config.`),r.stop("oxfmt config is ready.");else r.message(`\`${m.config}\` not found, creating...`),yield*m.create(t),r.stop("oxfmt config created successfully.")}),Oo=(t,e)=>g.gen(function*(){let r=yield*fr.FileSystem,n=yield*ar.Path,o=yield*E,i=yield*F(t),f=o.spinner();f.start("Adding scripts to your `package.json`..."),i.scripts??={};for(let c of e)switch(c){case"check":i.scripts.check="adamantite check";break;case"fix":i.scripts.fix="adamantite fix";break;case"format":i.scripts.format="adamantite format";break;case"check:monorepo":i.scripts["check:monorepo"]="adamantite monorepo";break;case"fix:monorepo":i.scripts["fix:monorepo"]="adamantite monorepo --fix";break;case"analyze":i.scripts.analyze="adamantite analyze";break;default:return yield*new Ve({script:c})}let s=n.join(t,"package.json");yield*r.writeFileString(s,`${JSON.stringify(i,null,2)}
122
- `).pipe(g.mapError((c)=>new O({cause:c,path:s}))),f.stop("Scripts added to your `package.json`")}),jo=(t)=>g.gen(function*(){let e=yield*E,r=e.spinner();r.start("Setting up knip config...");let n=yield*d.exists(t);if(n.active?.format==="ts"&&n.legacy.length>0)yield*e.log.warning(`Found both \`${d.config}\` and \`knip.json(c)\`. Adamantite will use \`${d.config}\`.`);if(n.active&&n.active.format!=="ts"&&n.legacy.length>0)yield*e.log.warning("Found both `knip.json` and `knip.jsonc`. Multiple legacy knip configs exist; Adamantite will treat `knip.jsonc` as the source of truth when migration is needed.");if(n.active?.format==="json"||n.active?.format==="jsonc"){let o=n.active.path.endsWith(d.files[1].path)?d.files[1].path:d.files[2].path;r.message(`Found \`${o}\`, keeping existing config.`),r.stop("knip config is ready."),yield*xe("knip",o)}else if(n.active?.format==="ts")r.message(`Found \`${d.config}\`, keeping existing config.`),r.stop("knip config is ready.");else r.message(`\`${d.config}\` not found, creating...`),yield*d.create(t),r.stop("knip config created successfully.")}),So=(t)=>g.gen(function*(){let r=(yield*E).spinner();if(r.start("Setting up TypeScript config..."),yield*z.exists(t))r.message(`\`${z.config}\` found, updating...`),yield*z.update(t),r.stop(`\`${z.config}\` updated successfully`);else r.message(`\`${z.config}\` not found, creating...`),yield*z.create(t),r.stop(`\`${z.config}\` created successfully`)}),$o=(t,e)=>g.gen(function*(){let r=yield*E;if(e.includes("vscode")){let n=r.spinner();if(n.start(`Checking for \`${et.config}\`...`),yield*et.exists(t))n.message(`\`${et.config}\` found, updating...`),yield*et.update(t),n.stop(`\`${et.config}\` updated with Adamantite preset.`);else n.message(`\`${et.config}\` not found, creating...`),yield*et.create(t),n.stop(`\`${et.config}\` created with Adamantite preset.`)}if(e.includes("zed")){let n=r.spinner();if(n.start(`Checking for \`${at.config}\`...`),yield*at.exists(t))n.message(`\`${at.config}\` found, updating...`),yield*at.update(t),n.stop(`\`${at.config}\` updated with Adamantite preset.`);else n.message(`\`${at.config}\` not found, creating...`),yield*at.create(t),n.stop(`\`${at.config}\` created with Adamantite preset.`)}}),Fo=(t,e)=>g.gen(function*(){let r=yield*E,n=r.spinner();n.start("Installing editor extensions...");let o=t.includes("zed"),i=t.includes("vscode");if(yield*g.gen(function*(){if(t.includes("vscode"))n.message("Installing VS Code extension..."),yield*et.extension(e);return!0}).pipe(g.tapError(()=>g.sync(()=>{n.stop()})),g.catchTag("FailedToInstallExtension",(s)=>g.gen(function*(){return yield*r.log.warning(`⚠️ Failed to install the \`${s.extension}\` extension.`),yield*r.log.warning("Please install it manually after setup completes."),!1})),g.catchTag("VscodeCliNotFound",()=>g.gen(function*(){return yield*r.log.error("VSCode CLI ('code' command) not found."),yield*r.log.info("To install it:"),yield*r.log.info(" 1. Open VS Code"),yield*r.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))))if(o&&!i)n.stop("Zed extensions require manual install.");else n.stop("Editor extensions installed successfully.");if(o)yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),vo=(t,e,r)=>g.gen(function*(){let o=(yield*E).spinner();o.start("Setting up GitHub Actions workflow...");let i=yield*it.exists(t),f=it.files[0].path;if(i)o.message(`\`${f}\` found, updating...`),yield*it.update(t,{packageManager:e,scripts:r}),o.stop("GitHub Actions workflow updated successfully.");else o.message(`Creating \`${f}\`...`),yield*it.create(t,{packageManager:e,scripts:r}),o.stop("GitHub Actions workflow created successfully.")}).pipe(g.option),Ro=(t,e,r)=>g.gen(function*(){let n=yield*E,o=n.spinner();o.start("Updating AGENTS.md...");let i=yield*nr(t,{packageManager:e,scripts:r}).pipe(g.catchTag(["FailedToReadFile","FailedToWriteFile"],(f)=>g.gen(function*(){return o.stop("Failed to update AGENTS.md."),yield*n.log.warning(`Could not update AGENTS.md. ${f.message} Adamantite will continue initialization.`),"failed"})));if(i==="failed")return;if(o.stop("AGENTS.md check complete."),i==="malformed")yield*n.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),lr=zt.make("init").pipe(zt.withDescription("Initialize Adamantite in the current directory"),zt.withHandler(()=>g.gen(function*(){let t=mo.cwd(),e=yield*E;yield*Vt(),yield*e.intro("\uD83D\uDCA0 adamantite init");let n=yield*(yield*Y).detectPackageManager(t);if(!n)return yield*new bt({});if(n.warnings?.length)for(let j of n.warnings)yield*e.log.warning(j);yield*e.log.info(`Detected package manager: ${n.name}`);let o=yield*Ze(t);if(o)yield*e.log.info("We've detected a monorepo setup in your project.");let i=yield*e.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:"recommended",label:"check - find issues and type errors using oxlint",value:"check"},{hint:"recommended",label:"fix - fix code issues using oxlint",value:"fix"},{hint:"recommended",label:"format - code formatting using oxfmt",value:"format"},{disabled:!o,hint:o?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!o,hint:o?void 0:"available for monorepo projects",label:"fix:monorepo - fix monorepo-specific issues using Sherif",value:"fix:monorepo"},{label:"analyze - find unused dependencies, exports, and files using knip",value:"analyze"}]}),f=i.includes("check")||i.includes("fix"),s=[];if(f)s=yield*e.multiselect({message:"Which presets do you want to install? (core is always included)",options:[{label:"React",value:"react"},{label:"Next.js",value:"nextjs"},{label:"Vue",value:"vue"},{label:"Jest",value:"jest"},{label:"Vitest",value:"vitest"},{label:"Node",value:"node"}],required:!1});let c=!1;if(f)c=yield*e.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"});let a=yield*e.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),p=!1;if(a.length>0)p=yield*e.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"});let l=ae(i),h=!1;if(l)h=yield*e.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"});let $=yield*e.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),R=i.includes("format"),_=i.includes("check:monorepo")||i.includes("fix:monorepo"),nt=i.includes("analyze"),u=["adamantite"];if(f)u.push(`${y.name}@${y.version}`,`${lt.name}@${lt.version}`);if(R)u.push(`${m.name}@${m.version}`);if(_)u.push(`${M.name}@${M.version}`);if(nt)u.push(`${d.name}@${d.version}`);if(yield*ho(t,u),R)yield*go(t);if(f)yield*Eo(t,s);if(nt)yield*jo(t);if(yield*Oo(t,i),$)yield*Ro(t,n.name,i);if(c)yield*So(t);if(yield*$o(t,a),p)yield*Fo(a,i);if(h){let j=n.name;if(At(j))yield*vo(t,j,i);else yield*e.log.warning(`Skipping GitHub Actions setup: \`${j}\` is not a supported package manager for CI workflow generation.`)}yield*e.log.success("Your project is now configured"),yield*e.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(g.catchTags({OperationCancelled:()=>g.gen(function*(){yield*(yield*E).cancel("You've cancelled the initialization process.")})}))));import*as sr from"effect/Effect";import*as kt from"effect/unstable/cli/Command";import*as je from"effect/unstable/cli/Flag";import*as pr from"effect/unstable/process/ChildProcessSpawner";var Do=je.boolean("fix").pipe(je.withDescription("Automatically fix issues")),ur=kt.make("monorepo",{fix:Do}).pipe(kt.withDescription("Find and fix monorepo-specific issues using Sherif"),kt.withHandler(({fix:t})=>sr.gen(function*(){let e=yield*I,r=t?["--fix"]:[],n=yield*e.run({args:r,command:M.name,stdin:"inherit"});if(n!==pr.ExitCode(0))yield*new T({command:M.name,exitCode:n})})));import*as cr from"effect/Effect";import*as Ut from"effect/unstable/cli/Command";import*as yr from"effect/unstable/process/ChildProcessSpawner";var dr=Ut.make("typecheck").pipe(Ut.withDescription("Deprecated alias for `check`"),Ut.withHandler(()=>cr.gen(function*(){let t=yield*E,e=yield*I;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*e.run({args:[],command:y.name});if(r!==yr.ExitCode(0))yield*new T({command:y.name,exitCode:r})})));import Vo from"node:process";import*as w from"effect/Effect";import*as Jt from"effect/unstable/cli/Command";var Po=[y,lt,m,M,d],No=[y,lt,m,M,d];function _o(t){return t.applicable&&Array.isArray(t.actions)}function Io(t,e){let r=[];for(let n of No){if(e.has(n.name))continue;let o=t.devDependencies?.[n.name]??t.dependencies?.[n.name];if(o&&x(o)!==n.version)r.push({currentVersion:o,name:n.name,targetVersion:n.version})}return r}var mr=Jt.make("update").pipe(Jt.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Jt.withHandler(()=>w.gen(function*(){let t=Vo.cwd(),e=yield*E,r=yield*Y,n={cwd:t};yield*Vt(),yield*e.intro("\uD83D\uDCA0 adamantite update");let o=()=>w.gen(function*(){let u=[];for(let j of Po){let Ht=yield*j.assess(t);if(_o(Ht))u.push({assessment:Ht,integration:j})}return u}),i=yield*o();for(let{assessment:u}of i)for(let j of u.warnings)yield*e.log.warning(j);let f=new Set(i.map(({integration:u})=>u.name)),s=i.flatMap(({assessment:u})=>u.actions),c=new Set(s.filter((u)=>u.type==="run_migration").map((u)=>u.migrationId)),a=[];for(let u of ye.filter((j)=>j.tags.includes("update"))){let j=Un[u.id];if(f.has(j))continue;let Ht=yield*u.check(n);a.push({migration:u,result:Ht})}for(let u of a){for(let j of u.result.warnings)yield*e.log.warning(j);if(u.result.applicable&&u.result.summary)yield*e.log.info(u.result.summary)}let p=[];for(let u of ye){if(!c.has(u.id))continue;yield*Zt(u,n,{onRestore:e.log.warning(`Migration "${u.title}" failed, restoring files...`)}),p.push(u.id)}for(let{migration:u,result:j}of a){if(!j.applicable||!j.summary)continue;yield*Zt(u,n,{onRestore:e.log.warning(`Migration "${u.title}" failed, restoring files...`)}),p.push(u.id)}if(p.length>0)yield*e.log.success("Migrations ran successfully.");let l=yield*F(t),h=yield*o(),$=h.flatMap(({assessment:u})=>u.actions).filter((u)=>u.type==="create_config"||u.type==="update_config"||u.type==="manual_fix"),R=h.flatMap(({assessment:u})=>u.actions).filter((u)=>u.type==="install_package"||u.type==="update_package").map((u)=>u.type==="install_package"?{currentVersion:"not installed",name:u.package,targetVersion:u.targetVersion}:{currentVersion:u.currentVersion,name:u.package,targetVersion:u.targetVersion}),_=new Set(R.map((u)=>u.name)),nt=[...R,...Io(l,_)];if(nt.length>0){yield*e.log.info("The following dependencies will be updated:");for(let j of nt)yield*e.log.info(` ${j.name}: ${j.currentVersion} → ${j.targetVersion}`);let u=e.spinner();u.start("Updating dependencies..."),yield*r.addDevDependencies(nt.map((j)=>`${j.name}@${j.targetVersion}`),t,{silent:!0}).pipe(w.tapError(()=>w.sync(()=>{u.stop("Failed to update dependencies")}))),u.stop("Dependencies updated successfully"),yield*e.log.success("Dependencies updated successfully.")}if($.length>0){yield*e.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let u of $)yield*e.log.warning(`Doctor follow-up: ${u.description}`)}if(p.length===0&&nt.length===0&&$.length===0)return yield*e.log.success("No changes needed."),"no-changes";return"success"}).pipe(w.tapError(()=>w.gen(function*(){yield*(yield*E).outro("❌ Update failed")})),w.tap((t)=>w.gen(function*(){let e=yield*E;switch(t){case"no-changes":yield*e.outro("✅ Adamantite is already up to date.");break;case"success":yield*e.outro("✅ Update completed successfully!");break;default:break}})))));var To=ct.make("adamantite").pipe(ct.withDescription("Opinionated preset package for modern TypeScript applications"),ct.withSubcommands([Le,ln,xn,wn,Kn,lr,ur,dr,mr]));var qo=ct.run(To,{version:"0.33.2"}).pipe(U.as(0),U.catchTag("CommandFailed",(t)=>U.succeed(t.exitCode)),U.catch((t)=>U.service(E).pipe(U.flatMap((e)=>e.log.error(t.message)),U.as(Sr.ExitCode(1)))),U.provide(Or.mergeAll(Er.layer,E.layer,I.layer,Y.layer)));hr.runMain(qo,{teardown:(t,e)=>{if(gr.isSuccess(t)){e(Number(t.value));return}jr.defaultTeardown(t,e)}});
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)}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adamantite",
3
- "version": "0.33.2",
3
+ "version": "0.34.0",
4
4
  "description": "An strict and opinionated set of presets for modern TypeScript applications",
5
5
  "keywords": [
6
6
  "adamantite",
@@ -70,24 +70,24 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@clack/prompts": "1.7.0",
73
- "@effect/platform-node": "4.0.0-beta.99",
73
+ "@effect/platform-node": "4.0.0-beta.102",
74
74
  "defu": "6.1.7",
75
- "effect": "4.0.0-beta.99",
75
+ "effect": "4.0.0-beta.102",
76
76
  "esrap": "2.3.0",
77
77
  "jsonc-parser": "3.3.1",
78
- "nypm": "0.6.8",
79
- "oxc-parser": "^0.140.0"
78
+ "nypm": "0.6.9",
79
+ "oxc-parser": "^0.142.0"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@changesets/changelog-github": "0.7.0",
83
- "@changesets/cli": "2.31.0",
83
+ "@changesets/cli": "2.31.1",
84
84
  "@types/bun": "1.3.14",
85
85
  "@types/figlet": "1.7.0",
86
86
  "bunup": "0.16.32",
87
- "figlet": "1.11.3",
88
- "knip": "6.29.0",
89
- "oxfmt": "0.60.0",
90
- "oxlint": "1.75.0",
87
+ "figlet": "1.11.4",
88
+ "knip": "6.30.0",
89
+ "oxfmt": "0.61.0",
90
+ "oxlint": "1.76.0",
91
91
  "oxlint-tsgolint": "7.0.2001",
92
92
  "sherif": "1.13.0",
93
93
  "type-fest": "5.8.0",