adamantite 0.34.3 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.js +43 -49
- package/dist/presets/analyze.js +0 -9
- package/dist/presets/tsconfig.json +4 -0
- package/package.json +3 -3
- package/presets/analyze.ts +0 -9
- package/presets/tsconfig.json +4 -0
- package/skills/adamantite/SKILL.md +6 -1
package/README.md
CHANGED
|
@@ -96,6 +96,17 @@ Presets and TypeScript require the `check` or `fix` script. Editor extension ins
|
|
|
96
96
|
requires an editor. Monorepo scripts require a detected monorepo. GitHub Actions requires a
|
|
97
97
|
compatible script and a supported package manager. Omitted boolean flags are disabled.
|
|
98
98
|
|
|
99
|
+
Existing package scripts whose commands differ from Adamantite's are kept and reported
|
|
100
|
+
instead of being replaced. The interactive initializer asks before overwriting them; in
|
|
101
|
+
non-interactive mode, pass `--overwrite-scripts` to replace them. To keep custom flags,
|
|
102
|
+
forward them to the Adamantite command after `--`, e.g.
|
|
103
|
+
`adamantite monorepo -- --ignore-dependency tailwindcss`.
|
|
104
|
+
|
|
105
|
+
In a detected monorepo, TypeScript setup does not write a root `tsconfig.json`, because a
|
|
106
|
+
catch-all root config makes TypeScript treat all packages as one project. Adamantite
|
|
107
|
+
prints guidance instead: add `"extends": "adamantite/typescript"` to each package's
|
|
108
|
+
`tsconfig.json` or to a shared base config.
|
|
109
|
+
|
|
99
110
|
## Commands
|
|
100
111
|
|
|
101
112
|
Run `adamantite --help` or `adamantite <command> --help` for the complete CLI reference.
|
|
@@ -218,7 +229,8 @@ Adamantite publishes configuration that can also be consumed directly:
|
|
|
218
229
|
|
|
219
230
|
## Requirements and boundaries
|
|
220
231
|
|
|
221
|
-
- Adamantite requires
|
|
232
|
+
- Adamantite requires Bun 1.0 or later when run with Bun, or Node.js 22.19 or later when
|
|
233
|
+
run with Node.js.
|
|
222
234
|
- This repository uses Bun, but the CLI can configure projects that use Bun, Deno, npm,
|
|
223
235
|
pnpm, or Yarn where the selected integration supports them.
|
|
224
236
|
- Adamantite manages recognized package scripts and supported configuration shapes. It
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
|
|
3
|
-
`)}
|
|
1
|
+
import*as Q$ from"@effect/platform-node/NodeRuntime";import*as Ru from"@effect/platform-node/NodeServices";import*as _ from"effect/Effect";import*as h$ from"effect/Exit";import*as ky from"effect/Layer";import*as b$ from"effect/Runtime";import*as Z$ from"effect/Stdio";import*as K$ from"effect/unstable/process/ChildProcessSpawner";import*as wy from"effect/Array";import*as ey from"effect/Effect";import*as hr from"effect/unstable/cli/Command";import*as xu from"effect/Effect";import*as mr from"effect/unstable/cli/Command";import*as lr from"effect/unstable/cli/Flag";import*as Mu from"effect/unstable/process/ChildProcessSpawner";import*as Au from"effect/Context";import*as Wr from"effect/Effect";import*as Nu from"effect/Layer";import*as Gu from"effect/unstable/process/ChildProcess";import{stripVTControlCharacters as V$}from"node:util";import*as n from"effect/Array";import*as Y from"effect/Data";import{pipe as lu}from"effect/Function";import*as jy from"effect/Option";import*as my from"effect/Predicate";import*as $r from"effect/String";import{printParseErrorCode as H$}from"jsonc-parser";var X$=20;function Su(r){return my.isError(r)?lu(V$(r.message),$r.split(/\r\n|[\r\n]/),n.map((y)=>$r.trimEnd(y)),n.filter((y)=>$r.isNonEmpty(y))):[]}function Or(r){return lu(Su(r),n.head,jy.map((y)=>{let u=$r.trim(y);return/[.!?]$/.test(u)?` Cause: ${u}`:` Cause: ${u}.`}),jy.getOrElse(()=>""))}function L$(r){let y=Su(r);if(!n.isReadonlyArrayNonEmpty(y))return"";let u=n.takeRight(y,X$);return`
|
|
2
|
+
${(u.length<y.length?["…",...u]:u).join(`
|
|
3
|
+
`)}`}function W$(r=[]){if(r.length===0)return"- Unknown JSON/JSONC parsing error";return r.slice(0,3).map((y)=>`- ${H$(y.error)} (offset: ${y.offset})`).join(`
|
|
4
|
+
`)}class ay extends Y.TaggedError("CliNotFound"){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}}class T extends Y.TaggedError("CommandFailed"){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}}class ny extends Y.TaggedError("FailedToCreateDirectory"){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:"the target directory"}.${Or(this.cause)}`}}class dy extends Y.TaggedError("FailedToInstallDependency"){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(", ")}`:""}.${L$(this.cause)}`}}class Ey extends Y.TaggedError("FailedToInstallExtension"){get message(){let r=this.extension?`\`${this.extension}\``:"the target extension";if(my.isNumber(this.cause))return`Failed to install ${r}. The \`code\` CLI exited with code ${this.cause}.`;return`Failed to install ${r}.${Or(this.cause)}`}}class gy extends Y.TaggedError("FailedToMergeConfig"){get message(){return`Failed to merge configuration.${Or(this.cause)}`}}class sy extends Y.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:",W$(this.errors)].join(`
|
|
5
|
+
`)}}class V extends Y.TaggedError("FailedToReadFile"){get message(){return`Failed to read ${this.path?`\`${this.path}\``:"the target file"}.${Or(this.cause)}`}}class py extends Y.TaggedError("FailedToDeleteFile"){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:"the target file"}.${Or(this.cause)}`}}class b extends Y.TaggedError("FailedToWriteFile"){get message(){return`Failed to write ${this.path?`\`${this.path}\``:"the target file"}.${Or(this.cause)}`}}class iy extends Y.TaggedError("FileNotFound"){get message(){return this.path?`File not found: \`${this.path}\`.`:"File not found."}}class rr extends Y.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 d extends Y.TaggedError("InvalidInitOptions"){get message(){return`Invalid init options. ${this.reason}`}}class oy extends Y.TaggedError("UnsupportedConfigState"){get message(){let r=this.path?`\`${this.path}\``:"the target config file",y=this.reason?` ${this.reason}`:"";return`Unsupported config state in ${r}.${y}`}}class ir extends Y.TaggedError("NoPackageManager"){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${Or(this.cause)}`}}class _$ extends Y.TaggedError("MissingPackageVersion"){get message(){let r=this.path?`\`${this.path}\``:"package.json";if(this.dependency)return`Missing \`${this.dependency}\` in ${r} dependencies or devDependencies.`;return`Missing version field in ${r}.`}}class yr extends Y.TaggedError("MigrationValidationFailed"){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}}class vy extends Y.TaggedError("OperationCancelled"){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:""}`}}class cy extends Y.TaggedError("PassthroughNotSupported"){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}}class ru extends Y.TaggedError("VscodeCliNotFound"){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${Or(this.cause)}`}}class W extends Au.Service()("CommandRunner"){static layer=Nu.succeed(this)({run:({args:r,command:y,cwd:u,stderr:f="inherit",stdin:$="ignore",stdout:O="inherit"})=>Wr.mapError(Wr.scoped(Wr.gen(function*(){return yield*(yield*Gu.make(y,r,{cwd:u,stderr:f,stdin:$,stdout:O})).exitCode})),(j)=>j.reason._tag==="NotFound"?new ay({command:y}):j)})}import*as Ju from"effect/Context";var J=Ju.Reference("adamantite/ForwardedArguments",{defaultValue:()=>[]});import*as or from"effect/Array";import*as s from"effect/Effect";import*as $u from"effect/FileSystem";import{pipe as Ou}from"effect/Function";import*as I from"effect/Option";import*as ju from"effect/Path";function x(r){return r}import l$ from"node:process";import*as qy from"effect/Array";import*as Rr from"effect/Effect";import*as yu from"effect/FileSystem";import{pipe as S$}from"effect/Function";import*as uu from"effect/Path";import*as Iu from"effect/Record";import*as zy from"effect/Result";import{defu as T$}from"defu";import*as g from"effect/Effect";import{parse as R$}from"jsonc-parser";var M=(r,y)=>g.sync(()=>{let u=[],f=R$(r,u,{allowTrailingComma:!0});return{errors:u,parsed:f}}).pipe(g.flatMap(({errors:u,parsed:f})=>u.length>0?g.fail(new sy({errors:u,path:y})):g.succeed(f)));function _r(r,y={}){let{continuationIndent:u,indentation:f=2}=y,$=JSON.stringify(r,null,f).replaceAll(/"([A-Za-z_$][\w$]*)":/g,"$1:");if(!u)return $;return $.replaceAll(`
|
|
4
6
|
`,`
|
|
5
|
-
${
|
|
6
|
-
`).pipe(
|
|
7
|
-
`);return` ${
|
|
8
|
-
`);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...
|
|
9
|
-
`)}var
|
|
10
|
-
`);return[...
|
|
11
|
-
`)}var
|
|
12
|
-
`)?
|
|
13
|
-
`}function
|
|
14
|
-
`);if(
|
|
15
|
-
`)}function
|
|
16
|
-
`)}function
|
|
17
|
-
`);return['import { defineConfig } from "oxfmt"','import format from "adamantite/format"',"","export default defineConfig({"," ...format,",...
|
|
18
|
-
`)}var
|
|
7
|
+
${u}`)}var Tr=(r,y)=>g.try({catch:(u)=>new gy({cause:u}),try:()=>T$(r,y)});var A$=/^workspace:/,N$=/^[\^~]/;function By(r){return r.trim().replace(A$,"").replace(N$,"")}var H=(r=l$.cwd())=>Rr.gen(function*(){let y=yield*yu.FileSystem,f=(yield*uu.Path).join(r,"package.json"),$=yield*y.readFileString(f).pipe(Rr.mapError((j)=>new V({cause:j,path:f})));return yield*M($,f)}),Dy=(r,y)=>Rr.gen(function*(){let u=yield*yu.FileSystem,$=(yield*uu.Path).join(r,"package.json");yield*u.writeFileString($,`${JSON.stringify(y,null,2)}
|
|
8
|
+
`).pipe(Rr.mapError((O)=>new b({cause:O,path:$})))});function br(r){return r==="bun"||r==="deno"||r==="npm"||r==="pnpm"||r==="yarn"}var k={analyze:"adamantite analyze",check:"adamantite check","check:monorepo":"adamantite monorepo",fix:"adamantite fix","fix:monorepo":"adamantite monorepo --fix",format:"adamantite format"};function jr(r){let y=r.scripts??{};return S$(Iu.keys(k),qy.filter((u)=>y[u]===k[u]))}function fu(r,y){let u=r.scripts??{};return qy.filterMap(y,(f)=>{let $=u[f];return $!==void 0&&$!==""&&$!==k[f]?zy.succeed({command:$,script:f}):zy.failVoid})}function Fu(r){if(r.endsWith(".jsonc"))return"jsonc";if(r.endsWith(".json"))return"json";return"ts"}function Uy(r,y){return or.findFirst(r.legacyConfigs,(u)=>Fu(u)===y)}function G$(r){let y=Uy(r,"json"),u=Uy(r,"jsonc");return Ou(I.zipWith(y,u,(f)=>`${f}(c)`),I.orElse(()=>u),I.orElse(()=>y),I.getOrElse(()=>""))}function J$(r,y,u,f){if(u===null||f.length===0)return[];if(u.format==="ts")return[`Found both \`${y.config}\` and \`${G$(y)}\`. Adamantite will use \`${y.config}\`.`];return Ou(I.zipWith(Uy(y,"json"),Uy(y,"jsonc"),($,O)=>`Found both \`${$}\` and \`${O}\`. Multiple legacy ${r} configs exist; Adamantite will treat \`${O}\` as the source of truth when migration is needed.`),I.toArray)}var mu=s.fn("detectToolingConfig")(function*(r,y,u){let f=yield*$u.FileSystem,$=yield*ju.Path,O=[u.config,...u.legacyConfigs].map((q)=>({file:q,format:Fu(q),path:$.join(r,q)})),j=yield*s.forEach(O,(q)=>f.exists(q.path),{concurrency:"unbounded"}),m=O.filter((q,B)=>j[B]),E=Ou(or.findFirst(m,(q)=>q.format==="ts"),I.orElse(()=>or.findFirst(m,(q)=>q.format==="jsonc")),I.orElse(()=>or.findFirst(m,(q)=>q.format==="json")),I.getOrNull),v=m.filter((q)=>q!==E&&q.format!=="ts");return{active:E,legacy:v,warnings:J$(y,u,E,v)}});function Qy(r,y,u){let f=r.devDependencies?.[y.name]??r.dependencies?.[y.name];if(!f)return[{description:`Install \`${y.name}@${y.version}\` for ${u}.`,package:y.name,targetVersion:y.version,type:"install_package"}];if(By(f)!==y.version)return[{currentVersion:f,description:`Update \`${y.name}\` from \`${f}\` to \`${y.version}\`.`,package:y.name,targetVersion:y.version,type:"update_package"}];return[]}function Eu(r,y){if(r.active===null)return[{description:`Create \`${y.configFile}\` for \`${y.toolName}\`.`,path:y.configFile,type:"create_config"}];if(r.active.format!=="ts")return[{description:`Migrate legacy \`${r.active.file}\` to \`${y.configFile}\`.`,migrationId:y.migrationId,type:"run_migration"}];return[]}function Pu(r,y){let u=jr(r);return y.some((f)=>u.includes(f))}function hy(r){return x({assess:(y)=>s.gen(function*(){let u=yield*H(y);if(!Pu(u,r.scripts))return{applicable:!1,warnings:[]};return{actions:Qy(u,r,r.purpose),applicable:!0,warnings:[]}}),kind:"tooling",name:r.name,version:r.version})}function by(r){let y=[{path:r.configFiles.config,type:"config"},...r.configFiles.legacyConfigs.map((f)=>({path:f,type:"legacy_config"}))],u=(f)=>mu(f,r.name,r.configFiles);return x({assess:(f)=>s.gen(function*(){let $=yield*H(f);if(!Pu($,r.scripts))return{applicable:!1,warnings:[]};let O=yield*u(f);return{actions:[...Qy($,r,r.purpose),...Eu(O,{configFile:r.configFiles.config,migrationId:r.migrationId,toolName:r.name})],applicable:!0,warnings:O.warnings}}),config:r.configFiles.config,create:(f)=>s.gen(function*(){let $=yield*$u.FileSystem,j=(yield*ju.Path).join(f,r.configFiles.config);yield*$.writeFileString(j,r.configContent()).pipe(s.mapError((m)=>new b({cause:m,path:j})))}),detect:u,files:y,kind:"tooling",name:r.name,version:r.version})}function Zy(r={}){let y=Object.entries(r).map(([u,f])=>{if(u==="rules"&&typeof f==="object"&&f!==null&&!Array.isArray(f))return[" rules: {"," ...analyze.rules,",...Object.entries(f).map(([O,j])=>` ${O}: ${_r(j,{continuationIndent:" ",indentation:" "})},`)," },"].join(`
|
|
9
|
+
`);return` ${u}: ${_r(f)},`});if(y.length===0)return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = analyze","","export default config",""].join(`
|
|
10
|
+
`);return['import type { KnipConfig } from "knip"','import analyze from "adamantite/analyze"',"","const config: KnipConfig = {"," ...analyze,",...y,"}","","export default config",""].join(`
|
|
11
|
+
`)}var A=by({configContent:()=>Zy(),configFiles:{config:"knip.config.ts",legacyConfigs:["knip.json","knip.jsonc"]},migrationId:"legacy-knip-json",name:"knip",purpose:"the managed `analyze` script",scripts:["analyze"],version:"6.32.2"});var I$=lr.boolean("fix").pipe(lr.withDescription("Automatically fix issues")),F$=lr.boolean("strict").pipe(lr.withDescription("Enable strict mode")),vu=mr.make("analyze",{fix:I$,strict:F$}).pipe(mr.withDescription("Find unused dependencies, exports, and files using knip"),mr.withExamples([{command:"adamantite analyze -- --directory packages/app",description:"Run knip from a specific directory"}]),mr.withHandler(({fix:r,strict:y})=>xu.gen(function*(){let u=yield*J,f=yield*W,$=[];if(r)$.push("--fix","--allow-remove-files");if(y)$.push("--production","--strict");$.push(...u);let O=yield*f.run({args:$,command:A.name});if(O!==Mu.ExitCode(0))yield*new T({command:A.name,exitCode:O})})));import*as pu from"effect/Effect";import*as Sr from"effect/unstable/cli/Argument";import*as Ar from"effect/unstable/cli/Command";import*as iu from"effect/unstable/process/ChildProcessSpawner";import*as ur from"effect/Effect";import*as Hy from"effect/FileSystem";import*as zu from"effect/Path";import*as ry from"effect/Array";import{pipe as cr}from"effect/Function";import*as Z from"effect/Option";import*as Ky from"effect/Predicate";import{print as P$}from"esrap";import x$ from"esrap/languages/ts";import{parseSync as M$}from"oxc-parser";var ku=["respectEslintDisableDirectives","typeAware","typeCheck"],Cu="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",tu="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",wu="`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.";function Yy(r=[]){return r.includes("core")?r:["core",...r]}function eu(r){return r.replaceAll(/-([a-z])/g,(y,u)=>u.toUpperCase())}function Vy(r,y,u=[]){let{options:f,...$}=r,O=['import { defineConfig } from "oxlint"',...y.map((z)=>`import ${eu(z)} from "${z==="core"?"adamantite/lint":`adamantite/lint/${z}`}"`)],m=[...y.map((z)=>eu(z)),...u.map((z)=>JSON.stringify(z))],E=JSON.stringify(Ky.isObject(f)?{...f,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),v=Object.entries($).map(([z,S])=>[z,JSON.stringify(S,null,2)]),q=`[${m.join(", ")}]`,B=[["options",E],...v,["extends",q]].map(([z,S])=>` ${z}: ${S},`).join(`
|
|
12
|
+
`);return[...O,"","export default defineConfig({",B,"})",""].join(`
|
|
13
|
+
`)}var C$=Z.liftThrowable((r)=>M$("oxlint.config.ts",r,{astType:"ts",lang:"ts",sourceType:"module"}));function t$(r){return C$(r).pipe(Z.flatMap((y)=>y.errors.length===0?Z.fromNullishOr(y.program):Z.none()))}function au(r){let{code:y}=P$(r,x$({quotes:"double"}));return y.endsWith(`
|
|
14
|
+
`)?y:`${y}
|
|
15
|
+
`}function w$(r){if(r.type==="Identifier")return cr(r.name,Z.some);if(r.type==="Literal"&&Ky.isString(r.value))return cr(r.value,Z.some);return Z.none()}function e$(r){if(r.type==="ObjectExpression")return cr(r,Z.some);if(r.type!=="CallExpression"||r.callee.type!=="Identifier"||r.callee.name!=="defineConfig")return Z.none();return cr(r.arguments.length===1?ry.head(r.arguments):Z.none(),Z.filter((y)=>y.type==="ObjectExpression"))}function k$(r){return cr(r.body,ry.filter((y)=>y.type==="ExportDefaultDeclaration"),(y)=>y.length===1?ry.head(y):Z.none(),Z.flatMap((y)=>e$(y.declaration)))}function nu(r,y){let u=null;for(let f of r.properties){if(f.type==="SpreadElement")return{status:"manual"};if(f.computed)return{status:"manual"};let $=Z.contains(w$(f.key),y);if(f.method||f.kind!=="init"){if($)return{status:"manual"};continue}if(!$)continue;if(u)return{status:"manual"};u=f}if(!u)return{status:"missing"};return{property:u,status:"found"}}function du(r){return{computed:!1,end:0,key:{end:0,name:r,start:0,type:"Identifier"},kind:"init",method:!1,shorthand:!1,start:0,type:"Property",value:{end:0,raw:"true",start:0,type:"Literal",value:!0}}}function a$(){return{computed:!1,end:0,key:{end:0,name:"options",start:0,type:"Identifier"},kind:"init",method:!1,shorthand:!1,start:0,type:"Property",value:{end:0,properties:ku.map((r)=>du(r)),start:0,type:"ObjectExpression"}}}function n$(r,y){let u=[],f=!1;for(let $ of ku){let O=nu(y,$);if(O.status==="manual")return{kind:"manual",reason:wu};if(O.status==="missing"){u.push($);continue}let j=O.property.value;if(j.type!=="Literal"||typeof j.value!=="boolean")return{kind:"manual",reason:wu};if(j.value)continue;j.raw="true",j.value=!0,f=!0}if(u.length>0)y.properties.unshift(...u.map(($)=>du($))),f=!0;if(!f)return{kind:"configured"};return{kind:"patchable",updatedContent:au(r)}}function qu(r){let y=t$(r);if(Z.isNone(y))return{kind:"manual",reason:Cu};let u=k$(y.value);if(Z.isNone(u))return{kind:"manual",reason:Cu};let f=nu(u.value,"options");if(f.status==="manual")return{kind:"manual",reason:tu};if(f.status==="missing")return u.value.properties.unshift(a$()),{kind:"patchable",updatedContent:au(y.value)};if(f.property.value.type!=="ObjectExpression")return{kind:"manual",reason:tu};return n$(y.value,f.property.value)}var p="oxlint.config.ts",su=".oxlintrc.json",d$=[{path:p,type:"config"},{path:su,type:"legacy_config"}],g$={config:p,legacyConfigs:[su]};var gu=(r)=>mu(r,"oxlint",g$),Q=x({assess:(r)=>ur.gen(function*(){let y=yield*Hy.FileSystem,u=yield*H(r),f=jr(u);if(!f.includes("check")&&!f.includes("fix"))return{applicable:!1,warnings:[]};let $=yield*gu(r),O=[...Qy(u,{name:"oxlint",version:"1.78.0"},"the managed lint scripts"),...Eu($,{configFile:p,migrationId:"legacy-oxlint-json",toolName:"oxlint"})],j=$.active;if(j?.format==="ts"){let m=yield*y.readFileString(j.path).pipe(ur.mapError((v)=>new V({cause:v,path:j.path}))),E=qu(m);if(E.kind==="patchable")O.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:p,type:"update_config"});if(E.kind==="manual")O.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:p,type:"manual_fix"})}return{actions:O,applicable:!0,warnings:$.warnings}}),config:p,create:(r,y=[])=>ur.gen(function*(){let u=yield*Hy.FileSystem,$=(yield*zu.Path).join(r,p),O=Vy({},Yy(y));yield*u.writeFileString($,O).pipe(ur.mapError((j)=>new b({cause:j,path:$})))}),detect:gu,files:d$,kind:"tooling",name:"oxlint",update:(r)=>ur.gen(function*(){let y=yield*Hy.FileSystem,f=(yield*zu.Path).join(r,p);if(!(yield*y.exists(f)))return yield*new iy({path:p});let $=yield*y.readFileString(f).pipe(ur.mapError((j)=>new V({cause:j,path:f}))),O=qu($);if(O.kind==="configured")return;if(O.kind==="manual")return yield*new oy({path:p,reason:O.reason});yield*y.writeFileString(f,O.updatedContent).pipe(ur.mapError((j)=>new b({cause:j,path:f})))}),version:"1.78.0"});var s$=Sr.file("files",{mustExist:!0}).pipe(Sr.withDescription("Specific files to lint (optional)"),Sr.variadic()),Bu=Ar.make("check",{files:s$}).pipe(Ar.withDescription("Find issues and type errors in code using oxlint"),Ar.withHandler(({files:r})=>pu.gen(function*(){let y=yield*J,f=yield*(yield*W).run({args:[...r,...y],command:Q.name});if(f!==iu.ExitCode(0))yield*new T({command:Q.name,exitCode:f})})));import VO from"node:process";import*as Mr from"effect/Effect";import*as Cr from"effect/unstable/cli/Command";import*as Iy from"effect/unstable/cli/Flag";import*as bu from"effect/unstable/process/ChildProcessSpawner";import*as ou from"effect/Predicate";var p$=new Set(["sortImports","sortPackageJson","sortTailwindcss"]);function i$(r){let y=r.split(`
|
|
16
|
+
`);if(y.length===1)return r.slice(1,-1).trim();return y.slice(1,-1).map((u)=>` ${u.trimStart()}`).join(`
|
|
17
|
+
`)}function o$(r,y){let u=_r(y),f=i$(u);return[` ${r}: {`,` ...format.${r},`,...f===""?[]:[f]," },"].join(`
|
|
18
|
+
`)}function Xy(r={}){let y=Object.entries(r).map(([u,f])=>{if(p$.has(u)&&ou.isObject(f))return o$(u,f);let $=_r(f,{continuationIndent:" "});return` ${u}: ${$},`});if(y.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,",...y,"})",""].join(`
|
|
20
|
+
`)}var N=by({configContent:()=>Xy(),configFiles:{config:"oxfmt.config.ts",legacyConfigs:[".oxfmtrc.json",".oxfmtrc.jsonc"]},migrationId:"legacy-oxfmt-json",name:"oxfmt",purpose:"the managed `format` script",scripts:["format"],version:"0.63.0"});var a=hy({name:"sherif",purpose:"the managed monorepo scripts",scripts:["check:monorepo","fix:monorepo"],version:"1.13.0"});var Er=hy({name:"oxlint-tsgolint",purpose:"the managed lint scripts",scripts:["check","fix"],version:"7.0.2001"});import*as F from"effect/Effect";import*as cu from"effect/FileSystem";import*as rf from"effect/Path";function Nr(r){return r}function Ly(r,y){return F.gen(function*(){let u=yield*cu.FileSystem,f=yield*rf.Path,$=r.files??[],O=new Map;for(let j of $){let m=f.join(y.cwd,j);if(yield*u.exists(m)){let v=yield*u.readFileString(m);O.set(m,v)}else O.set(m,null)}return yield*r.migrate(y).pipe(F.tap(()=>r.validate?.(y)??F.void),F.onError(()=>F.gen(function*(){for(let[j,m]of O){if(m!==null){yield*u.writeFileString(j,m).pipe(F.ignore);continue}if(!(yield*u.exists(j).pipe(F.orElseSucceed(()=>!1))))continue;yield*u.remove(j).pipe(F.ignore)}})))})}import*as i from"effect/Effect";import*as Qf from"effect/FileSystem";import*as hf from"effect/Path";import*as Jr from"effect/Effect";import*as Qu from"effect/FileSystem";import*as Ry from"effect/Path";import*as Wy from"effect/Effect";import*as yf from"effect/FileSystem";var Gr=(r)=>Wy.gen(function*(){yield*(yield*yf.FileSystem).makeDirectory(r,{recursive:!0}).pipe(Wy.mapError((u)=>new ny({cause:u,path:r})))});import{runScriptCommand as c$}from"nypm";var uf=[{name:"check",script:"check"},{args:["--check"],name:"format",script:"format"},{name:"monorepo",script:"check:monorepo"},{name:"analyze",script:"analyze"}];function ff(r,y){let u=[];for(let f of uf){if(!y.includes(f.script))continue;u.push({command:c$(r,f.script,{args:f.args}),name:f.name})}return u}function Zr(r){return uf.some((y)=>r.includes(y.script))}import*as $f from"effect/Context";import*as Kr from"effect/Effect";import*as Of from"effect/FileSystem";import*as jf from"effect/Layer";import*as mf from"effect/Path";import*as Uu from"effect/Predicate";import*as G from"effect/Schema";import*as Ef from"effect/String";function Du(r){return{_tag:"File",path:r}}function rO(r){return{_tag:"Version",value:r}}var yO=[".node-version",".nvmrc"],uO=G.Struct({volta:G.Struct({node:G.NonEmptyString})}),fO=G.Struct({engines:G.Struct({node:G.NonEmptyString})}),$O=G.Struct({name:G.NonEmptyString,version:G.NonEmptyString});function OO(r){return r.split(`
|
|
21
|
+
`).map((y)=>y.split("#")[0]?.trim()??"").some((y)=>/^node(?:js)?\s+\S/.test(y))}function jO(r){return G.is($O)(r)&&r.name.toLowerCase()==="node"}function mO(r){if(G.is(uO)(r))return!0;if(Uu.isObject(r)&&Uu.isObject(r.devEngines)){let y=r.devEngines.runtime;if((Array.isArray(y)?y:[y]).some((f)=>jO(f)))return!0}return G.is(fO)(r)}class yy extends $f.Service()("NodeVersionResolver"){static layer=jf.effect(this,Kr.gen(function*(){let r=yield*Of.FileSystem,y=yield*mf.Path,u=(f,$)=>Kr.gen(function*(){let O=y.join(f,$);if(!(yield*r.exists(O)))return null;return yield*r.readFileString(O).pipe(Kr.mapError((m)=>new V({cause:m,path:O})))});return{resolve:Kr.fn("NodeVersionResolver.resolve")(function*(f){for(let j of yO){let m=yield*u(f,j);if(m!==null&&Ef.isNonEmpty(m.trim()))return Du(j)}let $=yield*u(f,".tool-versions");if($!==null&&OO($))return Du(".tool-versions");let O=yield*u(f,"package.json");if(O!==null){let j=yield*M(O,y.join(f,"package.json"));if(mO(j))return Du("package.json")}return rO("lts/*")})}}))}function _y(r){return` - name: Setup Node.js
|
|
19
22
|
uses: actions/setup-node@v7
|
|
20
23
|
with:
|
|
21
|
-
node-version: "
|
|
24
|
+
${r._tag==="File"?`node-version-file: "${r.path}"`:`node-version: "${r.value}"`}`}function EO(r){return{bun:`${_y(r)}
|
|
22
25
|
|
|
23
26
|
- name: Setup Bun
|
|
24
27
|
uses: oven-sh/setup-bun@v2
|
|
@@ -38,31 +41,22 @@ ${t}`)}var ir=(r,e)=>N.try({catch:(t)=>new Re({cause:t}),try:()=>Tn(r,e)});var X
|
|
|
38
41
|
uses: denoland/setup-deno@v2
|
|
39
42
|
|
|
40
43
|
- name: Install dependencies
|
|
41
|
-
run: deno install --frozen`,npm
|
|
42
|
-
uses: actions/setup-node@v7
|
|
43
|
-
with:
|
|
44
|
-
node-version: "24"
|
|
44
|
+
run: deno install --frozen`,npm:`${_y(r)}
|
|
45
45
|
cache: "npm"
|
|
46
46
|
|
|
47
47
|
- name: Install dependencies
|
|
48
48
|
run: npm ci`,pnpm:` - name: Setup pnpm
|
|
49
49
|
uses: pnpm/action-setup@v4
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
uses: actions/setup-node@v7
|
|
53
|
-
with:
|
|
54
|
-
node-version: "24"
|
|
51
|
+
${_y(r)}
|
|
55
52
|
cache: "pnpm"
|
|
56
53
|
|
|
57
54
|
- name: Install dependencies
|
|
58
|
-
run: pnpm install --frozen-lockfile`,yarn
|
|
59
|
-
uses: actions/setup-node@v7
|
|
60
|
-
with:
|
|
61
|
-
node-version: "24"
|
|
55
|
+
run: pnpm install --frozen-lockfile`,yarn:`${_y(r)}
|
|
62
56
|
cache: "yarn"
|
|
63
57
|
|
|
64
58
|
- name: Install dependencies
|
|
65
|
-
run: yarn install --frozen-lockfile`}
|
|
59
|
+
run: yarn install --frozen-lockfile`}}function vO({packageManager:r,scripts:y},u){let f=ff(r,y);if(f.length===0)return null;return`${`name: adamantite
|
|
66
60
|
|
|
67
61
|
on:
|
|
68
62
|
push:
|
|
@@ -87,33 +81,33 @@ jobs:
|
|
|
87
81
|
fail-fast: false
|
|
88
82
|
matrix:
|
|
89
83
|
include:
|
|
90
|
-
${
|
|
91
|
-
command: ${
|
|
84
|
+
${f.map((j)=>` - name: ${j.name}
|
|
85
|
+
command: ${j.command}`).join(`
|
|
92
86
|
`)}
|
|
93
87
|
|
|
94
88
|
steps:
|
|
95
89
|
- name: Checkout
|
|
96
90
|
uses: actions/checkout@v7
|
|
97
91
|
|
|
98
|
-
${
|
|
92
|
+
${EO(u)[r]}
|
|
99
93
|
|
|
100
94
|
- name: Run \${{ matrix.name }}
|
|
101
95
|
run: \${{ matrix.command }}`}
|
|
102
|
-
`}var
|
|
103
|
-
`).pipe(
|
|
104
|
-
`).pipe(
|
|
105
|
-
`).reduce((
|
|
106
|
-
`).pipe(
|
|
107
|
-
`).pipe(
|
|
108
|
-
`).pipe(
|
|
109
|
-
`).pipe(
|
|
110
|
-
`);return[
|
|
111
|
-
`)}var
|
|
112
|
-
`)?
|
|
113
|
-
`).pipe(
|
|
114
|
-
|
|
115
|
-
`)?"":
|
|
96
|
+
`}var Ty=[{path:".github/workflows/adamantite.yml",type:"ci"}],vf=(r,y)=>Jr.gen(function*(){let u=yield*Qu.FileSystem,f=yield*Ry.Path,$=yield*yy,O=f.join(r,Ty[0].path),j=yield*$.resolve(r),m=vO(y,j);if(!m)return;yield*u.writeFileString(O,m).pipe(Jr.mapError((E)=>new b({cause:E,path:O})))}),C=x({create:(r,y)=>Jr.gen(function*(){let u=yield*Ry.Path;yield*Gr(u.dirname(u.join(r,Ty[0].path))),yield*vf(r,y)}),detect:(r)=>Jr.gen(function*(){let y=yield*Qu.FileSystem,u=yield*Ry.Path;return yield*y.exists(u.join(r,Ty[0].path))}),files:Ty,kind:"ci",name:"github",update:vf});import*as qf from"effect/Context";import*as Yr from"effect/Effect";import*as zf from"effect/Layer";import{addDevDependency as qO,detectPackageManager as zO}from"nypm";class P extends qf.Service()("DependencyInstaller"){static layer=zf.succeed(this)({addDevDependencies:(r,y,u)=>Yr.tryPromise({catch:(f)=>new dy({cause:f,packages:r}),try:()=>qO(r,{...u,cwd:y})}).pipe(Yr.asVoid),detectPackageManager:(r)=>Yr.tryPromise({catch:(y)=>new ir({cause:y}),try:()=>zO(r)}).pipe(Yr.map((y)=>y??null))})}var Bf=/^\s*node-version:\s*"?\d/m;function bf(){return C.files[0].path}var Df=(r)=>i.gen(function*(){let y=yield*Qf.FileSystem,f=(yield*hf.Path).join(r,bf());if(!(yield*y.exists(f)))return null;return yield*y.readFileString(f).pipe(i.mapError((O)=>new V({cause:O,path:f})))}),Uf=(r)=>i.gen(function*(){let y=yield*P,u=yield*H(r),f=jr(u);if(!Zr(f))return{reason:"scripts",supported:!1};let $=yield*y.detectPackageManager(r);if(!$)return{reason:"no-package-manager",supported:!1};if(!br($.name))return{packageManagerName:$.name,reason:"unsupported-package-manager",supported:!1};return{packageManager:$.name,scripts:f,supported:!0}}),Zf=Nr({check:(r)=>i.gen(function*(){let y=yield*Df(r.cwd);if(y===null||!Bf.test(y))return{status:"not-applicable",warnings:[]};let u=yield*Uf(r.cwd);if(!u.supported)return{status:"not-applicable",warnings:[u.reason==="scripts"?"No CI-compatible managed scripts were found, so the GitHub Actions workflow was not updated.":u.reason==="no-package-manager"?"Could not detect a package manager, so the GitHub Actions workflow was not updated.":`\`${u.packageManagerName}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`]};return{status:"needed",summary:"Replacing the hard-coded Node.js version in the GitHub Actions workflow with the project's Node.js version declaration.",warnings:[]}}),files:[bf()],id:"hardcoded-node-version",migrate:(r)=>i.gen(function*(){let y=yield*Uf(r.cwd);if(!y.supported)return yield*i.die(Error("check() guaranteed workflow regeneration is supported"));return yield*C.update(r.cwd,{packageManager:y.packageManager,scripts:y.scripts}),{warnings:[]}}),tags:["update"],title:"Hard-coded workflow Node.js version",validate:(r)=>i.gen(function*(){let y=yield*Df(r.cwd);if(y!==null&&Bf.test(y))return yield*new yr({migrationId:"hardcoded-node-version",reason:"The GitHub Actions workflow still contains a hard-coded Node.js version."})})});import*as o from"effect/Effect";import*as Kf from"effect/FileSystem";import*as Yf from"effect/Path";import*as Vf from"effect/Predicate";function BO(r,y){return o.gen(function*(){let u=yield*Kf.FileSystem,f=yield*Yf.Path,$=yield*y.integration.detect(r);if($.active===null||$.active.format==="ts")return yield*o.die(Error(`check() guaranteed a legacy ${y.displayName} config exists`));let O=$.active.path,j=f.join(r,y.integration.config),m=yield*u.readFileString(O).pipe(o.mapError((B)=>new V({cause:B,path:O}))),E=yield*M(m,O);if(!Vf.isObject(E))return yield*new rr({path:O});let{$schema:v,...q}=E;yield*u.writeFileString(j,y.serialize(q)).pipe(o.mapError((B)=>new b({cause:B,path:j})));for(let B of[$.active,...$.legacy])yield*u.remove(B.path).pipe(o.mapError((z)=>new py({cause:z,path:B.path})));return{warnings:[]}})}function Ir(r){return Nr({check:(y)=>o.gen(function*(){let u=yield*r.integration.detect(y.cwd);if(u.active===null||u.active.format==="ts")return{status:"not-applicable",warnings:u.warnings};return{status:"needed",summary:`Migrating legacy \`${u.active.file}\` configuration to \`${r.integration.config}\`.`,warnings:u.warnings}}),files:r.integration.files.map((y)=>y.path),id:r.id,migrate:(y)=>BO(y.cwd,r),tags:["update"],title:r.title,validate:(y)=>o.gen(function*(){if((yield*r.integration.detect(y.cwd)).active?.format!=="ts")return yield*new yr({migrationId:r.id,reason:`\`${r.integration.config}\` is not the active ${r.displayName} config.`})})})}var Hf=Ir({displayName:"Knip",id:"legacy-knip-json",integration:A,serialize:Zy,title:"Legacy Knip JSON config"});var Xf=Ir({displayName:"Oxfmt",id:"legacy-oxfmt-json",integration:N,serialize:Xy,title:"Legacy oxfmt JSON config"});var DO=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,UO=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function QO(r){let y=Array.isArray(r.extends)?r.extends.filter((j)=>typeof j==="string"):typeof r.extends==="string"?[r.extends]:[],u=new Set(Yy()),f=new Set;for(let j of y){let m=j.match(DO),E=j.match(UO),v=m?.[1]??(E?E[1]??"core":null);if(v)u.add(v);else f.add(j)}let{extends:$,...O}=r;return Vy(O,[...u],[...f])}var Lf=Ir({displayName:"Oxlint",id:"legacy-oxlint-json",integration:Q,serialize:QO,title:"Legacy oxlint JSON config"});import*as Pr from"effect/Effect";import hO from"node:process";import*as Wf from"effect/Effect";import*as _f from"effect/FileSystem";import*as Tf from"effect/Path";var Fr=(r=hO.cwd())=>Wf.gen(function*(){let y=yield*_f.FileSystem,u=yield*Tf.Path;if(yield*y.exists(u.join(r,"pnpm-workspace.yaml")))return!0;return(yield*H(r)).workspaces!==void 0});import*as lf from"effect/Array";import*as vr from"effect/Effect";import*as ly from"effect/FileSystem";import*as Sy from"effect/Path";import*as Ay from"effect/Predicate";var uy=[{path:"tsconfig.json",type:"config"}],Vr="adamantite/typescript",Rf={extends:Vr},Ny=["Skipping `tsconfig.json` setup: a root config in a monorepo makes TypeScript treat all packages as one project.",`To use the TypeScript preset, add \`"extends": "${Vr}"\` to each package's \`tsconfig.json\` or to a shared base config.`];function bO(r){if(Ay.isString(r))return r===Vr?r:[r,Vr];if(lf.isArray(r))return r.includes(Vr)?r:[...r,Vr];return Vr}var R=x({config:uy[0].path,create:(r)=>vr.gen(function*(){let y=yield*ly.FileSystem,f=(yield*Sy.Path).join(r,uy[0].path),$=JSON.stringify(Rf,null,2);yield*y.writeFileString(f,`${$}
|
|
97
|
+
`).pipe(vr.mapError((O)=>new b({cause:O,path:f})))}),detect:(r)=>vr.gen(function*(){let y=yield*ly.FileSystem,u=yield*Sy.Path;return yield*y.exists(u.join(r,uy[0].path))}),files:uy,kind:"workspace",name:"tsconfig",update:(r)=>vr.gen(function*(){let y=yield*ly.FileSystem,f=(yield*Sy.Path).join(r,uy[0].path),$=yield*y.readFileString(f).pipe(vr.mapError((E)=>new V({cause:E,path:f}))),O=yield*M($,f);if(!Ay.isObject(O))return yield*new rr({path:f});let m={...yield*Tr(Rf,O),extends:bO("extends"in O?O.extends:void 0)};yield*y.writeFileString(f,`${JSON.stringify(m,null,2)}
|
|
98
|
+
`).pipe(vr.mapError((E)=>new b({cause:E,path:f})))})});var Af="adamantite typecheck";function ZO(){return Q.files[1].path}function KO(){return C.files[0].path}function Sf(r){let y={...r.scripts};if(y.typecheck!==Af)return{migrated:!1,packageJson:r};return delete y.typecheck,y.check??=k.check,{migrated:!0,packageJson:{...r,scripts:y}}}var Nf=Nr({check:(r)=>Pr.gen(function*(){let y=yield*H(r.cwd),{migrated:u}=Sf(y);if(!u)return{status:"not-applicable",warnings:[]};return{status:"needed",summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}}),files:["package.json",Q.config,ZO(),R.config,KO()],id:"legacy-typecheck-script",migrate:(r)=>Pr.gen(function*(){let y=yield*P,u=[],f=yield*H(r.cwd),$=Sf(f);if(!$.migrated)return yield*Pr.die(Error("check() guaranteed the legacy typecheck script exists"));yield*Dy(r.cwd,$.packageJson);let O=yield*Q.detect(r.cwd);if(O.active===null)yield*Q.create(r.cwd);else if(O.active.format==="ts")yield*Q.update(r.cwd);if(yield*Fr(r.cwd))u.push(...Ny);else yield*(yield*R.detect(r.cwd))?R.update(r.cwd):R.create(r.cwd);let m=yield*C.detect(r.cwd),E=jr($.packageJson);if(m&&Zr(E)){let v=yield*y.detectPackageManager(r.cwd);if(v&&br(v.name))yield*C.update(r.cwd,{packageManager:v.name,scripts:E});else if(v)u.push(`\`${v.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`);else u.push("Could not detect a package manager, so the GitHub Actions workflow was not updated.")}return{warnings:u}}),tags:["update"],title:"Legacy typecheck script",validate:(r)=>Pr.gen(function*(){if((yield*H(r.cwd)).scripts?.typecheck===Af)return yield*new yr({migrationId:"legacy-typecheck-script",reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*Q.detect(r.cwd)).active?.format!=="ts")return yield*new yr({migrationId:"legacy-typecheck-script",reason:`\`${Q.config}\` is not the active oxlint config.`});if(yield*Fr(r.cwd))return;if(!(yield*R.detect(r.cwd)))return yield*new yr({migrationId:"legacy-typecheck-script",reason:`\`${R.config}\` is missing after the migration.`})})});var hu=[Xf,Hf,Lf,Nf,Zf],Gf=Object.fromEntries(hu.map((r)=>[r.id,r]));import*as Jf from"effect/Array";import*as Hr from"effect/Effect";import*as Gy from"effect/Option";var YO=Hr.fn("collectApplicableAssessments")((r,y)=>Hr.forEach((u)=>u.assess(y).pipe(Hr.map((f)=>f.applicable?Gy.some({assessment:f,integration:u}):Gy.none())))(r).pipe(Hr.map((u)=>Jf.getSomes(u))));function Jy(r,y){return YO(r,y)}import*as X from"@clack/prompts";import*as If from"effect/Context";import*as L from"effect/Effect";import*as Ff from"effect/Exit";import*as Pf from"effect/Layer";class K extends If.Service()("Prompter"){static layer=Pf.succeed(this)({cancel:(r)=>L.sync(()=>{X.cancel(r)}),confirm:(r)=>L.promise(()=>X.confirm(r)).pipe(L.filterOrFail((y)=>!X.isCancel(y),()=>new vy({}))),intro:(r)=>L.sync(()=>{X.intro(r)}),log:{error:(r)=>L.sync(()=>{X.log.error(r)}),info:(r)=>L.sync(()=>{X.log.info(r)}),success:(r)=>L.sync(()=>{X.log.success(r)}),warning:(r)=>L.sync(()=>{X.log.warning(r)})},multiselect:(r)=>L.promise(()=>X.multiselect(r)).pipe(L.filterOrFail((y)=>!X.isCancel(y),()=>new vy({}))),outro:(r)=>L.sync(()=>{X.outro(r)}),withSpinner:(r,y)=>L.acquireUseRelease(L.sync(()=>{let u=X.spinner();return u.start(y.start),u}),(u)=>r({message:(f)=>L.sync(()=>{u.message(f)})}),(u,f)=>L.sync(()=>{u.stop(Ff.match(f,{onFailure:()=>y.failure,onSuccess:($)=>typeof y.success==="function"?y.success($):y.success}))}))})}import*as xf from"effect/Console";import*as Mf from"effect/Effect";import*as Cf from"effect/Terminal";var xr=()=>Mf.gen(function*(){let y=yield*(yield*Cf.Terminal).columns,u=' .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(`
|
|
99
|
+
`).reduce((f,$)=>Math.max(f,$.trim().length),0);if(!y||y<u)return;yield*xf.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 HO=Iy.boolean("fix").pipe(Iy.withDescription("Automatically fix safe package install/update issues")),XO=[A,N,Q,a,Er],tf=Cr.make("doctor",{fix:HO}).pipe(Cr.withDescription("Check Adamantite-managed integrations in the current project"),Cr.withHandler(({fix:r})=>Mr.gen(function*(){let y=VO.cwd(),u=yield*K;yield*xr(),yield*u.intro("\uD83D\uDCA0 adamantite doctor");let f=yield*H(y);if(!f.devDependencies?.adamantite&&!f.dependencies?.adamantite)yield*u.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*u.outro("⚠️ Doctor found issues."),yield*new T({command:"doctor",exitCode:bu.ExitCode(1)});let $=yield*Jy(XO,y);for(let{assessment:E}of $)for(let v of E.warnings)yield*u.log.warning(v);if($.length===0){yield*u.log.success("No applicable integrations found."),yield*u.outro("✅ Doctor completed successfully!");return}let O=$.flatMap(({assessment:E,integration:v})=>E.actions.map((q)=>({action:q,integration:v})));if(O.length===0){yield*u.log.success("No issues found."),yield*u.outro("✅ Doctor completed successfully!");return}let j=new Set;if(r)yield*Mr.gen(function*(){let E=O.filter(({action:v})=>v.type==="install_package"||v.type==="update_package");if(E.length>0){let v=yield*P,q=[];for(let{action:B}of E)if(B.type==="install_package"||B.type==="update_package")q.push(`${B.package}@${B.targetVersion}`);yield*v.addDevDependencies(q,y,{silent:!0});for(let B of E){let{action:z}=B;if(z.type==="install_package")yield*u.log.success(`Fixed: installed \`${z.package}@${z.targetVersion}\`.`);if(z.type==="update_package")yield*u.log.success(`Fixed: updated \`${z.package}\` from \`${z.currentVersion}\` to \`${z.targetVersion}\`.`);j.add(B)}}for(let v of O){let{action:q,integration:B}=v;if(q.type!=="create_config"||!("create"in B))continue;yield*B.create(y),yield*u.log.success(`Fixed: created \`${q.path}\`.`),j.add(v)}for(let v of O){let{action:q,integration:B}=v;if(q.type!=="update_config"||!("update"in B))continue;yield*B.update(y),yield*u.log.success(`Fixed: updated \`${q.path}\`.`),j.add(v)}for(let v of O){let{action:q}=v;if(q.type!=="run_migration")continue;let B=Gf[q.migrationId];if(!B)continue;let z=yield*B.check({cwd:y});for(let t of z.warnings)yield*u.log.warning(t);if(z.status!=="needed"){j.add(v);continue}let S=yield*u.withSpinner(()=>Ly(B,{cwd:y}),{failure:`Migration "${B.title}" failed, files restored.`,start:z.summary,success:`Fixed: ${q.description}`});for(let t of S.warnings)yield*u.log.warning(t);j.add(v)}}).pipe(Mr.tapError(()=>Mr.gen(function*(){yield*u.outro("❌ Doctor failed")})));let m=O.filter((E)=>!j.has(E));if(r&&m.length===0){yield*u.outro("✅ Doctor completed successfully!");return}for(let{action:E}of r?m:O)yield*u.log.warning(`Needs attention: ${E.description}`);yield*u.outro("⚠️ Doctor found issues."),yield*new T({command:"doctor",exitCode:bu.ExitCode(1)})})));import*as wf from"effect/Array";import*as ef from"effect/Effect";import*as tr from"effect/unstable/cli/Argument";import*as wr from"effect/unstable/cli/Command";import*as qr from"effect/unstable/cli/Flag";import*as kf from"effect/unstable/process/ChildProcessSpawner";var LO=tr.file("files",{mustExist:!0}).pipe(tr.withDescription("Specific files to fix (optional)"),tr.variadic()),WO=qr.boolean("suggested").pipe(qr.withDescription("Apply suggested fixes")),_O=qr.boolean("dangerous").pipe(qr.withDescription("Apply dangerous fixes")),TO=qr.boolean("all").pipe(qr.withDescription("Apply all fixes, including suggested and dangerous fixes")),Zu=wr.make("fix",{all:TO,dangerous:_O,files:LO,suggested:WO}).pipe(wr.withDescription("Fix issues in code using oxlint"),wr.withHandler(({all:r,dangerous:y,files:u,suggested:f})=>ef.gen(function*(){let $=yield*J,O=yield*W,j=wf.dedupe(["--fix",...f||r?["--fix-suggestions"]:[],...y||r?["--fix-dangerously"]:[],...u]),m=yield*O.run({args:[...j,...$],command:Q.name});if(m!==kf.ExitCode(0))yield*new T({command:Q.name,exitCode:m})})));import*as af from"effect/Effect";import*as er from"effect/unstable/cli/Argument";import*as kr from"effect/unstable/cli/Command";import*as Fy from"effect/unstable/cli/Flag";import*as nf from"effect/unstable/process/ChildProcessSpawner";var RO=er.file("files",{mustExist:!0}).pipe(er.withDescription("Specific files to format (optional)"),er.variadic()),lO=Fy.boolean("check").pipe(Fy.withDescription("Check if files are formatted without writing")),Ku=kr.make("format",{check:lO,files:RO}).pipe(kr.withDescription("Format files using oxfmt"),kr.withHandler(({check:r,files:y})=>af.gen(function*(){let u=yield*J,f=yield*W,$=[];if(r)$.push("--check");$.push(...y,...u);let O=yield*f.run({args:$,command:N.name});if(O!==nf.ExitCode(0))yield*new T({command:N.name,exitCode:O})})));import IO from"node:process";import*as ar from"effect/Array";import*as U from"effect/Effect";import{pipe as FO}from"effect/Function";import*as j$ from"effect/Predicate";import*as Ur from"effect/unstable/cli/Command";import*as h from"effect/unstable/cli/Flag";import*as c from"effect/Effect";import*as Py from"effect/FileSystem";import*as xy from"effect/Path";import*as gf from"effect/Predicate";import*as sf from"effect/unstable/process/ChildProcessSpawner";var fy=[{path:".vscode/settings.json",type:"config"}],df={"[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},zr=x({config:fy[0].path,create:(r)=>c.gen(function*(){let y=yield*Py.FileSystem,u=yield*xy.Path,f=u.join(r,fy[0].path);yield*Gr(u.dirname(f)),yield*y.writeFileString(f,`${JSON.stringify(df,null,2)}
|
|
100
|
+
`).pipe(c.mapError(($)=>new b({cause:$,path:f})))}),detect:(r)=>c.gen(function*(){let y=yield*Py.FileSystem,u=yield*xy.Path;return yield*y.exists(u.join(r,fy[0].path))}),extension:(r=[])=>c.gen(function*(){let y=[];if(r.includes("check")||r.includes("fix")||r.includes("format"))y.push("oxc.oxc-vscode");if(r.includes("analyze"))y.push("webpro.vscode-knip");for(let u of y){let $=yield*(yield*W).run({args:["--install-extension",u],command:"code"}).pipe(c.mapError((O)=>O._tag==="CliNotFound"&&O.command==="code"?new ru({cause:O}):new Ey({cause:O,extension:u})));if($!==sf.ExitCode(0))return yield*new Ey({cause:$,extension:u})}}),files:fy,kind:"editor",name:"vscode",update:(r)=>c.gen(function*(){let y=yield*Py.FileSystem,f=(yield*xy.Path).join(r,fy[0].path),$=yield*y.readFileString(f).pipe(c.mapError((m)=>new V({cause:m,path:f}))),O=yield*M($,f);if(!gf.isObject(O))return yield*new rr({path:f});let j=yield*Tr(df,O);yield*y.writeFileString(f,`${JSON.stringify(j,null,2)}
|
|
101
|
+
`).pipe(c.mapError((m)=>new b({cause:m,path:f})))})});import*as pf from"effect/Array";import*as Br from"effect/Effect";import*as My from"effect/FileSystem";import*as Cy from"effect/Path";import*as of from"effect/Predicate";import*as l from"effect/Schema";var $y=[{path:".zed/settings.json",type:"config"}],Yu={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"}}}}};function SO(r){let y=r.languages;if(!l.is(l.Record(l.String,l.Json))(y))return r;let u=Object.fromEntries(Object.entries(y).map(([f,$])=>{if(f in Yu.languages&&l.is(l.Record(l.String,l.Json))($)&&l.is(l.Array(l.Json))($.formatter))return[f,Object.fromEntries([...Object.entries($),["formatter",pf.dedupe($.formatter)]])];return[f,$]}));return{...r,languages:u}}var Xr=x({config:$y[0].path,create:(r)=>Br.gen(function*(){let y=yield*My.FileSystem,u=yield*Cy.Path,f=u.join(r,$y[0].path);yield*Gr(u.dirname(f)),yield*y.writeFileString(f,`${JSON.stringify(Yu,null,2)}
|
|
102
|
+
`).pipe(Br.mapError(($)=>new b({cause:$,path:f})))}),detect:(r)=>Br.gen(function*(){let y=yield*My.FileSystem,u=yield*Cy.Path;return yield*y.exists(u.join(r,$y[0].path))}),files:$y,kind:"editor",name:"zed",update:(r)=>Br.gen(function*(){let y=yield*My.FileSystem,f=(yield*Cy.Path).join(r,$y[0].path),$=yield*y.readFileString(f).pipe(Br.mapError((E)=>new V({cause:E,path:f}))),O=yield*M($,f);if(!of.isObject(O))return yield*new rr({path:f});let j=yield*Tr(Yu,O),m=SO(j);yield*y.writeFileString(f,`${JSON.stringify(m,null,2)}
|
|
103
|
+
`).pipe(Br.mapError((E)=>new b({cause:E,path:f})))})});import*as Lr from"effect/Effect";import*as cf from"effect/FileSystem";import{pipe as Vu}from"effect/Function";import*as Dr from"effect/Option";import*as r$ from"effect/Path";import*as Hu from"effect/String";import{runScriptCommand as AO}from"nypm";var NO="AGENTS.md",y$="<!-- ADAMANTITE:START -->",Xu="<!-- ADAMANTITE:END -->";function GO(r,y){let u=AO(r,y),f=k[y];switch(y){case"analyze":return`- Run \`${u}\` after changing dependencies, imports, or exports. Direct command: \`${f}\`.`;case"check":return`- Run \`${u}\` to catch lint and type issues. Direct command: \`${f}\`.`;case"check:monorepo":return`- Run \`${u}\` to check monorepo package consistency. Direct command: \`${f}\`.`;case"fix":return`- Run \`${u}\` to apply safe lint fixes. Direct command: \`${f}\`.`;case"fix:monorepo":return`- Run \`${u}\` to fix monorepo package consistency. Direct command: \`${f}\`.`;case"format":return`- Run \`${u}\` after editing files. Direct command: \`${f}\`.`}}function JO({packageManager:r,scripts:y}){let f=["format","check","fix","analyze","check:monorepo","fix:monorepo"].filter((O)=>y.includes(O)).map((O)=>GO(r,O)),$=["## Adamantite","","This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.","",...f.length>0?["- Prefer the package scripts Adamantite added for this workspace.",...f]:[],"- Use `adamantite doctor` to inspect managed setup and `adamantite doctor --fix` for safe local fixes."].join(`
|
|
104
|
+
`);return[y$,"",$,"",Xu,""].join(`
|
|
105
|
+
`)}var u$=(r,y)=>Lr.gen(function*(){let u=yield*cf.FileSystem,$=(yield*r$.Path).join(r,NO),j=(yield*u.exists($).pipe(Lr.mapError((z)=>new V({cause:z,path:$}))))?yield*u.readFileString($).pipe(Lr.mapError((z)=>new V({cause:z,path:$}))):"",m=Vu(j,Hu.indexOf(y$)),E=Vu(j,Hu.indexOf(Xu)),v=Vu(Dr.all({end:E,start:m}),Dr.filter(({end:z,start:S})=>S<z)),q=JO(y);if(Dr.isSome(v)){let{end:z,start:S}=v.value,t=z+Xu.length,w=`${j.slice(0,S)}${q.trimEnd()}${j.slice(t)}`;return yield*u.writeFileString($,w.endsWith(`
|
|
106
|
+
`)?w:`${w}
|
|
107
|
+
`).pipe(Lr.mapError((D)=>new b({cause:D,path:$}))),"updated"}if(Dr.isSome(m)||Dr.isSome(E))return"malformed";let B=j.length===0||j.endsWith(`
|
|
108
|
+
|
|
109
|
+
`)?"":j.endsWith(`
|
|
116
110
|
`)?`
|
|
117
111
|
`:`
|
|
118
112
|
|
|
119
|
-
`;return yield*t.writeFileString(f,`${l}${m}${O}`).pipe(hr.mapError((h)=>new S({cause:h,path:f}))),"updated"});import Wf from"node:process";import*as yn from"effect/Effect";import*as an from"effect/FileSystem";import*as mn from"effect/Path";var Ge=(r=Wf.cwd())=>yn.gen(function*(){let e=yield*an.FileSystem,t=yield*mn.Path;if(yield*e.exists(t.join(r,"pnpm-workspace.yaml")))return!0;return(yield*b(r)).workspaces!==void 0});var Kf=(r,e)=>$.gen(function*(){let t=yield*Y;yield*(yield*o).withSpinner(()=>$.gen(function*(){let f=yield*Ge(r);yield*t.addDevDependencies(e,r,{silent:!0,workspace:f})}),{failure:"Failed to install dependencies.",start:"Installing dependencies...",success:"Dependencies installed."})});function Me(r,e,t){return $.gen(function*(){let n=yield*o,f=yield*n.withSpinner((u)=>$.gen(function*(){let l=yield*e.detect(r);for(let a of l.warnings)yield*n.log.warning(a);if(l.active===null)return yield*u.message(`\`${e.config}\` not found, creating...`),yield*t,{created:!0,legacyConfig:null};if(l.active.format==="ts")return yield*u.message(`Found \`${e.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*u.message(`Found \`${l.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:l.active.file}}),{failure:`Failed to set up ${e.name} config.`,start:`Setting up ${e.name} config...`,success:(u)=>u.created?`${e.name} config created successfully.`:`${e.name} config is ready.`});if(f.legacyConfig)yield*n.log.info(`Legacy \`${f.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor --fix\` to migrate it to the latest ${e.name} config.`)})}var Pf=(r,e)=>$.gen(function*(){let t=yield*o,n=yield*b(r);yield*t.withSpinner(()=>$.gen(function*(){n.scripts??={};for(let f of e)n.scripts[f]=ur[f];yield*Gr(r,n)}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:"Scripts added to your `package.json`"})}),Ff=(r)=>$.gen(function*(){yield*(yield*o).withSpinner((t)=>$.gen(function*(){if(yield*V.detect(r))return yield*t.message(`\`${V.config}\` found, updating...`),yield*V.update(r),!1;return yield*t.message(`\`${V.config}\` not found, creating...`),yield*V.create(r),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(t)=>t?`\`${V.config}\` created successfully`:`\`${V.config}\` updated successfully`})}),Tf=(r,e)=>$.gen(function*(){let t=yield*o;if(e.includes("vscode"))yield*t.withSpinner((n)=>$.gen(function*(){let f=yield*k.detect(r);return yield*n.message(`\`${k.config}\` ${f?"found, updating":"not found, creating"}...`),yield*f?k.update(r):k.create(r),!f}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${k.config}\`...`,success:(n)=>`\`${k.config}\` ${n?"created":"updated"} with Adamantite preset.`});if(e.includes("zed"))yield*t.withSpinner((n)=>$.gen(function*(){let f=yield*Er.detect(r);return yield*n.message(`\`${Er.config}\` ${f?"found, updating":"not found, creating"}...`),yield*f?Er.update(r):Er.create(r),!f}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Er.config}\`...`,success:(n)=>`\`${Er.config}\` ${n?"created":"updated"} with Adamantite preset.`})}),Yf=(r,e)=>$.gen(function*(){let t=yield*o,n=r.includes("zed"),f=r.includes("vscode");if(yield*t.withSpinner((u)=>$.gen(function*(){if(f)yield*u.message("Installing VS Code extension..."),yield*k.extension(e);return!0}),{start:"Installing editor extensions...",success:n&&!f?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe($.catchTag("FailedToInstallExtension",(u)=>$.gen(function*(){return yield*t.log.warning(`⚠️ Failed to install the \`${u.extension}\` extension.`),yield*t.log.warning("Please install it manually after setup completes."),!1})),$.catchTag("VscodeCliNotFound",()=>$.gen(function*(){return yield*t.log.error("VSCode CLI ('code' command) not found."),yield*t.log.info("To install it:"),yield*t.log.info(" 1. Open VS Code"),yield*t.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*t.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),n)yield*t.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),_f=(r,e,t)=>$.gen(function*(){let n=yield*o,f=g.files[0].path;yield*n.withSpinner((u)=>$.gen(function*(){let l=yield*g.detect(r);return yield*u.message(l?`\`${f}\` found, updating...`:`Creating \`${f}\`...`),yield*l?g.update(r,{packageManager:e,scripts:t}):g.create(r,{packageManager:e,scripts:t}),!l}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(u)=>`GitHub Actions workflow ${u?"created":"updated"} successfully.`})}).pipe($.option),Xf=(r,e,t)=>$.gen(function*(){let n=yield*o,f=yield*n.withSpinner(()=>ln(r,{packageManager:e,scripts:t}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe($.catchTag(["FailedToReadFile","FailedToWriteFile"],(u)=>$.gen(function*(){return yield*n.log.warning(`Could not update AGENTS.md. ${u.message} Adamantite will continue initialization.`),"failed"})));if(f==="failed")return;if(f==="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.")}),En=["check","fix","format","check:monorepo","fix:monorepo","analyze"],hn=["react","nextjs","vue","jest","vitest","node"],On=["vscode","zed"],Nf=$.fn("validateInitOptions")(function*(r,e){let t={agents:r.agents,editors:Zr.dedupe(r.editors),githubActions:r.githubActions,installExtensions:r.installExtensions,presets:Zr.dedupe(r.presets),scripts:Zr.dedupe(r.scripts),typescript:r.typescript};if(t.scripts.length===0)return yield*new X({reason:"Select at least one script with `--script <name>`."});let n=t.scripts.includes("check")||t.scripts.includes("fix");if((t.scripts.includes("check:monorepo")||t.scripts.includes("fix:monorepo"))&&!e.isMonorepo)return yield*new X({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(t.presets.length>0&&!n)return yield*new X({reason:"`--preset` requires the `check` or `fix` script."});if(t.typescript&&!n)return yield*new X({reason:"`--typescript` requires the `check` or `fix` script."});if(t.installExtensions&&t.editors.length===0)return yield*new X({reason:"`--install-extensions` requires at least one `--editor`."});if(t.githubActions&&!Hr(t.scripts))return yield*new X({reason:"`--github-actions` requires a CI-compatible script."});if(t.githubActions&&e.nonInteractive&&!Xr(e.packageManager))return yield*new X({reason:`\`--github-actions\` does not support the detected package manager \`${e.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return t}),Hf=v.boolean("non-interactive").pipe(v.withDescription("Configure without prompts; requires at least one --script")),Lf=v.choice("script",En).pipe(v.atMost(En.length),v.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),xf=v.choice("preset",hn).pipe(v.atMost(hn.length),v.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),Jf=v.choice("editor",On).pipe(v.atMost(On.length),v.withDescription("Editor to configure; may be specified multiple times")),If=v.boolean("typescript").pipe(v.withDescription("Configure the TypeScript preset; requires --script check or fix")),df=v.boolean("install-extensions").pipe(v.withDescription("Install recommended extensions; requires at least one --editor")),Af=v.boolean("github-actions").pipe(v.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),Gf=v.boolean("agents").pipe(v.withDescription("Add Adamantite guidance to AGENTS.md")),Mf=$.fn("collectInteractiveInitOptions")(function*(r){let e=yield*o,t=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:!r,hint:r?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!r,hint:r?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"}]}),n=t.includes("check")||t.includes("fix"),f=[];if(n)f=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 u=n?yield*e.confirm({initialValue:!0,message:"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,l=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}),a=l.length>0?yield*e.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,y=Hr(t)?yield*e.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*e.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:l,githubActions:y,installExtensions:a,presets:f,scripts:t,typescript:u}}),jn=er.make("init",{agents:Gf,editors:Jf,githubActions:Af,installExtensions:df,nonInteractive:Hf,presets:xf,scripts:Lf,typescript:If}).pipe(er.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),er.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"}]),er.withHandler((r)=>$.gen(function*(){let e=Zf.cwd(),t=yield*o;yield*Rr(),yield*t.intro("\uD83D\uDCA0 adamantite init");let f=yield*(yield*Y).detectPackageManager(e);if(!f)return yield*new _r({});if(f.warnings?.length)for(let Yr of f.warnings)yield*t.log.warning(Yr);yield*t.log.info(`Detected package manager: ${f.name}`);let u=yield*Ge(e);if(u)yield*t.log.info("We've detected a monorepo setup in your project.");if(!r.nonInteractive&&Zr.some([r.scripts.length>0,r.presets.length>0,r.editors.length>0,r.typescript,r.installExtensions,r.githubActions,r.agents],$n.isTruthy))return yield*new X({reason:"Setup flags require `--non-interactive`."});let l=r.nonInteractive?r:yield*Mf(u),a=yield*Nf(l,{isMonorepo:u,nonInteractive:r.nonInteractive,packageManager:f.name}),y=a.scripts,O=a.presets,m=a.editors,h=a.typescript,i=a.installExtensions,I=a.githubActions,Or=a.agents,E=y.includes("check")||y.includes("fix"),d=y.includes("format"),Zn=y.includes("check:monorepo")||y.includes("fix:monorepo"),Ce=y.includes("analyze"),Tr=["adamantite"];if(E)Tr.push(`${j.name}@${j.version}`,`${C.name}@${C.version}`);if(d)Tr.push(`${K.name}@${K.version}`);if(Zn)Tr.push(`${_.name}@${_.version}`);if(Ce)Tr.push(`${Z.name}@${Z.version}`);if(yield*Kf(e,Tr),d)yield*Me(e,K,K.create(e));if(E)yield*Me(e,j,j.create(e,O));if(Ce)yield*Me(e,Z,Z.create(e));if(yield*Pf(e,y),Or)yield*Xf(e,f.name,y);if(h)yield*Ff(e);if(yield*Tf(e,m),i)yield*Yf(m,y);if(I){let Yr=f.name;if(Xr(Yr))yield*_f(e,Yr,y);else yield*t.log.warning(`Skipping GitHub Actions setup: \`${Yr}\` is not a supported package manager for CI workflow generation.`)}yield*t.log.success("Your project is now configured"),yield*t.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe($.catchTags({OperationCancelled:()=>$.gen(function*(){yield*(yield*o).cancel("You've cancelled the initialization process.")})}))));import*as on from"effect/Effect";import*as Kr from"effect/unstable/cli/Command";import*as Se from"effect/unstable/cli/Flag";import*as Sn from"effect/unstable/process/ChildProcessSpawner";var gf=Se.boolean("fix").pipe(Se.withDescription("Automatically fix issues")),ge=Kr.make("monorepo",{fix:gf}).pipe(Kr.withDescription("Find and fix monorepo-specific issues using Sherif"),Kr.withHandler(({fix:r})=>on.gen(function*(){let e=yield*P,t=yield*s,n=r?["--fix",...e]:[...e],f=yield*t.run({args:n,command:_.name,stdin:"inherit"});if(f!==Sn.ExitCode(0))yield*new Q({command:_.name,exitCode:f})})));import*as vn from"effect/Effect";import*as Pr from"effect/unstable/cli/Command";import*as Dn from"effect/unstable/process/ChildProcessSpawner";var we=Pr.make("typecheck").pipe(Pr.withDescription("Deprecated alias for `check`"),Pr.withHandler(()=>vn.gen(function*(){let r=yield*P,e=yield*o,t=yield*s;yield*e.log.warning("Deprecated. Use `adamantite check` for typechecking.");let n=yield*t.run({args:[...r],command:j.name});if(n!==Dn.ExitCode(0))yield*new Q({command:j.name,exitCode:n})})));import wf from"node:process";import*as tr from"effect/Effect";import*as Fr from"effect/unstable/cli/Command";var Cf=[j,C,K,_,Z],pf=[j,C,K,_,Z];function cf(r,e){let t=[];for(let n of pf){if(e.has(n.name))continue;let f=r.devDependencies?.[n.name]??r.dependencies?.[n.name];if(f&&Ar(f)!==n.version)t.push({currentVersion:f,name:n.name,targetVersion:n.version})}return t}var zn=Fr.make("update").pipe(Fr.withDescription("Run applicable Adamantite migrations and update managed dependencies"),Fr.withHandler(()=>tr.gen(function*(){let r=wf.cwd(),e=yield*o,t=yield*Y,n={cwd:r};yield*Rr(),yield*e.intro("\uD83D\uDCA0 adamantite update");let f=()=>Ee(Cf,r),u=yield*f(),l=[];for(let E of Le.filter((d)=>d.tags.includes("update"))){let d=yield*E.check(n);l.push({migration:E,result:d})}let a=new Set([...u.flatMap(({assessment:E})=>E.warnings),...l.flatMap(({result:E})=>E.warnings)]);for(let E of a)yield*e.log.warning(E);let y=[];for(let{migration:E,result:d}of l){if(d.status!=="needed")continue;yield*e.log.info(d.summary),yield*te(E,n,{onRestore:e.log.warning(`Migration "${E.title}" failed, restoring files...`)}),y.push(E.id)}if(y.length>0)yield*e.log.success("Migrations ran successfully.");let O=yield*b(r),m=yield*f(),h=m.flatMap(({assessment:E})=>E.actions).filter((E)=>E.type==="create_config"||E.type==="update_config"||E.type==="manual_fix"),i=m.flatMap(({assessment:E})=>E.actions).filter((E)=>E.type==="install_package"||E.type==="update_package").map((E)=>E.type==="install_package"?{currentVersion:"not installed",name:E.package,targetVersion:E.targetVersion}:{currentVersion:E.currentVersion,name:E.package,targetVersion:E.targetVersion}),I=new Set(i.map((E)=>E.name)),Or=[...i,...cf(O,I)];if(Or.length>0){yield*e.log.info("The following dependencies will be updated:");for(let E of Or)yield*e.log.info(` ${E.name}: ${E.currentVersion} → ${E.targetVersion}`);yield*e.withSpinner(()=>t.addDevDependencies(Or.map((E)=>`${E.name}@${E.targetVersion}`),r,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"Dependencies updated successfully"}),yield*e.log.success("Dependencies updated successfully.")}if(h.length>0){yield*e.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let E of h)yield*e.log.warning(`Doctor follow-up: ${E.description}`)}if(y.length===0&&Or.length===0&&h.length===0)return yield*e.log.success("No changes needed."),"no-changes";return"success"}).pipe(tr.tapError(()=>tr.gen(function*(){yield*(yield*o).outro("❌ Update failed")})),tr.tap((r)=>tr.gen(function*(){let e=yield*o;switch(r){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 kf=[_e,He,Je,Ie,ge,we],qn=[_e,He,Gt,Je,Ie,jn,ge,we,zn],ru=new Set(qn.map((r)=>r.name)),eu=new Set(kf.map((r)=>r.name)),tu=nr.make("adamantite").pipe(nr.withDescription("Opinionated preset package for modern TypeScript applications"),nr.withSubcommands(qn)),Bn=De.fn("runCli")(function*(r,e){let[t,n]=ve.splitWhere(r,(l)=>l==="--"),f=ve.drop(n,1),u=t.find((l)=>ru.has(l));if(f.length>0&&u!==void 0&&!eu.has(u))return yield*new Ve({command:u});yield*nr.runWith(tu,{version:e})(t).pipe(De.provideService(P,f))});var nu=U.gen(function*(){let e=yield*(yield*Vn.Stdio).args;yield*Bn(e,"0.34.3")}).pipe(U.as(0),U.catchTag("CommandFailed",(r)=>U.succeed(r.exitCode)),U.catch((r)=>U.service(o).pipe(U.flatMap((e)=>e.log.error(r.message)),U.as(Wn.ExitCode(1)))),U.provide(Un.mergeAll(bn.layer,o.layer,s.layer,Y.layer)));Rn.runMain(nu,{teardown:(r,e)=>{if(sn.isSuccess(r)){e(Number(r.value));return}Qn.defaultTeardown(r,e)}});
|
|
113
|
+
`;return yield*u.writeFileString($,`${j}${B}${q}`).pipe(Lr.mapError((z)=>new b({cause:z,path:$}))),"updated"});var PO=(r,y)=>U.gen(function*(){let u=yield*P;yield*(yield*K).withSpinner(()=>U.gen(function*(){let $=yield*Fr(r);yield*u.addDevDependencies(y,r,{silent:!0,workspace:$})}),{failure:"Failed to install dependencies.",start:"Installing dependencies...",success:"Dependencies installed."})});function Lu(r,y,u){return U.gen(function*(){let f=yield*K,$=yield*f.withSpinner((O)=>U.gen(function*(){let j=yield*y.detect(r);for(let m of j.warnings)yield*f.log.warning(m);if(j.active===null)return yield*O.message(`\`${y.config}\` not found, creating...`),yield*u,{created:!0,legacyConfig:null};if(j.active.format==="ts")return yield*O.message(`Found \`${y.config}\`, keeping existing config.`),{created:!1,legacyConfig:null};return yield*O.message(`Found \`${j.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:j.active.file}}),{failure:`Failed to set up ${y.name} config.`,start:`Setting up ${y.name} config...`,success:(O)=>O.created?`${y.name} config created successfully.`:`${y.name} config is ready.`});if($.legacyConfig)yield*f.log.info(`Legacy \`${$.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor --fix\` to migrate it to the latest ${y.name} config.`)})}var xO=(r)=>`\`${r.script}\` is currently \`${r.command}\`; Adamantite would replace it with \`${k[r.script]}\`.`,MO=(r,y,u)=>U.gen(function*(){let f=yield*K,$=yield*H(r),O=u.overwriteScripts?[]:fu($,y),j=new Set(O.map((v)=>v.script)),m=y.filter((v)=>!j.has(v));yield*f.withSpinner(()=>U.gen(function*(){if(m.length===0)return;$.scripts??={};for(let v of m)$.scripts[v]=k[v];yield*Dy(r,$)}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:O.length===0?"Scripts added to your `package.json`":m.length===0?"Kept your existing `package.json` scripts.":"Scripts added to your `package.json`; conflicting scripts were kept."});let E=u.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Re-run `adamantite init` and confirm overwriting to replace it.";for(let v of O)yield*f.log.warning(`Kept existing \`${v.script}\` script (\`${v.command}\`) instead of \`${k[v.script]}\`. ${E}`);if(O.length>0)yield*f.log.info("Adamantite commands forward extra arguments after `--`, so custom flags can be kept, e.g. `adamantite monorepo -- --ignore-dependency tailwindcss`.");return m}),CO=(r,y)=>U.gen(function*(){let u=yield*K;if(y){yield*FO(Ny,U.forEach((f)=>u.log.info(f)));return}yield*u.withSpinner((f)=>U.gen(function*(){if(yield*R.detect(r))return yield*f.message(`\`${R.config}\` found, updating...`),yield*R.update(r),!1;return yield*f.message(`\`${R.config}\` not found, creating...`),yield*R.create(r),!0}),{failure:"Failed to set up TypeScript config.",start:"Setting up TypeScript config...",success:(f)=>f?`\`${R.config}\` created successfully`:`\`${R.config}\` updated successfully`})}),tO=(r,y)=>U.gen(function*(){let u=yield*K;if(y.includes("vscode"))yield*u.withSpinner((f)=>U.gen(function*(){let $=yield*zr.detect(r);return yield*f.message(`\`${zr.config}\` ${$?"found, updating":"not found, creating"}...`),yield*$?zr.update(r):zr.create(r),!$}),{failure:"Failed to set up VS Code config.",start:`Checking for \`${zr.config}\`...`,success:(f)=>`\`${zr.config}\` ${f?"created":"updated"} with Adamantite preset.`});if(y.includes("zed"))yield*u.withSpinner((f)=>U.gen(function*(){let $=yield*Xr.detect(r);return yield*f.message(`\`${Xr.config}\` ${$?"found, updating":"not found, creating"}...`),yield*$?Xr.update(r):Xr.create(r),!$}),{failure:"Failed to set up Zed config.",start:`Checking for \`${Xr.config}\`...`,success:(f)=>`\`${Xr.config}\` ${f?"created":"updated"} with Adamantite preset.`})}),wO=(r,y)=>U.gen(function*(){let u=yield*K,f=r.includes("zed"),$=r.includes("vscode");if(yield*u.withSpinner((O)=>U.gen(function*(){if($)yield*O.message("Installing VS Code extension..."),yield*zr.extension(y);return!0}),{start:"Installing editor extensions...",success:f&&!$?"Zed extensions require manual install.":"Editor extensions installed successfully."}).pipe(U.catchTag("FailedToInstallExtension",(O)=>U.gen(function*(){return yield*u.log.warning(`⚠️ ${O.message}`),yield*u.log.warning("Please install it manually after setup completes."),!1})),U.catchTag("VscodeCliNotFound",()=>U.gen(function*(){return yield*u.log.error("VSCode CLI ('code' command) not found."),yield*u.log.info("To install it:"),yield*u.log.info(" 1. Open VS Code"),yield*u.log.info(" 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)"),yield*u.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),f)yield*u.log.info("Install the Zed `oxc` extension: zed://extension/oxc")}),eO=(r,y,u)=>U.gen(function*(){let f=yield*K,$=C.files[0].path;yield*f.withSpinner((O)=>U.gen(function*(){let j=yield*C.detect(r);return yield*O.message(j?`\`${$}\` found, updating...`:`Creating \`${$}\`...`),yield*j?C.update(r,{packageManager:y,scripts:u}):C.create(r,{packageManager:y,scripts:u}),!j}),{failure:"Failed to set up GitHub Actions workflow.",start:"Setting up GitHub Actions workflow...",success:(O)=>`GitHub Actions workflow ${O?"created":"updated"} successfully.`})}).pipe(U.option),kO=(r,y,u)=>U.gen(function*(){let f=yield*K,$=yield*f.withSpinner(()=>u$(r,{packageManager:y,scripts:u}),{failure:"Failed to update AGENTS.md.",start:"Updating AGENTS.md...",success:"AGENTS.md check complete."}).pipe(U.catchTag(["FailedToReadFile","FailedToWriteFile"],(O)=>U.gen(function*(){return yield*f.log.warning(`Could not update AGENTS.md. ${O.message} Adamantite will continue initialization.`),"failed"})));if($==="failed")return;if($==="malformed")yield*f.log.warning("Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.")}),f$=["check","fix","format","check:monorepo","fix:monorepo","analyze"],$$=["react","nextjs","vue","jest","vitest","node"],O$=["vscode","zed"],aO=U.fn("validateInitOptions")(function*(r,y){let u={agents:r.agents,editors:ar.dedupe(r.editors),githubActions:r.githubActions,installExtensions:r.installExtensions,overwriteScripts:r.overwriteScripts,presets:ar.dedupe(r.presets),scripts:ar.dedupe(r.scripts),typescript:r.typescript};if(u.scripts.length===0)return yield*new d({reason:"Select at least one script with `--script <name>`."});let f=u.scripts.includes("check")||u.scripts.includes("fix");if((u.scripts.includes("check:monorepo")||u.scripts.includes("fix:monorepo"))&&!y.isMonorepo)return yield*new d({reason:"Monorepo scripts can only be selected in a detected monorepo."});if(u.presets.length>0&&!f)return yield*new d({reason:"`--preset` requires the `check` or `fix` script."});if(u.typescript&&!f)return yield*new d({reason:"`--typescript` requires the `check` or `fix` script."});if(u.installExtensions&&u.editors.length===0)return yield*new d({reason:"`--install-extensions` requires at least one `--editor`."});if(u.githubActions&&!Zr(u.scripts))return yield*new d({reason:"`--github-actions` requires a CI-compatible script."});if(u.githubActions&&y.nonInteractive&&!br(y.packageManager))return yield*new d({reason:`\`--github-actions\` does not support the detected package manager \`${y.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`});return u}),nO=h.boolean("non-interactive").pipe(h.withDescription("Configure without prompts; requires at least one --script")),dO=h.choice("script",f$).pipe(h.atMost(f$.length),h.withDescription("Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo")),gO=h.choice("preset",$$).pipe(h.atMost($$.length),h.withDescription("Oxlint preset to configure; repeatable and requires --script check or fix")),sO=h.choice("editor",O$).pipe(h.atMost(O$.length),h.withDescription("Editor to configure; may be specified multiple times")),pO=h.boolean("typescript").pipe(h.withDescription("Configure the TypeScript preset; requires --script check or fix")),iO=h.boolean("install-extensions").pipe(h.withDescription("Install recommended extensions; requires at least one --editor")),oO=h.boolean("github-actions").pipe(h.withDescription("Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn")),cO=h.boolean("agents").pipe(h.withDescription("Add Adamantite guidance to AGENTS.md")),rj=h.boolean("overwrite-scripts").pipe(h.withDescription("Replace existing package scripts that conflict with Adamantite's managed commands")),yj=U.fn("collectInteractiveInitOptions")(function*(r,y){let u=yield*K,f=yield*u.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:!y,hint:y?void 0:"available for monorepo projects",label:"check:monorepo - check for monorepo-specific issues using Sherif",value:"check:monorepo"},{disabled:!y,hint:y?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"}]}),$=yield*H(r),O=fu($,f),j=!1;if(O.length>0){for(let t of O)yield*u.log.warning(xO(t));j=yield*u.confirm({initialValue:!1,message:O.length===1?"Overwrite this existing script with Adamantite's command?":"Overwrite these existing scripts with Adamantite's commands?"})}let m=f.includes("check")||f.includes("fix"),E=[];if(m)E=yield*u.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 v=m?yield*u.confirm({initialValue:!0,message:y?"Adamantite provides a TypeScript preset to enforce strict type-safety. In a monorepo, each package's `tsconfig.json` must extend it. Would you like instructions on how to set it up?":"Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?"}):!1,q=yield*u.multiselect({message:"Which editors do you want to configure? (optional)",options:[{label:"VSCode / Cursor / Windsurf",value:"vscode"},{label:"Zed",value:"zed"}],required:!1}),B=q.length>0?yield*u.confirm({initialValue:!0,message:"Do you want to install the recommended editor extensions?"}):!1,z=Zr(f)?yield*u.confirm({message:"Do you want to add a GitHub Actions workflow to run checks in CI?"}):!1;return{agents:yield*u.confirm({initialValue:!0,message:"Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?"}),editors:q,githubActions:z,installExtensions:B,overwriteScripts:j,presets:E,scripts:f,typescript:v}}),m$=Ur.make("init",{agents:cO,editors:sO,githubActions:oO,installExtensions:iO,nonInteractive:nO,overwriteScripts:rj,presets:gO,scripts:dO,typescript:pO}).pipe(Ur.withDescription("Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled"),Ur.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"}]),Ur.withHandler((r)=>U.gen(function*(){let y=IO.cwd(),u=yield*K;yield*xr(),yield*u.intro("\uD83D\uDCA0 adamantite init");let $=yield*(yield*P).detectPackageManager(y);if(!$)return yield*new ir({});if($.warnings?.length)for(let pr of $.warnings)yield*u.log.warning(pr);yield*u.log.info(`Detected package manager: ${$.name}`);let O=yield*Fr(y);if(O)yield*u.log.info("We've detected a monorepo setup in your project.");if(!r.nonInteractive&&ar.some([r.scripts.length>0,r.presets.length>0,r.editors.length>0,r.typescript,r.installExtensions,r.githubActions,r.agents,r.overwriteScripts],j$.isTruthy))return yield*new d({reason:"Setup flags require `--non-interactive`."});let j=r.nonInteractive?r:yield*yj(y,O),m=yield*aO(j,{isMonorepo:O,nonInteractive:r.nonInteractive,packageManager:$.name}),E=m.scripts,v=m.presets,q=m.editors,B=m.typescript,z=m.installExtensions,S=m.githubActions,t=m.agents,w=E.includes("check")||E.includes("fix"),D=E.includes("format"),e=E.includes("check:monorepo")||E.includes("fix:monorepo"),Oy=E.includes("analyze"),sr=["adamantite"];if(w)sr.push(`${Q.name}@${Q.version}`,`${Er.name}@${Er.version}`);if(D)sr.push(`${N.name}@${N.version}`);if(e)sr.push(`${a.name}@${a.version}`);if(Oy)sr.push(`${A.name}@${A.version}`);if(yield*PO(y,sr),D)yield*Lu(y,N,N.create(y));if(w)yield*Lu(y,Q,Q.create(y,v));if(Oy)yield*Lu(y,A,A.create(y));let Y$=yield*MO(y,E,{nonInteractive:r.nonInteractive,overwriteScripts:m.overwriteScripts});if(t)yield*kO(y,$.name,Y$);if(B)yield*CO(y,O);if(yield*tO(y,q),z)yield*wO(q,E);if(S){let pr=$.name;if(br(pr))yield*eO(y,pr,E);else yield*u.log.warning(`Skipping GitHub Actions setup: \`${pr}\` is not a supported package manager for CI workflow generation.`)}yield*u.log.success("Your project is now configured"),yield*u.outro("\uD83D\uDCA0 Adamantite initialized successfully!")}).pipe(U.catchTags({OperationCancelled:()=>U.gen(function*(){yield*(yield*K).cancel("You've cancelled the initialization process.")})}))));import*as E$ from"effect/Effect";import*as nr from"effect/unstable/cli/Command";import*as ty from"effect/unstable/cli/Flag";import*as v$ from"effect/unstable/process/ChildProcessSpawner";var uj=ty.boolean("fix").pipe(ty.withDescription("Automatically fix issues")),Wu=nr.make("monorepo",{fix:uj}).pipe(nr.withDescription("Find and fix monorepo-specific issues using Sherif"),nr.withHandler(({fix:r})=>E$.gen(function*(){let y=yield*J,u=yield*W,f=r?["--fix",...y]:[...y],$=yield*u.run({args:f,command:a.name,stdin:"inherit"});if($!==v$.ExitCode(0))yield*new T({command:a.name,exitCode:$})})));import*as q$ from"effect/Effect";import*as dr from"effect/unstable/cli/Command";import*as z$ from"effect/unstable/process/ChildProcessSpawner";var _u=dr.make("typecheck").pipe(dr.withDescription("Deprecated alias for `check`"),dr.withHandler(()=>q$.gen(function*(){let r=yield*J,y=yield*K,u=yield*W;yield*y.log.warning("Deprecated. Use `adamantite check` for typechecking.");let f=yield*u.run({args:[...r],command:Q.name});if(f!==z$.ExitCode(0))yield*new T({command:Q.name,exitCode:f})})));import fj from"node:process";import*as Tu from"effect/Array";import*as fr from"effect/Effect";import*as Qr from"effect/Result";import*as gr from"effect/unstable/cli/Command";var $j=[Q,Er,N,a,A],Oj=[Q,Er,N,a,A];function jj(r,y){return Tu.filterMap(Oj,(u)=>{if(y.has(u.name))return Qr.failVoid;let f=r.devDependencies?.[u.name]??r.dependencies?.[u.name];return f&&By(f)!==u.version?Qr.succeed({currentVersion:f,name:u.name,targetVersion:u.version}):Qr.failVoid})}var B$=gr.make("update").pipe(gr.withDescription("Run applicable Adamantite migrations and update managed dependencies"),gr.withHandler(()=>fr.gen(function*(){let r=fj.cwd(),y=yield*K,u=yield*P,f={cwd:r};yield*xr(),yield*y.intro("\uD83D\uDCA0 adamantite update");let $=()=>Jy($j,r),O=yield*$(),j=new Set,m=(D)=>fr.gen(function*(){for(let e of D){if(j.has(e))continue;j.add(e),yield*y.log.warning(e)}});yield*m(O.flatMap(({assessment:D})=>D.warnings));let E=[];for(let D of hu.filter((e)=>e.tags.includes("update"))){let e=yield*D.check(f);if(yield*m(e.warnings),e.status!=="needed")continue;let Oy=yield*y.withSpinner(()=>Ly(D,f),{failure:`Migration "${D.title}" failed, files restored.`,start:e.summary,success:`Migration "${D.title}" completed successfully.`});yield*m(Oy.warnings),E.push(D.id)}if(E.length>0)yield*y.log.success("Migrations ran successfully.");let v=yield*H(r),B=(yield*$()).flatMap(({assessment:D})=>D.actions),z=B.filter((D)=>D.type==="create_config"||D.type==="update_config"||D.type==="manual_fix"),S=Tu.filterMap(B,(D)=>{switch(D.type){case"install_package":return Qr.succeed({currentVersion:"not installed",name:D.package,targetVersion:D.targetVersion});case"update_package":return Qr.succeed({currentVersion:D.currentVersion,name:D.package,targetVersion:D.targetVersion});default:return Qr.failVoid}}),t=new Set(S.map((D)=>D.name)),w=[...S,...jj(v,t)];if(w.length>0){yield*y.log.info("The following dependencies will be updated:");for(let D of w)yield*y.log.info(` ${D.name}: ${D.currentVersion} → ${D.targetVersion}`);yield*y.withSpinner(()=>u.addDevDependencies(w.map((D)=>`${D.name}@${D.targetVersion}`),r,{silent:!0}),{failure:"Failed to update dependencies",start:"Updating dependencies...",success:"Dependencies updated successfully"}),yield*y.log.success("Dependencies updated successfully.")}if(z.length>0){yield*y.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let D of z)yield*y.log.warning(`Doctor follow-up: ${D.description}`)}if(E.length===0&&w.length===0&&z.length===0)return yield*y.log.success("No changes needed."),"no-changes";return"success"}).pipe(fr.tapError(()=>fr.gen(function*(){yield*(yield*K).outro("❌ Update failed")})),fr.tap((r)=>fr.gen(function*(){let y=yield*K;switch(r){case"no-changes":yield*y.outro("✅ Adamantite is already up to date.");break;case"success":yield*y.outro("✅ Update completed successfully!");break;default:break}})))));var mj=[vu,Bu,Zu,Ku,Wu,_u],D$=[vu,Bu,tf,Zu,Ku,m$,Wu,_u,B$],Ej=new Set(D$.map((r)=>r.name)),vj=new Set(mj.map((r)=>r.name)),qj=hr.make("adamantite").pipe(hr.withDescription("Opinionated preset package for modern TypeScript applications"),hr.withSubcommands(D$)),U$=ey.fn("runCli")(function*(r,y){let[u,f]=wy.splitWhere(r,(j)=>j==="--"),$=wy.drop(f,1),O=u.find((j)=>Ej.has(j));if($.length>0&&O!==void 0&&!vj.has(O))return yield*new cy({command:O});yield*hr.runWith(qj,{version:y})(u).pipe(ey.provideService(J,$))});var zj=_.gen(function*(){let y=yield*(yield*Z$.Stdio).args;yield*U$(y,"0.35.0")}).pipe(_.as(0),_.catchTag("CommandFailed",(r)=>_.succeed(r.exitCode)),_.catch((r)=>_.service(K).pipe(_.flatMap((y)=>y.log.error(r.message)),_.as(K$.ExitCode(1)))),_.provide(ky.mergeAll(Ru.layer,yy.layer.pipe(ky.provide(Ru.layer)),K.layer,W.layer,P.layer)));Q$.runMain(zj,{teardown:(r,y)=>{if(h$.isSuccess(r)){y(Number(r.value));return}b$.defaultTeardown(r,y)}});
|
package/dist/presets/analyze.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
// presets/analyze.ts
|
|
2
2
|
var config = {
|
|
3
|
-
ignore: ["**/*.d.ts"],
|
|
4
3
|
ignoreExportsUsedInFile: true,
|
|
5
|
-
ignoreFiles: [
|
|
6
|
-
"**/dist/**",
|
|
7
|
-
"**/build/**",
|
|
8
|
-
"**/coverage/**",
|
|
9
|
-
"**/.next/**",
|
|
10
|
-
"**/.vercel/**",
|
|
11
|
-
"**/.turbo/**"
|
|
12
|
-
],
|
|
13
4
|
rules: {
|
|
14
5
|
binaries: "error",
|
|
15
6
|
catalog: "error",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"resolveJsonModule": true,
|
|
9
9
|
"moduleDetection": "force",
|
|
10
10
|
|
|
11
|
+
// The preset is a type-checking base. Set "noEmit": false in your project
|
|
12
|
+
// if you emit output with tsc.
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
|
|
11
15
|
// Strictness and best practices. We only recommend settings that are not
|
|
12
16
|
// covered by linting rules.
|
|
13
17
|
"strict": true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adamantite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "An strict and opinionated set of presets for modern TypeScript applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adamantite",
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
"typescript": ">=7"
|
|
102
102
|
},
|
|
103
103
|
"engines": {
|
|
104
|
-
"bun": ">=1.
|
|
105
|
-
"node": ">=
|
|
104
|
+
"bun": ">=1.0.0",
|
|
105
|
+
"node": ">=22.19.0"
|
|
106
106
|
},
|
|
107
107
|
"packageManager": "bun@1.3.14"
|
|
108
108
|
}
|
package/presets/analyze.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import type { KnipConfiguration } from "knip"
|
|
2
2
|
|
|
3
3
|
const config: KnipConfiguration = {
|
|
4
|
-
ignore: ["**/*.d.ts"],
|
|
5
4
|
ignoreExportsUsedInFile: true,
|
|
6
|
-
ignoreFiles: [
|
|
7
|
-
"**/dist/**",
|
|
8
|
-
"**/build/**",
|
|
9
|
-
"**/coverage/**",
|
|
10
|
-
"**/.next/**",
|
|
11
|
-
"**/.vercel/**",
|
|
12
|
-
"**/.turbo/**",
|
|
13
|
-
],
|
|
14
5
|
rules: {
|
|
15
6
|
binaries: "error",
|
|
16
7
|
catalog: "error",
|
package/presets/tsconfig.json
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"resolveJsonModule": true,
|
|
9
9
|
"moduleDetection": "force",
|
|
10
10
|
|
|
11
|
+
// The preset is a type-checking base. Set "noEmit": false in your project
|
|
12
|
+
// if you emit output with tsc.
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
|
|
11
15
|
// Strictness and best practices. We only recommend settings that are not
|
|
12
16
|
// covered by linting rules.
|
|
13
17
|
"strict": true,
|
|
@@ -29,13 +29,18 @@ Repeat `--script`, `--preset`, and `--editor` for multiple values. Available val
|
|
|
29
29
|
|
|
30
30
|
- Scripts: `check`, `fix`, `format`, `analyze`, `check:monorepo`, `fix:monorepo`
|
|
31
31
|
- Presets: `react`, `nextjs`, `vue`, `jest`, `vitest`, `node`; editors: `vscode`, `zed`
|
|
32
|
-
- Optional flags: `--typescript`, `--install-extensions`, `--github-actions`, `--agents
|
|
32
|
+
- Optional flags: `--typescript`, `--install-extensions`, `--github-actions`, `--agents`,
|
|
33
|
+
`--overwrite-scripts`
|
|
33
34
|
|
|
34
35
|
Only select options supported by the project. Presets and TypeScript require `check` or
|
|
35
36
|
`fix`; extension installation requires an editor; monorepo scripts require a detected
|
|
36
37
|
monorepo; `--github-actions` requires a CI-compatible script and a supported package
|
|
37
38
|
manager (bun, deno, npm, pnpm, or yarn). Omitted boolean flags are disabled.
|
|
38
39
|
|
|
40
|
+
Existing package scripts whose commands differ from Adamantite's are kept and reported,
|
|
41
|
+
not replaced; pass `--overwrite-scripts` to replace them. Custom flags can be forwarded
|
|
42
|
+
to the Adamantite command after `--`, e.g. `adamantite monorepo -- --ignore-dependency tailwindcss`.
|
|
43
|
+
|
|
39
44
|
## Daily workflow
|
|
40
45
|
|
|
41
46
|
Use the scripts written by `init` when available. Otherwise invoke the CLI directly:
|