adamantite 0.35.0 → 0.36.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/CHANGELOG.md +1142 -0
- package/README.md +35 -15
- package/dist/index.js +32 -45
- package/dist/presets/analyze.d.ts +5 -3
- package/dist/presets/analyze.js +22 -24
- package/dist/presets/format.d.ts +3 -1
- package/dist/presets/format.js +73 -63
- package/dist/presets/lint/antislop/license.md +27 -0
- package/dist/presets/lint/antislop/plugin.d.mts +11 -0
- package/dist/presets/lint/antislop/plugin.mjs +1629 -0
- package/dist/presets/lint/antislop.d.ts +5 -0
- package/dist/presets/lint/antislop.js +28 -0
- package/dist/presets/lint/core.d.ts +17 -1
- package/dist/presets/lint/core.js +511 -481
- package/dist/presets/lint/jest.d.ts +3 -1
- package/dist/presets/lint/jest.js +66 -68
- package/dist/presets/lint/nextjs.d.ts +3 -1
- package/dist/presets/lint/nextjs.js +28 -30
- package/dist/presets/lint/node.d.ts +3 -1
- package/dist/presets/lint/node.js +12 -14
- package/dist/presets/lint/react.d.ts +3 -1
- package/dist/presets/lint/react.js +101 -105
- package/dist/presets/lint/vitest.d.ts +3 -1
- package/dist/presets/lint/vitest.js +71 -73
- package/dist/presets/lint/vue.d.ts +3 -1
- package/dist/presets/lint/vue.js +50 -52
- package/package.json +23 -21
- package/skills/adamantite/SKILL.md +2 -1
- package/presets/analyze.ts +0 -24
- package/presets/format.ts +0 -63
- package/presets/lint/core.ts +0 -481
- package/presets/lint/jest.ts +0 -68
- package/presets/lint/nextjs.ts +0 -30
- package/presets/lint/node.ts +0 -14
- package/presets/lint/react.ts +0 -105
- package/presets/lint/vitest.ts +0 -73
- package/presets/lint/vue.ts +0 -52
- package/presets/tsconfig.json +0 -28
package/README.md
CHANGED
|
@@ -28,7 +28,8 @@ and Sherif so humans and coding agents can use the same project workflow.
|
|
|
28
28
|
- **Fast checks**: Run Oxlint and Oxfmt on the Oxc toolchain.
|
|
29
29
|
- **Strict defaults**: Use opinionated lint and TypeScript presets without assembling a
|
|
30
30
|
configuration from scratch.
|
|
31
|
-
- **
|
|
31
|
+
- **Optional presets**: Add rules for different needs — frameworks like React, Next.js,
|
|
32
|
+
and Vue, test runners like Jest and Vitest, Node.js, and stricter opt-in rule sets.
|
|
32
33
|
- **Project setup**: Create package scripts, configuration files, editor settings, and CI
|
|
33
34
|
through an interactive or non-interactive initializer.
|
|
34
35
|
- **Setup maintenance**: Assess managed integrations with `doctor`, apply safe fixes, and
|
|
@@ -214,25 +215,44 @@ underlying CLI.
|
|
|
214
215
|
|
|
215
216
|
Adamantite publishes configuration that can also be consumed directly:
|
|
216
217
|
|
|
217
|
-
| Export
|
|
218
|
-
|
|
|
219
|
-
| `adamantite/lint`
|
|
220
|
-
| `adamantite/lint/react`
|
|
221
|
-
| `adamantite/lint/nextjs`
|
|
222
|
-
| `adamantite/lint/vue`
|
|
223
|
-
| `adamantite/lint/node`
|
|
224
|
-
| `adamantite/lint/jest`
|
|
225
|
-
| `adamantite/lint/vitest`
|
|
226
|
-
| `adamantite/
|
|
227
|
-
| `adamantite/
|
|
228
|
-
| `adamantite/
|
|
218
|
+
| Export | Purpose |
|
|
219
|
+
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
220
|
+
| `adamantite/lint` | Core Oxlint rules. |
|
|
221
|
+
| `adamantite/lint/react` | React, JSX accessibility, and performance. |
|
|
222
|
+
| `adamantite/lint/nextjs` | Next.js rules. |
|
|
223
|
+
| `adamantite/lint/vue` | Vue rules. |
|
|
224
|
+
| `adamantite/lint/node` | Node.js rules. |
|
|
225
|
+
| `adamantite/lint/jest` | Jest rules. |
|
|
226
|
+
| `adamantite/lint/vitest` | Vitest rules. |
|
|
227
|
+
| `adamantite/lint/antislop` | Vendored [anti-slop](https://github.com/dmmulroy/anti-slop) rules that reject low-evidence, low-signal patterns. Also turns off `typescript/consistent-indexed-object-style` and `unicorn/no-immediate-mutation` from the core preset, which conflict with these rules. |
|
|
228
|
+
| `adamantite/format` | Oxfmt configuration. |
|
|
229
|
+
| `adamantite/analyze` | Knip configuration. |
|
|
230
|
+
| `adamantite/typescript` | Strict TypeScript configuration for TS 7+. |
|
|
231
|
+
|
|
232
|
+
When consuming the lint presets directly, hoist the core preset's ignore patterns onto the
|
|
233
|
+
root config. Oxlint does not merge `ignorePatterns` from extended configs, so without the
|
|
234
|
+
hoist, dependencies, build output, and generated code are only skipped when your
|
|
235
|
+
`.gitignore` happens to cover them:
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
import { defineConfig } from "oxlint"
|
|
239
|
+
import core from "adamantite/lint"
|
|
240
|
+
|
|
241
|
+
export default defineConfig({
|
|
242
|
+
extends: [core],
|
|
243
|
+
ignorePatterns: core.ignorePatterns,
|
|
244
|
+
})
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Configs generated by `adamantite init` include this automatically.
|
|
229
248
|
|
|
230
249
|
## Requirements and boundaries
|
|
231
250
|
|
|
232
251
|
- Adamantite requires Bun 1.0 or later when run with Bun, or Node.js 22.19 or later when
|
|
233
252
|
run with Node.js.
|
|
234
|
-
- This repository uses
|
|
235
|
-
pnpm, or Yarn where the selected integration supports
|
|
253
|
+
- This repository uses pnpm and Node.js for development, but the CLI can configure
|
|
254
|
+
projects that use Bun, Deno, npm, pnpm, or Yarn where the selected integration supports
|
|
255
|
+
them.
|
|
236
256
|
- Adamantite manages recognized package scripts and supported configuration shapes. It
|
|
237
257
|
reports custom configurations that require manual work instead of overwriting them.
|
|
238
258
|
- `fix`, `format`, `analyze --fix`, `monorepo --fix`, `doctor --fix`, `init`, and `update`
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
${(
|
|
3
|
-
`)}`}
|
|
4
|
-
`)}class
|
|
5
|
-
`)}
|
|
6
|
-
`,`
|
|
7
|
-
|
|
8
|
-
`)
|
|
9
|
-
`);return
|
|
10
|
-
`);
|
|
11
|
-
`)}
|
|
12
|
-
`);return
|
|
13
|
-
`)}
|
|
14
|
-
`)?
|
|
15
|
-
`
|
|
16
|
-
`)
|
|
17
|
-
`)}function
|
|
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
|
|
1
|
+
import*as e from"@effect/platform-node/NodeRuntime";import*as t from"@effect/platform-node/NodeServices";import*as n from"effect/Effect";import*as r from"effect/Exit";import*as i from"effect/Layer";import*as a from"effect/Runtime";import*as o from"effect/Stdio";import*as s from"effect/unstable/process/ChildProcessSpawner";import*as c from"effect/Array";import*as l from"effect/unstable/cli/Command";import*as u from"effect/unstable/cli/Flag";import*as d from"effect/Context";import*as ee from"effect/unstable/process/ChildProcess";import{stripVTControlCharacters as f}from"node:util";import*as p from"effect/Data";import{pipe as m}from"effect/Function";import*as h from"effect/Option";import*as g from"effect/Predicate";import*as _ from"effect/String";import{parse as te,printParseErrorCode as v}from"jsonc-parser";import*as y from"effect/FileSystem";import*as b from"effect/Path";import x from"node:process";import*as ne from"effect/Record";import*as S from"effect/Result";import{defu as re}from"defu";import*as C from"effect/unstable/cli/Argument";import{print as ie}from"esrap";import ae from"esrap/languages/ts";import{parseSync as oe}from"oxc-parser";import{addDevDependency as se,detectPackageManager as ce,runScriptCommand as le}from"nypm";import*as w from"effect/Schema";import*as T from"@clack/prompts";import*as ue from"effect/Console";import*as de from"effect/Terminal";function fe(e){return g.isError(e)?m(f(e.message),_.split(/\r\n|[\r\n]/),c.map(e=>_.trimEnd(e)),c.filter(e=>_.isNonEmpty(e))):[]}function E(e){return m(fe(e),c.head,h.map(e=>{let t=_.trim(e);return/[.!?]$/.test(t)?` Cause: ${t}`:` Cause: ${t}.`}),h.getOrElse(()=>``))}function pe(e){let t=fe(e);if(!c.isReadonlyArrayNonEmpty(t))return``;let n=c.takeRight(t,20);return`\n${(n.length<t.length?[`…`,...n]:n).join(`
|
|
2
|
+
`)}`}function me(e=[]){return e.length===0?`- Unknown JSON/JSONC parsing error`:e.slice(0,3).map(e=>`- ${v(e.error)} (offset: ${e.offset})`).join(`
|
|
3
|
+
`)}var he=class extends p.TaggedError(`CliNotFound`){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}},D=class extends p.TaggedError(`CommandFailed`){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}},ge=class extends p.TaggedError(`FailedToCreateDirectory`){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:`the target directory`}.${E(this.cause)}`}},_e=class extends p.TaggedError(`FailedToInstallDependency`){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(`, `)}`:``}.${pe(this.cause)}`}},ve=class extends p.TaggedError(`FailedToInstallExtension`){get message(){let e=this.extension?`\`${this.extension}\``:`the target extension`;return g.isNumber(this.cause)?`Failed to install ${e}. The \`code\` CLI exited with code ${this.cause}.`:`Failed to install ${e}.${E(this.cause)}`}},ye=class extends p.TaggedError(`FailedToMergeConfig`){get message(){return`Failed to merge configuration.${E(this.cause)}`}},be=class extends p.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:`,me(this.errors)].join(`
|
|
4
|
+
`)}},xe=class extends p.TaggedError(`FailedToReadFile`){get message(){return`Failed to read ${this.path?`\`${this.path}\``:`the target file`}.${E(this.cause)}`}},Se=class extends p.TaggedError(`FailedToDeleteFile`){get message(){return`Failed to delete ${this.path?`\`${this.path}\``:`the target file`}.${E(this.cause)}`}},Ce=class extends p.TaggedError(`FailedToWriteFile`){get message(){return`Failed to write ${this.path?`\`${this.path}\``:`the target file`}.${E(this.cause)}`}},we=class extends p.TaggedError(`FileNotFound`){get message(){return this.path?`File not found: \`${this.path}\`.`:`File not found.`}},Te=class extends p.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: {}).`}},O=class extends p.TaggedError(`InvalidInitOptions`){get message(){return`Invalid init options. ${this.reason}`}},Ee=class extends p.TaggedError(`UnsupportedConfigState`){get message(){return`Unsupported config state in ${this.path?`\`${this.path}\``:`the target config file`}.${this.reason?` ${this.reason}`:``}`}},De=class extends p.TaggedError(`NoPackageManager`){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${E(this.cause)}`}};p.TaggedError(`MissingPackageVersion`);var k=class extends p.TaggedError(`MigrationValidationFailed`){get message(){return`Migration \`${this.migrationId}\` validation failed. ${this.reason}`}},Oe=class extends p.TaggedError(`OperationCancelled`){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:``}`}},ke=class extends p.TaggedError(`PassthroughNotSupported`){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}},Ae=class extends p.TaggedError(`VscodeCliNotFound`){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${E(this.cause)}`}},A=class extends d.Service()(`CommandRunner`){static layer=i.succeed(this)({run:n.fn(`CommandRunner.run`)(function*({args:e,command:t,cwd:r,stderr:i=`inherit`,stdin:a=`ignore`,stdout:o=`inherit`}){return yield*n.scoped(n.gen(function*(){return yield*(yield*ee.make(t,e,{cwd:r,stderr:i,stdin:a,stdout:o})).exitCode})).pipe(n.mapError(e=>e.reason._tag===`NotFound`?new he({command:t}):e))})})};const j=d.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]});function M(e){return e}const je=e=>y.FileSystem.pipe(n.flatMap(t=>t.makeDirectory(e,{recursive:!0})),n.mapError(t=>new ge({cause:t,path:e}))),N=e=>y.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.mapError(t=>new xe({cause:t,path:e}))),Me=e=>y.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.map(e=>m(e,h.some)),n.catch(t=>t.reason._tag===`NotFound`?n.succeedNone:n.fail(new xe({cause:t,path:e})))),P=(e,t)=>y.FileSystem.pipe(n.flatMap(n=>n.writeFileString(e,t)),n.mapError(t=>new Ce({cause:t,path:e}))),F=(e,t)=>P(e,`${JSON.stringify(t,null,2)}\n`),Ne=e=>y.FileSystem.pipe(n.flatMap(t=>t.remove(e)),n.mapError(t=>new Se({cause:t,path:e}))),I=(e,t)=>n.suspend(()=>{let r=[],i=te(e,r,{allowTrailingComma:!0});return r.length>0?n.fail(new be({errors:r,path:t})):n.succeed(i)}),Pe=e=>g.isObject(e);function Fe(e,t={}){let{continuationIndent:n,indentation:r=2}=t,i=JSON.stringify(e,null,r).replaceAll(/"([A-Za-z_$][\w$]*)":/g,`$1:`);return n?i.replaceAll(`
|
|
5
|
+
`,`\n${n}`):i}const Ie=(e,t)=>n.try({catch:e=>new ye({cause:e}),try:()=>re(e,t)}),Le=/^workspace:/,Re=/^[\^~]/;function ze(e){return e.trim().replace(Le,``).replace(Re,``)}const L=(e=x.cwd())=>n.gen(function*(){let t=(yield*b.Path).join(e,`package.json`),n=yield*N(t);return yield*I(n,t)}),Be=(e,t)=>n.gen(function*(){let n=yield*b.Path;yield*F(n.join(e,`package.json`),t)});function Ve(e){return e===`bun`||e===`deno`||e===`npm`||e===`pnpm`||e===`yarn`}const R={analyze:`adamantite analyze`,check:`adamantite check`,"check:monorepo":`adamantite monorepo`,fix:`adamantite fix`,"fix:monorepo":`adamantite monorepo --fix`,format:`adamantite format`};function He(e){let t=e.scripts??{};return m(ne.keys(R),c.filter(e=>t[e]===R[e]))}function Ue(e,t){let n=e.scripts??{};return c.filterMap(t,e=>{let t=n[e];return t!==void 0&&t!==``&&t!==R[e]?S.succeed({command:t,script:e}):S.failVoid})}function We(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function Ge(e,t){return c.findFirst(e.legacyConfigs,e=>We(e)===t)}function Ke(e){let t=Ge(e,`json`),n=Ge(e,`jsonc`);return m(h.zipWith(t,n,e=>`${e}(c)`),h.orElse(()=>n),h.orElse(()=>t),h.getOrElse(()=>``))}function qe(e,t,n,r){return n===null||r.length===0?[]:n.format===`ts`?[`Found both \`${t.config}\` and \`${Ke(t)}\`. Adamantite will use \`${t.config}\`.`]:m(h.zipWith(Ge(t,`json`),Ge(t,`jsonc`),(t,n)=>`Found both \`${t}\` and \`${n}\`. Multiple legacy ${e} configs exist; Adamantite will treat \`${n}\` as the source of truth when migration is needed.`),h.toArray)}const Je=n.fn(`detectToolingConfig`)(function*(e,t,r){let i=yield*y.FileSystem,a=yield*b.Path,o=[r.config,...r.legacyConfigs].map(t=>({file:t,format:We(t),path:a.join(e,t)})),s=yield*n.forEach(o,e=>i.exists(e.path),{concurrency:`unbounded`}),l=o.filter((e,t)=>s[t]),u=m(c.findFirst(l,e=>e.format===`ts`),h.orElse(()=>c.findFirst(l,e=>e.format===`jsonc`)),h.orElse(()=>c.findFirst(l,e=>e.format===`json`)),h.getOrNull),d=l.filter(e=>e!==u&&e.format!==`ts`);return{active:u,legacy:d,warnings:qe(t,r,u,d)}});function Ye(e,t,n){let r=e.devDependencies?.[t.name]??e.dependencies?.[t.name];return r?ze(r)===t.version?[]:[{currentVersion:r,description:`Update \`${t.name}\` from \`${r}\` to \`${t.version}\`.`,package:t.name,targetVersion:t.version,type:`update_package`}]:[{description:`Install \`${t.name}@${t.version}\` for ${n}.`,package:t.name,targetVersion:t.version,type:`install_package`}]}function Xe(e,t){return e.active===null?[{description:`Create \`${t.configFile}\` for \`${t.toolName}\`.`,path:t.configFile,type:`create_config`}]:e.active.format===`ts`?[]:[{description:`Migrate legacy \`${e.active.file}\` to \`${t.configFile}\`.`,migrationId:t.migrationId,type:`run_migration`}]}function Ze(e,t){let n=He(e);return t.some(e=>n.includes(e))}function Qe(e){return M({assess:(t,r)=>n.sync(()=>Ze(r,e.scripts)?{actions:Ye(r,e,e.purpose),applicable:!0,warnings:[]}:{applicable:!1,warnings:[]}),kind:`tooling`,name:e.name,version:e.version})}function $e(e){let t=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],r=t=>Je(t,e.name,e.configFiles);return M({assess:(t,i)=>n.gen(function*(){if(!Ze(i,e.scripts))return{applicable:!1,warnings:[]};let n=yield*r(t);return{actions:[...Ye(i,e,e.purpose),...Xe(n,{configFile:e.configFiles.config,migrationId:e.migrationId,toolName:e.name})],applicable:!0,warnings:n.warnings}}),config:e.configFiles.config,create:t=>n.gen(function*(){let n=yield*b.Path;yield*P(n.join(t,e.configFiles.config),e.configContent())}),detect:r,files:t,kind:`tooling`,name:e.name,version:e.version})}function et(e={}){let t=Object.entries(e).map(([e,t])=>e===`rules`&&Pe(t)?[` rules: {`,` ...analyze.rules,`,...Object.entries(t).map(([e,t])=>` ${e}: ${Fe(t,{continuationIndent:` `,indentation:` `})},`),` },`].join(`
|
|
6
|
+
`):` ${e}: ${Fe(t)},`);return t.length===0?[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = analyze`,``,`export default config`,``].join(`
|
|
7
|
+
`):[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = {`,` ...analyze,`,...t,`}`,``,`export default config`,``].join(`
|
|
8
|
+
`)}var z=$e({configContent:()=>et(),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`});const tt=u.boolean(`fix`).pipe(u.withDescription(`Automatically fix issues`)),nt=u.boolean(`strict`).pipe(u.withDescription(`Enable strict mode`));var rt=l.make(`analyze`,{fix:tt,strict:nt}).pipe(l.withDescription(`Find unused dependencies, exports, and files using knip`),l.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run knip from a specific directory`}]),l.withHandler(({fix:e,strict:t})=>n.gen(function*(){let n=yield*j,r=yield*A,i=[];e&&i.push(`--fix`,`--allow-remove-files`),t&&i.push(`--production`,`--strict`),i.push(...n);let a=yield*r.run({args:i,command:z.name});a!==s.ExitCode(0)&&(yield*new D({command:z.name,exitCode:a}))})));const it=`**/node_modules,**/.yarn,**/.git,**/dist,**/build,**/out,**/.next,**/.open-next,**/.nuxt,**/.output,**/.svelte-kit,**/.vitepress/cache,**/.turbo,**/.vercel,**/.netlify,**/.wrangler,**/.docusaurus,**/.cache,**/.parcel-cache,**/.vite,**/.astro,**/_astro,**/storybook-static,**/_generated,**/__generated__,**/*.gen.*,**/*.generated.*,**/generated,**/codegen,**/graphql-types.*,**/*.d.ts.map,**/coverage,**/.nyc_output,**/.expo,**/.expo-shared,**/next-env.d.ts,**/worker-configuration.d.ts`.split(`,`),at=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],ot="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",st="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",ct="`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 lt(e=[]){return e.includes(`core`)?e:[`core`,...e]}function ut(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function dt(e){let t=(c.isArray(e)?e:[]).filter(e=>g.isString(e)).filter(e=>!it.includes(e));return t.length===0?`core.ignorePatterns`:`[...core.ignorePatterns, ${t.map(e=>JSON.stringify(e)).join(`, `)}]`}function ft(e,t,n=[]){let{ignorePatterns:r,options:i,...a}=e,o=[`import { defineConfig } from "oxlint"`,...t.map(e=>`import ${ut(e)} from "${e===`core`?`adamantite/lint`:`adamantite/lint/${e}`}"`)],s=[...t.map(e=>ut(e)),...n.map(e=>JSON.stringify(e))],c=JSON.stringify(g.isObject(i)?{...i,respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0}:{respectEslintDisableDirectives:!0,typeAware:!0,typeCheck:!0},null,2),l=Object.entries(a).map(([e,t])=>[e,JSON.stringify(t,null,2)]),u=`[${s.join(`, `)}]`,d=[[`options`,c],[`ignorePatterns`,dt(r)],...l,[`extends`,u]].map(([e,t])=>` ${e}: ${t},`).join(`
|
|
9
|
+
`);return[...o,``,`export default defineConfig({`,d,`})`,``].join(`
|
|
10
|
+
`)}const pt=h.liftThrowable(e=>oe(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function mt(e){return pt(e).pipe(h.flatMap(e=>e.errors.length===0?h.fromNullishOr(e.program):h.none()))}function ht(e){let{code:t}=ie(e,ae({quotes:`double`}));return t.endsWith(`
|
|
11
|
+
`)?t:`${t}\n`}function gt(e){return e.type===`Identifier`?m(e.name,h.some):e.type===`Literal`&&g.isString(e.value)?m(e.value,h.some):h.none()}function _t(e){return e.type===`ObjectExpression`?m(e,h.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?h.none():m(e.arguments.length===1?c.head(e.arguments):h.none(),h.filter(e=>e.type===`ObjectExpression`))}function vt(e){return m(e.body,c.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?c.head(e):h.none(),h.flatMap(e=>_t(e.declaration)))}function yt(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`manual`};let e=h.contains(gt(r.key),t);if(r.method||r.kind!==`init`){if(e)return{status:`manual`};continue}if(e){if(n)return{status:`manual`};n=r}}return n?{property:n,status:`found`}:{status:`missing`}}function bt(e){return{computed:!1,end:0,key:{end:0,name:e,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 xt(){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:at.map(e=>bt(e)),start:0,type:`ObjectExpression`}}}function St(e,t){let n=[],r=!1;for(let e of at){let i=yt(t,e);if(i.status===`manual`)return{kind:`manual`,reason:ct};if(i.status===`missing`){n.push(e);continue}let a=i.property.value;if(a.type!==`Literal`||!g.isBoolean(a.value))return{kind:`manual`,reason:ct};a.value||(a.raw=`true`,a.value=!0,r=!0)}return n.length>0&&(t.properties.unshift(...n.map(e=>bt(e))),r=!0),r?{kind:`patchable`,updatedContent:ht(e)}:{kind:`configured`}}function Ct(e){let t=mt(e);if(h.isNone(t))return{kind:`manual`,reason:ot};let n=vt(t.value);if(h.isNone(n))return{kind:`manual`,reason:ot};let r=yt(n.value,`options`);return r.status===`manual`?{kind:`manual`,reason:st}:r.status===`missing`?(n.value.properties.unshift(xt()),{kind:`patchable`,updatedContent:ht(t.value)}):r.property.value.type===`ObjectExpression`?St(t.value,r.property.value):{kind:`manual`,reason:st}}const B=`oxlint.config.ts`,wt=`.oxlintrc.json`,Tt=[{path:B,type:`config`},{path:wt,type:`legacy_config`}],Et={config:B,legacyConfigs:[wt]},Dt=`1.78.0`,Ot=e=>Je(e,`oxlint`,Et);var V=M({assess:(e,t)=>n.gen(function*(){let n=He(t);if(!n.includes(`check`)&&!n.includes(`fix`))return{applicable:!1,warnings:[]};let r=yield*Ot(e),i=[...Ye(t,{name:`oxlint`,version:Dt},`the managed lint scripts`),...Xe(r,{configFile:B,migrationId:`legacy-oxlint-json`,toolName:`oxlint`})],a=r.active;if(a?.format===`ts`){let e=Ct(yield*N(a.path));e.kind===`patchable`&&i.push({description:"Update `oxlint.config.ts` with Adamantite's required options.",path:B,type:`update_config`}),e.kind===`manual`&&i.push({description:"Manually update `oxlint.config.ts` with Adamantite's required options; Adamantite cannot patch the current file shape safely.",path:B,type:`manual_fix`})}return{actions:i,applicable:!0,warnings:r.warnings}}),config:B,create:(e,t=[])=>n.gen(function*(){let n=yield*b.Path,r=ft({},lt(t));yield*P(n.join(e,B),r)}),detect:Ot,files:Tt,kind:`tooling`,name:`oxlint`,update:e=>n.gen(function*(){let t=yield*y.FileSystem,n=(yield*b.Path).join(e,B);if(!(yield*t.exists(n)))return yield*new we({path:B});let r=Ct(yield*N(n));if(r.kind!==`configured`){if(r.kind===`manual`)return yield*new Ee({path:B,reason:r.reason});yield*P(n,r.updatedContent)}}),version:Dt});const kt=C.file(`files`,{mustExist:!0}).pipe(C.withDescription(`Specific files to lint (optional)`),C.variadic());var At=l.make(`check`,{files:kt}).pipe(l.withDescription(`Find issues and type errors in code using oxlint`),l.withHandler(({files:e})=>n.gen(function*(){let t=yield*j,n=yield*(yield*A).run({args:[...e,...t],command:V.name});n!==s.ExitCode(0)&&(yield*new D({command:V.name,exitCode:n}))})));const jt=new Set([`sortImports`,`sortPackageJson`,`sortTailwindcss`]);function Mt(e){let t=e.split(`
|
|
12
|
+
`);return t.length===1?e.slice(1,-1).trim():t.slice(1,-1).map(e=>` ${e.trimStart()}`).join(`
|
|
13
|
+
`)}function Nt(e,t){let n=Mt(Fe(t));return[` ${e}: {`,` ...format.${e},`,...n===``?[]:[n],` },`].join(`
|
|
14
|
+
`)}function Pt(e={}){let t=Object.entries(e).map(([e,t])=>jt.has(e)&&Pe(t)?Nt(e,t):` ${e}: ${Fe(t,{continuationIndent:` `})},`);return t.length===0?[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig(format)`,``].join(`
|
|
15
|
+
`):[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig({`,` ...format,`,...t,`})`,``].join(`
|
|
16
|
+
`)}var H=$e({configContent:()=>Pt(),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`}),U=Qe({name:`sherif`,purpose:`the managed monorepo scripts`,scripts:[`check:monorepo`,`fix:monorepo`],version:`1.13.0`}),W=Qe({name:`oxlint-tsgolint`,purpose:`the managed lint scripts`,scripts:[`check`,`fix`],version:`7.0.2001`});function Ft(e){return e}const It=n.fn(`runMigration`)(function*(e,t){let r=yield*b.Path,i=e.files??[],a=yield*n.forEach(i,e=>{let i=r.join(t.cwd,e);return Me(i).pipe(n.map(e=>[i,e]))},{concurrency:`unbounded`});return yield*e.migrate(t).pipe(n.tap(()=>e.validate?.(t)??n.void),n.onError(()=>n.forEach(([e,t])=>h.match(t,{onNone:()=>Ne(e).pipe(n.ignore),onSome:t=>P(e,t).pipe(n.ignore)}))(a)))}),Lt=[{name:`check`,script:`check`},{args:[`--check`],name:`format`,script:`format`},{name:`monorepo`,script:`check:monorepo`},{name:`analyze`,script:`analyze`}];function Rt(e,t){let n=[];for(let r of Lt)t.includes(r.script)&&n.push({command:le(e,r.script,{args:r.args}),name:r.name});return n}function zt(e){return Lt.some(t=>e.includes(t.script))}function Bt(e){return{_tag:`File`,path:e}}function Vt(e){return{_tag:`Version`,value:e}}const Ht=[`.node-version`,`.nvmrc`],Ut=w.Struct({volta:w.Struct({node:w.NonEmptyString})}),Wt=w.Struct({engines:w.Struct({node:w.NonEmptyString})}),Gt=w.Struct({name:w.NonEmptyString,version:w.NonEmptyString});function Kt(e){return e.split(`
|
|
17
|
+
`).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function qt(e){return w.is(Gt)(e)&&e.name.toLowerCase()===`node`}function Jt(e){if(w.is(Ut)(e))return!0;if(g.isObject(e)&&g.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>qt(e)))return!0}return w.is(Wt)(e)}var Yt=class extends d.Service()(`NodeVersionResolver`){static layer=i.effect(this,n.gen(function*(){let e=yield*y.FileSystem,t=yield*b.Path,r=(r,i)=>Me(t.join(r,i)).pipe(n.provideService(y.FileSystem,e));return{resolve:n.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of Ht){let n=yield*r(e,t);if(h.exists(n,e=>_.isNonEmpty(e.trim())))return Bt(t)}let n=yield*r(e,`.tool-versions`);if(h.exists(n,e=>Kt(e)))return Bt(`.tool-versions`);let i=yield*r(e,`package.json`);return h.isSome(i)&&Jt(yield*I(i.value,t.join(e,`package.json`)))?Bt(`package.json`):Vt(`lts/*`)})}}))};function Xt(e){return` - name: Setup Node.js
|
|
22
18
|
uses: actions/setup-node@v7
|
|
23
19
|
with:
|
|
24
|
-
${
|
|
20
|
+
${e._tag===`File`?`node-version-file: "${e.path}"`:`node-version: "${e.value}"`}`}function Zt(e){return{bun:`${Xt(e)}
|
|
25
21
|
|
|
26
22
|
- name: Setup Bun
|
|
27
23
|
uses: oven-sh/setup-bun@v2
|
|
@@ -41,22 +37,22 @@ ${u}`)}var Tr=(r,y)=>g.try({catch:(u)=>new gy({cause:u}),try:()=>T$(r,y)});var A
|
|
|
41
37
|
uses: denoland/setup-deno@v2
|
|
42
38
|
|
|
43
39
|
- name: Install dependencies
|
|
44
|
-
run: deno install --frozen`,npm:`${
|
|
40
|
+
run: deno install --frozen`,npm:`${Xt(e)}
|
|
45
41
|
cache: "npm"
|
|
46
42
|
|
|
47
43
|
- name: Install dependencies
|
|
48
44
|
run: npm ci`,pnpm:` - name: Setup pnpm
|
|
49
45
|
uses: pnpm/action-setup@v4
|
|
50
46
|
|
|
51
|
-
${
|
|
47
|
+
${Xt(e)}
|
|
52
48
|
cache: "pnpm"
|
|
53
49
|
|
|
54
50
|
- name: Install dependencies
|
|
55
|
-
run: pnpm install --frozen-lockfile`,yarn:`${
|
|
51
|
+
run: pnpm install --frozen-lockfile`,yarn:`${Xt(e)}
|
|
56
52
|
cache: "yarn"
|
|
57
53
|
|
|
58
54
|
- name: Install dependencies
|
|
59
|
-
run: yarn install --frozen-lockfile`}}function
|
|
55
|
+
run: yarn install --frozen-lockfile`}}function Qt({packageManager:e,scripts:t},n){let r=Rt(e,t);return r.length===0?null:`${`name: adamantite
|
|
60
56
|
|
|
61
57
|
on:
|
|
62
58
|
push:
|
|
@@ -81,33 +77,24 @@ jobs:
|
|
|
81
77
|
fail-fast: false
|
|
82
78
|
matrix:
|
|
83
79
|
include:
|
|
84
|
-
${
|
|
85
|
-
command: ${j.command}`).join(`
|
|
80
|
+
${r.map(e=>` - name: ${e.name}\n command: ${e.command}`).join(`
|
|
86
81
|
`)}
|
|
87
82
|
|
|
88
83
|
steps:
|
|
89
84
|
- name: Checkout
|
|
90
85
|
uses: actions/checkout@v7
|
|
91
86
|
|
|
92
|
-
${
|
|
87
|
+
${Zt(n)[e]}
|
|
93
88
|
|
|
94
89
|
- name: Run \${{ matrix.name }}
|
|
95
|
-
run: \${{ matrix.command }}`}
|
|
96
|
-
`}var
|
|
97
|
-
`)
|
|
98
|
-
`)
|
|
99
|
-
`)
|
|
100
|
-
|
|
101
|
-
`)
|
|
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(`
|
|
90
|
+
run: \${{ matrix.command }}`}\n`}const $t=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],en=(e,t)=>n.gen(function*(){let n=yield*b.Path,r=yield*Yt,i=n.join(e,$t[0].path),a=Qt(t,yield*r.resolve(e));a&&(yield*P(i,a))});var G=M({create:(e,t)=>n.gen(function*(){let n=yield*b.Path;yield*je(n.dirname(n.join(e,$t[0].path))),yield*en(e,t)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,$t[0].path))}),files:$t,kind:`ci`,name:`github`,update:en}),K=class extends d.Service()(`DependencyInstaller`){static layer=i.succeed(this)({addDevDependencies:n.fn(`DependencyInstaller.addDevDependencies`)((e,t,r)=>n.tryPromise({catch:t=>new _e({cause:t,packages:e}),try:()=>se(e,{...r,cwd:t})}).pipe(n.asVoid)),detectPackageManager:n.fn(`DependencyInstaller.detectPackageManager`)(e=>n.tryPromise({catch:e=>new De({cause:e}),try:()=>ce(e)}).pipe(n.map(e=>e??null)))})};const tn=/^\s*node-version:\s*"?\d/m;function nn(){return G.files[0].path}const rn=e=>n.gen(function*(){let t=yield*b.Path;return yield*Me(t.join(e,nn()))}),an=e=>n.gen(function*(){let t=yield*K,n=He(yield*L(e));if(!zt(n))return{reason:`scripts`,supported:!1};let r=yield*t.detectPackageManager(e);return r?Ve(r.name)?{packageManager:r.name,scripts:n,supported:!0}:{packageManagerName:r.name,reason:`unsupported-package-manager`,supported:!1}:{reason:`no-package-manager`,supported:!1}});var on=Ft({check:e=>n.gen(function*(){let t=yield*rn(e.cwd);if(!h.exists(t,e=>tn.test(e)))return{status:`not-applicable`,warnings:[]};let n=yield*an(e.cwd);return n.supported?{status:`needed`,summary:`Replacing the hard-coded Node.js version in the GitHub Actions workflow with the project's Node.js version declaration.`,warnings:[]}:{status:`not-applicable`,warnings:[n.reason===`scripts`?`No CI-compatible managed scripts were found, so the GitHub Actions workflow was not updated.`:n.reason===`no-package-manager`?`Could not detect a package manager, so the GitHub Actions workflow was not updated.`:`\`${n.packageManagerName}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`]}}),files:[nn()],id:`hardcoded-node-version`,migrate:e=>n.gen(function*(){let t=yield*an(e.cwd);return t.supported?(yield*G.update(e.cwd,{packageManager:t.packageManager,scripts:t.scripts}),{warnings:[]}):yield*n.die(Error(`check() guaranteed workflow regeneration is supported`))}),tags:[`update`],title:`Hard-coded workflow Node.js version`,validate:e=>n.gen(function*(){let t=yield*rn(e.cwd);if(h.exists(t,e=>tn.test(e)))return yield*new k({migrationId:`hardcoded-node-version`,reason:`The GitHub Actions workflow still contains a hard-coded Node.js version.`})})});function sn(e,t){return n.gen(function*(){let r=yield*b.Path,i=yield*t.integration.detect(e);if(i.active===null||i.active.format===`ts`)return yield*n.die(Error(`check() guaranteed a legacy ${t.displayName} config exists`));let a=i.active.path,o=r.join(e,t.integration.config),s=yield*N(a),c=yield*I(s,a);if(!Pe(c))return yield*new Te({path:a});let{$schema:l,...u}=c;yield*P(o,t.serialize(u));for(let e of[i.active,...i.legacy])yield*Ne(e.path);return{warnings:[]}})}function cn(e){return Ft({check:t=>n.gen(function*(){let n=yield*e.integration.detect(t.cwd);return n.active===null||n.active.format===`ts`?{status:`not-applicable`,warnings:n.warnings}:{status:`needed`,summary:`Migrating legacy \`${n.active.file}\` configuration to \`${e.integration.config}\`.`,warnings:n.warnings}}),files:e.integration.files.map(e=>e.path),id:e.id,migrate:t=>sn(t.cwd,e),tags:[`update`],title:e.title,validate:t=>n.gen(function*(){if((yield*e.integration.detect(t.cwd)).active?.format!==`ts`)return yield*new k({migrationId:e.id,reason:`\`${e.integration.config}\` is not the active ${e.displayName} config.`})})})}var ln=cn({displayName:`Knip`,id:`legacy-knip-json`,integration:z,serialize:et,title:`Legacy Knip JSON config`}),un=cn({displayName:`Oxfmt`,id:`legacy-oxfmt-json`,integration:H,serialize:Pt,title:`Legacy oxfmt JSON config`});const dn=/^(?:\.\/)?node_modules\/adamantite\/presets\/lint\/([a-z0-9-]+)\.(?:json|ts)$/,fn=/^adamantite\/lint(?:\/([a-z0-9-]+))?$/;function pn(e){let t=Array.isArray(e.extends)?e.extends.filter(e=>typeof e==`string`):g.isString(e.extends)?[e.extends]:[],n=new Set(lt()),r=new Set;for(let e of t){let t=e.match(dn),i=e.match(fn),a=t?.[1]??(i?i[1]??`core`:null);a?n.add(a):r.add(e)}let{extends:i,...a}=e;return ft(a,[...n],[...r])}var mn=cn({displayName:`Oxlint`,id:`legacy-oxlint-json`,integration:V,serialize:pn,title:`Legacy oxlint JSON config`});const hn=(e=x.cwd())=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return(yield*t.exists(n.join(e,`pnpm-workspace.yaml`)))?!0:(yield*L(e)).workspaces!==void 0}),q=[{path:`tsconfig.json`,type:`config`}],J=`adamantite/typescript`,gn={extends:J},_n=["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": "${J}"\` to each package's \`tsconfig.json\` or to a shared base config.`];function vn(e){return g.isString(e)?e===J?e:[e,J]:c.isArray(e)?e.includes(J)?e:[...e,J]:J}var Y=M({config:q[0].path,create:e=>n.gen(function*(){let t=yield*b.Path;yield*F(t.join(e,q[0].path),gn)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,q[0].path))}),files:q,kind:`workspace`,name:`tsconfig`,update:e=>n.gen(function*(){let t=(yield*b.Path).join(e,q[0].path),n=yield*N(t),r=yield*I(n,t);if(!g.isObject(r))return yield*new Te({path:t});let i={...yield*Ie(gn,r),extends:vn(`extends`in r?r.extends:void 0)};yield*F(t,i)})});const yn=`adamantite typecheck`;function bn(){return V.files[1].path}function xn(){return G.files[0].path}function Sn(e){let t={...e.scripts};return t.typecheck===yn?(delete t.typecheck,t.check??=R.check,{migrated:!0,packageJson:{...e,scripts:t}}):{migrated:!1,packageJson:e}}const Cn=[un,ln,mn,Ft({check:e=>n.gen(function*(){let{migrated:t}=Sn(yield*L(e.cwd));return t?{status:`needed`,summary:"Migrating `typecheck` to `check` so oxlint handles linting and type diagnostics together.",warnings:[]}:{status:`not-applicable`,warnings:[]}}),files:[`package.json`,V.config,bn(),Y.config,xn()],id:`legacy-typecheck-script`,migrate:e=>n.gen(function*(){let t=yield*K,r=[],i=Sn(yield*L(e.cwd));if(!i.migrated)return yield*n.die(Error(`check() guaranteed the legacy typecheck script exists`));yield*Be(e.cwd,i.packageJson);let a=yield*V.detect(e.cwd);a.active===null?yield*V.create(e.cwd):a.active.format===`ts`&&(yield*V.update(e.cwd)),(yield*hn(e.cwd))?r.push(..._n):yield*(yield*Y.detect(e.cwd))?Y.update(e.cwd):Y.create(e.cwd);let o=yield*G.detect(e.cwd),s=He(i.packageJson);if(o&&zt(s)){let n=yield*t.detectPackageManager(e.cwd);n&&Ve(n.name)?yield*G.update(e.cwd,{packageManager:n.name,scripts:s}):n?r.push(`\`${n.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow was not updated.`):r.push(`Could not detect a package manager, so the GitHub Actions workflow was not updated.`)}return{warnings:r}}),tags:[`update`],title:`Legacy typecheck script`,validate:e=>n.gen(function*(){if((yield*L(e.cwd)).scripts?.typecheck===yn)return yield*new k({migrationId:`legacy-typecheck-script`,reason:"The legacy `typecheck` script is still present in `package.json`."});if((yield*V.detect(e.cwd)).active?.format!==`ts`)return yield*new k({migrationId:`legacy-typecheck-script`,reason:`\`${V.config}\` is not the active oxlint config.`});if(!(yield*hn(e.cwd))&&!(yield*Y.detect(e.cwd)))return yield*new k({migrationId:`legacy-typecheck-script`,reason:`\`${Y.config}\` is missing after the migration.`})})}),on],wn=Object.fromEntries(Cn.map(e=>[e.id,e])),Tn=n.fn(`collectApplicableAssessments`)(function*(e,t,r){let i=r??(yield*L(t));return yield*n.forEach(e,e=>e.assess(t,i).pipe(n.map(t=>t.applicable?h.some({assessment:t,integration:e}):h.none())),{concurrency:`unbounded`}).pipe(n.map(e=>c.getSomes(e)))});function En(e,t,n){return Tn(e,t,n)}var X=class extends d.Service()(`Prompter`){static layerWithSpinner(e){return i.succeed(this)({cancel:e=>n.sync(()=>{T.cancel(e)}),confirm:e=>n.promise(()=>T.confirm(e)).pipe(n.filterOrFail(e=>!T.isCancel(e),()=>new Oe({}))),intro:e=>n.sync(()=>{T.intro(e)}),log:{error:e=>n.sync(()=>{T.log.error(e)}),info:e=>n.sync(()=>{T.log.info(e)}),success:e=>n.sync(()=>{T.log.success(e)}),warning:e=>n.sync(()=>{T.log.warning(e)})},multiselect:e=>n.promise(()=>T.multiselect(e)).pipe(n.filterOrFail(e=>!T.isCancel(e),()=>new Oe({}))),outro:e=>n.sync(()=>{T.outro(e)}),withSpinner:(t,i)=>n.acquireUseRelease(n.sync(()=>{let t=e();return t.start(i.start),t}),e=>t({message:t=>n.sync(()=>{e.message(t)})}),(e,t)=>n.sync(()=>{e.stop(r.match(t,{onFailure:()=>i.failure,onSuccess:e=>g.isFunction(i.success)?i.success(e):i.success}))}))})}static layer=this.layerWithSpinner(T.spinner)};const Dn=' .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 ',On=()=>n.gen(function*(){let e=yield*(yield*de.Terminal).columns,t=Dn.split(`
|
|
91
|
+
`).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*ue.info(Dn))}),kn=u.boolean(`fix`).pipe(u.withDescription(`Automatically fix safe package install/update issues`)),An=[z,H,V,U,W];var jn=l.make(`doctor`,{fix:kn}).pipe(l.withDescription(`Check Adamantite-managed integrations in the current project`),l.withHandler(({fix:e})=>n.gen(function*(){let t=x.cwd(),r=yield*X;yield*On(),yield*r.intro(`💠 adamantite doctor`);let i=yield*L(t);if(!i.devDependencies?.adamantite&&!i.dependencies?.adamantite)return yield*r.log.warning("`adamantite` is not installed in this project. Install it before running `adamantite doctor`."),yield*r.outro(`⚠️ Doctor found issues.`),yield*new D({command:`doctor`,exitCode:s.ExitCode(1)});let a=yield*En(An,t,i);for(let{assessment:e}of a)for(let t of e.warnings)yield*r.log.warning(t);if(a.length===0){yield*r.log.success(`No applicable integrations found.`),yield*r.outro(`✅ Doctor completed successfully!`);return}let o=a.flatMap(({assessment:e,integration:t})=>e.actions.map(e=>({action:e,integration:t})));if(o.length===0){yield*r.log.success(`No issues found.`),yield*r.outro(`✅ Doctor completed successfully!`);return}let c=new Set;e&&(yield*n.gen(function*(){let e=o.filter(({action:e})=>e.type===`install_package`||e.type===`update_package`);if(e.length>0){let n=yield*K,i=[];for(let{action:t}of e)(t.type===`install_package`||t.type===`update_package`)&&i.push(`${t.package}@${t.targetVersion}`);yield*n.addDevDependencies(i,t,{silent:!0});for(let t of e){let{action:e}=t;e.type===`install_package`&&(yield*r.log.success(`Fixed: installed \`${e.package}@${e.targetVersion}\`.`)),e.type===`update_package`&&(yield*r.log.success(`Fixed: updated \`${e.package}\` from \`${e.currentVersion}\` to \`${e.targetVersion}\`.`)),c.add(t)}}for(let e of o){let{action:n,integration:i}=e;n.type!==`create_config`||!(`create`in i)||(yield*i.create(t),yield*r.log.success(`Fixed: created \`${n.path}\`.`),c.add(e))}for(let e of o){let{action:n,integration:i}=e;n.type!==`update_config`||!(`update`in i)||(yield*i.update(t),yield*r.log.success(`Fixed: updated \`${n.path}\`.`),c.add(e))}for(let e of o){let{action:n}=e;if(n.type!==`run_migration`)continue;let i=wn[n.migrationId];if(!i)continue;let a=yield*i.check({cwd:t});for(let e of a.warnings)yield*r.log.warning(e);if(a.status!==`needed`){c.add(e);continue}let o=yield*r.withSpinner(()=>It(i,{cwd:t}),{failure:`Migration "${i.title}" failed, files restored.`,start:a.summary,success:`Fixed: ${n.description}`});for(let e of o.warnings)yield*r.log.warning(e);c.add(e)}}).pipe(n.tapError(()=>n.gen(function*(){yield*r.outro(`❌ Doctor failed`)}))));let l=o.filter(e=>!c.has(e));if(e&&l.length===0){yield*r.outro(`✅ Doctor completed successfully!`);return}for(let{action:t}of e?l:o)yield*r.log.warning(`Needs attention: ${t.description}`);yield*r.outro(`⚠️ Doctor found issues.`),yield*new D({command:`doctor`,exitCode:s.ExitCode(1)})})));const Mn=C.file(`files`,{mustExist:!0}).pipe(C.withDescription(`Specific files to fix (optional)`),C.variadic()),Nn=u.boolean(`suggested`).pipe(u.withDescription(`Apply suggested fixes`)),Pn=u.boolean(`dangerous`).pipe(u.withDescription(`Apply dangerous fixes`)),Fn=u.boolean(`all`).pipe(u.withDescription(`Apply all fixes, including suggested and dangerous fixes`));var In=l.make(`fix`,{all:Fn,dangerous:Pn,files:Mn,suggested:Nn}).pipe(l.withDescription(`Fix issues in code using oxlint`),l.withHandler(({all:e,dangerous:t,files:r,suggested:i})=>n.gen(function*(){let n=yield*j,a=yield*A,o=c.dedupe([`--fix`,...i||e?[`--fix-suggestions`]:[],...t||e?[`--fix-dangerously`]:[],...r]),l=yield*a.run({args:[...o,...n],command:V.name});l!==s.ExitCode(0)&&(yield*new D({command:V.name,exitCode:l}))})));const Ln=C.file(`files`,{mustExist:!0}).pipe(C.withDescription(`Specific files to format (optional)`),C.variadic()),Rn=u.boolean(`check`).pipe(u.withDescription(`Check if files are formatted without writing`));var zn=l.make(`format`,{check:Rn,files:Ln}).pipe(l.withDescription(`Format files using oxfmt`),l.withHandler(({check:e,files:t})=>n.gen(function*(){let n=yield*j,r=yield*A,i=[];e&&i.push(`--check`),i.push(...t,...n);let a=yield*r.run({args:i,command:H.name});a!==s.ExitCode(0)&&(yield*new D({command:H.name,exitCode:a}))})));const Z=[{path:`.vscode/settings.json`,type:`config`}],Bn={"[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};var Q=M({config:Z[0].path,create:e=>n.gen(function*(){let t=yield*b.Path,n=t.join(e,Z[0].path);yield*je(t.dirname(n)),yield*F(n,Bn)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,Z[0].path))}),extension:(e=[])=>n.gen(function*(){let t=[];(e.includes(`check`)||e.includes(`fix`)||e.includes(`format`))&&t.push(`oxc.oxc-vscode`),e.includes(`analyze`)&&t.push(`webpro.vscode-knip`);for(let e of t){let t=yield*(yield*A).run({args:[`--install-extension`,e],command:`code`}).pipe(n.mapError(t=>t._tag===`CliNotFound`&&t.command===`code`?new Ae({cause:t}):new ve({cause:t,extension:e})));if(t!==s.ExitCode(0))return yield*new ve({cause:t,extension:e})}}),files:Z,kind:`editor`,name:`vscode`,update:e=>n.gen(function*(){let t=(yield*b.Path).join(e,Z[0].path),n=yield*N(t),r=yield*I(n,t);if(!g.isObject(r))return yield*new Te({path:t});let i=yield*Ie(Bn,r);yield*F(t,i)})});const Vn=[{path:`.zed/settings.json`,type:`config`}],Hn={languages:{CSS:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}]},HTML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}]},JSON:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}]},JSONC:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}]},JavaScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}]},MDX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}]},Markdown:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}]},TSX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}]},TypeScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}]},YAML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}]}},lsp:{oxfmt:{initialization_options:{settings:{configPath:null,"fmt.experimental":!0,run:`onSave`,typeAware:!1,unusedDisableDirectives:!1}}},oxlint:{initialization_options:{settings:{configPath:null,fixKind:`safe_fix`,run:`onType`,typeAware:!0,unusedDisableDirectives:`deny`}}}}};function Un(e){let t=e.languages;if(!w.is(w.Record(w.String,w.Json))(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>e in Hn.languages&&w.is(w.Record(w.String,w.Json))(t)&&w.is(w.Array(w.Json))(t.formatter)?[e,Object.fromEntries([...Object.entries(t),[`formatter`,c.dedupe(t.formatter)]])]:[e,t]));return{...e,languages:n}}var $=M({config:Vn[0].path,create:e=>n.gen(function*(){let t=yield*b.Path,n=t.join(e,Vn[0].path);yield*je(t.dirname(n)),yield*F(n,Hn)}),detect:e=>n.gen(function*(){let t=yield*y.FileSystem,n=yield*b.Path;return yield*t.exists(n.join(e,Vn[0].path))}),files:Vn,kind:`editor`,name:`zed`,update:e=>n.gen(function*(){let t=(yield*b.Path).join(e,Vn[0].path),n=yield*N(t),r=yield*I(n,t);if(!g.isObject(r))return yield*new Te({path:t});let i=Un(yield*Ie(Hn,r));yield*F(t,i)})});const Wn=`<!-- ADAMANTITE:START -->`,Gn=`<!-- ADAMANTITE:END -->`;function Kn(e,t){let n=le(e,t),r=R[t];switch(t){case`analyze`:return`- Run \`${n}\` after changing dependencies, imports, or exports. Direct command: \`${r}\`.`;case`check`:return`- Run \`${n}\` to catch lint and type issues. Direct command: \`${r}\`.`;case`check:monorepo`:return`- Run \`${n}\` to check monorepo package consistency. Direct command: \`${r}\`.`;case`fix`:return`- Run \`${n}\` to apply safe lint fixes. Direct command: \`${r}\`.`;case`fix:monorepo`:return`- Run \`${n}\` to fix monorepo package consistency. Direct command: \`${r}\`.`;case`format`:return`- Run \`${n}\` after editing files. Direct command: \`${r}\`.`}}function qn({packageManager:e,scripts:t}){let n=[`format`,`check`,`fix`,`analyze`,`check:monorepo`,`fix:monorepo`].filter(e=>t.includes(e)).map(t=>Kn(e,t)),r=[`## Adamantite`,``,`This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.`,``,...n.length>0?[`- Prefer the package scripts Adamantite added for this workspace.`,...n]:[],"- Use `adamantite doctor` to inspect managed setup and `adamantite doctor --fix` for safe local fixes."].join(`
|
|
92
|
+
`);return[Wn,``,r,``,Gn,``].join(`
|
|
93
|
+
`)}const Jn=(e,t)=>n.gen(function*(){let n=(yield*b.Path).join(e,`AGENTS.md`),r=m(yield*Me(n),h.getOrElse(()=>``)),i=m(r,_.indexOf(Wn)),a=m(r,_.indexOf(Gn)),o=m(h.all({end:a,start:i}),h.filter(({end:e,start:t})=>t<e)),s=qn(t);if(h.isSome(o)){let{end:e,start:t}=o.value,i=e+23,a=`${r.slice(0,t)}${s.trimEnd()}${r.slice(i)}`;return yield*P(n,a.endsWith(`
|
|
94
|
+
`)?a:`${a}\n`),`updated`}if(h.isSome(i)||h.isSome(a))return`malformed`;let c=r.length===0||r.endsWith(`
|
|
95
|
+
|
|
96
|
+
`)?``:r.endsWith(`
|
|
110
97
|
`)?`
|
|
111
98
|
`:`
|
|
112
99
|
|
|
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)}});
|
|
100
|
+
`;return yield*P(n,`${r}${c}${s}`),`updated`}),Yn=(e,t)=>n.gen(function*(){let r=yield*K;yield*(yield*X).withSpinner(()=>n.gen(function*(){let n=yield*hn(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:n})}),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function Xn(e,t,r){return n.gen(function*(){let i=yield*X,a=yield*i.withSpinner(a=>n.gen(function*(){let n=yield*t.detect(e);for(let e of n.warnings)yield*i.log.warning(e);return n.active===null?(yield*a.message(`\`${t.config}\` not found, creating...`),yield*r,{created:!0,legacyConfig:null}):n.active.format===`ts`?(yield*a.message(`Found \`${t.config}\`, keeping existing config.`),{created:!1,legacyConfig:null}):(yield*a.message(`Found \`${n.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:n.active.file})}),{failure:`Failed to set up ${t.name} config.`,start:`Setting up ${t.name} config...`,success:e=>e.created?`${t.name} config created successfully.`:`${t.name} config is ready.`});a.legacyConfig&&(yield*i.log.info(`Legacy \`${a.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor --fix\` to migrate it to the latest ${t.name} config.`))})}const Zn=e=>`\`${e.script}\` is currently \`${e.command}\`; Adamantite would replace it with \`${R[e.script]}\`.`,Qn=(e,t,r)=>n.gen(function*(){let i=yield*X,a=yield*L(e),o=r.overwriteScripts?[]:Ue(a,t),s=new Set(o.map(e=>e.script)),c=t.filter(e=>!s.has(e));yield*i.withSpinner(()=>n.gen(function*(){if(c.length!==0){a.scripts??={};for(let e of c)a.scripts[e]=R[e];yield*Be(e,a)}}),{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`":c.length===0?"Kept your existing `package.json` scripts.":"Scripts added to your `package.json`; conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Re-run `adamantite init` and confirm overwriting to replace it.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${R[e.script]}\`. ${l}`);return o.length>0&&(yield*i.log.info("Adamantite commands forward extra arguments after `--`, so custom flags can be kept, e.g. `adamantite monorepo -- --ignore-dependency tailwindcss`.")),c}),$n=(e,t)=>n.gen(function*(){let r=yield*X;if(t){yield*m(_n,n.forEach(e=>r.log.info(e)));return}yield*r.withSpinner(t=>n.gen(function*(){return(yield*Y.detect(e))?(yield*t.message(`\`${Y.config}\` found, updating...`),yield*Y.update(e),!1):(yield*t.message(`\`${Y.config}\` not found, creating...`),yield*Y.create(e),!0)}),{failure:`Failed to set up TypeScript config.`,start:`Setting up TypeScript config...`,success:e=>e?`\`${Y.config}\` created successfully`:`\`${Y.config}\` updated successfully`})}),er=(e,t)=>n.gen(function*(){let r=yield*X;t.includes(`vscode`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*Q.detect(e);return yield*t.message(`\`${Q.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?Q.update(e):Q.create(e),!n}),{failure:`Failed to set up VS Code config.`,start:`Checking for \`${Q.config}\`...`,success:e=>`\`${Q.config}\` ${e?`created`:`updated`} with Adamantite preset.`})),t.includes(`zed`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*$.detect(e);return yield*t.message(`\`${$.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?$.update(e):$.create(e),!n}),{failure:`Failed to set up Zed config.`,start:`Checking for \`${$.config}\`...`,success:e=>`\`${$.config}\` ${e?`created`:`updated`} with Adamantite preset.`}))}),tr=(e,t)=>n.gen(function*(){let r=yield*X,i=e.includes(`zed`),a=e.includes(`vscode`);yield*r.withSpinner(e=>n.gen(function*(){return a&&(yield*e.message(`Installing VS Code extension...`),yield*Q.extension(t)),!0}),{start:`Installing editor extensions...`,success:i&&!a?`Zed extensions require manual install.`:`Editor extensions installed successfully.`}).pipe(n.catchTag(`FailedToInstallExtension`,e=>n.gen(function*(){return yield*r.log.warning(`⚠️ ${e.message}`),yield*r.log.warning(`Please install it manually after setup completes.`),!1})),n.catchTag(`VscodeCliNotFound`,()=>n.gen(function*(){return yield*r.log.error(`VSCode CLI ('code' command) not found.`),yield*r.log.info(`To install it:`),yield*r.log.info(` 1. Open VS Code`),yield*r.log.info(` 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)`),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),i&&(yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc"))}),nr=(e,t,r)=>n.gen(function*(){let i=yield*X,a=G.files[0].path;yield*i.withSpinner(i=>n.gen(function*(){let n=yield*G.detect(e);return yield*i.message(n?`\`${a}\` found, updating...`:`Creating \`${a}\`...`),yield*n?G.update(e,{packageManager:t,scripts:r}):G.create(e,{packageManager:t,scripts:r}),!n}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e?`created`:`updated`} successfully.`})}).pipe(n.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>n.gen(function*(){let t=yield*X;yield*t.log.warning(`Could not set up the GitHub Actions workflow. ${e.message}`),yield*t.log.warning("Fix the reported problem and run `adamantite init` again, or create the workflow manually.")}))),rr=(e,t,r)=>n.gen(function*(){let i=yield*X,a=yield*i.withSpinner(()=>Jn(e,{packageManager:t,scripts:r}),{failure:`Failed to update AGENTS.md.`,start:`Updating AGENTS.md...`,success:`AGENTS.md check complete.`}).pipe(n.catchTag([`FailedToReadFile`,`FailedToWriteFile`],e=>n.gen(function*(){return yield*i.log.warning(`Could not update AGENTS.md. ${e.message} Adamantite will continue initialization.`),`failed`})));a!==`failed`&&a===`malformed`&&(yield*i.log.warning(`Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.`))}),ir=[`check`,`fix`,`format`,`check:monorepo`,`fix:monorepo`,`analyze`],ar=[`react`,`nextjs`,`vue`,`jest`,`vitest`,`node`,`antislop`],or=[`vscode`,`zed`],sr=n.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:c.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:c.dedupe(e.presets),scripts:c.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new O({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes(`check`)||n.scripts.includes(`fix`);return(n.scripts.includes(`check:monorepo`)||n.scripts.includes(`fix:monorepo`))&&!t.isMonorepo?yield*new O({reason:`Monorepo scripts can only be selected in a detected monorepo.`}):n.presets.length>0&&!r?yield*new O({reason:"`--preset` requires the `check` or `fix` script."}):n.typescript&&!r?yield*new O({reason:"`--typescript` requires the `check` or `fix` script."}):n.installExtensions&&n.editors.length===0?yield*new O({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!zt(n.scripts)?yield*new O({reason:"`--github-actions` requires a CI-compatible script."}):n.githubActions&&t.nonInteractive&&!Ve(t.packageManager)?yield*new O({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`}):n}),cr=u.boolean(`non-interactive`).pipe(u.withDescription(`Configure without prompts; requires at least one --script`)),lr=u.choice(`script`,ir).pipe(u.atMost(ir.length),u.withDescription(`Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo`)),ur=u.choice(`preset`,ar).pipe(u.atMost(ar.length),u.withDescription(`Oxlint preset to configure; repeatable and requires --script check or fix`)),dr=u.choice(`editor`,or).pipe(u.atMost(or.length),u.withDescription(`Editor to configure; may be specified multiple times`)),fr=u.boolean(`typescript`).pipe(u.withDescription(`Configure the TypeScript preset; requires --script check or fix`)),pr=u.boolean(`install-extensions`).pipe(u.withDescription(`Install recommended extensions; requires at least one --editor`)),mr=u.boolean(`github-actions`).pipe(u.withDescription(`Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn`)),hr=u.boolean(`agents`).pipe(u.withDescription(`Add Adamantite guidance to AGENTS.md`)),gr=u.boolean(`overwrite-scripts`).pipe(u.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),_r=n.fn(`collectInteractiveInitOptions`)(function*(e,t){let n=yield*X,r=yield*n.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:!t,hint:t?void 0:`available for monorepo projects`,label:`check:monorepo - check for monorepo-specific issues using Sherif`,value:`check:monorepo`},{disabled:!t,hint:t?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`}]}),i=Ue(yield*L(e),r),a=!1;if(i.length>0){for(let e of i)yield*n.log.warning(Zn(e));a=yield*n.confirm({initialValue:!1,message:i.length===1?`Overwrite this existing script with Adamantite's command?`:`Overwrite these existing scripts with Adamantite's commands?`})}let o=r.includes(`check`)||r.includes(`fix`),s=[];o&&(s=yield*n.multiselect({message:`Which presets do you want to install? (core is always included)`,options:[{hint:`React, JSX accessibility, and performance rules`,label:`React`,value:`react`},{hint:`Next.js rules`,label:`Next.js`,value:`nextjs`},{hint:`Vue rules`,label:`Vue`,value:`vue`},{hint:`Jest rules`,label:`Jest`,value:`jest`},{hint:`Vitest rules`,label:`Vitest`,value:`vitest`},{hint:`Node.js rules`,label:`Node`,value:`node`},{hint:`anti-slop rules that reject low-evidence, low-signal patterns`,label:`antislop`,value:`antislop`}],required:!1}));let c=o?yield*n.confirm({initialValue:!0,message:t?"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,l=yield*n.multiselect({message:`Which editors do you want to configure? (optional)`,options:[{label:`VSCode / Cursor / Windsurf`,value:`vscode`},{label:`Zed`,value:`zed`}],required:!1}),u=l.length>0?yield*n.confirm({initialValue:!0,message:`Do you want to install the recommended editor extensions?`}):!1,d=zt(r)?yield*n.confirm({message:`Do you want to add a GitHub Actions workflow to run checks in CI?`}):!1;return{agents:yield*n.confirm({initialValue:!0,message:`Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?`}),editors:l,githubActions:d,installExtensions:u,overwriteScripts:a,presets:s,scripts:r,typescript:c}});var vr=l.make(`init`,{agents:hr,editors:dr,githubActions:mr,installExtensions:pr,nonInteractive:cr,overwriteScripts:gr,presets:ur,scripts:lr,typescript:fr}).pipe(l.withDescription(`Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled`),l.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`}]),l.withHandler(e=>n.gen(function*(){let t=x.cwd(),n=yield*X;yield*On(),yield*n.intro(`💠 adamantite init`);let r=yield*(yield*K).detectPackageManager(t);if(!r)return yield*new De({});if(r.warnings?.length)for(let e of r.warnings)yield*n.log.warning(e);yield*n.log.info(`Detected package manager: ${r.name}`);let i=yield*hn(t);if(i&&(yield*n.log.info(`We've detected a monorepo setup in your project.`)),!e.nonInteractive&&c.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],g.isTruthy))return yield*new O({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*_r(t,i),o=yield*sr(a,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:r.name}),s=o.scripts,l=o.presets,u=o.editors,d=o.typescript,ee=o.installExtensions,f=o.githubActions,p=o.agents,m=s.includes(`check`)||s.includes(`fix`),h=s.includes(`format`),_=s.includes(`check:monorepo`)||s.includes(`fix:monorepo`),te=s.includes(`analyze`),v=[`adamantite`];m&&v.push(`${V.name}@${V.version}`,`${W.name}@${W.version}`),h&&v.push(`${H.name}@${H.version}`),_&&v.push(`${U.name}@${U.version}`),te&&v.push(`${z.name}@${z.version}`),yield*Yn(t,v),h&&(yield*Xn(t,H,H.create(t))),m&&(yield*Xn(t,V,V.create(t,l))),te&&(yield*Xn(t,z,z.create(t)));let y=yield*Qn(t,s,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(p&&(yield*rr(t,r.name,y)),d&&(yield*$n(t,i)),yield*er(t,u),ee&&(yield*tr(u,s)),f){let e=r.name;Ve(e)?yield*nr(t,e,s):yield*n.log.warning(`Skipping GitHub Actions setup: \`${e}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success(`Your project is now configured`),yield*n.outro(`💠 Adamantite initialized successfully!`)}).pipe(n.catchTags({OperationCancelled:()=>n.gen(function*(){yield*(yield*X).cancel(`You've cancelled the initialization process.`)})}))));const yr=u.boolean(`fix`).pipe(u.withDescription(`Automatically fix issues`));var br=l.make(`monorepo`,{fix:yr}).pipe(l.withDescription(`Find and fix monorepo-specific issues using Sherif`),l.withHandler(({fix:e})=>n.gen(function*(){let t=yield*j,n=yield*A,r=e?[`--fix`,...t]:[...t],i=yield*n.run({args:r,command:U.name,stdin:`inherit`});i!==s.ExitCode(0)&&(yield*new D({command:U.name,exitCode:i}))}))),xr=l.make(`typecheck`).pipe(l.withDescription("Deprecated alias for `check`"),l.withHandler(()=>n.gen(function*(){let e=yield*j,t=yield*X,n=yield*A;yield*t.log.warning("Deprecated. Use `adamantite check` for typechecking.");let r=yield*n.run({args:[...e],command:V.name});r!==s.ExitCode(0)&&(yield*new D({command:V.name,exitCode:r}))})));const Sr=[V,W,H,U,z],Cr=[V,W,H,U,z];function wr(e,t){return c.filterMap(Cr,n=>{if(t.has(n.name))return S.failVoid;let r=e.devDependencies?.[n.name]??e.dependencies?.[n.name];return r&&ze(r)!==n.version?S.succeed({currentVersion:r,name:n.name,targetVersion:n.version}):S.failVoid})}var Tr=l.make(`update`).pipe(l.withDescription(`Run applicable Adamantite migrations and update managed dependencies`),l.withHandler(()=>n.gen(function*(){let e=x.cwd(),t=yield*X,r=yield*K,i={cwd:e};yield*On(),yield*t.intro(`💠 adamantite update`);let a=t=>En(Sr,e,t),o=yield*a(),s=new Set,l=e=>n.gen(function*(){for(let n of e)s.has(n)||(s.add(n),yield*t.log.warning(n))});yield*l(o.flatMap(({assessment:e})=>e.warnings));let u=[];for(let e of Cn.filter(e=>e.tags.includes(`update`))){let n=yield*e.check(i);yield*l(n.warnings),n.status===`needed`&&(yield*l((yield*t.withSpinner(()=>It(e,i),{failure:`Migration "${e.title}" failed, files restored.`,start:n.summary,success:`Migration "${e.title}" completed successfully.`})).warnings),u.push(e.id))}u.length>0&&(yield*t.log.success(`Migrations ran successfully.`));let d=yield*L(e),ee=(yield*a(d)).flatMap(({assessment:e})=>e.actions),f=ee.filter(e=>e.type===`create_config`||e.type===`update_config`||e.type===`manual_fix`),p=c.filterMap(ee,e=>{switch(e.type){case`install_package`:return S.succeed({currentVersion:`not installed`,name:e.package,targetVersion:e.targetVersion});case`update_package`:return S.succeed({currentVersion:e.currentVersion,name:e.package,targetVersion:e.targetVersion});default:return S.failVoid}}),m=new Set(p.map(e=>e.name)),h=[...p,...wr(d,m)];if(h.length>0){yield*t.log.info(`The following dependencies will be updated:`);for(let e of h)yield*t.log.info(` ${e.name}: ${e.currentVersion} → ${e.targetVersion}`);yield*t.withSpinner(()=>r.addDevDependencies(h.map(e=>`${e.name}@${e.targetVersion}`),e,{silent:!0}),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated successfully`}),yield*t.log.success(`Dependencies updated successfully.`)}if(f.length>0){yield*t.log.warning("Some configuration follow-up belongs to `adamantite doctor --fix`.");for(let e of f)yield*t.log.warning(`Doctor follow-up: ${e.description}`)}return u.length===0&&h.length===0&&f.length===0?(yield*t.log.success(`No changes needed.`),`no-changes`):`success`}).pipe(n.tapError(()=>n.gen(function*(){yield*(yield*X).outro(`❌ Update failed`)})),n.tap(e=>n.gen(function*(){let t=yield*X;switch(e){case`no-changes`:yield*t.outro(`✅ Adamantite is already up to date.`);break;case`success`:yield*t.outro(`✅ Update completed successfully!`)}})))));const Er=[rt,At,In,zn,br,xr],Dr=[rt,At,jn,In,zn,vr,br,xr,Tr],Or=new Set(Dr.map(e=>e.name)),kr=new Set(Er.map(e=>e.name)),Ar=l.make(`adamantite`).pipe(l.withDescription(`Opinionated preset package for modern TypeScript applications`),l.withSubcommands(Dr)),jr=n.fn(`runCli`)(function*(e,t){let[r,i]=c.splitWhere(e,e=>e===`--`),a=c.drop(i,1),o=r.find(e=>Or.has(e));if(a.length>0&&o!==void 0&&!kr.has(o))return yield*new ke({command:o});yield*l.runWith(Ar,{version:t})(r).pipe(n.provideService(j,a))}),Mr=n.gen(function*(){let e=yield*(yield*o.Stdio).args;yield*jr(e,`0.36.0`)}).pipe(n.as(0),n.catchTag(`CommandFailed`,e=>n.succeed(e.exitCode)),n.catch(e=>n.service(X).pipe(n.flatMap(t=>t.log.error(e.message)),n.as(s.ExitCode(1)))),n.provide(i.mergeAll(t.layer,Yt.layer.pipe(i.provide(t.layer)),X.layer,A.layer,K.layer)));e.runMain(Mr,{teardown:(e,t)=>{if(r.isSuccess(e)){t(Number(e.value));return}a.defaultTeardown(e,t)}});export{};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { KnipConfiguration } from "knip";
|
|
2
|
+
//#region presets/analyze.d.ts
|
|
3
|
+
declare const config: KnipConfiguration;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { config as default };
|