adamantite 0.46.0 โ†’ 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +82 -8
  2. package/dist/index.js +56 -66
  3. package/dist/presets/lint/core.js +1 -1
  4. package/dist/presets/lint/vendor/antislop/plugin.mjs +19 -2
  5. package/dist/presets/typescript/resets/array-includes.d.ts +15 -0
  6. package/dist/presets/typescript/resets/array-index-of.d.ts +23 -0
  7. package/dist/presets/typescript/resets/eval.d.ts +1 -0
  8. package/dist/presets/typescript/resets/fetch.d.ts +3 -0
  9. package/dist/presets/typescript/resets/filter-boolean.d.ts +24 -0
  10. package/dist/presets/typescript/resets/helpers.d.ts +15 -0
  11. package/dist/presets/typescript/resets/index.d.ts +20 -0
  12. package/dist/presets/typescript/resets/is-array.d.ts +3 -0
  13. package/dist/presets/typescript/resets/json-parse.d.ts +14 -0
  14. package/dist/presets/typescript/resets/license.md +12 -0
  15. package/dist/presets/typescript/resets/map-constructor.d.ts +3 -0
  16. package/dist/presets/typescript/resets/map-groupby.d.ts +3 -0
  17. package/dist/presets/typescript/resets/map-has.d.ts +9 -0
  18. package/dist/presets/typescript/resets/object-assign.d.ts +8 -0
  19. package/dist/presets/typescript/resets/object-get-prototype-of.d.ts +3 -0
  20. package/dist/presets/typescript/resets/object-groupby.d.ts +6 -0
  21. package/dist/presets/typescript/resets/object-values.d.ts +8 -0
  22. package/dist/presets/typescript/resets/reflect.d.ts +12 -0
  23. package/dist/presets/typescript/resets/set-has.d.ts +9 -0
  24. package/dist/presets/typescript/resets/storage.d.ts +3 -0
  25. package/dist/presets/typescript.json +13 -0
  26. package/package.json +3 -2
  27. package/skills/adamantite/SKILL.md +0 -2
  28. package/skills/adamantite/references/lint-rules.md +0 -6
  29. package/skills/adamantite/references/setup.md +8 -2
package/dist/index.js CHANGED
@@ -1,28 +1,20 @@
1
- import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,Mt as v,N as ee,O as y,Ot as te,P as b,Q as ne,R as x,S as re,St as ie,T as ae,Tt as oe,U as S,V as C,W as se,X as ce,Y as w,Z as le,_ as ue,_t as de,a as fe,at as pe,bt as me,c as he,ct as ge,d as _e,dt as ve,et as ye,f as be,ft as xe,g as Se,gt as T,h as Ce,ht as we,i as Te,it as Ee,j as De,jt as Oe,k as ke,kt as Ae,l as je,lt as Me,m as Ne,mt as Pe,n as Fe,nt as Ie,ot as Le,p as Re,pt as ze,q as Be,r as Ve,rt as He,s as Ue,st as We,t as Ge,tt as Ke,u as qe,ut as Je,vt as Ye,w as Xe,wt as Ze,x as Qe,xt as $e,y as et,yt as tt,z as nt}from"./runtime-CVZPDpfE.js";import*as rt from"@effect/platform-node/NodeRuntime";import*as E from"effect/Effect";import*as it from"effect/Exit";import*as D from"effect/process/ChildProcessSpawner";import*as at from"effect/Runtime";import*as ot from"effect/Stdio";import*as st from"@effect/platform-node/NodeServices";import*as O from"effect/Array";import*as k from"effect/cli/Command";import*as A from"effect/Layer";import j from"node:process";import*as M from"effect/cli/Flag";import*as N from"effect/Option";import*as ct from"effect/Context";import*as P from"effect/Path";import*as F from"effect/Predicate";import{styleText as lt}from"node:util";import*as ut from"effect/Console";import*as dt from"effect/process/ChildProcess";import*as ft from"effect/Result";import*as I from"effect/Data";import{pipe as L}from"effect/Function";import*as pt from"effect/String";import*as R from"effect/FileSystem";import*as mt from"effect/Equal";import*as z from"effect/Schema";import*as ht from"effect/encoding/Yaml";import*as gt from"effect/SchemaTransformation";import*as _t from"effect/Record";import*as vt from"effect/RegExp";import{Visitor as yt,parseSync as bt}from"oxc-parser";import*as B from"effect/Order";import*as xt from"effect/Config";import*as V from"effect/cli/Argument";import{addDevDependency as St,detectPackageManager as Ct,runScriptCommand as wt}from"nypm";import*as H from"@clack/prompts";import*as Tt from"effect/Cause";import{posix as U,win32 as Et}from"node:path";import*as Dt from"effect/Stream";import*as Ot from"effect/Brand";import*as kt from"effect/Terminal";const At=ct.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]}),jt=(e,t)=>ut.log(`${lt(`bold`,e)} ${lt(`dim`,`ยท adamantite (${t})`)}`),Mt=()=>[j.env.NODE_OPTIONS,`--disable-warning=MODULE_TYPELESS_PACKAGE_JSON`].filter(Boolean).join(` `),Nt=E.fn(`CommandRunner.exitCode`)(function*(e){let{command:t}=e;return yield*E.scoped(E.gen(function*(){return yield*(yield*dt.make(t,e.args,{cwd:e.cwd,detached:e.stdin!==`inherit`&&void 0,env:{...e.env,NODE_OPTIONS:Mt()},extendEnv:!0,stderr:e.stderr??`inherit`,stdin:e.stdin??`ignore`,stdout:e.stdout??`inherit`})).exitCode})).pipe(E.catchReason(`PlatformError`,`NotFound`,()=>E.fail(new Ke({command:t}))))});var Pt=class e extends ct.Service()(`CommandRunner`){static make(e){let t=E.fn(`CommandRunner.run`)(function*(t){t.title!==void 0&&(yield*jt(t.title,t.name??t.command));let n=yield*e(t);if(n!==D.ExitCode(0))return yield*new Ie({command:t.command,exitCode:n})}),n=e=>e.map((e,n)=>n===0?t(e):E.andThen(ut.log(``),t(e)));return{exitCode:e,run:t,runAll:E.fn(`CommandRunner.runAll`)(function*(e){let t=yield*E.all(n(e),{concurrency:1,mode:`result`});yield*E.fromResult(ft.all(t))}),runUntilFailure:E.fn(`CommandRunner.runUntilFailure`)(function*(e){yield*E.all(n(e),{concurrency:1,discard:!0})})}}static layer=A.effect(this)(E.gen(function*(){let t=yield*D.ChildProcessSpawner;return e.make(e=>Nt(e).pipe(E.provideService(D.ChildProcessSpawner,t)))}))};function W(e){return e}var Ft=class extends I.TaggedClass(`Missing`){},It=class extends I.TaggedClass(`Current`){},Lt=class extends I.TaggedClass(`Legacy`){};function Rt(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function zt(e,t){return O.findFirst(e.legacyConfigs,e=>Rt(e)===t)}function Bt(e){let t=zt(e,`json`),n=zt(e,`jsonc`);return L(N.zipWith(t,n,e=>`${e}(c)`),N.orElse(()=>n),N.orElse(()=>t),N.getOrElse(()=>``))}function Vt(e,t,n,r){return n instanceof Ft||r.length===0?[]:n instanceof It?[`Found both \`${t.config}\` and \`${Bt(t)}\`. Adamantite will use \`${t.config}\`.`]:L(N.zipWith(zt(t,`json`),zt(t,`jsonc`),(t,n)=>`Found both \`${t}\` and \`${n}\`. Multiple legacy ${e} configs exist. Doctor uses \`${n}\` when checking the setup.`),N.toArray)}const Ht=E.fn(`detectToolingConfig`)(function*(e,t,n){let r=yield*R.FileSystem,i=yield*P.Path,a=[n.config,...n.legacyConfigs].map(t=>({file:t,format:Rt(t),path:i.join(e,t)})),o=yield*E.forEach(a,e=>r.exists(e.path),{concurrency:`unbounded`}),s=a.filter((e,t)=>o[t]),c=({file:e,path:t})=>({file:e,path:t}),l=L(O.findFirst(s,e=>e.format===`ts`),N.orElse(()=>O.findFirst(s,e=>e.format===`jsonc`)),N.orElse(()=>O.findFirst(s,e=>e.format===`json`))),u=N.match(l,{onNone:()=>new Ft,onSome:e=>e.format===`ts`?new It({file:c(e)}):new Lt({file:c(e)})}),d=s.flatMap(e=>e.format!==`ts`&&!N.exists(l,t=>t===e)?[c(e)]:[]);return{active:u,legacy:d,warnings:Vt(t,n,u,d)}}),Ut={findings:[],packageActions:[],warnings:[]};function Wt({packageJson:e,workspace:{catalogs:t}},n,r,i){let a=e.devDependencies?.[n.name]??e.dependencies?.[n.name];if(!a)return{findings:[{currentState:`The required package \`${n.name}\` is not installed.`,goal:[`Run \`adamantite update\` so \`${n.name}@${n.version}\` is installed.`],id:`missing-${n.name}`,integration:i,title:`Missing ${n.name}`}],packageActions:[{description:`Install \`${n.name}@${n.version}\` for ${r}.`,package:n.name,targetVersion:n.version,type:`install_package`}],warnings:[]};function o(e){return{findings:[],packageActions:[],warnings:[`\`${n.name}\` is declared as \`${e}\`, so Adamantite cannot check it against the required version \`${n.version}\`.`]}}function s(e,t){let r=e==="default"?"the `catalog`":`the \`${e}\` catalog`;return{findings:[{currentState:`${r} of \`pnpm-workspace.yaml\` sets \`${n.name}\` to \`${t}\`, but Adamantite requires \`${n.version}\`.`,goal:[`Set \`${n.name}\` to \`${n.version}\` in ${r} of \`pnpm-workspace.yaml\`, then install the dependencies.`],id:`outdated-${n.name}`,integration:i,notes:["Keep the `catalog:` specifier in `package.json`. `adamantite update` does not change catalogs."],title:`Outdated ${n.name}`}],packageActions:[],warnings:[]}}return ee(b(a),{Catalog:({catalog:e})=>{let r=t[e]?.[n.name];return r===void 0?o(a):ee(b(r),{Catalog:()=>o(a),Unreadable:()=>o(a),Version:({version:t})=>t===n.version?Ut:s(e,r)})},Unreadable:()=>o(a),Version:({version:e})=>e===n.version?Ut:{findings:[{currentState:`The installed \`${n.name}\` version is \`${a}\`, but Adamantite requires \`${n.version}\`.`,goal:[`Run \`adamantite update\` so \`${n.name}@${n.version}\` is installed.`],id:`outdated-${n.name}`,integration:i,title:`Outdated ${n.name}`}],packageActions:[{currentVersion:a,description:`Update \`${n.name}\` from \`${a}\` to \`${n.version}\`.`,package:n.name,targetVersion:n.version,type:`update_package`}],warnings:[]}})}function Gt(e,t){if(e.active instanceof Ft)return[{currentState:`The managed \`${t.configFile}\` file is missing.`,goal:[`Create \`${t.configFile}\` with the reference content.`,`Do not create a legacy JSON or JSONC ${t.toolName} config.`],id:`missing-${t.toolName}-config`,integration:t.toolName,reference:{content:t.configContent,language:`ts`},title:`Missing ${t.toolName} configuration`}];if(e.active instanceof Lt)return[{currentState:`Legacy \`${e.active.file.file}\` is the active ${t.toolName} configuration.`,goal:[`Move the project settings into \`${t.configFile}\` using the reference content as the base.`,`Delete every legacy ${t.toolName} JSON or JSONC config after its settings are preserved.`],id:`legacy-${t.toolName}-config`,integration:t.toolName,notes:[`Preserve project-specific settings. Do not replace them with the reference defaults.`],reference:{content:t.configContent,language:`ts`},title:`Legacy ${t.toolName} configuration`}];let n=[];return e.legacy.length>0&&n.push({currentState:`Legacy ${t.toolName} config files remain next to \`${t.configFile}\`: ${e.legacy.map(({file:e})=>`\`${e}\``).join(`, `)}.`,goal:[`Delete the legacy files after you confirm that \`${t.configFile}\` preserves their project-specific settings.`],id:`shadowed-legacy-${t.toolName}-config`,integration:t.toolName,title:`Legacy ${t.toolName} files remain`}),t.inspection?.kind===`invalid`&&n.push({currentState:`\`${t.configFile}\` does not meet Adamantite's required shape. ${t.inspection.reason}`,goal:[t.inspection.goal],id:`invalid-${t.toolName}-config`,integration:t.toolName,notes:[`Treat the reference as a known-good example, not an exact replacement.`],reference:{content:t.configContent,language:`ts`},title:`Invalid ${t.toolName} configuration`}),n}function Kt(e,n){let r=t(e);return n.some(e=>r.includes(e))}function qt(e){return W({assess:t=>E.sync(()=>{let{packageJson:n}=t,r=Kt(n,e.scripts)&&(!e.monorepoOnly||t.workspace.isMonorepo)&&(e.isRequired===void 0||e.isRequired(t)),i=e.legacyFindings?.(n)??[];if(!r)return i.length>0?{applicable:!0,findings:[...i],packageActions:[],warnings:[]}:{applicable:!1};let a=Wt(t,e,e.purpose,e.name);return{applicable:!0,findings:[...a.findings,...i],packageActions:a.packageActions,warnings:a.warnings}}),kind:`tooling`,name:e.name,version:e.version})}const Jt=E.fn(`readToolingFacts`)(function*(e){let t=yield*P.Path,[n,r]=yield*E.all([Qe(e),C(t.join(e,`oxlint.config.ts`))],{concurrency:`unbounded`});return{isMonorepo:n,lintConfig:r}});function Yt(e){let t=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],n=t=>Ht(t,e.name,e.configFiles);return W({assess:t=>E.gen(function*(){let{cwd:i,lintConfig:a,packageJson:o,workspace:{isMonorepo:s}}=t;if(!Kt(o,e.scripts))return{applicable:!1};let c=yield*n(i),l=e.workspace({isMonorepo:s,lintConfig:a}),u=Wt(t,e,e.purpose,e.name),d=e.configContent(l),f=c.active instanceof It?e.inspectConfig(yield*r(c.active.file.path),l):void 0;return{applicable:!0,findings:[...u.findings,...Gt(c,{configContent:d,configFile:e.configFiles.config,inspection:f,toolName:e.name})],packageActions:u.packageActions,warnings:[...u.warnings,...c.warnings]}}),config:e.configFiles.config,create:t=>E.gen(function*(){let n=yield*P.Path;yield*S(n.join(t,e.configFiles.config),e.configContent(e.workspace(yield*Jt(t))))}),detect:n,files:t,kind:`tooling`,name:e.name,version:e.version})}function G(e){return`adamantite${e.slice(1)}`}const Xt=G(`./rules`),K=`.adamantite/lint`,Zt=/* @__PURE__ */ new Set([`.js`,`.mjs`,`.mts`,`.ts`]);function Qt(e){let t=/\.[^.]+$/.exec(e)?.[0]??``;return Zt.has(t)&&!e.startsWith(`_`)&&!/\.(?:d\.m?ts|test\.[^.]+)$/.test(e)}function $t(e){return!e.startsWith(`_`)&&/\.test\.(?:js|mjs|mts|ts)$/.test(e)}var en=class extends I.TaggedClass(`Dynamic`){},tn=class extends I.TaggedClass(`Literal`){};const nn=new en;function rn(e,t){return bt(e,t,{preserveParens:!1,sourceType:`module`})}function an(e){return e.body.flatMap(e=>e.type===`ImportDeclaration`&&e.source.value===Xt?e.specifiers:[]).filter(e=>e.type===`ImportDefaultSpecifier`).map(e=>e.local.name)}function on(e,t){let n=rn(e,t);return n.errors.length>0?!1:n.program.body.some(e=>e.type===`ImportDeclaration`?e.source.value===`adamantite/lint/custom`||e.source.value===Xt&&e.specifiers.some(e=>e.type===`ImportSpecifier`&&(e.imported.type===`Identifier`?e.imported.name:e.imported.value)!==`CustomRulesOptions`):e.type===`ExportNamedDeclaration`&&e.source!==null?e.source.value===`adamantite/lint/custom`||e.source.value===Xt&&e.specifiers.some(e=>{let t=e.local.type===`Identifier`?e.local.name:e.local.value;return t!=="default"&&t!==`CustomRulesOptions`}):e.type===`ExportAllDeclaration`&&e.source.value===`adamantite/lint/custom`)}function sn(e){return e.type===`Literal`&&F.isString(e.value)?e.value:e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0]?.value.cooked??null:null}function cn(e){return e.type===`Literal`&&F.isString(e.value)?e.value:null}function ln(e,t,n){let r=L(e,O.findLast(e=>(e.key.type===`Identifier`?e.key.name:cn(e.key))===t));return N.fromNullOr(N.match(r,{onNone:()=>n,onSome:({value:e})=>sn(e)}))}function un(e){let t=e.filter(e=>e.type!==`SpreadElement`&&!e.computed);return t.length<e.length?nn:N.match(ln(t,`dir`,K),{onNone:()=>nn,onSome:e=>new tn({dir:e,name:ln(t,`name`,`project`)})})}function dn(e,t){let n=rn(e,t),r=an(n.program);if(n.errors.length>0||r.length===0)return[];let i=[];return new yt({CallExpression(e){if(e.callee.type!==`Identifier`||!r.includes(e.callee.name))return;let[t]=e.arguments;t===void 0?i.push(un([])):t.type===`ObjectExpression`?i.push(un(t.properties)):i.push(nn)}}).visit(n.program),i}function fn(e,t){return e.slice(0,t).split(`
2
- `).length}function pn(e){switch(e.type){case`TSInterfaceDeclaration`:case`TSTypeAliasDeclaration`:return!0;case`TSModuleDeclaration`:return mn(e);case`ClassDeclaration`:case`FunctionDeclaration`:case`TSEnumDeclaration`:case`VariableDeclaration`:return e.declare===!0;case`ExportNamedDeclaration`:return e.declaration===null?e.exportKind===`type`:pn(e.declaration);default:return!1}}function mn(e){return e.kind===`global`||e.declare||e.body===null||e.body.body.every(e=>e.type!==`ExpressionStatement`&&pn(e))}function hn(e){return e.body.some(e=>e.type===`ExportDefaultDeclaration`?e.declaration.type!==`TSInterfaceDeclaration`:e.type===`ExportNamedDeclaration`&&e.exportKind!==`type`&&e.specifiers.some(e=>e.exportKind!==`type`&&(e.exported.type===`Literal`?e.exported.value==="default":e.exported.name==="default")))}function gn(e,t){let n=rn(e,t);return n.errors.length>0?[]:n.program.body.flatMap(e=>{switch(e.type){case`ImportDeclaration`:return e.importKind===`type`?[]:[e.source.value];case`ExportAllDeclaration`:case`ExportNamedDeclaration`:return e.source===null||e.exportKind===`type`?[]:[e.source.value];default:return[]}})}function _n(e,t){let n=rn(e,t);if(n.errors.length>0)return n.errors.map(e=>`Syntax error: ${e.message}`);let r=[],i=(e,n)=>{r.push(`Line ${fn(t,e)}: ${n} needs a TypeScript transform, which type stripping does not do.`)};return new yt({TSEnumDeclaration(e){e.declare||i(e.start,"`enum`")},TSExportAssignment(e){i(e.start,"`export =`")},TSImportEqualsDeclaration(e){e.importKind!==`type`&&i(e.start,"`import x = ...`")},TSModuleDeclaration(e){mn(e)||i(e.start,"A `namespace` with values")},TSParameterProperty(e){i(e.start,`A parameter property`)}}).visit(n.program),hn(n.program)||r.push(`The file has no default export. Export the rule as default.`),r}const vn=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],yn="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to inspect `options`.",bn="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can inspect.",xn="Set `respectEslintDisableDirectives`, `typeAware`, and `typeCheck` to `true` in the `options` object. Preserve every other project setting.";function Sn(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Cn(e=[]){let t=[`core`,...e];return[`import { defineConfig } from "oxlint"`,...t.map(e=>`import ${Sn(e)} from "${G(e===`core`?`./lint`:`./lint/${e}`)}"`),`import custom from "${G(`./rules`)}"`,``,`export default defineConfig({`,` extends: [${[...t.map(e=>Sn(e)),`custom()`].join(`, `)}],`,` ignorePatterns: core.ignorePatterns,`,` options: {`,...vn.map(e=>` ${e}: true,`),` },`,`})`,``].join(`
3
- `)}const wn=N.liftThrowable(e=>bt(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function Tn(e){return wn(e).pipe(N.flatMap(e=>e.errors.length===0?N.fromNullishOr(e.program):N.none()))}const En=`${G(`./lint`)}/`;function Dn(e){return L(Tn(e),N.map(e=>e.body.flatMap(e=>e.type===`ImportDeclaration`&&e.source.value.startsWith(En)&&e.source.value!==`adamantite/lint/custom`?[e.source.value.slice(En.length)]:[])),N.getOrElse(()=>[]))}function On(e,t){return N.exists(e,e=>Dn(e).includes(t))}function kn(e){return e.type===`Identifier`?L(e.name,N.some):e.type===`Literal`&&F.isString(e.value)?L(e.value,N.some):N.none()}function An(e){return e.type===`ObjectExpression`?L(e,N.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?N.none():L(e.arguments.length===1?O.head(e.arguments):N.none(),N.filter(e=>e.type===`ObjectExpression`))}function jn(e){return L(e.body,O.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?O.head(e):N.none(),N.flatMap(e=>An(e.declaration)))}function Mn(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`invalid`};let e=N.contains(kn(r.key),t);if(r.method||r.kind!==`init`){if(e)return{status:`invalid`}}else if(e){if(n)return{status:`invalid`};n=r}}return n?{property:n,status:`found`}:{status:`missing`}}function Nn(e){for(let t of vn){let n=Mn(e,t);if(n.status===`invalid`)return{goal:xn,kind:`invalid`,reason:"`oxlint.config.ts` has an `options` object Adamantite cannot inspect. 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."};if(n.status===`missing`||n.property.value.type!==`Literal`||n.property.value.value!==!0)return{goal:xn,kind:`invalid`,reason:`The required Oxlint options are missing or are not set to true.`}}return{kind:`configured`}}function Pn(e){let t=Tn(e);if(N.isNone(t))return{goal:"Fix the syntax errors in `oxlint.config.ts`. Preserve every project setting.",kind:`invalid`,reason:yn};let n=jn(t.value);if(N.isNone(n))return{goal:"Export the config object literal directly from `oxlint.config.ts`, with or without `defineConfig(...)`. Preserve every project setting.",kind:`invalid`,reason:yn};let r=Mn(n.value,`options`);return r.status===`invalid`?{goal:xn,kind:`invalid`,reason:bn}:r.status===`missing`?{goal:xn,kind:`invalid`,reason:`The required Oxlint options are missing.`}:r.property.value.type===`ObjectExpression`?Nn(r.property.value):{goal:xn,kind:`invalid`,reason:bn}}function Fn(e,t){for(let n of e.body)if(n.type===`ImportDeclaration`&&n.source.value===t){for(let e of n.specifiers)if(e.type===`ImportDefaultSpecifier`)return e.local.name}return null}function In(e,t){for(let n of e.body)if(n.type===`VariableDeclaration`){for(let e of n.declarations)if(e.id.type===`Identifier`&&e.id.name===t)return e.init}return null}function Ln(e,t,n){let r=!1;return new yt({Identifier:e=>{e.start>=n.start&&e.end<=n.end&&e.name===t&&(r=!0)}}).visit(e),r}function Rn(e,t){let n=e.body.filter(e=>e.type===`ExportDefaultDeclaration`);if(n.length!==1)return!1;let r=n[0]?.declaration;if(!r)return!1;if(r.type!==`Identifier`)return Ln(e,t,r);if(r.name===t)return!0;let i=In(e,r.name);return i!==null&&Ln(e,t,i)}function zn(e,t){let n=`Import the ${t.presetName} preset from \`${t.moduleName}\`, and use it in the exported config. Preserve every project-specific setting.`,r=bt(`config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`});if(r.errors.length>0)return{goal:`Fix the syntax errors in the file. Preserve every project-specific setting.`,kind:`invalid`,reason:`The file is not valid TypeScript.`};let i=Fn(r.program,t.moduleName);return i?Rn(r.program,i)?{kind:`configured`}:{goal:n,kind:`invalid`,reason:`The imported ${t.presetName} preset is not used by the exported configuration.`}:{goal:n,kind:`invalid`,reason:`The file must import the ${t.presetName} preset from \`${t.moduleName}\`.`}}const Bn=[`monorepo`,`effect`],Vn={effect:[`@effect/language-service`],monorepo:[`sherif`]},Hn={effect:e=>e.usesEffectPreset,monorepo:e=>e.isMonorepo},Un={effect:"the `effect` lint preset names the `@effect/language-service` plugin in `tsconfig.json`, and no package has that name",monorepo:"Knip cannot see that `adamantite analyze` runs Sherif in a monorepo"},Wn={isMonorepo:!1,usesEffectPreset:!1};function Gn(e,t){return new RegExp(String.raw`ignoreDependencies\s*:\s*\[[^\]]*?${vt.escape(t)}`,`u`).test(e)}function Kn(e,t){return new RegExp(String.raw`ignoreDependencies\s*:\s*(?:ignoreDependencies\.${t}|\[[^\]]*?ignoreDependencies\.${t})`,`u`).test(e)}const qn=/import\s[^;]*?\{[^}]*\bignoreDependencies\b[^}]*\}\s*from\s*["']adamantite\/analyze["']/u;function Jn(e){return Bn.filter(t=>Hn[t](e))}function Yn(e,t){return Vn[t].every(t=>Gn(e,t))||Kn(e,t)&&qn.test(e)}function Xn(e){let[t]=e;return e.length===1&&t!==void 0?`ignoreDependencies.${t}`:`[${e.map(e=>`...ignoreDependencies.${e}`).join(`, `)}]`}function Zn({isMonorepo:e,lintConfig:t}){return{isMonorepo:e,usesEffectPreset:On(t,`effect`)}}function Qn(e,t){let n=zn(e,{moduleName:G(`./analyze`),presetName:`Adamantite analyze`});if(n.kind!==`configured`)return n;let r=Jn(t),i=r.filter(t=>!Yn(e,t));if(i.length===0)return n;let a=`\`ignoreDependencies: ${Xn(r)}\``;return{goal:`Set ${a} in \`knip.config.ts\`, with the named \`ignoreDependencies\` import from \`adamantite/analyze\`, and keep the other settings.`,kind:`invalid`,reason:`The file must set ${a} from \`adamantite/analyze\`, because ${i.map(e=>Un[e]).join(`, and `)}.`}}function $n(e=Wn){let t=Jn(e);return[`import type { KnipConfig } from "knip"`,t.length>0?`import analyze, { ignoreDependencies } from "${G(`./analyze`)}"`:`import analyze from "${G(`./analyze`)}"`,``,...t.length>0?[`const config: KnipConfig = {`,` ...analyze,`,` ignoreDependencies: ${Xn(t)},`,`}`]:[`const config: KnipConfig = analyze`],``,`export default config`,``].join(`
4
- `)}function er(e){return{args:[...e.fix?[`--fix`,`--allow-remove-files`]:[],...e.strict?[`--production`,`--strict`]:[],...e.forwardedArguments],command:`knip`,cwd:e.cwd,stdin:`ignore`,title:`๐Ÿงน Analyzing unused code`}}var tr={analyze:er,...Yt({configContent:$n,configFiles:{config:`knip.config.ts`,legacyConfigs:[`knip.json`,`knip.jsonc`]},inspectConfig:Qn,name:`knip`,purpose:"the managed `analyze` script",scripts:De(`knip`),version:`6.42.0`,workspace:Zn})};function nr(e){return{args:[`--check`,...e.files,...e.forwardedArguments],command:`oxfmt`,cwd:e.cwd,title:`โœจ Checking formatting`}}function rr(e){return{args:[`--write`,...e.files,...e.forwardedArguments],command:`oxfmt`,cwd:e.cwd,title:`โœจ Formatting`}}function ir(e){return zn(e,{moduleName:G(`./format`),presetName:`Adamantite format`})}function ar(){return`import { defineConfig } from "oxfmt"
1
+ import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,Mt as v,N as ee,O as y,Ot as te,P as b,Q as ne,R as x,S as re,St as ie,T as ae,Tt as oe,U as S,V as C,W as se,X as ce,Y as w,Z as le,_ as ue,_t as de,a as fe,at as pe,bt as me,c as he,ct as ge,d as _e,dt as ve,et as ye,f as be,ft as xe,g as Se,gt as Ce,h as we,ht as Te,i as Ee,it as De,j as Oe,jt as ke,k as Ae,kt as je,l as Me,lt as Ne,m as Pe,mt as Fe,n as Ie,nt as Le,ot as Re,p as ze,pt as Be,q as Ve,r as He,rt as Ue,s as We,st as Ge,t as Ke,tt as qe,u as Je,ut as Ye,vt as Xe,w as Ze,wt as Qe,x as $e,xt as et,y as tt,yt as nt,z as rt}from"./runtime-CVZPDpfE.js";import*as it from"@effect/platform-node/NodeRuntime";import*as T from"effect/Effect";import*as at from"effect/Exit";import*as E from"effect/process/ChildProcessSpawner";import*as ot from"effect/Runtime";import*as st from"effect/Stdio";import*as ct from"@effect/platform-node/NodeServices";import*as D from"effect/Array";import*as O from"effect/cli/Command";import*as k from"effect/Layer";import A from"node:process";import*as j from"effect/cli/Flag";import*as M from"effect/Option";import*as N from"effect/Context";import*as P from"effect/Path";import*as F from"effect/Predicate";import{styleText as lt}from"node:util";import*as ut from"effect/Console";import*as dt from"effect/process/ChildProcess";import*as ft from"effect/Result";import*as I from"effect/Data";import{pipe as L}from"effect/Function";import*as pt from"effect/String";import*as R from"effect/FileSystem";import*as mt from"effect/Equal";import*as z from"effect/Schema";import*as ht from"effect/encoding/Yaml";import*as gt from"effect/SchemaTransformation";import*as _t from"effect/Record";import*as vt from"effect/RegExp";import{Visitor as yt,parseSync as bt}from"oxc-parser";import*as B from"effect/Order";import*as xt from"effect/Config";import*as St from"effect/Match";import*as V from"effect/cli/Argument";import{addDevDependency as Ct,detectPackageManager as wt,runScriptCommand as Tt}from"nypm";import*as H from"effect/Stream";import*as U from"@clack/prompts";import*as Et from"effect/Cause";import{posix as W,win32 as Dt}from"node:path";import*as Ot from"effect/Brand";import*as kt from"effect/Terminal";const At=N.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]}),jt=(e,t)=>ut.log(`${lt(`bold`,e)} ${lt(`dim`,`ยท adamantite (${t})`)}`),Mt=()=>[A.env.NODE_OPTIONS,`--disable-warning=MODULE_TYPELESS_PACKAGE_JSON`].filter(Boolean).join(` `),Nt=T.fn(`CommandRunner.exitCode`)(function*(e){let{command:t}=e;return yield*T.scoped(T.gen(function*(){return yield*(yield*dt.make(t,e.args,{cwd:e.cwd,detached:e.stdin!==`inherit`&&void 0,env:{...e.env,NODE_OPTIONS:Mt()},extendEnv:!0,stderr:e.stderr??`inherit`,stdin:e.stdin??`ignore`,stdout:e.stdout??`inherit`})).exitCode})).pipe(T.catchReason(`PlatformError`,`NotFound`,()=>T.fail(new qe({command:t}))))});var Pt=class e extends N.Service()(`CommandRunner`){static make(e){let t=T.fn(`CommandRunner.run`)(function*(t){t.title!==void 0&&(yield*jt(t.title,t.name??t.command));let n=yield*e(t);if(n!==E.ExitCode(0))return yield*new Le({command:t.command,exitCode:n})}),n=e=>e.map((e,n)=>n===0?t(e):T.andThen(ut.log(``),t(e)));return{exitCode:e,run:t,runAll:T.fn(`CommandRunner.runAll`)(function*(e){let t=yield*T.all(n(e),{concurrency:1,mode:`result`});yield*T.fromResult(ft.all(t))}),runUntilFailure:T.fn(`CommandRunner.runUntilFailure`)(function*(e){yield*T.all(n(e),{concurrency:1,discard:!0})})}}static layer=k.effect(this)(T.gen(function*(){let t=yield*E.ChildProcessSpawner;return e.make(e=>Nt(e).pipe(T.provideService(E.ChildProcessSpawner,t)))}))};function G(e){return e}var Ft=class extends I.TaggedClass(`Missing`){},It=class extends I.TaggedClass(`Current`){},Lt=class extends I.TaggedClass(`Legacy`){};function Rt(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function zt(e,t){return D.findFirst(e.legacyConfigs,e=>Rt(e)===t)}function Bt(e){let t=zt(e,`json`),n=zt(e,`jsonc`);return L(M.zipWith(t,n,e=>`${e}(c)`),M.orElse(()=>n),M.orElse(()=>t),M.getOrElse(()=>``))}function Vt(e,t,n,r){return n instanceof Ft||r.length===0?[]:n instanceof It?[`Found both \`${t.config}\` and \`${Bt(t)}\`. Adamantite will use \`${t.config}\`.`]:L(M.zipWith(zt(t,`json`),zt(t,`jsonc`),(t,n)=>`Found both \`${t}\` and \`${n}\`. Multiple legacy ${e} configs exist. Doctor uses \`${n}\` when checking the setup.`),M.toArray)}const Ht=T.fn(`detectToolingConfig`)(function*(e,t,n){let r=yield*R.FileSystem,i=yield*P.Path,a=[n.config,...n.legacyConfigs].map(t=>({file:t,format:Rt(t),path:i.join(e,t)})),o=yield*T.forEach(a,e=>r.exists(e.path),{concurrency:`unbounded`}),s=a.filter((e,t)=>o[t]),c=({file:e,path:t})=>({file:e,path:t}),l=L(D.findFirst(s,e=>e.format===`ts`),M.orElse(()=>D.findFirst(s,e=>e.format===`jsonc`)),M.orElse(()=>D.findFirst(s,e=>e.format===`json`))),u=M.match(l,{onNone:()=>new Ft,onSome:e=>e.format===`ts`?new It({file:c(e)}):new Lt({file:c(e)})}),d=s.flatMap(e=>e.format!==`ts`&&!M.exists(l,t=>t===e)?[c(e)]:[]);return{active:u,legacy:d,warnings:Vt(t,n,u,d)}}),Ut={findings:[],packageActions:[],warnings:[]};function Wt({packageJson:e,workspace:{catalogs:t}},n,r,i){let a=e.devDependencies?.[n.name]??e.dependencies?.[n.name];if(!a)return{findings:[{currentState:`The required package \`${n.name}\` is not installed.`,goal:[`Run \`adamantite update\` so \`${n.name}@${n.version}\` is installed.`],id:`missing-${n.name}`,integration:i,title:`Missing ${n.name}`}],packageActions:[{description:`Install \`${n.name}@${n.version}\` for ${r}.`,package:n.name,targetVersion:n.version,type:`install_package`}],warnings:[]};function o(e){return{findings:[],packageActions:[],warnings:[`\`${n.name}\` is declared as \`${e}\`, so Adamantite cannot check it against the required version \`${n.version}\`.`]}}function s(e,t){let r=e==="default"?"the `catalog`":`the \`${e}\` catalog`;return{findings:[{currentState:`${r} of \`pnpm-workspace.yaml\` sets \`${n.name}\` to \`${t}\`, but Adamantite requires \`${n.version}\`.`,goal:[`Set \`${n.name}\` to \`${n.version}\` in ${r} of \`pnpm-workspace.yaml\`, then install the dependencies.`],id:`outdated-${n.name}`,integration:i,notes:["Keep the `catalog:` specifier in `package.json`. `adamantite update` does not change catalogs."],title:`Outdated ${n.name}`}],packageActions:[],warnings:[]}}return ee(b(a),{Catalog:({catalog:e})=>{let r=t[e]?.[n.name];return r===void 0?o(a):ee(b(r),{Catalog:()=>o(a),Unreadable:()=>o(a),Version:({version:t})=>t===n.version?Ut:s(e,r)})},Unreadable:()=>o(a),Version:({version:e})=>e===n.version?Ut:{findings:[{currentState:`The installed \`${n.name}\` version is \`${a}\`, but Adamantite requires \`${n.version}\`.`,goal:[`Run \`adamantite update\` so \`${n.name}@${n.version}\` is installed.`],id:`outdated-${n.name}`,integration:i,title:`Outdated ${n.name}`}],packageActions:[{currentVersion:a,description:`Update \`${n.name}\` from \`${a}\` to \`${n.version}\`.`,package:n.name,targetVersion:n.version,type:`update_package`}],warnings:[]}})}function Gt(e,t){if(e.active instanceof Ft)return[{currentState:`The managed \`${t.configFile}\` file is missing.`,goal:[`Create \`${t.configFile}\` with the reference content.`,`Do not create a legacy JSON or JSONC ${t.toolName} config.`],id:`missing-${t.toolName}-config`,integration:t.toolName,reference:{content:t.configContent,language:`ts`},title:`Missing ${t.toolName} configuration`}];if(e.active instanceof Lt)return[{currentState:`Legacy \`${e.active.file.file}\` is the active ${t.toolName} configuration.`,goal:[`Move the project settings into \`${t.configFile}\` using the reference content as the base.`,`Delete every legacy ${t.toolName} JSON or JSONC config after its settings are preserved.`],id:`legacy-${t.toolName}-config`,integration:t.toolName,notes:[`Preserve project-specific settings. Do not replace them with the reference defaults.`],reference:{content:t.configContent,language:`ts`},title:`Legacy ${t.toolName} configuration`}];let n=[];return e.legacy.length>0&&n.push({currentState:`Legacy ${t.toolName} config files remain next to \`${t.configFile}\`: ${e.legacy.map(({file:e})=>`\`${e}\``).join(`, `)}.`,goal:[`Delete the legacy files after you confirm that \`${t.configFile}\` preserves their project-specific settings.`],id:`shadowed-legacy-${t.toolName}-config`,integration:t.toolName,title:`Legacy ${t.toolName} files remain`}),t.inspection?.kind===`invalid`&&n.push({currentState:`\`${t.configFile}\` does not meet Adamantite's required shape. ${t.inspection.reason}`,goal:[t.inspection.goal],id:`invalid-${t.toolName}-config`,integration:t.toolName,notes:[`Treat the reference as a known-good example, not an exact replacement.`],reference:{content:t.configContent,language:`ts`},title:`Invalid ${t.toolName} configuration`}),n}function Kt(e,n){let r=t(e);return n.some(e=>r.includes(e))}function qt(e){return G({assess:t=>T.sync(()=>{let{packageJson:n}=t,r=Kt(n,e.scripts)&&(!e.monorepoOnly||t.workspace.isMonorepo)&&(e.isRequired===void 0||e.isRequired(t)),i=e.legacyFindings?.(n)??[];if(!r)return i.length>0?{applicable:!0,findings:[...i],packageActions:[],warnings:[]}:{applicable:!1};let a=Wt(t,e,e.purpose,e.name);return{applicable:!0,findings:[...a.findings,...i],packageActions:a.packageActions,warnings:a.warnings}}),kind:`tooling`,name:e.name,version:e.version})}const Jt=T.fn(`readToolingFacts`)(function*(e){let t=yield*P.Path,[n,r]=yield*T.all([$e(e),C(t.join(e,`oxlint.config.ts`))],{concurrency:`unbounded`});return{isMonorepo:n,lintConfig:r}});function Yt(e){let t=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],n=t=>Ht(t,e.name,e.configFiles);return G({assess:t=>T.gen(function*(){let{cwd:i,lintConfig:a,packageJson:o,workspace:{isMonorepo:s}}=t;if(!Kt(o,e.scripts))return{applicable:!1};let c=yield*n(i),l=e.workspace({isMonorepo:s,lintConfig:a}),u=Wt(t,e,e.purpose,e.name),d=e.configContent(l),f=c.active instanceof It?e.inspectConfig(yield*r(c.active.file.path),l):void 0;return{applicable:!0,findings:[...u.findings,...Gt(c,{configContent:d,configFile:e.configFiles.config,inspection:f,toolName:e.name})],packageActions:u.packageActions,warnings:[...u.warnings,...c.warnings]}}),config:e.configFiles.config,create:t=>T.gen(function*(){let n=yield*P.Path;yield*S(n.join(t,e.configFiles.config),e.configContent(e.workspace(yield*Jt(t))))}),detect:n,files:t,kind:`tooling`,name:e.name,version:e.version})}function K(e){return`adamantite${e.slice(1)}`}const Xt=K(`./rules`),q=`.adamantite/lint`,Zt=/* @__PURE__ */ new Set([`.js`,`.mjs`,`.mts`,`.ts`]);function Qt(e){let t=/\.[^.]+$/.exec(e)?.[0]??``;return Zt.has(t)&&!e.startsWith(`_`)&&!/\.(?:d\.m?ts|test\.[^.]+)$/.test(e)}function $t(e){return!e.startsWith(`_`)&&/\.test\.(?:js|mjs|mts|ts)$/.test(e)}var en=class extends I.TaggedClass(`Dynamic`){},tn=class extends I.TaggedClass(`Literal`){};const nn=new en;function rn(e,t){return bt(e,t,{preserveParens:!1,sourceType:`module`})}function an(e){return e.body.flatMap(e=>e.type===`ImportDeclaration`&&e.source.value===Xt?e.specifiers:[]).filter(e=>e.type===`ImportDefaultSpecifier`).map(e=>e.local.name)}function on(e,t){let n=rn(e,t);return n.errors.length>0?!1:n.program.body.some(e=>e.type===`ImportDeclaration`?e.source.value===`adamantite/lint/custom`||e.source.value===Xt&&e.specifiers.some(e=>e.type===`ImportSpecifier`&&(e.imported.type===`Identifier`?e.imported.name:e.imported.value)!==`CustomRulesOptions`):e.type===`ExportNamedDeclaration`&&e.source!==null?e.source.value===`adamantite/lint/custom`||e.source.value===Xt&&e.specifiers.some(e=>{let t=e.local.type===`Identifier`?e.local.name:e.local.value;return t!=="default"&&t!==`CustomRulesOptions`}):e.type===`ExportAllDeclaration`&&e.source.value===`adamantite/lint/custom`)}function sn(e){return e.type===`Literal`&&F.isString(e.value)?e.value:e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0]?.value.cooked??null:null}function cn(e){return e.type===`Literal`&&F.isString(e.value)?e.value:null}function ln(e,t,n){let r=L(e,D.findLast(e=>(e.key.type===`Identifier`?e.key.name:cn(e.key))===t));return M.fromNullOr(M.match(r,{onNone:()=>n,onSome:({value:e})=>sn(e)}))}function un(e){let t=e.filter(e=>e.type!==`SpreadElement`&&!e.computed);return t.length<e.length?nn:M.match(ln(t,`dir`,q),{onNone:()=>nn,onSome:e=>new tn({dir:e,name:ln(t,`name`,`project`)})})}function dn(e,t){let n=rn(e,t),r=an(n.program);if(n.errors.length>0||r.length===0)return[];let i=[];return new yt({CallExpression(e){if(e.callee.type!==`Identifier`||!r.includes(e.callee.name))return;let[t]=e.arguments;t===void 0?i.push(un([])):t.type===`ObjectExpression`?i.push(un(t.properties)):i.push(nn)}}).visit(n.program),i}function fn(e,t){return e.slice(0,t).split(`
2
+ `).length}function pn(e){switch(e.type){case`TSInterfaceDeclaration`:case`TSTypeAliasDeclaration`:return!0;case`TSModuleDeclaration`:return mn(e);case`ClassDeclaration`:case`FunctionDeclaration`:case`TSEnumDeclaration`:case`VariableDeclaration`:return e.declare===!0;case`ExportNamedDeclaration`:return e.declaration===null?e.exportKind===`type`:pn(e.declaration);default:return!1}}function mn(e){return e.kind===`global`||e.declare||e.body===null||e.body.body.every(e=>e.type!==`ExpressionStatement`&&pn(e))}function hn(e){return e.body.some(e=>e.type===`ExportDefaultDeclaration`?e.declaration.type!==`TSInterfaceDeclaration`:e.type===`ExportNamedDeclaration`&&e.exportKind!==`type`&&e.specifiers.some(e=>e.exportKind!==`type`&&(e.exported.type===`Literal`?e.exported.value==="default":e.exported.name==="default")))}function gn(e,t){let n=rn(e,t);return n.errors.length>0?[]:n.program.body.flatMap(e=>{switch(e.type){case`ImportDeclaration`:return e.importKind===`type`?[]:[e.source.value];case`ExportAllDeclaration`:case`ExportNamedDeclaration`:return e.source===null||e.exportKind===`type`?[]:[e.source.value];default:return[]}})}function _n(e,t){let n=rn(e,t);if(n.errors.length>0)return n.errors.map(e=>`Syntax error: ${e.message}`);let r=[],i=(e,n)=>{r.push(`Line ${fn(t,e)}: ${n} needs a TypeScript transform, which type stripping does not do.`)};return new yt({TSEnumDeclaration(e){e.declare||i(e.start,"`enum`")},TSExportAssignment(e){i(e.start,"`export =`")},TSImportEqualsDeclaration(e){e.importKind!==`type`&&i(e.start,"`import x = ...`")},TSModuleDeclaration(e){mn(e)||i(e.start,"A `namespace` with values")},TSParameterProperty(e){i(e.start,`A parameter property`)}}).visit(n.program),hn(n.program)||r.push(`The file has no default export. Export the rule as default.`),r}const vn=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],yn="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to inspect `options`.",bn="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can inspect.",xn="Set `respectEslintDisableDirectives`, `typeAware`, and `typeCheck` to `true` in the `options` object. Preserve every other project setting.";function Sn(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Cn(e=[]){let t=[`core`,...e];return[`import { defineConfig } from "oxlint"`,...t.map(e=>`import ${Sn(e)} from "${K(e===`core`?`./lint`:`./lint/${e}`)}"`),`import custom from "${K(`./rules`)}"`,``,`export default defineConfig({`,` extends: [${[...t.map(e=>Sn(e)),`custom()`].join(`, `)}],`,` ignorePatterns: core.ignorePatterns,`,` options: {`,...vn.map(e=>` ${e}: true,`),` },`,`})`,``].join(`
3
+ `)}const wn=M.liftThrowable(e=>bt(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function Tn(e){return wn(e).pipe(M.flatMap(e=>e.errors.length===0?M.fromNullishOr(e.program):M.none()))}const En=`${K(`./lint`)}/`;function Dn(e){return L(Tn(e),M.map(e=>e.body.flatMap(e=>e.type===`ImportDeclaration`&&e.source.value.startsWith(En)&&e.source.value!==`adamantite/lint/custom`?[e.source.value.slice(En.length)]:[])),M.getOrElse(()=>[]))}function On(e,t){return M.exists(e,e=>Dn(e).includes(t))}function kn(e){return e.type===`Identifier`?L(e.name,M.some):e.type===`Literal`&&F.isString(e.value)?L(e.value,M.some):M.none()}function An(e){return e.type===`ObjectExpression`?L(e,M.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?M.none():L(e.arguments.length===1?D.head(e.arguments):M.none(),M.filter(e=>e.type===`ObjectExpression`))}function jn(e){return L(e.body,D.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?D.head(e):M.none(),M.flatMap(e=>An(e.declaration)))}function Mn(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`invalid`};let e=M.contains(kn(r.key),t);if(r.method||r.kind!==`init`){if(e)return{status:`invalid`}}else if(e){if(n)return{status:`invalid`};n=r}}return n?{property:n,status:`found`}:{status:`missing`}}function Nn(e){for(let t of vn){let n=Mn(e,t);if(n.status===`invalid`)return{goal:xn,kind:`invalid`,reason:"`oxlint.config.ts` has an `options` object Adamantite cannot inspect. 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."};if(n.status===`missing`||n.property.value.type!==`Literal`||n.property.value.value!==!0)return{goal:xn,kind:`invalid`,reason:`The required Oxlint options are missing or are not set to true.`}}return{kind:`configured`}}function Pn(e){let t=Tn(e);if(M.isNone(t))return{goal:"Fix the syntax errors in `oxlint.config.ts`. Preserve every project setting.",kind:`invalid`,reason:yn};let n=jn(t.value);if(M.isNone(n))return{goal:"Export the config object literal directly from `oxlint.config.ts`, with or without `defineConfig(...)`. Preserve every project setting.",kind:`invalid`,reason:yn};let r=Mn(n.value,`options`);return r.status===`invalid`?{goal:xn,kind:`invalid`,reason:bn}:r.status===`missing`?{goal:xn,kind:`invalid`,reason:`The required Oxlint options are missing.`}:r.property.value.type===`ObjectExpression`?Nn(r.property.value):{goal:xn,kind:`invalid`,reason:bn}}function Fn(e,t){for(let n of e.body)if(n.type===`ImportDeclaration`&&n.source.value===t){for(let e of n.specifiers)if(e.type===`ImportDefaultSpecifier`)return e.local.name}return null}function In(e,t){for(let n of e.body)if(n.type===`VariableDeclaration`){for(let e of n.declarations)if(e.id.type===`Identifier`&&e.id.name===t)return e.init}return null}function Ln(e,t,n){let r=!1;return new yt({Identifier:e=>{e.start>=n.start&&e.end<=n.end&&e.name===t&&(r=!0)}}).visit(e),r}function Rn(e,t){let n=e.body.filter(e=>e.type===`ExportDefaultDeclaration`);if(n.length!==1)return!1;let r=n[0]?.declaration;if(!r)return!1;if(r.type!==`Identifier`)return Ln(e,t,r);if(r.name===t)return!0;let i=In(e,r.name);return i!==null&&Ln(e,t,i)}function zn(e,t){let n=`Import the ${t.presetName} preset from \`${t.moduleName}\`, and use it in the exported config. Preserve every project-specific setting.`,r=bt(`config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`});if(r.errors.length>0)return{goal:`Fix the syntax errors in the file. Preserve every project-specific setting.`,kind:`invalid`,reason:`The file is not valid TypeScript.`};let i=Fn(r.program,t.moduleName);return i?Rn(r.program,i)?{kind:`configured`}:{goal:n,kind:`invalid`,reason:`The imported ${t.presetName} preset is not used by the exported configuration.`}:{goal:n,kind:`invalid`,reason:`The file must import the ${t.presetName} preset from \`${t.moduleName}\`.`}}const Bn=[`monorepo`,`effect`],Vn={effect:[`@effect/language-service`],monorepo:[`sherif`]},Hn={effect:e=>e.usesEffectPreset,monorepo:e=>e.isMonorepo},Un={effect:"the `effect` lint preset names the `@effect/language-service` plugin in `tsconfig.json`, and no package has that name",monorepo:"Knip cannot see that `adamantite analyze` runs Sherif in a monorepo"},Wn={isMonorepo:!1,usesEffectPreset:!1};function Gn(e,t){return new RegExp(String.raw`ignoreDependencies\s*:\s*\[[^\]]*?${vt.escape(t)}`,`u`).test(e)}function Kn(e,t){return new RegExp(String.raw`ignoreDependencies\s*:\s*(?:ignoreDependencies\.${t}|\[[^\]]*?ignoreDependencies\.${t})`,`u`).test(e)}const qn=/import\s[^;]*?\{[^}]*\bignoreDependencies\b[^}]*\}\s*from\s*["']adamantite\/analyze["']/u;function Jn(e){return Bn.filter(t=>Hn[t](e))}function Yn(e,t){return Vn[t].every(t=>Gn(e,t))||Kn(e,t)&&qn.test(e)}function Xn(e){let[t]=e;return e.length===1&&t!==void 0?`ignoreDependencies.${t}`:`[${e.map(e=>`...ignoreDependencies.${e}`).join(`, `)}]`}function Zn({isMonorepo:e,lintConfig:t}){return{isMonorepo:e,usesEffectPreset:On(t,`effect`)}}function Qn(e,t){let n=zn(e,{moduleName:K(`./analyze`),presetName:`Adamantite analyze`});if(n.kind!==`configured`)return n;let r=Jn(t),i=r.filter(t=>!Yn(e,t));if(i.length===0)return n;let a=`\`ignoreDependencies: ${Xn(r)}\``;return{goal:`Set ${a} in \`knip.config.ts\`, with the named \`ignoreDependencies\` import from \`adamantite/analyze\`, and keep the other settings.`,kind:`invalid`,reason:`The file must set ${a} from \`adamantite/analyze\`, because ${i.map(e=>Un[e]).join(`, and `)}.`}}function $n(e=Wn){let t=Jn(e);return[`import type { KnipConfig } from "knip"`,t.length>0?`import analyze, { ignoreDependencies } from "${K(`./analyze`)}"`:`import analyze from "${K(`./analyze`)}"`,``,...t.length>0?[`const config: KnipConfig = {`,` ...analyze,`,` ignoreDependencies: ${Xn(t)},`,`}`]:[`const config: KnipConfig = analyze`],``,`export default config`,``].join(`
4
+ `)}function er(e){return{args:[...e.fix?[`--fix`,`--allow-remove-files`]:[],...e.strict?[`--production`,`--strict`]:[],...e.forwardedArguments],command:`knip`,cwd:e.cwd,stdin:`ignore`,title:`๐Ÿงน Analyzing unused code`}}var tr={analyze:er,...Yt({configContent:$n,configFiles:{config:`knip.config.ts`,legacyConfigs:[`knip.json`,`knip.jsonc`]},inspectConfig:Qn,name:`knip`,purpose:"the managed `analyze` script",scripts:Oe(`knip`),version:`6.42.0`,workspace:Zn})};function nr(e){return{args:[`--check`,...e.files,...e.forwardedArguments],command:`oxfmt`,cwd:e.cwd,title:`โœจ Checking formatting`}}function rr(e){return{args:[`--write`,...e.files,...e.forwardedArguments],command:`oxfmt`,cwd:e.cwd,title:`โœจ Formatting`}}function ir(e){return zn(e,{moduleName:K(`./format`),presetName:`Adamantite format`})}function ar(){return`import { defineConfig } from "oxfmt"
5
5
  import format from "adamantite/format"
6
6
 
7
7
  export default defineConfig(format)
8
- `}var q={check:nr,fix:rr,...Yt({configContent:ar,configFiles:{config:`oxfmt.config.ts`,legacyConfigs:[`.oxfmtrc.json`,`.oxfmtrc.jsonc`]},inspectConfig:ir,name:`oxfmt`,purpose:"the managed `check` and `fix` scripts",scripts:De(`oxfmt`),version:`0.76.0`,workspace:({isMonorepo:e})=>({isMonorepo:e})})};function or(e){let t=et(e.cwd),n=e.forwardedArguments.some(e=>e===`--deny-warnings`||e.startsWith(`--max-warnings`)),r=e.allowWarnings||n?[]:[`--deny-warnings`];return{...t,args:[...t.args,...e.files,...r,...e.forwardedArguments],title:`๐Ÿ” Linting`}}const sr={all:[`--fix-suggestions`,`--fix-dangerously`],dangerous:[`--fix-dangerously`],safe:[],suggested:[`--fix-suggestions`]};function cr(e){let t=et(e.cwd);return{...t,args:[...t.args,`--fix`,...sr[e.level],...e.files,...e.forwardedArguments],title:`๐Ÿ”ง Fixing lint issues`}}function lr(e){if(!e.computed)return e.key.type===`Identifier`?e.key.name:e.key.type===`Literal`&&F.isString(e.key.value)?e.key.value:void 0}function ur(e,t){let{file:n,content:r}=e,i=n.endsWith(`.json`),a=bt(i?`${n}.ts`:n,i?`(${r})`:r,{preserveParens:!1,sourceType:`module`});if(a.errors.length>0)return;let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=new Map(t.filter(e=>e.from===n).map(e=>[e.specifier,e.file]));for(let e of a.program.body){let t=e.type===`ExportNamedDeclaration`?e.declaration:e;if(t?.type===`VariableDeclaration`&&t.kind===`const`){for(let r of t.declarations)if(r.id.type===`Identifier`&&r.init!==null){let t={expression:r.init,file:n,type:`value`};o.set(r.id.name,t),e.type===`ExportNamedDeclaration`&&s.set(r.id.name,t)}}if(e.type===`ImportDeclaration`&&e.importKind!==`type`){let t=c.get(e.source.value);if(t===void 0)continue;for(let n of e.specifiers)if(n.type===`ImportDefaultSpecifier`)o.set(n.local.name,{file:t,name:`default`,type:`export`});else if(n.type===`ImportSpecifier`&&n.importKind!==`type`){let e=n.imported.type===`Identifier`?n.imported.name:n.imported.value;o.set(n.local.name,{file:t,name:e,type:`export`})}}if(e.type===`ExportDefaultDeclaration`){let t=e.declaration;t.type!==`FunctionDeclaration`&&t.type!==`ClassDeclaration`&&t.type!==`TSInterfaceDeclaration`&&s.set(`default`,{expression:t,file:n,type:`value`})}else if(i&&e.type===`ExpressionStatement`)s.set(`default`,{expression:e.expression,file:n,type:`value`});else if(e.type===`ExportNamedDeclaration`)for(let t of e.specifiers){let r=t.exported.type===`Identifier`?t.exported.name:t.exported.value,i=e.source===null?void 0:c.get(e.source.value);i===void 0?t.local.type===`Identifier`&&s.set(r,{expression:t.local,file:n,type:`value`}):s.set(r,{file:i,name:t.local.type===`Identifier`?t.local.name:t.local.value,type:`export`})}}return{bindings:o,exports:s,file:n,program:a.program}}function dr(e,t){let n=e,r=/* @__PURE__ */ new Set;for(;n!==void 0;){let e=n.type===`value`?n.expression:n;if(r.has(e))return;if(r.add(e),n.type===`export`){n=t.get(n.file)?.exports.get(n.name);continue}let i=n.expression;if(i.type===`Identifier`)n=t.get(n.file)?.bindings.get(i.name);else if(i.type===`TSAsExpression`||i.type===`TSSatisfiesExpression`||i.type===`TSNonNullExpression`)n={...n,expression:i.expression};else return n}return n}function fr(e,t,n=/* @__PURE__ */ new Set){let r=e.expression;if(r.type!==`ObjectExpression`||n.has(r))return[];n.add(r);let i=r.properties.find(e=>e.type===`Property`&&lr(e)===`layers`);if(i?.type!==`Property`)return[];let a=dr({...e,expression:i.value},t);return a?.expression.type===`ObjectExpression`?a.expression.properties.flatMap(e=>{if(e.type!==`Property`)return[];let r=dr({...a,expression:e.value},t);return r===void 0?[]:r.expression.type===`ArrayExpression`?[r.file]:fr(r,t,n)}):[]}function pr(e){let t=/* @__PURE__ */ new Set;for(let n of e.values())new yt({ObjectExpression(r){for(let i of r.properties){if(i.type!==`Property`||lr(i)!==`adamantite/layers`)continue;let r=dr({expression:i.value,file:n.file,type:`value`},e);if(r?.expression.type===`ArrayExpression`)for(let n of r.expression.elements){if(n===null||n.type===`SpreadElement`)continue;let i=dr({...r,expression:n},e);if(i!==void 0)for(let n of fr(i,e))t.add(n)}}}}).visit(n.program);return[...t]}const mr=E.fn(`assessLayerMaps`)(function*(e){let t=yield*P.Path,n=/* @__PURE__ */ new Map;for(let t of e.customRules.sources){let r=ur(t,e.customRules.resolvedImports);r!==void 0&&n.set(r.file,r)}let r=pr(n);return r.length===0?[]:[{currentState:r.map(n=>`\`${t.relative(e.cwd,n)}\` uses arrays for layer declarations in \`adamantite/layers\`.`).join(`
9
- `),goal:['Replace each layer\'s dependency array with an object containing `imports`. For example, `workspace: ["shared"]` becomes `workspace: { imports: ["shared"] }`, and `shared: []` becomes `shared: { imports: [] }`.',`Preserve every dependency and its transitive permissions, rule severity, root, override, entry, ignore, isolation, type-import setting, and resolution condition. Keep independent branches separate. Do not add permissions or exemptions to make the config pass.`,"Put an existing direct child map in its containing layer's `layers` property. Remove that child map's `root` and separate option object. Its folder name derives the child root. Keep the containing layer's `imports` as the parent's dependencies.","Move the child map's `entries`, `ignore`, `isolate`, `ignoreTypes`, and `conditions` beside its nested `layers`. Each setting applies only to that child map. Parent exemptions do not skip child checks, and settings do not inherit.",`Keep separate roots when nesting would require a new intermediate map or change a glob's matched scope. Declare each concrete scope once. A child root uses the parent's actual matched folder, not a concatenated glob.`,`Compare the allowed and forbidden imports before and after the edit. Keep the original config if a permission, scope, or setting cannot be preserved.`,"Run `adamantite check`, verify representative allowed and forbidden imports, then run `adamantite doctor` again."],id:`layers-map-migration`,integration:`oxlint`,reference:{content:`"adamantite/layers": ["error", {
10
- root: "src",
11
- layers: {
12
- lib: {
13
- imports: [],
14
- layers: {
15
- shared: { imports: [] },
16
- workspace: { imports: ["shared"] },
17
- },
18
- },
19
- terminal: { imports: ["lib"] },
20
- },
21
- }]`,language:`ts`},title:`Layer maps need explicit imports and nested declarations`}]}),hr=z.decodeUnknownOption(z.Struct({header:z.Struct({glibcVersionRuntime:z.optional(z.String)}),sharedObjects:z.Array(z.String)}));function gr(e,t){return[{currentState:e,goal:t,id:`unavailable-oxlint-runtime`,integration:`oxlint`,notes:["Verification: run `adamantite check --only lint` after the repair."],title:`Oxlint runtime unavailable`}]}const _r=E.fn(`assessOxlintRuntime`)(function*(e){let t=t=>e.packageJson.devDependencies?.[t]??e.packageJson.dependencies?.[t];return t(`oxlint`)?yield*E.gen(function*(){let n=yield*fe(e.cwd),{backend:r,binding:i}=n;if(t(`tsrs`)&&r instanceof Ge)return gr(`Oxlint cannot resolve the declared tsrs backend or its launcher.`,[`Install the target project's dependencies so that the tsrs-lint launcher is available.`]);for(let n of Ue)if(n.runtime instanceof Se&&t(n.name)){let t=yield*Ce(e.cwd,n.name);if(N.isNone(t))return yield*new ie({packageName:n.name,project:e.cwd})}if(i instanceof Fe&&!(r instanceof Te))return[];let a=yield*R.FileSystem,o=yield*P.Path,s=yield*Ne,c=`${j.platform}-${j.arch}`,l=`gnu`;if(j.platform===`linux`){let e=yield*C(`/usr/bin/ldd`),t=N.isNone(e)?hr(j.report.getReport()):N.none();l=(N.isSome(e)?e.value.includes(`musl`):N.isSome(t)&&!t.value.header.glibcVersionRuntime&&t.value.sharedObjects.some(e=>e.includes(`libc.musl-`)||e.includes(`ld-musl-`)))?`musl`:`gnu`}let u=c+({android:j.arch===`arm`?`-eabi`:``,linux:`-${l}${j.arch===`arm`?`eabihf`:``}`,win32:j.arch===`x64`&&(`shlib_suffix`in j.config.variables&&j.config.variables.shlib_suffix===`dll.a`||`node_target_type`in j.config.variables&&j.config.variables.node_target_type===`shared_library`)?`-gnu`:`-msvc`}[j.platform]??``);if(i instanceof Ve){let e=yield*xt.String(`NAPI_RS_NATIVE_LIBRARY_PATH`).pipe(xt.withDefault(``)),t=j.platform===`darwin`?[`darwin-universal`,u]:[u],r=[...e?[e]:t.flatMap(e=>[`./oxlint.${e}.node`,`@oxlint/binding-${e}`]),`./oxlint.wasi.cjs`,`@oxlint/binding-wasm32-wasi`],i=yield*E.findFirst(r,e=>E.gen(function*(){let t=yield*s.resolve(o.join(n.oxlint,`dist`),e);return N.isNone(t)||!(yield*a.exists(t.value))?!1:e!==`./oxlint.wasi.cjs`||(yield*a.exists(o.join(n.oxlint,`dist`,`oxlint.wasm32-wasi.wasm`)))||(yield*a.exists(o.join(n.oxlint,`dist`,`oxlint.wasm32-wasi.debug.wasm`)))}));if(N.isNone(i))return gr(`Oxlint cannot resolve its installed native binding.`,[`Install the target project's optional dependencies for this platform, or restore its local binding.`])}if(r instanceof Te){let t=yield*Ce(e.cwd,`tsrs`),n=yield*xt.String(`TSRS_BINARY`).pipe(xt.withDefault(``)),i=`${c}${j.platform===`linux`?`-${l}`:``}`,s=N.isSome(t)&&!n?yield*Ce(t.value,`@tsrs/${i}`):N.none(),u=n===``?N.isSome(s)?o.join(s.value,j.platform===`win32`?`tsrs.exe`:`tsrs`):void 0:n;if(!(yield*a.exists(r.launcher))||u===void 0||!(yield*a.exists(u)))return gr(`Oxlint cannot resolve the installed tsrs binary or its launcher.`,[`Install the target project's optional dependencies for this platform, or restore TSRS_BINARY.`])}return[]}).pipe(E.catchTags({EffectBuildMissing:e=>E.succeed(gr(e.message,["Run `adamantite update` to align Oxlint, tsrs, and @effect/tsgo with supported builds."])),EffectPlatformUnsupported:e=>E.succeed(gr(e.message,["Lint on a platform that `@effect/tsgo` has builds for, or remove `@effect/tsgo` and the effect preset."])),NativeRuntimeConflict:e=>E.succeed(gr(e.message,[`Install at most one Oxlint plugin that replaces each native part of the Oxlint runtime.`])),PackageNotInstalled:e=>E.succeed(t(e.packageName)?gr(e.message,[`Install the target project's dependencies, then run Doctor again.`]):[])})):[]}),vr=`oxlint.config.ts`,yr=`.oxlintrc.json`,br=[{path:vr,type:`config`},{path:yr,type:`legacy_config`}],xr={config:vr,legacyConfigs:[yr]},Sr=`1.91.0`,Cr={antislop:{currentState:"`oxlint.config.ts` imports the retired `adamantite/lint/antislop` preset.",goal:["Replace `adamantite/lint/antislop` with `adamantite/lint/strict`. If strict is already imported, remove the antislop import and its `extends` entry.","Keep `anti-slop/*` rule settings, rule severity, rule options, and all other project settings. The rule namespace stays the same.",'strict sets `anti-slop/no-chained-type-assertions`, `anti-slop/no-widen-then-assert`, and `anti-slop/require-safety-comment-for-type-assertion` in an override for test files, which takes priority over top-level `rules`. Move a project setting for these three rules into an `overrides` entry with `files: ["**/*.{test,spec}.{ts,tsx,mts,cts}", "**/__tests__/**"]`.',"The strict preset also bans type assertions outside tests, console calls other than `console.info`, task comments, and deep destructuring, and it requires a reason on each suppression. Follow those reports when updating the code.","Use `--preset strict` in init commands. Run `adamantite check`, then run `adamantite doctor` again."],id:`strict-preset-migration`,integration:`oxlint`,title:`The antislop rules now belong to strict`},"react-doctor":{currentState:"`oxlint.config.ts` imports the retired `adamantite/lint/react-doctor` preset.",goal:["Replace `adamantite/lint/react-doctor` with `adamantite/lint/react-strict`. If react-strict is already imported, use its existing binding and remove the old import.","Keep the `react` preset and exactly one `react-strict` entry in extends. Keep `oxlint-plugin-react-doctor` as a devDependency. Run `adamantite update` if the package is missing or off its managed version.","Preserve project settings, custom rules, rule severity, and rule options, including `react-doctor/*` overrides. The upstream rule namespace stays the same.",`The react-strict preset also reports state, effect, and memoization hooks outside hook modules. Follow those reports when updating feature code.`,"Run `adamantite check`, then run Doctor again."],id:`react-doctor-preset-migration`,integration:`oxlint`,title:`React Doctor rules now belong to react-strict`},shadcn:{currentState:"`oxlint.config.ts` imports the removed `adamantite/lint/shadcn` preset.",goal:["Replace `adamantite/lint/shadcn` with `adamantite/lint/tailwind` in `oxlint.config.ts`. Keep the local import name and its `extends` entry.","Keep the managed `@shadcn/lint` package, `shadcn/*` rule names, `settings.shadcn` keys, rule severity, rule options, and all other project settings.","Use `--preset tailwind` in init commands. Run `adamantite check`, then run `adamantite doctor` again."],id:`tailwind-preset-migration`,integration:`oxlint`,title:`The shadcn preset was renamed to tailwind`}},wr=e=>Ht(e,`oxlint`,xr);var J=W({assess:e=>E.gen(function*(){let{cwd:n,lintConfig:r,packageJson:i}=e,a=t(i),o=yield*mr(e);if(!y(a,`oxlint`))return o.length===0?{applicable:!1}:{applicable:!0,findings:o,packageActions:[],warnings:[]};let s=yield*wr(n),c=yield*_r(e),l=Wt(e,{name:`oxlint`,version:Sr},`the managed lint scripts`,`oxlint`),u=s.active instanceof It?r.pipe(N.map(e=>Pn(e)),N.getOrUndefined):void 0,d=Cn(),f=je.flatMap(e=>On(r,e)?[Cr[e]]:[]);return{applicable:!0,findings:[...l.findings,...c,...f,...o,...Gt(s,{configContent:d,configFile:vr,inspection:u,toolName:`oxlint`})],packageActions:l.packageActions,warnings:[...l.warnings,...s.warnings]}}),check:or,config:vr,create:(e,t=[])=>E.gen(function*(){let n=yield*P.Path,r=Cn(t);yield*S(n.join(e,vr),r)}),detect:wr,files:br,fix:cr,kind:`tooling`,name:`oxlint`,version:Sr});function Tr(e){return{args:[...e.fix?[`--fix`]:[],...e.forwardedArguments],command:`sherif`,cwd:e.cwd,stdin:`inherit`,title:`๐Ÿ“ฆ Analyzing the monorepo`}}var Er={analyze:Tr,...qt({monorepoOnly:!0,name:`sherif`,purpose:"the managed `analyze` script in a monorepo",scripts:De(`sherif`),version:`1.13.0`})};const Dr=E.fn(`Toolchain.check`)(function*({allowWarnings:e=!1,cwd:t,files:n=[],forwardedArguments:r=[],only:i}){if(i===`format`&&e)return yield*new ze({reason:"`--allow-warnings` applies to the lint stage. Remove it or `--only format`."});let a=yield*Pt,o=i??`lint`,s={format:q.check({cwd:t,files:n,forwardedArguments:o===`format`?r:[]}),lint:J.check({allowWarnings:e,cwd:t,files:n,forwardedArguments:o===`lint`?r:[]})};yield*a.runAll(i===void 0?[s.format,s.lint]:[s[i]])}),Or=E.fn(`Toolchain.fix`)(function*({cwd:e,files:t=[],forwardedArguments:n=[],level:r=`safe`,only:i}){if(i===`format`&&r!==`safe`)return yield*new we({reason:"`--suggested`, `--dangerous`, and `--all` apply to the lint stage. Remove them or `--only format`."});let a=yield*Pt,o=O.dedupe(t),s=i??`lint`,c={format:q.fix({cwd:e,files:o,forwardedArguments:s===`format`?n:[]}),lint:J.fix({cwd:e,files:o,forwardedArguments:s===`lint`?n:[],level:r})};yield*a.runAll(i===void 0?[c.lint,c.format]:[c[i]])}),kr=E.fn(`Toolchain.analyze`)(function*({cwd:e,fix:t=!1,forwardedArguments:n=[],only:r,strict:i=!1}){let a=yield*Pt,o=yield*P.Path,s=r!==`unused`&&(yield*g(o.join(e,`package.json`)))&&(yield*Qe(e).pipe(E.catchTags({FailedToParseFile:()=>E.succeed(!1),InvalidPackageJson:()=>E.succeed(!1)})));if(r===`monorepo`){if(i)return yield*new xe({reason:"`--strict` applies to the unused stage. Remove it or `--only monorepo`."});if(!s)return yield*new xe({reason:"`--only monorepo` requires a monorepo. Run from the monorepo root, or use `--only unused` for a single-package project."})}let c=r??`unused`,l={monorepo:Er.analyze({cwd:e,fix:t,forwardedArguments:c===`monorepo`?n:[]}),unused:tr.analyze({cwd:e,fix:t,forwardedArguments:c===`unused`?n:[],strict:i})},u=r===void 0?[...s?[l.monorepo]:[],l.unused]:[l[r]];yield*(t?a.runUntilFailure(u):a.runAll(u)).pipe(E.mapError(e=>F.isTagged(e,`CliNotFound`)&&e.command===Er.name?new Ke({command:e.command,hint:"Run `adamantite update` to install it."}):e))}),Ar=M.Boolean(`fix`).pipe(M.withDefault(!1),M.withDescription(`Apply fixes in each selected stage`)),jr=M.Boolean(`strict`).pipe(M.withDefault(!1),M.withDescription(`Enable Knip's strict mode when checking unused code`)),Mr=M.Literals(`only`,[`monorepo`,`unused`]).pipe(M.optional,M.withDescription(`Run only monorepo (Sherif) or unused (Knip). Pass tool arguments after --`));var Nr=k.make(`analyze`,{fix:Ar,only:Mr,strict:jr}).pipe(k.withDescription(`Check monorepo consistency with Sherif and find unused code with Knip`),k.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run Knip from a specific directory`},{command:`adamantite analyze --only monorepo --fix -- --select highest`,description:`Fix monorepo issues and use the highest version when versions differ`}]),k.withHandler(({fix:e,only:t,strict:n})=>E.gen(function*(){yield*kr({cwd:j.cwd(),fix:e,forwardedArguments:yield*At,only:N.getOrUndefined(t),strict:n})})));const Pr=V.File(`files`,{mustExist:!0}).pipe(V.withDescription(`Files to check. Omit to check the project`),V.variadic()),Fr=M.Literals(`only`,[`format`,`lint`]).pipe(M.optional,M.withDescription(`Run only format (Oxfmt) or lint (Oxlint). Pass tool arguments after --`)),Ir=M.Boolean(`allow-warnings`).pipe(M.withDefault(!1),M.withDescription(`Allow the lint check to pass when Oxlint reports only warnings`));var Lr=k.make(`check`,{allowWarnings:Ir,files:Pr,only:Fr}).pipe(k.withDescription(`Check formatting, lint issues, and TypeScript types`),k.withHandler(({allowWarnings:e,files:t,only:n})=>E.gen(function*(){yield*Dr({allowWarnings:e,cwd:j.cwd(),files:t,forwardedArguments:yield*At,only:N.getOrUndefined(n)})})));function Rr(e,t){return e.replaceAll(/\{\{(\w+)\}\}/g,(e,n)=>Object.hasOwn(t,n)?t[n]??e:e)}function zr(e,t){return i.flatMap(n=>t.includes(n)?[{command:wt(e,n),name:n}]:[])}function Br(){return i.reduce((e,t)=>e.flatMap(e=>[e,[...e,t]]),[[]]).filter(e=>e.length>0)}function Vr(e){return i.some(t=>e.includes(t))}var Hr=class extends ct.Service()(`DependencyInstaller`){static layer=A.succeed(this)({addDevDependencies:E.fn(`DependencyInstaller.addDevDependencies`)((e,t,n)=>E.tryPromise({catch:t=>new Le({cause:t,packages:e}),try:()=>St(e,{...n,cwd:t})}).pipe(E.asVoid)),detectPackageManager:E.fn(`DependencyInstaller.detectPackageManager`)(e=>E.tryPromise({catch:e=>new me({cause:e}),try:()=>Ct(e)}).pipe(E.map(e=>e??null)))})};function Ur(e,t){return t&&e!==`npm`}const Wr=(e,t)=>E.gen(function*(){let n=yield*Hr,r=yield*Ne,[i,a]=yield*E.all([Qe(e),n.detectPackageManager(e)],{concurrency:`unbounded`});yield*n.addDevDependencies(t,e,{silent:!0,workspace:Ur(a?.name,i)}).pipe(E.ensuring(r.clearCache))});var Gr=class extends I.TaggedClass(`File`){},Kr=class extends I.TaggedClass(`Version`){};const qr=[`.node-version`,`.nvmrc`],Jr=z.Struct({volta:z.Struct({node:z.NonEmptyString})}),Yr=z.Struct({engines:z.Struct({node:z.NonEmptyString})}),Xr=z.Struct({name:z.NonEmptyString,version:z.NonEmptyString});function Zr(e){return e.split(`
22
- `).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function Qr(e){return z.is(Xr)(e)&&e.name.toLowerCase()===`node`}function $r(e){if(z.is(Jr)(e))return!0;if(F.isObject(e)&&F.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>Qr(e)))return!0}return z.is(Yr)(e)}const ei=[...qr.map(e=>new Gr({path:e})),new Gr({path:`.tool-versions`}),new Gr({path:`package.json`}),new Kr({value:`lts/*`})];var ti=class extends ct.Service()(`NodeVersionResolver`){static layer=A.effect(this,E.gen(function*(){let e=yield*R.FileSystem,t=yield*P.Path,n=(n,r)=>C(t.join(n,r)).pipe(E.provideService(R.FileSystem,e));return{resolve:E.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of qr){let r=yield*n(e,t);if(N.exists(r,e=>pt.isNonEmpty(e.trim())))return new Gr({path:t})}let r=yield*n(e,`.tool-versions`);if(N.exists(r,e=>Zr(e)))return new Gr({path:`.tool-versions`});let i=yield*n(e,`package.json`);return N.isSome(i)&&$r(yield*w(i.value,t.join(e,`package.json`)))?new Gr({path:`package.json`}):new Kr({value:`lts/*`})})}}))};function ni(e){return c.map(t=>{let[n,r]=wt(t,`script`).split(` `);return`${n}(?:\\s+(?!${r}\\b)\\S+)*\\s+${r}\\s+${e}`}).join(`|`)}const ri=new RegExp(String.raw`\b(?:${ni(`check`)})\b`),ii=z.Struct({jobs:z.Record(z.String,z.Struct({steps:z.optionalKey(z.Array(z.Struct({run:z.optionalKey(z.String),with:z.optionalKey(z.Struct({"node-version":z.optionalKey(z.Union([z.String,z.Finite]))}))}))),strategy:z.optionalKey(z.Struct({matrix:z.optionalKey(z.Unknown)}))}))}),ai=z.Struct({include:z.Array(z.Struct({command:z.optionalKey(z.String)}))}),oi=(e,t)=>E.try({catch:e=>new Me({cause:e,path:t}),try:()=>ht.parse(e)}).pipe(E.flatMap(e=>z.decodeUnknownEffect(ii)(e)),E.map(({jobs:e})=>{let t=Object.values(e),n=t.flatMap(e=>e.steps??[]),r=t.flatMap(e=>N.match(z.decodeUnknownOption(ai)(e.strategy?.matrix),{onNone:()=>[],onSome:({include:e})=>e.flatMap(e=>e.command??[])}));return{commands:[...n.flatMap(e=>e.run??[]),...r],nodeVersions:n.flatMap(e=>e.with?.[`node-version`]??[])}}),E.orElseSucceed(()=>({commands:[],nodeVersions:[]})));function si(e){return` - name: Setup Node.js
8
+ `}var or={check:nr,fix:rr,...Yt({configContent:ar,configFiles:{config:`oxfmt.config.ts`,legacyConfigs:[`.oxfmtrc.json`,`.oxfmtrc.jsonc`]},inspectConfig:ir,name:`oxfmt`,purpose:"the managed `check` and `fix` scripts",scripts:Oe(`oxfmt`),version:`0.76.0`,workspace:({isMonorepo:e})=>({isMonorepo:e})})};function sr(e){let t=tt(e.cwd),n=e.forwardedArguments.some(e=>e===`--deny-warnings`||e.startsWith(`--max-warnings`)),r=e.allowWarnings||n?[]:[`--deny-warnings`];return{...t,args:[...t.args,...e.files,...r,...e.forwardedArguments],title:`๐Ÿ” Linting`}}const cr={all:[`--fix-suggestions`,`--fix-dangerously`],dangerous:[`--fix-dangerously`],safe:[],suggested:[`--fix-suggestions`]};function lr(e){let t=tt(e.cwd);return{...t,args:[...t.args,`--fix`,...cr[e.level],...e.files,...e.forwardedArguments],title:`๐Ÿ”ง Fixing lint issues`}}const ur=z.decodeUnknownOption(z.Struct({header:z.Struct({glibcVersionRuntime:z.optional(z.String)}),sharedObjects:z.Array(z.String)}));function dr(e,t){return[{currentState:e,goal:t,id:`unavailable-oxlint-runtime`,integration:`oxlint`,notes:["Verification: run `adamantite check --only lint` after the repair."],title:`Oxlint runtime unavailable`}]}const fr=T.fn(`assessOxlintRuntime`)(function*(e){let t=t=>e.packageJson.devDependencies?.[t]??e.packageJson.dependencies?.[t];return t(`oxlint`)?yield*T.gen(function*(){let n=yield*fe(e.cwd),{backend:r,binding:i}=n;if(t(`tsrs`)&&r instanceof Ke)return dr(`Oxlint cannot resolve the declared tsrs backend or its launcher.`,[`Install the target project's dependencies so that the tsrs-lint launcher is available.`]);for(let n of We)if(n.runtime instanceof Se&&t(n.name)){let t=yield*we(e.cwd,n.name);if(M.isNone(t))return yield*new ie({packageName:n.name,project:e.cwd})}if(i instanceof Ie&&!(r instanceof Ee))return[];let a=yield*R.FileSystem,o=yield*P.Path,s=yield*Pe,c=`${A.platform}-${A.arch}`,l=`gnu`;if(A.platform===`linux`){let e=yield*C(`/usr/bin/ldd`),t=M.isNone(e)?ur(A.report.getReport()):M.none();l=(M.isSome(e)?e.value.includes(`musl`):M.isSome(t)&&!t.value.header.glibcVersionRuntime&&t.value.sharedObjects.some(e=>e.includes(`libc.musl-`)||e.includes(`ld-musl-`)))?`musl`:`gnu`}let u=c+({android:A.arch===`arm`?`-eabi`:``,linux:`-${l}${A.arch===`arm`?`eabihf`:``}`,win32:A.arch===`x64`&&(`shlib_suffix`in A.config.variables&&A.config.variables.shlib_suffix===`dll.a`||`node_target_type`in A.config.variables&&A.config.variables.node_target_type===`shared_library`)?`-gnu`:`-msvc`}[A.platform]??``);if(i instanceof He){let e=yield*xt.String(`NAPI_RS_NATIVE_LIBRARY_PATH`).pipe(xt.withDefault(``)),t=A.platform===`darwin`?[`darwin-universal`,u]:[u],r=[...e?[e]:t.flatMap(e=>[`./oxlint.${e}.node`,`@oxlint/binding-${e}`]),`./oxlint.wasi.cjs`,`@oxlint/binding-wasm32-wasi`],i=yield*T.findFirst(r,e=>T.gen(function*(){let t=yield*s.resolve(o.join(n.oxlint,`dist`),e);return M.isNone(t)||!(yield*a.exists(t.value))?!1:e!==`./oxlint.wasi.cjs`||(yield*a.exists(o.join(n.oxlint,`dist`,`oxlint.wasm32-wasi.wasm`)))||(yield*a.exists(o.join(n.oxlint,`dist`,`oxlint.wasm32-wasi.debug.wasm`)))}));if(M.isNone(i))return dr(`Oxlint cannot resolve its installed native binding.`,[`Install the target project's optional dependencies for this platform, or restore its local binding.`])}if(r instanceof Ee){let t=yield*we(e.cwd,`tsrs`),n=yield*xt.String(`TSRS_BINARY`).pipe(xt.withDefault(``)),i=`${c}${A.platform===`linux`?`-${l}`:``}`,s=M.isSome(t)&&!n?yield*we(t.value,`@tsrs/${i}`):M.none(),u=n===``?M.isSome(s)?o.join(s.value,A.platform===`win32`?`tsrs.exe`:`tsrs`):void 0:n;if(!(yield*a.exists(r.launcher))||u===void 0||!(yield*a.exists(u)))return dr(`Oxlint cannot resolve the installed tsrs binary or its launcher.`,[`Install the target project's optional dependencies for this platform, or restore TSRS_BINARY.`])}return[]}).pipe(T.catchTags({EffectBuildMissing:e=>T.succeed(dr(e.message,["Run `adamantite update` to align Oxlint, tsrs, and @effect/tsgo with supported builds."])),EffectPlatformUnsupported:e=>T.succeed(dr(e.message,["Lint on a platform that `@effect/tsgo` has builds for, or remove `@effect/tsgo` and the effect preset."])),NativeRuntimeConflict:e=>T.succeed(dr(e.message,[`Install at most one Oxlint plugin that replaces each native part of the Oxlint runtime.`])),PackageNotInstalled:e=>T.succeed(t(e.packageName)?dr(e.message,[`Install the target project's dependencies, then run Doctor again.`]):[])})):[]}),pr=`oxlint.config.ts`,mr=`.oxlintrc.json`,hr=[{path:pr,type:`config`},{path:mr,type:`legacy_config`}],gr={config:pr,legacyConfigs:[mr]},_r=`1.91.0`,vr={antislop:{currentState:"`oxlint.config.ts` imports the retired `adamantite/lint/antislop` preset.",goal:["Replace `adamantite/lint/antislop` with `adamantite/lint/strict`. If strict is already imported, remove the antislop import and its `extends` entry.","Keep `anti-slop/*` rule settings, rule severity, rule options, and all other project settings. The rule namespace stays the same.",'strict sets `anti-slop/no-chained-type-assertions`, `anti-slop/no-widen-then-assert`, and `anti-slop/require-safety-comment-for-type-assertion` in an override for test files, which takes priority over top-level `rules`. Move a project setting for these three rules into an `overrides` entry with `files: ["**/*.{test,spec}.{ts,tsx,mts,cts}", "**/__tests__/**"]`.',"The strict preset also bans type assertions outside tests, console calls other than `console.info`, task comments, and deep destructuring, and it requires a reason on each suppression. Follow those reports when updating the code.","Use `--preset strict` in init commands. Run `adamantite check`, then run `adamantite doctor` again."],id:`strict-preset-migration`,integration:`oxlint`,title:`The antislop rules now belong to strict`},"react-doctor":{currentState:"`oxlint.config.ts` imports the retired `adamantite/lint/react-doctor` preset.",goal:["Replace `adamantite/lint/react-doctor` with `adamantite/lint/react-strict`. If react-strict is already imported, use its existing binding and remove the old import.","Keep the `react` preset and exactly one `react-strict` entry in extends. Keep `oxlint-plugin-react-doctor` as a devDependency. Run `adamantite update` if the package is missing or off its managed version.","Preserve project settings, custom rules, rule severity, and rule options, including `react-doctor/*` overrides. The upstream rule namespace stays the same.",`The react-strict preset also reports state, effect, and memoization hooks outside hook modules. Follow those reports when updating feature code.`,"Run `adamantite check`, then run Doctor again."],id:`react-doctor-preset-migration`,integration:`oxlint`,title:`React Doctor rules now belong to react-strict`},shadcn:{currentState:"`oxlint.config.ts` imports the removed `adamantite/lint/shadcn` preset.",goal:["Replace `adamantite/lint/shadcn` with `adamantite/lint/tailwind` in `oxlint.config.ts`. Keep the local import name and its `extends` entry.","Keep the managed `@shadcn/lint` package, `shadcn/*` rule names, `settings.shadcn` keys, rule severity, rule options, and all other project settings.","Use `--preset tailwind` in init commands. Run `adamantite check`, then run `adamantite doctor` again."],id:`tailwind-preset-migration`,integration:`oxlint`,title:`The shadcn preset was renamed to tailwind`}},yr=e=>Ht(e,`oxlint`,gr);var br=G({assess:e=>T.gen(function*(){let{cwd:n,lintConfig:r,packageJson:i}=e,a=t(i);if(!y(a,`oxlint`))return{applicable:!1};let o=yield*yr(n),s=yield*fr(e),c=Wt(e,{name:`oxlint`,version:_r},`the managed lint scripts`,`oxlint`),l=o.active instanceof It?r.pipe(M.map(e=>Pn(e)),M.getOrUndefined):void 0,u=Cn(),d=Me.flatMap(e=>On(r,e)?[vr[e]]:[]);return{applicable:!0,findings:[...c.findings,...s,...d,...Gt(o,{configContent:u,configFile:pr,inspection:l,toolName:`oxlint`})],packageActions:c.packageActions,warnings:[...c.warnings,...o.warnings]}}),check:sr,config:pr,create:(e,t=[])=>T.gen(function*(){let n=yield*P.Path,r=Cn(t);yield*S(n.join(e,pr),r)}),detect:yr,files:hr,fix:lr,kind:`tooling`,name:`oxlint`,version:_r});function xr(e){return{args:[...e.fix?[`--fix`]:[],...e.forwardedArguments],command:`sherif`,cwd:e.cwd,stdin:`inherit`,title:`๐Ÿ“ฆ Analyzing the monorepo`}}var Sr={analyze:xr,...qt({monorepoOnly:!0,name:`sherif`,purpose:"the managed `analyze` script in a monorepo",scripts:Oe(`sherif`),version:`1.13.0`})};const Cr=T.fn(`Toolchain.check`)(function*({allowWarnings:e=!1,cwd:t,files:n=[],forwardedArguments:r=[],only:i}){if(i===`format`&&e)return yield*new Be({reason:"`--allow-warnings` applies to the lint stage. Remove it or `--only format`."});let a=yield*Pt,o=i??`lint`,s={format:or.check({cwd:t,files:n,forwardedArguments:o===`format`?r:[]}),lint:br.check({allowWarnings:e,cwd:t,files:n,forwardedArguments:o===`lint`?r:[]})};yield*a.runAll(i===void 0?[s.format,s.lint]:[s[i]])}),wr=T.fn(`Toolchain.fix`)(function*({cwd:e,files:t=[],forwardedArguments:n=[],level:r=`safe`,only:i}){if(i===`format`&&r!==`safe`)return yield*new Te({reason:"`--suggested`, `--dangerous`, and `--all` apply to the lint stage. Remove them or `--only format`."});let a=yield*Pt,o=D.dedupe(t),s=i??`lint`,c={format:or.fix({cwd:e,files:o,forwardedArguments:s===`format`?n:[]}),lint:br.fix({cwd:e,files:o,forwardedArguments:s===`lint`?n:[],level:r})};yield*a.runAll(i===void 0?[c.lint,c.format]:[c[i]])}),Tr=T.fn(`Toolchain.analyze`)(function*({cwd:e,fix:t=!1,forwardedArguments:n=[],only:r,strict:i=!1}){let a=yield*Pt,o=yield*P.Path,s=r!==`unused`&&(yield*g(o.join(e,`package.json`)))&&(yield*$e(e).pipe(T.catchTags({FailedToParseFile:()=>T.succeed(!1),InvalidPackageJson:()=>T.succeed(!1)})));if(r===`monorepo`){if(i)return yield*new xe({reason:"`--strict` applies to the unused stage. Remove it or `--only monorepo`."});if(!s)return yield*new xe({reason:"`--only monorepo` requires a monorepo. Run from the monorepo root, or use `--only unused` for a single-package project."})}let c=r??`unused`,l={monorepo:Sr.analyze({cwd:e,fix:t,forwardedArguments:c===`monorepo`?n:[]}),unused:tr.analyze({cwd:e,fix:t,forwardedArguments:c===`unused`?n:[],strict:i})},u=r===void 0?[...s?[l.monorepo]:[],l.unused]:[l[r]];yield*(t?a.runUntilFailure(u):a.runAll(u)).pipe(T.mapError(e=>F.isTagged(e,`CliNotFound`)&&e.command===Sr.name?new qe({command:e.command,hint:"Run `adamantite update` to install it."}):e))}),Er=j.Boolean(`fix`).pipe(j.withDefault(!1),j.withDescription(`Apply fixes in each selected stage`)),Dr=j.Boolean(`strict`).pipe(j.withDefault(!1),j.withDescription(`Enable Knip's strict mode when checking unused code`)),Or=j.Literals(`only`,[`monorepo`,`unused`]).pipe(j.optional,j.withDescription(`Run only monorepo (Sherif) or unused (Knip). Pass tool arguments after --`));var kr=O.make(`analyze`,{fix:Er,only:Or,strict:Dr}).pipe(O.withDescription(`Check monorepo consistency with Sherif and find unused code with Knip`),O.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run Knip from a specific directory`},{command:`adamantite analyze --only monorepo --fix -- --select highest`,description:`Fix monorepo issues and use the highest version when versions differ`}]),O.withHandler(({fix:e,only:t,strict:n})=>T.gen(function*(){yield*Tr({cwd:A.cwd(),fix:e,forwardedArguments:yield*At,only:M.getOrUndefined(t),strict:n})})));const Ar=V.File(`files`,{mustExist:!0}).pipe(V.withDescription(`Files to check. Omit to check the project`),V.variadic()),jr=j.Literals(`only`,[`format`,`lint`]).pipe(j.optional,j.withDescription(`Run only format (Oxfmt) or lint (Oxlint). Pass tool arguments after --`)),Mr=j.Boolean(`allow-warnings`).pipe(j.withDefault(!1),j.withDescription(`Allow the lint check to pass when Oxlint reports only warnings`));var Nr=O.make(`check`,{allowWarnings:Mr,files:Ar,only:jr}).pipe(O.withDescription(`Check formatting, lint issues, and TypeScript types`),O.withHandler(({allowWarnings:e,files:t,only:n})=>T.gen(function*(){yield*Cr({allowWarnings:e,cwd:A.cwd(),files:t,forwardedArguments:yield*At,only:M.getOrUndefined(n)})})));const Pr=`# ADAMANTITE:START`,Fr=`# ADAMANTITE:END`;var Ir=class extends I.TaggedClass(`Block`){},Lr=class extends I.TaggedClass(`None`){},Rr=class extends I.TaggedClass(`Malformed`){};function zr(e,t){return e.flatMap((e,n)=>e.trim()===t?[n]:[])}function Br(e){let t=e.split(`
9
+ `),n=zr(t,Pr),r=zr(t,Fr),[i]=n,[a]=r;return i===void 0&&a===void 0?new Lr:n.length>1||r.length>1?new Rr({reason:`It has more than one \`${Pr}\` or \`${Fr}\` comment.`}):a===void 0||i!==void 0&&a<i?new Rr({reason:`It has \`${Pr}\` without \`${Fr}\` after it.`}):i===void 0?new Rr({reason:`It has \`${Fr}\` without \`${Pr}\` before it.`}):new Ir({after:t.slice(a).join(`
10
+ `),before:t.slice(0,i+1).join(`
11
+ `),body:t.slice(i+1,a).join(`
12
+ `)})}function Vr(e,t){return[e.before,...t===``?[]:[t],e.after].join(`
13
+ `)}function Hr(e,t){return e.replaceAll(/\{\{(\w+)\}\}/g,(e,n)=>Object.hasOwn(t,n)?t[n]??e:e)}function Ur(e,t){return i.flatMap(n=>t.includes(n)?[{command:Tt(e,n),name:n}]:[])}function Wr(){return i.reduce((e,t)=>e.flatMap(e=>[e,[...e,t]]),[[]]).filter(e=>e.length>0)}function Gr(e){return i.some(t=>e.includes(t))}var Kr=class extends N.Service()(`DependencyInstaller`){static layer=k.succeed(this)({addDevDependencies:T.fn(`DependencyInstaller.addDevDependencies`)((e,t,n)=>T.tryPromise({catch:t=>new Re({cause:t,packages:e}),try:()=>Ct(e,{...n,cwd:t})}).pipe(T.asVoid)),detectPackageManager:T.fn(`DependencyInstaller.detectPackageManager`)(e=>T.tryPromise({catch:e=>new me({cause:e}),try:()=>wt(e)}).pipe(T.map(e=>e??null)))})};function qr(e,t){return t&&e!==`npm`}const Jr=(e,t)=>T.gen(function*(){let n=yield*Kr,r=yield*Pe,[i,a]=yield*T.all([$e(e),n.detectPackageManager(e)],{concurrency:`unbounded`});yield*n.addDevDependencies(t,e,{silent:!0,workspace:qr(a?.name,i)}).pipe(T.ensuring(r.clearCache))});var Yr=class extends I.TaggedClass(`File`){},Xr=class extends I.TaggedClass(`Version`){};const Zr=[`.node-version`,`.nvmrc`],Qr=z.Struct({volta:z.Struct({node:z.NonEmptyString})}),$r=z.Struct({engines:z.Struct({node:z.NonEmptyString})}),ei=z.Struct({name:z.NonEmptyString,version:z.NonEmptyString});function ti(e){return e.split(`
14
+ `).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function ni(e){return z.is(ei)(e)&&e.name.toLowerCase()===`node`}function ri(e){if(z.is(Qr)(e))return!0;if(F.isObject(e)&&F.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>ni(e)))return!0}return z.is($r)(e)}const ii=[...Zr.map(e=>new Yr({path:e})),new Yr({path:`.tool-versions`}),new Yr({path:`package.json`}),new Xr({value:`lts/*`})];var ai=class extends N.Service()(`NodeVersionResolver`){static layer=k.effect(this,T.gen(function*(){let e=yield*R.FileSystem,t=yield*P.Path,n=(n,r)=>C(t.join(n,r)).pipe(T.provideService(R.FileSystem,e));return{resolve:T.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of Zr){let r=yield*n(e,t);if(M.exists(r,e=>pt.isNonEmpty(e.trim())))return new Yr({path:t})}let r=yield*n(e,`.tool-versions`);if(M.exists(r,e=>ti(e)))return new Yr({path:`.tool-versions`});let i=yield*n(e,`package.json`);return M.isSome(i)&&ri(yield*w(i.value,t.join(e,`package.json`)))?new Yr({path:`package.json`}):new Xr({value:`lts/*`})})}}))};function oi(e){return c.map(t=>{let[n,r]=Tt(t,`script`).split(` `);return`${n}(?:\\s+(?!${r}\\b)\\S+)*\\s+${r}\\s+${e}`}).join(`|`)}const si=new RegExp(String.raw`\b(?:${oi(`check`)})\b`),ci=`.github/workflows`,li=[{path:`${ci}/adamantite.yml`,type:`ci`}],ui=z.Struct({steps:z.optionalKey(z.Array(z.Struct({run:z.optionalKey(z.String),with:z.optionalKey(z.Struct({"node-version":z.optionalKey(z.Union([z.String,z.Finite]))}))}))),strategy:z.optionalKey(z.Struct({matrix:z.optionalKey(z.Unknown)}))}),di=z.Struct({jobs:z.Record(z.String,ui)}),fi=z.Struct({include:z.Array(z.Struct({command:z.optionalKey(z.String)}))});var pi=class extends I.TaggedClass(`Missing`){},mi=class extends I.TaggedClass(`Managed`){},hi=class extends I.TaggedClass(`Legacy`){},gi=class extends I.TaggedClass(`Malformed`){};const _i=(e,t)=>T.try({catch:e=>new Ne({cause:e,path:t}),try:()=>ht.parse(e)}),vi=(e,t)=>_i(e,t).pipe(T.flatMap(e=>z.decodeUnknownEffect(di)(e)),T.map(({jobs:e})=>Object.values(e)),T.option),yi=z.Struct({jobs:z.NullOr(z.Record(z.String,z.Unknown))}),bi=(e,t)=>_i(e,t).pipe(T.flatMap(e=>z.decodeUnknownEffect(yi)(e)),T.map(({jobs:e})=>e??{})),xi=(e,t)=>T.gen(function*(){let n=e.before.replaceAll(`\r`,``),r=yield*bi(n,t),i=yield*bi(`${n}\n${e.body.replaceAll(`\r`,``)}`,t);return yield*z.decodeUnknownEffect(z.Array(ui))(Object.entries(i).flatMap(([e,t])=>_t.has(r,e)?[]:[t]))}).pipe(T.option),Si=e=>T.gen(function*(){let t=yield*P.Path,n=yield*rt(t.join(e,ci)),r=D.sort(M.getOrElse(n,()=>[]).filter(e=>/\.ya?ml$/u.test(e)),B.String).map(e=>`${ci}/${e}`),i=D.getSomes(yield*T.forEach(r,n=>f(t.join(e,n)).pipe(T.map(e=>M.map(e,e=>({block:Br(e),content:e,path:n})))))),[a]=i.flatMap(({block:e,path:t})=>e instanceof Rr?[{path:t,reason:e.reason}]:[]);if(a)return new gi({paths:[a.path],reason:a.reason});let o=i.flatMap(({block:e,path:t})=>e instanceof Ir?[{block:e,path:t}]:[]);if(o.length>1)return new gi({paths:o.map(e=>e.path),reason:`More than one workflow file has a managed block.`});let[s]=o;if(s){let n=yield*xi(s.block,t.join(e,s.path));return M.match(n,{onNone:()=>new gi({paths:[s.path],reason:`The jobs between the markers do not parse as workflow jobs.`}),onSome:e=>new mi({block:s.block,jobs:e,path:s.path})})}let c=i.find(e=>e.path===li[0].path);if(c){let n=yield*vi(c.content,t.join(e,c.path));return new hi({content:c.content,jobs:M.getOrElse(n,()=>[]),path:c.path})}return new pi});function Ci(e){let t=e.flatMap(e=>e.steps??[]),n=e.flatMap(e=>M.match(z.decodeUnknownOption(fi)(e.strategy?.matrix),{onNone:()=>[],onSome:({include:e})=>e.flatMap(e=>e.command??[])}));return{commands:[...t.flatMap(e=>e.run??[]),...n],nodeVersions:t.flatMap(e=>e.with?.[`node-version`]??[])}}function wi(e){return` - name: Setup Node.js
23
15
  uses: actions/setup-node@v7
24
16
  with:
25
- ${e instanceof Gr?`node-version-file: "${e.path}"`:`node-version: "${e.value}"`}`}function ci(e){return{bun:`${si(e)}
17
+ ${e instanceof Yr?`node-version-file: "${e.path}"`:`node-version: "${e.value}"`}`}function Ti(e){return{bun:`${wi(e)}
26
18
 
27
19
  - name: Setup Bun
28
20
  uses: oven-sh/setup-bun@v2
@@ -42,22 +34,23 @@ export default defineConfig(format)
42
34
  uses: denoland/setup-deno@v2
43
35
 
44
36
  - name: Install dependencies
45
- run: deno install --frozen`,npm:`${si(e)}
37
+ run: deno install --frozen`,npm:`${wi(e)}
46
38
  cache: "npm"
47
39
 
48
40
  - name: Install dependencies
49
41
  run: npm ci`,pnpm:` - name: Setup pnpm
50
42
  uses: pnpm/action-setup@v6
51
43
 
52
- ${si(e)}
44
+ ${wi(e)}
53
45
  cache: "pnpm"
54
46
 
55
47
  - name: Install dependencies
56
- run: pnpm install --frozen-lockfile`,yarn:`${si(e)}
48
+ run: pnpm install --frozen-lockfile`,yarn:`${wi(e)}
57
49
  cache: "yarn"
58
50
 
59
51
  - name: Install dependencies
60
- run: yarn install --frozen-lockfile`}}function li({packageManager:e,scripts:t},n){let r=zr(e,t);return r.length===0?null:Rr(`name: adamantite
52
+ run: yarn install --frozen-lockfile`}}function Ei({packageManager:e,scripts:t},n){let r=Ur(e,t);if(r.length===0)return null;let i=r.map(e=>` - name: ${e.name}\n command: ${e.command}`).join(`
53
+ `);return Hr(`name: adamantite
61
54
 
62
55
  on:
63
56
  push:
@@ -74,6 +67,7 @@ concurrency:
74
67
  cancel-in-progress: true
75
68
 
76
69
  jobs:
70
+ {{start}}
77
71
  verify:
78
72
  name: \${{ matrix.name }}
79
73
  runs-on: ubuntu-latest
@@ -92,19 +86,23 @@ jobs:
92
86
 
93
87
  - name: Run \${{ matrix.name }}
94
88
  run: \${{ matrix.command }}
95
- `,{matrix:r.map(e=>` - name: ${e.name}\n command: ${e.command}`).join(`
96
- `),setup:ci(n)[e]})}function ui(e){return e.replaceAll(`\r
89
+ {{end}}
90
+ `,{end:Fr,matrix:i,setup:Ti(n)[e],start:Pr})}function Di(e){let t=Br(e);if(!(t instanceof Ir))throw TypeError(`The GitHub Actions workflow template has no managed block.`);return t.body}function Oi(){return ii.flatMap(e=>_t.keys(Ti(e)).flatMap(t=>Wr().flatMap(n=>Ei({packageManager:t,scripts:n},e)??[])))}function ki(e){return e.replaceAll(`\r
97
91
  `,`
98
- `).trimEnd()}function di(e){let t=ui(e);return ei.some(e=>_t.keys(ci(e)).some(n=>Br().some(r=>ui(li({packageManager:n,scripts:r},e)??``)===t)))}const fi=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],pi=(e,t)=>E.gen(function*(){let n=yield*P.Path,r=yield*ti,i=n.join(e,fi[0].path),a=li(t,yield*r.resolve(e));a&&(yield*S(i,a))});var mi=W({assess:({cwd:e,packageJson:n})=>E.gen(function*(){let r=(yield*P.Path).join(e,fi[0].path),i=yield*C(r);if(N.isNone(i))return{applicable:!1};let a=t(n),s=yield*oi(i.value,r),c=s.nodeVersions.some(e=>/^\d/.test(String(e))),l=a.includes(`check`)&&!s.commands.some(e=>ri.test(e));if(!c&&!l)return{applicable:!0,findings:[],packageActions:[],warnings:[]};if(!Vr(a))return{applicable:!0,findings:[],packageActions:[],warnings:[`No CI-compatible managed scripts were found, so the GitHub Actions workflow cannot be regenerated.`]};let u=yield*(yield*Hr).detectPackageManager(e);return u?o(u.name)?{applicable:!0,findings:[{currentState:[...c?[`The workflow contains a hard-coded Node.js version.`]:[],...l?["The workflow does not run the managed `check` script."]:[]].join(` `),goal:[...a.includes(`check`)?["Make the workflow run the managed `check` script."]:[],`Use the project's Node.js version declaration instead of a hard-coded version.`],id:`outdated-adamantite-workflow`,integration:`github`,notes:[`The detected package manager is \`${u.name}\`. Preserve unrelated workflow jobs and project-specific settings.`],title:`Outdated Adamantite workflow`}],packageActions:[],warnings:[]}:{applicable:!0,findings:[],packageActions:[],warnings:[`\`${u.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow cannot be regenerated.`]}:{applicable:!0,findings:[],packageActions:[],warnings:[`Could not detect a package manager, so the GitHub Actions workflow cannot be regenerated.`]}}),create:(e,t)=>E.gen(function*(){let n=yield*P.Path;yield*x(n.dirname(n.join(e,fi[0].path))),yield*pi(e,t)}),detect:e=>E.gen(function*(){let t=yield*R.FileSystem,n=yield*P.Path;return yield*t.exists(n.join(e,fi[0].path))}),files:fi,kind:`ci`,name:`github`,update:(e,t)=>E.gen(function*(){let n=yield*P.Path,r=yield*C(n.join(e,fi[0].path));return N.isSome(r)&&!di(r.value)?`kept`:(yield*pi(e,t),`updated`)})});const Y={agents:`agents`,editor:`editor`,nonInteractive:`non-interactive`,preset:`preset`,script:`script`};function hi({agents:e=!1,editors:t=[],presets:n=[],scripts:r}){return[`adamantite init`,`--${Y.nonInteractive}`,...r.map(e=>`--${Y.script} ${e}`),...n.map(e=>`--${Y.preset} ${e}`),...t.map(e=>`--${Y.editor} ${e}`),...e?[`--${Y.agents}`]:[]].join(` `)}const gi=hi({editors:[`vscode`],scripts:[`check`]}),_i=`node_modules/.cache/adamantite/effect`,vi=`adamantite-sdk.json`,yi=z.Struct({gitHead:z.NonEmptyString,version:z.NonEmptyString}),bi=E.fn(`findNativeTypescript`)(function*(e){for(let t of[`typescript`,`@typescript/native`]){let n=yield*Ce(e,t);if(N.isSome(n)){let e=yield*u(n.value);if(Number(e.version?.split(`.`)[0])>=7)return z.decodeUnknownOption(yi)(e)}}return N.none()}),xi=E.fn(`resolveSdkSource`)(function*(e,t,n){let i=yield*P.Path,a=yield*R.FileSystem,o=yield*bi(e);if(N.isNone(o))return yield*new pe({reason:`The Effect editor SDK needs an installed native TypeScript package with its gitHead. Install TypeScript 7 or later, then run \`${gi}\`.`});let{gitHead:s,version:c}=o.value,l=`${j.platform}-${j.arch}`,u=yield*Ce(t,`@effect/tsgo-${l}`);if(N.isNone(u))return yield*new pe({reason:`The Effect editor SDK cannot find \`@effect/tsgo-${l}\`. Install the optional dependencies on a supported platform.`});let d=i.join(u.value,`lib`,`upstream.json`),f=yield*w(yield*r(d),d),p=h(f)&&f.components,m=h(p)&&p.typescript,g=h(f)&&f.tags,_=h(g)&&g.typescript;if(!h(f)||f.schemaVersion!==5||!h(m)||!h(_))return yield*new Pe({path:d});let v=j.platform===`win32`?`tsc.exe`:`tsc`;for(let[e,t]of Object.entries(m)){if(!h(t)||t.gitHead!==s)continue;let r=e===_.latest?i.join(u.value,`lib`):i.join(u.value,`artifacts`,`typescript`,e);if((yield*a.exists(i.join(r,v)))&&(yield*a.exists(i.join(r,`lib.d.ts`))))return{effectVersion:n,executable:v,gitHead:s,platform:l,source:r,typescriptVersion:c}}return yield*new pe({reason:`@effect/tsgo ${n} has no editor compiler matching TypeScript ${c} (${s}). Install a supported TypeScript version, then run \`${gi}\`.`})}),Si=E.fn(`sdkIsCurrent`)(function*(e,t){let n=yield*P.Path,r=yield*R.FileSystem,i=n.join(e,_i),a=n.join(i,vi),o=yield*C(a);if(N.isNone(o))return!1;let s=yield*w(o.value,a).pipe(E.catchTag(`FailedToParseFile`,()=>E.succeed(null)));if(!h(s)||!Object.entries(t).every(([e,t])=>s[e]===t))return!1;let c=yield*r.readDirectory(t.source);return(yield*E.forEach(c.filter(e=>e===t.executable||e.endsWith(`.d.ts`)),e=>r.exists(n.join(i,e)))).every(Boolean)}),Ci=E.fn(`readEffectEditor`)(function*(e){let t=yield*Ce(e,`@effect/tsgo`);if(N.isNone(t))return N.none();let n=yield*P.Path,i=yield*u(t.value),a=n.join(t.value,`oxlint-schema.json`),o=yield*w(yield*r(a),a),s=h(o)&&o.definitions,c=h(s)&&s.DummyRuleMap,l=h(c)&&c.properties;if(!h(l))return yield*new Pe({path:a});let d=Object.fromEntries(Object.keys(l).filter(e=>e.startsWith(`effecttsgo/`)).map(e=>[e,{severity:`off`}])),f=xi(e,t.value,i.version??`unknown`);return N.some({prepareSdk:E.gen(function*(){let t=yield*f;if(yield*Si(e,t))return;let r=yield*R.FileSystem,i=n.join(e,_i);yield*r.remove(i,{force:!0,recursive:!0}),yield*r.makeDirectory(n.dirname(i),{recursive:!0}),yield*r.copy(t.source,i),yield*se(n.join(i,vi),t)}),rulesCustomization:d,sdkIsCurrent:f.pipe(E.flatMap(t=>Si(e,t)))})}),X=[{path:`.vscode/settings.json`,type:`config`}],wi={"[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.path.oxlint":ue,"oxc.typeAware":!0};var Ti=W({assess:({cwd:e})=>E.gen(function*(){let t=(yield*P.Path).join(e,X[0].path),n=yield*C(t);if(N.isNone(n))return{applicable:!1};let r=yield*w(n.value,t);if(!h(r))return yield*new Pe({path:t});let i=r[`oxc.path.oxlint`],a=wi[`oxc.path.oxlint`],o=i===a?[]:[{currentState:`\`${X[0].path}\` sets \`oxc.path.oxlint\` to ${i===void 0?`no value`:`\`${yield*ce(i)}\``}. VS Code does not start Oxlint through Adamantite's Oxlint entry.`,goal:[`Set \`oxc.path.oxlint\` to \`${a}\` in \`${X[0].path}\`. Preserve every other setting.`],id:`vscode-oxlint-entry`,integration:`vscode`,reference:{content:`${yield*Be({"oxc.path.oxlint":a})}\n`,language:`json`},title:`VS Code does not use the Oxlint entry`}],s=yield*Ci(e);if(N.isSome(s)){let e=r[`oxc.lint.customization`],t=h(e)&&Object.keys(s.value.rulesCustomization).every(t=>{let n=e[t];return h(n)&&n.severity===`off`});(r[`js/ts.tsdk.path`]!==`node_modules/.cache/adamantite/effect`||!t)&&o.push({currentState:`\`${X[0].path}\` does not select the Effect editor SDK with duplicate Oxlint Effect reports hidden.`,goal:[`Set \`js/ts.tsdk.path\` to \`${_i}\` and merge the reference \`oxc.lint.customization\` entries. Preserve other settings and rule customizations.`],id:`vscode-effect-server`,integration:`vscode`,reference:{content:`${yield*Be({"js/ts.tsdk.path":_i,"oxc.lint.customization":s.value.rulesCustomization})}\n`,language:`json`},title:`VS Code does not use the Effect language server`});let n=yield*s.value.sdkIsCurrent.pipe(E.map(e=>e?void 0:`\`${_i}\` is missing or does not match the installed Effect compiler.`),E.catchTag(`EffectEditorUnavailable`,e=>E.succeed(e.message)));n!==void 0&&o.push({currentState:n,goal:[`Install a supported native TypeScript version and the Effect optional dependencies. Run \`${hi({editors:[`vscode`],scripts:[`check`]})}\` to prepare the SDK cache, then restart the TypeScript server.`],id:`vscode-effect-sdk`,integration:`vscode`,title:`The Effect editor SDK needs preparation`})}return{applicable:!0,findings:o,packageActions:[],warnings:[]}}),config:X[0].path,create:e=>E.gen(function*(){let t=yield*P.Path,n=t.join(e,X[0].path),r=yield*Ci(e),i=N.isSome(r)?{...wi,"js/ts.tsdk.path":_i,"oxc.lint.customization":r.value.rulesCustomization}:wi;N.isSome(r)&&(yield*r.value.prepareSdk),yield*x(t.dirname(n)),yield*se(n,i)}),detect:e=>E.gen(function*(){let t=yield*R.FileSystem,n=yield*P.Path;return yield*t.exists(n.join(e,X[0].path))}),extension:(e=[],t=[])=>E.gen(function*(){let n=[];y(e,`oxlint`)&&n.push(`oxc.oxc-vscode`),y(e,`knip`)&&n.push(`webpro.vscode-knip`),t.includes(`effect`)&&n.push(`TypeScriptTeam.native-preview`);for(let e of n)yield*(yield*Pt).run({args:[`--install-extension`,e],command:`code`}).pipe(E.mapError(t=>F.isTagged(t,`CliNotFound`)&&t.command===`code`?new v({cause:t}):new We({cause:F.isTagged(t,`CommandFailed`)?t.exitCode:t,extension:e})))}),files:X,kind:`editor`,name:`vscode`,update:e=>E.gen(function*(){let t=(yield*P.Path).join(e,X[0].path),n=yield*r(t),i=yield*w(n,t);if(!F.isObject(i))return yield*new Pe({path:t});let a=yield*Ci(e),o=yield*m({fallback:wi,preferred:i}),s=N.isSome(a)?[[`js/ts.tsdk.path`,_i],[`oxc.lint.customization`,yield*m({fallback:h(i[`oxc.lint.customization`])?i[`oxc.lint.customization`]:{},preferred:a.value.rulesCustomization})]]:[];N.isSome(a)&&(yield*a.value.prepareSdk);let c=Object.fromEntries([...Object.entries(o),[`oxc.path.oxlint`,wi[`oxc.path.oxlint`]],...s]);yield*S(t,le(n,c))})});const Z=[{path:`.zed/settings.json`,type:`config`}],Ei={languages:{Astro:{format_on_save:`on`,prettier:{allowed:!0,plugins:[`prettier-plugin-astro`]}},CSS:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},HTML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JSON:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JSONC:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JavaScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},MDX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},Markdown:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},TSX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},TypeScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},YAML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}}},lsp:{oxfmt:{initialization_options:{settings:{"fmt.configPath":null,run:`onSave`}}},oxlint:{binary:{arguments:[ue,`--lsp`],path:`node`},initialization_options:{settings:{configPath:null,fixKind:`safe_fix`,run:`onType`,typeAware:!0,unusedDisableDirectives:`deny`}}}}},Di={configPath:null,"fmt.experimental":!0,typeAware:!1,unusedDisableDirectives:!1},Oi=/* @__PURE__ */ new Set([`typescript-ls`,`tsgo`,`vtsls`,`typescript-language-server`]),ki=E.fn(`resolveEffectCli`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path,r=n.resolve(e);for(;;){let i=n.join(r,`node_modules`,`@effect`,`tsgo`);if(yield*t.exists(n.join(i,`package.json`)))return n.relative(e,n.join(i,`dist`,`effect-tsgo.cjs`)).replaceAll(`\\`,`/`);let a=n.dirname(r);if(a===r)return yield*new pe({reason:`Zed cannot find the installed Effect CLI in node_modules. Install @effect/tsgo, then run \`${hi({editors:[`zed`],scripts:[`check`]})}\`.`});r=a}}),Ai=E.fn(`setEffectSettings`)(function*(e,t,n){let r={arguments:[yield*ki(e),`tsc`,`--lsp`,`--stdio`],path:`node`},i=h(t.languages)?t.languages:{},a={};for(let e of[`JavaScript`,`JSX`,`TypeScript`,`TSX`]){let t=h(i[e])?i[e]:{},n=(yield*z.decodeUnknownEffect(z.Array(z.String))(t.language_servers??[`...`])).filter(e=>!Oi.has(e.replace(/^!/,``)));a[e]=Object.fromEntries([...Object.entries(t),[`language_servers`,O.dedupe([`typescript-ls`,`!vtsls`,`!typescript-language-server`,...n])]])}let o=h(t.lsp)?t.lsp:{},s=h(o.tsgo)?o.tsgo:{},c=h(o[`typescript-ls`])?o[`typescript-ls`]:{},l=yield*m({fallback:s,preferred:c}),u=h(o.oxlint)?o.oxlint:{},d=h(u.initialization_options)?u.initialization_options:{},f=h(d.settings)?d.settings:{},p=h(f.rulesCustomization)?f.rulesCustomization:{},g=yield*m({fallback:p,preferred:n});return Object.fromEntries([...Object.entries(t),[`languages`,Object.fromEntries([...Object.entries(i),...Object.entries(a)])],[`lsp`,Object.fromEntries([...Object.entries(o).filter(([e])=>e!==`tsgo`),[`typescript-ls`,Object.fromEntries([...Object.entries(l),[`binary`,r]])],[`oxlint`,Object.fromEntries([...Object.entries(u),[`initialization_options`,Object.fromEntries([...Object.entries(d),[`settings`,Object.fromEntries([...Object.entries(f),[`rulesCustomization`,g]])]])]])]])]])});function ji(e){let t=e.lsp,n=h(t)?t.oxfmt:void 0,r=h(n)?n.initialization_options:void 0,i=h(r)?r.settings:void 0;if(!h(i))return[];let a=Object.entries(Di);return Object.entries(i).filter(([e,t])=>a.some(([n,r])=>n===e&&r===t)).map(([e])=>e)}function Mi(e){return!h(e)||!d(e.plugins)?e:Object.fromEntries([...Object.entries(e),[`plugins`,O.dedupe(e.plugins)]])}function Ni(e){let t=e.languages;if(!h(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>!(e in Ei.languages)||!h(t)?[e,t]:[e,Object.fromEntries(Object.entries(t).map(([e,t])=>e===`formatter`&&d(t)?[e,O.dedupe(t)]:e===`prettier`?[e,Mi(t)]:[e,t]))]));return Object.fromEntries([...Object.entries(e),[`languages`,n]])}function Pi(e){let t=h(e.lsp)?e.lsp:{},n=h(t.oxlint)?t.oxlint:{};return Object.fromEntries([...Object.entries(e),[`lsp`,Object.fromEntries([...Object.entries(t),[`oxlint`,Object.fromEntries([...Object.entries(n),[`binary`,Ei.lsp.oxlint.binary]])]])]])}var Fi=W({assess:({cwd:e})=>E.gen(function*(){let t=(yield*P.Path).join(e,Z[0].path),n=yield*C(t);if(N.isNone(n))return{applicable:!1};let r=yield*w(n.value,t);if(!h(r))return yield*new Pe({path:t});let i=ji(r),a=h(r.lsp)?r.lsp:void 0,o=(h(a?.oxlint)?a.oxlint:void 0)?.binary,s=Ei.lsp.oxlint.binary,c=h(o)&&o.path===s.path&&mt.equals(o.arguments,s.arguments),l=yield*Ci(e),u=[];if(N.isSome(l)){let t=yield*Ai(e,r,l.value.rulesCustomization);mt.equals(r,t)||u.push({currentState:`\`${Z[0].path}\` does not select the installed Effect language server with duplicate Oxlint Effect reports hidden.`,goal:["Select `typescript-ls` for JavaScript, JSX, TypeScript, and TSX. Use the reference server binary and Oxlint rule customizations. Move old `lsp.tsgo` settings to `lsp.typescript-ls`, and preserve other settings and language servers."],id:`zed-effect-server`,integration:`zed`,reference:{content:`${yield*Be(yield*Ai(e,{},l.value.rulesCustomization))}\n`,language:`json`},title:`Zed does not use the Effect language server`})}return{applicable:!0,findings:[...u,...i.length===0?[]:[{currentState:`\`${Z[0].path}\` contains stale oxfmt settings: ${i.map(e=>`\`${e}\``).join(`, `)}.`,goal:[`Remove only the stale oxfmt entries that still have Adamantite's old default values.`,`Preserve entries that the project changed.`],id:`legacy-zed-oxfmt-settings`,integration:`zed`,title:`Legacy Zed oxfmt settings`}],...c?[]:[{currentState:`\`${Z[0].path}\` sets \`lsp.oxlint.binary\` to ${o===void 0?`no value`:`\`${yield*ce(o)}\``}. Zed does not start Oxlint through Adamantite's Oxlint entry.`,goal:[`Set \`lsp.oxlint.binary\` to \`${yield*ce(s)}\` in \`${Z[0].path}\`. Preserve every other setting.`],id:`zed-oxlint-entry`,integration:`zed`,reference:{content:`${yield*Be({lsp:{oxlint:{binary:s}}})}\n`,language:`json`},title:`Zed does not use the Oxlint entry`}]],packageActions:[],warnings:[]}}),config:Z[0].path,create:e=>E.gen(function*(){let t=yield*P.Path,n=t.join(e,Z[0].path),r=yield*Ci(e),i=N.isSome(r)?yield*Ai(e,Ei,r.value.rulesCustomization):Ei;yield*x(t.dirname(n)),yield*se(n,i)}),detect:e=>E.gen(function*(){let t=yield*R.FileSystem,n=yield*P.Path;return yield*t.exists(n.join(e,Z[0].path))}),files:Z,kind:`editor`,name:`zed`,update:e=>E.gen(function*(){let t=(yield*P.Path).join(e,Z[0].path),n=yield*r(t),i=yield*w(n,t);if(!F.isObject(i))return yield*new Pe({path:t});let a=yield*m({fallback:Ei,preferred:i}),o=yield*Ci(e),s=Pi(Ni(a)),c=N.isSome(o)?yield*Ai(e,s,o.value.rulesCustomization):s;yield*S(t,le(n,c))})});const Ii=[`oxlint.config.ts`,`oxlint.config.mts`,`oxlint.config.js`,`oxlint.config.mjs`];var Li=class extends I.TaggedClass(`external`){},Ri=class extends I.TaggedClass(`found`){},zi=class extends I.TaggedClass(`unresolved`){};const Bi=E.fn(`readPackageName`)(function*(e){let t=yield*u(e);return N.fromUndefinedOr(t.name)}),Vi=E.fn(`readFirstFile`)(function*(e){let t=yield*E.forEach(e,e=>f(e).pipe(E.map(t=>L(t,N.map(t=>({content:t,file:e}))))),{concurrency:`unbounded`});return O.head(O.getSomes(t))}),Hi=E.fn(`resolveImport`)(function*(e,t,n){let r=yield*P.Path,i=yield*Ne,a=t.startsWith(`.`)||t.startsWith(`#`)||r.isAbsolute(t)||[...n].some(e=>t===e||t.startsWith(`${e}/`)),o=yield*i.resolve(r.dirname(e),t);if(N.isNone(o))return a?new zi:new Li;if(o.value.split(r.sep).includes(`node_modules`))return new Li;let s=yield*Vi([o.value]);return N.match(s,{onNone:()=>new zi,onSome:e=>new Ri({module:e})})}),Ui=E.fn(`discoverCustomRules`)(function*(e,t=e){let n=yield*P.Path;yield*(yield*Ne).clearCache;let[r,i]=yield*E.all([E.forEach(e,e=>Bi(e),{concurrency:`unbounded`}),E.forEach(e,e=>Vi(Ii.map(t=>n.join(e,t))),{concurrency:`unbounded`})],{concurrency:`unbounded`}),a=new Set(O.getSomes(r)),o=O.getSomes(i),s=new Set(t.flatMap(e=>O.sort(o.filter(t=>{let r=n.dirname(t.file);return e===r||e.startsWith(r+n.sep)}),B.mapInput(B.flip(B.Number),e=>n.dirname(e.file).length)).slice(0,1))),c=o.filter(e=>s.has(e)),l=/* @__PURE__ */ new Set,u=/* @__PURE__ */ new Map,d=[],f=[],p=[],m=[],h=[],g=c;for(;g.length>0;){let e=g.filter(e=>!l.has(e.file));for(let t of e)if(l.add(t.file),u.set(t.file,t),on(t.file,t.content)&&p.push(t.file),t.content.includes(Xt))for(let e of dn(t.file,t.content))e instanceof en?m.push(t.file):f.push({dir:n.resolve(n.dirname(t.file),e.dir),name:e.name,source:t.file});let t=e.flatMap(e=>gn(e.file,e.content).map(t=>({from:e.file,specifier:t}))),r=yield*E.forEach(t,({from:e,specifier:t})=>Hi(e,t,a),{concurrency:`unbounded`});g=[];for(let[e,n]of r.entries()){let r=t[e];n instanceof Ri&&r!==void 0?(d.push({...r,file:n.module.file}),g.push(n.module)):n instanceof zi&&r!==void 0&&h.push(r)}}return{calls:f,configs:c.map(e=>e.file),legacyImports:p,resolvedImports:d,sources:[...u.values()],unresolvedCalls:m,unresolvedImports:h}});function Wi(e){return e.unresolvedCalls.length===0&&e.unresolvedImports.length===0}const Gi=`oxlint-custom`,Ki=`import { defineConfig } from "oxlint"
99
- import core from "${G(`./lint`)}"
100
- import custom from "${G(`./rules`)}"
92
+ `).replaceAll(`\r`,``).trimEnd()}function Ai(e){let t=ki(e);return Oi().some(e=>ki(Di(e))===t)}function ji(e){let t=ki(e);return Oi().some(e=>ki(e.split(`
93
+ `).filter(e=>e.trim()!==`# ADAMANTITE:START`&&e.trim()!==`# ADAMANTITE:END`).join(`
94
+ `))===t)}var Mi=G({assess:({cwd:e,packageJson:n})=>T.gen(function*(){let r=yield*Si(e);if(r instanceof pi)return{applicable:!1};if(r instanceof gi)return{applicable:!0,findings:[{currentState:`Adamantite cannot read the managed block in ${r.paths.map(e=>`\`${e}\``).join(`, `)}. ${r.reason}`,goal:[`Put the jobs that run the Adamantite scripts between one \`${Pr}\` comment and one \`${Fr}\` comment, in one workflow file.`],id:`malformed-adamantite-workflow`,integration:`github`,notes:[`Preserve the other jobs and project-specific settings.`],title:`Malformed Adamantite workflow block`}],packageActions:[],warnings:[]};let i=t(n),a=Ci(r.jobs),s=a.nodeVersions.some(e=>/^\d/.test(String(e))),c=i.includes(`check`)&&!a.commands.some(e=>si.test(e));if(!s&&!c)return{applicable:!0,findings:[],packageActions:[],warnings:[]};if(!Gr(i))return{applicable:!0,findings:[],packageActions:[],warnings:[`No CI-compatible managed scripts were found, so the GitHub Actions workflow cannot be regenerated.`]};let l=yield*(yield*Kr).detectPackageManager(e);return l?o(l.name)?{applicable:!0,findings:[{currentState:[...s?[`The managed jobs in \`${r.path}\` contain a hard-coded Node.js version.`]:[],...c?[`The managed jobs in \`${r.path}\` do not run the managed \`check\` script.`]:[]].join(` `),goal:[...i.includes(`check`)?["Make a managed job run the managed `check` script."]:[],`Use the project's Node.js version declaration instead of a hard-coded version.`],id:`outdated-adamantite-workflow`,integration:`github`,notes:[`The detected package manager is \`${l.name}\`.`,r instanceof hi?`\`${r.path}\` has no \`${Pr}\` and \`${Fr}\` comments, so Adamantite checks all its jobs. Put the jobs that run the Adamantite scripts between these comments, and preserve the other jobs and project-specific settings.`:`Adamantite checks only the jobs between \`${Pr}\` and \`${Fr}\`. Change only those jobs, and preserve the other jobs and project-specific settings.`],title:`Outdated Adamantite workflow`}],packageActions:[],warnings:[]}:{applicable:!0,findings:[],packageActions:[],warnings:[`\`${l.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow cannot be regenerated.`]}:{applicable:!0,findings:[],packageActions:[],warnings:[`Could not detect a package manager, so the GitHub Actions workflow cannot be regenerated.`]}}),create:(e,t)=>T.gen(function*(){let n=yield*P.Path,r=yield*ai,i=n.join(e,li[0].path),a=Ei(t,yield*r.resolve(e));a!==null&&(yield*x(n.dirname(i)),yield*S(i,a))}),detect:Si,files:li,kind:`ci`,name:`github`,update:(e,t)=>T.gen(function*(){let n=yield*P.Path,r=yield*ai,i=yield*Si(e),a=Ei(t,yield*r.resolve(e));if(a===null||i instanceof gi)return`kept`;if(i instanceof pi)return yield*S(n.join(e,li[0].path),a),`updated`;if(i instanceof hi)return ji(i.content)?(yield*S(n.join(e,i.path),a),`updated`):`kept`;if(!Ai(i.block.body))return`kept`;let o=Di(a),s=i.block.before.endsWith(`\r`);return yield*S(n.join(e,i.path),Vr(i.block,s?`${o.replaceAll(`
95
+ `,`\r
96
+ `)}\r`:o)),`updated`})});const J={agents:`agents`,editor:`editor`,nonInteractive:`non-interactive`,preset:`preset`,script:`script`};function Ni({agents:e=!1,editors:t=[],presets:n=[],scripts:r}){return[`adamantite init`,`--${J.nonInteractive}`,...r.map(e=>`--${J.script} ${e}`),...n.map(e=>`--${J.preset} ${e}`),...t.map(e=>`--${J.editor} ${e}`),...e?[`--${J.agents}`]:[]].join(` `)}const Pi=Ni({editors:[`vscode`],scripts:[`check`]}),Fi=`node_modules/.cache/adamantite/effect`,Ii=`adamantite-sdk.json`,Li=z.Struct({gitHead:z.NonEmptyString,version:z.NonEmptyString}),Ri=T.fn(`findNativeTypescript`)(function*(e){for(let t of[`typescript`,`@typescript/native`]){let n=yield*we(e,t);if(M.isSome(n)){let e=yield*u(n.value);if(Number(e.version?.split(`.`)[0])>=7)return z.decodeUnknownOption(Li)(e)}}return M.none()}),zi=T.fn(`resolveSdkSource`)(function*(e,t,n){let i=yield*P.Path,a=yield*R.FileSystem,o=yield*Ri(e);if(M.isNone(o))return yield*new pe({reason:`The Effect editor SDK needs an installed native TypeScript package with its gitHead. Install TypeScript 7 or later, then run \`${Pi}\`.`});let{gitHead:s,version:c}=o.value,l=`${A.platform}-${A.arch}`,u=yield*we(t,`@effect/tsgo-${l}`);if(M.isNone(u))return yield*new pe({reason:`The Effect editor SDK cannot find \`@effect/tsgo-${l}\`. Install the optional dependencies on a supported platform.`});let d=i.join(u.value,`lib`,`upstream.json`),f=yield*w(yield*r(d),d),p=h(f)&&f.components,m=h(p)&&p.typescript,g=h(f)&&f.tags,_=h(g)&&g.typescript;if(!h(f)||f.schemaVersion!==5||!h(m)||!h(_))return yield*new Fe({path:d});let v=A.platform===`win32`?`tsc.exe`:`tsc`;for(let[e,t]of Object.entries(m)){if(!h(t)||t.gitHead!==s)continue;let r=e===_.latest?i.join(u.value,`lib`):i.join(u.value,`artifacts`,`typescript`,e);if((yield*a.exists(i.join(r,v)))&&(yield*a.exists(i.join(r,`lib.d.ts`))))return{effectVersion:n,executable:v,gitHead:s,platform:l,source:r,typescriptVersion:c}}return yield*new pe({reason:`@effect/tsgo ${n} has no editor compiler matching TypeScript ${c} (${s}). Install a supported TypeScript version, then run \`${Pi}\`.`})}),Bi=T.fn(`sdkIsCurrent`)(function*(e,t){let n=yield*P.Path,r=yield*R.FileSystem,i=n.join(e,Fi),a=n.join(i,Ii),o=yield*C(a);if(M.isNone(o))return!1;let s=yield*w(o.value,a).pipe(T.catchTag(`FailedToParseFile`,()=>T.succeed(null)));if(!h(s)||!Object.entries(t).every(([e,t])=>s[e]===t))return!1;let c=yield*r.readDirectory(t.source);return(yield*T.forEach(c.filter(e=>e===t.executable||e.endsWith(`.d.ts`)),e=>r.exists(n.join(i,e)))).every(Boolean)}),Vi=T.fn(`readEffectEditor`)(function*(e){let t=yield*we(e,`@effect/tsgo`);if(M.isNone(t))return M.none();let n=yield*P.Path,i=yield*u(t.value),a=n.join(t.value,`oxlint-schema.json`),o=yield*w(yield*r(a),a),s=h(o)&&o.definitions,c=h(s)&&s.DummyRuleMap,l=h(c)&&c.properties;if(!h(l))return yield*new Fe({path:a});let d=Object.fromEntries(Object.keys(l).filter(e=>e.startsWith(`effecttsgo/`)).map(e=>[e,{severity:`off`}])),f=zi(e,t.value,i.version??`unknown`);return M.some({prepareSdk:T.gen(function*(){let t=yield*f;if(yield*Bi(e,t))return;let r=yield*R.FileSystem,i=n.join(e,Fi);yield*r.remove(i,{force:!0,recursive:!0}),yield*r.makeDirectory(n.dirname(i),{recursive:!0}),yield*r.copy(t.source,i),yield*se(n.join(i,Ii),t)}),rulesCustomization:d,sdkIsCurrent:f.pipe(T.flatMap(t=>Bi(e,t)))})}),Y=[{path:`.vscode/settings.json`,type:`config`}],Hi={"[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.path.oxlint":ue,"oxc.typeAware":!0};var Ui=G({assess:({cwd:e})=>T.gen(function*(){let t=(yield*P.Path).join(e,Y[0].path),n=yield*C(t);if(M.isNone(n))return{applicable:!1};let r=yield*w(n.value,t);if(!h(r))return yield*new Fe({path:t});let i=r[`oxc.path.oxlint`],a=Hi[`oxc.path.oxlint`],o=i===a?[]:[{currentState:`\`${Y[0].path}\` sets \`oxc.path.oxlint\` to ${i===void 0?`no value`:`\`${yield*ce(i)}\``}. VS Code does not start Oxlint through Adamantite's Oxlint entry.`,goal:[`Set \`oxc.path.oxlint\` to \`${a}\` in \`${Y[0].path}\`. Preserve every other setting.`],id:`vscode-oxlint-entry`,integration:`vscode`,reference:{content:`${yield*Ve({"oxc.path.oxlint":a})}\n`,language:`json`},title:`VS Code does not use the Oxlint entry`}],s=yield*Vi(e);if(M.isSome(s)){let e=r[`oxc.lint.customization`],t=h(e)&&Object.keys(s.value.rulesCustomization).every(t=>{let n=e[t];return h(n)&&n.severity===`off`});(r[`js/ts.tsdk.path`]!==`node_modules/.cache/adamantite/effect`||!t)&&o.push({currentState:`\`${Y[0].path}\` does not select the Effect editor SDK with duplicate Oxlint Effect reports hidden.`,goal:[`Set \`js/ts.tsdk.path\` to \`${Fi}\` and merge the reference \`oxc.lint.customization\` entries. Preserve other settings and rule customizations.`],id:`vscode-effect-server`,integration:`vscode`,reference:{content:`${yield*Ve({"js/ts.tsdk.path":Fi,"oxc.lint.customization":s.value.rulesCustomization})}\n`,language:`json`},title:`VS Code does not use the Effect language server`});let n=yield*s.value.sdkIsCurrent.pipe(T.map(e=>e?void 0:`\`${Fi}\` is missing or does not match the installed Effect compiler.`),T.catchTag(`EffectEditorUnavailable`,e=>T.succeed(e.message)));n!==void 0&&o.push({currentState:n,goal:[`Install a supported native TypeScript version and the Effect optional dependencies. Run \`${Ni({editors:[`vscode`],scripts:[`check`]})}\` to prepare the SDK cache, then restart the TypeScript server.`],id:`vscode-effect-sdk`,integration:`vscode`,title:`The Effect editor SDK needs preparation`})}return{applicable:!0,findings:o,packageActions:[],warnings:[]}}),config:Y[0].path,create:e=>T.gen(function*(){let t=yield*P.Path,n=t.join(e,Y[0].path),r=yield*Vi(e),i=M.isSome(r)?{...Hi,"js/ts.tsdk.path":Fi,"oxc.lint.customization":r.value.rulesCustomization}:Hi;M.isSome(r)&&(yield*r.value.prepareSdk),yield*x(t.dirname(n)),yield*se(n,i)}),detect:e=>T.gen(function*(){let t=yield*R.FileSystem,n=yield*P.Path;return yield*t.exists(n.join(e,Y[0].path))}),extension:(e=[],t=[])=>T.gen(function*(){let n=[];y(e,`oxlint`)&&n.push(`oxc.oxc-vscode`),y(e,`knip`)&&n.push(`webpro.vscode-knip`),t.includes(`effect`)&&n.push(`TypeScriptTeam.native-preview`);for(let e of n)yield*(yield*Pt).run({args:[`--install-extension`,e],command:`code`}).pipe(T.mapError(t=>F.isTagged(t,`CliNotFound`)&&t.command===`code`?new v({cause:t}):new Ge({cause:F.isTagged(t,`CommandFailed`)?t.exitCode:t,extension:e})))}),files:Y,kind:`editor`,name:`vscode`,update:e=>T.gen(function*(){let t=(yield*P.Path).join(e,Y[0].path),n=yield*r(t),i=yield*w(n,t);if(!F.isObject(i))return yield*new Fe({path:t});let a=yield*Vi(e),o=yield*m({fallback:Hi,preferred:i}),s=M.isSome(a)?[[`js/ts.tsdk.path`,Fi],[`oxc.lint.customization`,yield*m({fallback:h(i[`oxc.lint.customization`])?i[`oxc.lint.customization`]:{},preferred:a.value.rulesCustomization})]]:[];M.isSome(a)&&(yield*a.value.prepareSdk);let c=Object.fromEntries([...Object.entries(o),[`oxc.path.oxlint`,Hi[`oxc.path.oxlint`]],...s]);yield*S(t,le(n,c))})});const X=[{path:`.zed/settings.json`,type:`config`}],Wi={languages:{Astro:{format_on_save:`on`,prettier:{allowed:!0,plugins:[`prettier-plugin-astro`]}},CSS:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},HTML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JSON:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JSONC:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},JavaScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},MDX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},Markdown:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}},TSX:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},TypeScript:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}},{code_action:`source.fixAll.oxc`}],prettier:{allowed:!1}},YAML:{format_on_save:`on`,formatter:[{language_server:{name:`oxfmt`}}],prettier:{allowed:!1}}},lsp:{oxfmt:{initialization_options:{settings:{"fmt.configPath":null,run:`onSave`}}},oxlint:{binary:{arguments:[ue,`--lsp`],path:`node`},initialization_options:{settings:{configPath:null,fixKind:`safe_fix`,run:`onType`,typeAware:!0,unusedDisableDirectives:`deny`}}}}},Gi={configPath:null,"fmt.experimental":!0,typeAware:!1,unusedDisableDirectives:!1},Ki=/* @__PURE__ */ new Set([`typescript-ls`,`tsgo`,`vtsls`,`typescript-language-server`]),qi=T.fn(`resolveEffectCli`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path,r=n.resolve(e);for(;;){let i=n.join(r,`node_modules`,`@effect`,`tsgo`);if(yield*t.exists(n.join(i,`package.json`)))return n.relative(e,n.join(i,`dist`,`effect-tsgo.cjs`)).replaceAll(`\\`,`/`);let a=n.dirname(r);if(a===r)return yield*new pe({reason:`Zed cannot find the installed Effect CLI in node_modules. Install @effect/tsgo, then run \`${Ni({editors:[`zed`],scripts:[`check`]})}\`.`});r=a}}),Ji=T.fn(`setEffectSettings`)(function*(e,t,n){let r={arguments:[yield*qi(e),`tsc`,`--lsp`,`--stdio`],path:`node`},i=h(t.languages)?t.languages:{},a={};for(let e of[`JavaScript`,`JSX`,`TypeScript`,`TSX`]){let t=h(i[e])?i[e]:{},n=(yield*z.decodeUnknownEffect(z.Array(z.String))(t.language_servers??[`...`])).filter(e=>!Ki.has(e.replace(/^!/,``)));a[e]=Object.fromEntries([...Object.entries(t),[`language_servers`,D.dedupe([`typescript-ls`,`!vtsls`,`!typescript-language-server`,...n])]])}let o=h(t.lsp)?t.lsp:{},s=h(o.tsgo)?o.tsgo:{},c=h(o[`typescript-ls`])?o[`typescript-ls`]:{},l=yield*m({fallback:s,preferred:c}),u=h(o.oxlint)?o.oxlint:{},d=h(u.initialization_options)?u.initialization_options:{},f=h(d.settings)?d.settings:{},p=h(f.rulesCustomization)?f.rulesCustomization:{},g=yield*m({fallback:p,preferred:n});return Object.fromEntries([...Object.entries(t),[`languages`,Object.fromEntries([...Object.entries(i),...Object.entries(a)])],[`lsp`,Object.fromEntries([...Object.entries(o).filter(([e])=>e!==`tsgo`),[`typescript-ls`,Object.fromEntries([...Object.entries(l),[`binary`,r]])],[`oxlint`,Object.fromEntries([...Object.entries(u),[`initialization_options`,Object.fromEntries([...Object.entries(d),[`settings`,Object.fromEntries([...Object.entries(f),[`rulesCustomization`,g]])]])]])]])]])});function Yi(e){let t=e.lsp,n=h(t)?t.oxfmt:void 0,r=h(n)?n.initialization_options:void 0,i=h(r)?r.settings:void 0;if(!h(i))return[];let a=Object.entries(Gi);return Object.entries(i).filter(([e,t])=>a.some(([n,r])=>n===e&&r===t)).map(([e])=>e)}function Xi(e){return!h(e)||!d(e.plugins)?e:Object.fromEntries([...Object.entries(e),[`plugins`,D.dedupe(e.plugins)]])}function Zi(e){let t=e.languages;if(!h(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>!(e in Wi.languages)||!h(t)?[e,t]:[e,Object.fromEntries(Object.entries(t).map(([e,t])=>e===`formatter`&&d(t)?[e,D.dedupe(t)]:e===`prettier`?[e,Xi(t)]:[e,t]))]));return Object.fromEntries([...Object.entries(e),[`languages`,n]])}function Qi(e){let t=h(e.lsp)?e.lsp:{},n=h(t.oxlint)?t.oxlint:{};return Object.fromEntries([...Object.entries(e),[`lsp`,Object.fromEntries([...Object.entries(t),[`oxlint`,Object.fromEntries([...Object.entries(n),[`binary`,Wi.lsp.oxlint.binary]])]])]])}var $i=G({assess:({cwd:e})=>T.gen(function*(){let t=(yield*P.Path).join(e,X[0].path),n=yield*C(t);if(M.isNone(n))return{applicable:!1};let r=yield*w(n.value,t);if(!h(r))return yield*new Fe({path:t});let i=Yi(r),a=h(r.lsp)?r.lsp:void 0,o=(h(a?.oxlint)?a.oxlint:void 0)?.binary,s=Wi.lsp.oxlint.binary,c=h(o)&&o.path===s.path&&mt.equals(o.arguments,s.arguments),l=yield*Vi(e),u=[];if(M.isSome(l)){let t=yield*Ji(e,r,l.value.rulesCustomization);mt.equals(r,t)||u.push({currentState:`\`${X[0].path}\` does not select the installed Effect language server with duplicate Oxlint Effect reports hidden.`,goal:["Select `typescript-ls` for JavaScript, JSX, TypeScript, and TSX. Use the reference server binary and Oxlint rule customizations. Move old `lsp.tsgo` settings to `lsp.typescript-ls`, and preserve other settings and language servers."],id:`zed-effect-server`,integration:`zed`,reference:{content:`${yield*Ve(yield*Ji(e,{},l.value.rulesCustomization))}\n`,language:`json`},title:`Zed does not use the Effect language server`})}return{applicable:!0,findings:[...u,...i.length===0?[]:[{currentState:`\`${X[0].path}\` contains stale oxfmt settings: ${i.map(e=>`\`${e}\``).join(`, `)}.`,goal:[`Remove only the stale oxfmt entries that still have Adamantite's old default values.`,`Preserve entries that the project changed.`],id:`legacy-zed-oxfmt-settings`,integration:`zed`,title:`Legacy Zed oxfmt settings`}],...c?[]:[{currentState:`\`${X[0].path}\` sets \`lsp.oxlint.binary\` to ${o===void 0?`no value`:`\`${yield*ce(o)}\``}. Zed does not start Oxlint through Adamantite's Oxlint entry.`,goal:[`Set \`lsp.oxlint.binary\` to \`${yield*ce(s)}\` in \`${X[0].path}\`. Preserve every other setting.`],id:`zed-oxlint-entry`,integration:`zed`,reference:{content:`${yield*Ve({lsp:{oxlint:{binary:s}}})}\n`,language:`json`},title:`Zed does not use the Oxlint entry`}]],packageActions:[],warnings:[]}}),config:X[0].path,create:e=>T.gen(function*(){let t=yield*P.Path,n=t.join(e,X[0].path),r=yield*Vi(e),i=M.isSome(r)?yield*Ji(e,Wi,r.value.rulesCustomization):Wi;yield*x(t.dirname(n)),yield*se(n,i)}),detect:e=>T.gen(function*(){let t=yield*R.FileSystem,n=yield*P.Path;return yield*t.exists(n.join(e,X[0].path))}),files:X,kind:`editor`,name:`zed`,update:e=>T.gen(function*(){let t=(yield*P.Path).join(e,X[0].path),n=yield*r(t),i=yield*w(n,t);if(!F.isObject(i))return yield*new Fe({path:t});let a=yield*m({fallback:Wi,preferred:i}),o=yield*Vi(e),s=Qi(Zi(a)),c=M.isSome(o)?yield*Ji(e,s,o.value.rulesCustomization):s;yield*S(t,le(n,c))})});const ea=[`oxlint.config.ts`,`oxlint.config.mts`,`oxlint.config.js`,`oxlint.config.mjs`];var ta=class extends I.TaggedClass(`external`){},na=class extends I.TaggedClass(`found`){},ra=class extends I.TaggedClass(`unresolved`){};const ia=T.fn(`readPackageName`)(function*(e){let t=yield*u(e);return M.fromUndefinedOr(t.name)}),aa=T.fn(`readFirstFile`)(function*(e){let t=yield*T.forEach(e,e=>f(e).pipe(T.map(t=>L(t,M.map(t=>({content:t,file:e}))))),{concurrency:`unbounded`});return D.head(D.getSomes(t))}),oa=T.fn(`resolveImport`)(function*(e,t,n){let r=yield*P.Path,i=yield*Pe,a=t.startsWith(`.`)||t.startsWith(`#`)||r.isAbsolute(t)||[...n].some(e=>t===e||t.startsWith(`${e}/`)),o=yield*i.resolve(r.dirname(e),t);if(M.isNone(o))return a?new ra:new ta;if(o.value.split(r.sep).includes(`node_modules`))return new ta;let s=yield*aa([o.value]);return M.match(s,{onNone:()=>new ra,onSome:e=>new na({module:e})})}),sa=T.fn(`discoverCustomRules`)(function*(e,t=e){let n=yield*P.Path;yield*(yield*Pe).clearCache;let[r,i]=yield*T.all([T.forEach(e,e=>ia(e),{concurrency:`unbounded`}),T.forEach(e,e=>aa(ea.map(t=>n.join(e,t))),{concurrency:`unbounded`})],{concurrency:`unbounded`}),a=new Set(D.getSomes(r)),o=D.getSomes(i),s=new Set(t.flatMap(e=>D.sort(o.filter(t=>{let r=n.dirname(t.file);return e===r||e.startsWith(r+n.sep)}),B.mapInput(B.flip(B.Number),e=>n.dirname(e.file).length)).slice(0,1))),c=o.filter(e=>s.has(e)),l=/* @__PURE__ */ new Set,u=[],d=[],f=[],p=[],m=c;for(;m.length>0;){let e=m.filter(e=>!l.has(e.file));for(let t of e)if(l.add(t.file),on(t.file,t.content)&&d.push(t.file),t.content.includes(Xt))for(let e of dn(t.file,t.content))e instanceof en?f.push(t.file):u.push({dir:n.resolve(n.dirname(t.file),e.dir),name:e.name,source:t.file});let t=e.flatMap(e=>gn(e.file,e.content).map(t=>({from:e.file,specifier:t}))),r=yield*T.forEach(t,({from:e,specifier:t})=>oa(e,t,a),{concurrency:`unbounded`});m=[];for(let[e,n]of r.entries()){let r=t[e];n instanceof na?m.push(n.module):n instanceof ra&&r!==void 0&&p.push(r)}}return{calls:u,configs:c.map(e=>e.file),legacyImports:d,unresolvedCalls:f,unresolvedImports:p}});function ca(e){return e.unresolvedCalls.length===0&&e.unresolvedImports.length===0}const la=`oxlint-custom`,ua=`import { defineConfig } from "oxlint"
97
+ import core from "${K(`./lint`)}"
98
+ import custom from "${K(`./rules`)}"
101
99
 
102
100
  export default defineConfig({
103
101
  extends: [core, custom()],
104
102
  })
105
- `,qi=E.fn(`readRulesFolder`)(function*(e){return(yield*nt(e)).pipe(N.map(t=>({dir:e,ruleFiles:t.filter(e=>Qt(e))})))});var Ji=W({assess:({customRules:e,cwd:t,workspace:n})=>E.gen(function*(){let i=yield*P.Path,a=e=>i.relative(t,e)||`.`,o=[t,...n.packageDirectories],{calls:s,legacyImports:c,unresolvedCalls:l,unresolvedImports:u}=e,d=Wi(e),f=o.map(e=>i.join(e,K)),p=O.dedupe(s.map(e=>e.dir)),m=o.map(e=>i.join(e,`.adamantite/rules`)),h=yield*E.forEach(O.dedupe([...f,...m,...p]),e=>qi(e),{concurrency:`unbounded`}),g=O.getSomes(h),_=g.filter(e=>e.ruleFiles.length>0),v=O.dedupeWith(s.filter(e=>e.dir!==i.join(i.dirname(e.source),`.adamantite/lint`)&&!g.some(t=>t.dir===e.dir)),(e,t)=>e.dir===t.dir),ee=_.filter(e=>d&&m.includes(e.dir)&&!p.includes(e.dir));if(d&&s.length===0&&_.length===0&&c.length===0)return{applicable:!1};let y=s.filter(e=>N.isNone(e.name)),te=[...u.map(({from:e,specifier:t})=>`Doctor cannot resolve the import of \`${t}\` in \`${a(e)}\`, so it does not check the \`custom()\` calls and rules folders behind it. For a workspace package, install the dependencies and run Doctor again.`),...l.map(e=>`Doctor cannot read the \`dir\` of a \`custom()\` call in \`${a(e)}\`, because it is not a string literal. Doctor does not check that rules folder.`),...y.map(e=>`Doctor cannot read the \`name\` of a \`custom()\` call in \`${a(e.source)}\`, because it is not a string literal. Doctor does not check that its plugin name differs from the other rules folders.`)],b=v.map(e=>({currentState:`The \`custom()\` call in \`${a(e.source)}\` loads \`${a(e.dir)}\`, but that folder does not exist, so Oxlint runs none of its rules.`,goal:[`Set \`dir\` to the folder that holds the rules, or move the rules to \`${a(e.dir)}\`. A relative \`dir\` resolves from the file that calls \`custom()\`.`,`Preserve every other setting in the Oxlint config.`],id:`custom-rules-folder-missing:${a(e.dir)}`,integration:Gi,title:`The rules folder \`${a(e.dir)}\` does not exist`}));if(d)for(let e of _)p.includes(e.dir)||ee.includes(e)||b.push({currentState:`No \`custom()\` call loads the rules in \`${a(e.dir)}\`, so Oxlint does not run them.`,goal:[`Load \`${a(e.dir)}\` with \`custom()\` from \`adamantite/rules\` in the Oxlint config of \`${a(i.dirname(i.dirname(e.dir)))}\`. A relative \`dir\` resolves from the file that calls \`custom()\`.`,"Give each rules folder its own plugin name with the `name` option, because Oxlint rejects two plugins with the same name in one run.",`Preserve every other setting in the Oxlint config.`],id:`custom-rules-not-loaded:${a(e.dir)}`,integration:Gi,reference:{content:Ki,language:`ts`},title:`Custom rules in \`${a(e.dir)}\` are not loaded`});let ne=yield*E.forEach(_.flatMap(e=>e.ruleFiles.map(t=>i.join(e.dir,t))),e=>r(e).pipe(E.map(t=>({legacyImports:on(e,t),problems:_n(e,t),rulePath:e}))),{concurrency:`unbounded`}),x=O.dedupe([...c,...ne.filter(e=>e.legacyImports).map(e=>e.rulePath)]);(x.length>0||ee.length>0)&&b.push({currentState:[...x.map(e=>`\`${a(e)}\` imports the old custom-rules API.`),...ee.map(e=>`\`${a(e.dir)}\` is the previous default rules folder, and no current \`custom()\` call loads it.`)].join(`
106
- `),goal:['Import the rules-folder preset as `import custom from "adamantite/rules"`. Replace `adamantite/lint/custom` imports and keep `custom()` in the Oxlint config extends.',"Import `definePlugin`, `defineRule`, `eslintCompatPlugin`, and the Oxlint authoring types from `adamantite/rules/plugin`. Keep `RuleTester` at `adamantite/rules/testing`.",'Move `.adamantite/rules` to `.adamantite/lint`, or keep its path with `custom({ dir: ".adamantite/rules" })` and `rule add --dir .adamantite/rules`. A relative `dir` resolves from the file that calls `custom()`.',"If you keep `.adamantite/rules` or another explicit rules folder, add its rule and optional test patterns to Knip oxlint.entry. The preset defaults cover only `.adamantite/lint`.",`Update relative imports, tsconfig include paths, and Knip oxlint.entry patterns when a folder moves. Keep explicit rules folders and their options.`,"Keep optional saved tests beside their rules as `<name>.test.ts`, and update their relative imports. For tests saved elsewhere, use `adamantite rule test --path <file>` and keep their Knip entry settings. Add a test only on request with `adamantite rule test add [name]`.",`Saved RuleTester tests use node:test. Exclude them from Vitest/Jest discovery. If TypeScript checks them, enable compilerOptions.allowImportingTsExtensions for .ts rule imports.`,"Agents verify rules with RuleTester from `adamantite/rules/testing`, using stdin or a temporary file, and remove their temporary cases and fixtures. Preserve user-owned optional tests and CI steps. `adamantite rule test` runs saved tests only when explicitly invoked.","Preserve rule behavior, plugin names, rule severity, rule options, and all other config settings. Run `adamantite check`, then run Doctor again."],id:`custom-rules-api-migration`,integration:Gi,reference:{content:Ki,language:`ts`},title:`Custom rules need migration to the current agent workflow`});for(let{problems:e,rulePath:t}of ne)e.length!==0&&b.push({currentState:`\`${a(t)}\` cannot load as a rule, so the whole lint run fails with "Failed to parse oxlint configuration file":\n${e.map(e=>` - ${e}`).join(`
107
- `)}`,goal:["The file parses, uses only TypeScript that type stripping can erase (no `enum`, `namespace` with values, parameter properties, or `import x = require()`), and exports the rule as default.",`Keep the behavior of the rule.`],id:`custom-rule-cannot-load:${a(t)}`,integration:Gi,notes:["A file that starts with `_` is a helper, not a rule. Rename a helper file so that it starts with `_`."],title:`Custom rule \`${a(t)}\` cannot load`});let re=s.flatMap(({dir:e,name:t,source:n})=>N.isSome(t)&&_.some(t=>t.dir===e)?[{dir:e,name:t.value,source:n}]:[]);for(let[e,t]of Object.entries(O.groupBy(re,e=>e.name))){let n=O.dedupe(t.map(e=>e.dir));n.length<2||b.push({currentState:`${n.length.toLocaleString(`en-US`)} rules folders use the plugin name \`${e}\`: ${n.map(e=>`\`${a(e)}\``).join(`, `)}. Oxlint rejects two plugins with the same name in one run.`,goal:[`Each \`custom()\` call that loads one of these folders passes a \`name\` that no other rules folder uses, such as \`custom({ name: "web" })\`. The calls are in ${O.dedupe(t.map(e=>`\`${a(e.source)}\``)).join(`, `)}.`,"Rule names in `oxlint-disable` comments and `rules` settings use the new plugin name."],id:`custom-rules-duplicate-name:${e}`,integration:Gi,title:`Rules folders share the plugin name \`${e}\``})}return{applicable:!0,findings:b,packageActions:[],warnings:te}}),kind:`tooling`,name:Gi});function Yi(e){let{assess:t,name:n,preset:r,version:i,...a}=e,o=qt({isRequired:({lintConfig:e})=>On(e,r),name:n,purpose:`the \`adamantite/lint/${r}\` preset`,scripts:De(`oxlint`),version:i});return{...a,...o,assess:e=>E.gen(function*(){let n=yield*o.assess(e);if(!n.applicable||t===void 0)return n;let r=yield*t(e);return{...n,findings:[...n.findings,...r.findings],warnings:[...n.warnings,...r.warnings]}}),preset:r}}const Xi={"@effect/tsgo":`0.67.3`,"@shadcn/lint":`0.2.1`,"oxlint-plugin-react-doctor":`0.9.18`},Zi=be.flatMap(e=>`plugin`in e?[Yi({...e.plugin,preset:e.name,version:Xi[e.plugin.name]})]:[]),Qi=`oxlint-tsgolint`;var $i=qt({legacyFindings:e=>e.devDependencies?.[Qi]??e.dependencies?.[Qi]?[{currentState:`\`package.json\` lists \`${Qi}\`, which Adamantite no longer uses.`,goal:[`Remove \`${Qi}\` from \`package.json\`, and install again.`],id:`legacy-${Qi}`,integration:`tsrs`,notes:[`Adamantite runs the type-aware rules on tsrs, so Oxlint does not start oxlint-tsgolint.`],title:`Legacy ${Qi}`}]:[],name:`tsrs`,purpose:`the type-aware rules of the managed lint scripts`,scripts:De(`oxlint`),version:`0.21.0-ts7.1.0-beta`});const ea=[{path:`AGENTS.md`,type:`config`}];var ta=W({assess:({cwd:e,packageJson:n})=>E.gen(function*(){let r=t(n);if(r.length===0)return{applicable:!1};let i=yield*R.FileSystem,a=yield*P.Path;return{applicable:!0,findings:(yield*i.exists(a.join(e,ea[0].path)))?[]:[{currentState:"The project root has no `AGENTS.md`.",goal:["Create `AGENTS.md` at the project root with the instructions that coding agents must follow in this project.","Run `adamantite doctor` again. It must not report this finding."],id:`missing-agents-md`,integration:`agents`,notes:["`AGENTS.md` is where coding agents start. It points to the other documentation of the project.",`To create the file with an Adamantite section that lists the package scripts, run \`${hi({agents:!0,scripts:r})}\`.`],title:`Missing AGENTS.md`}],packageActions:[],warnings:[]}}),files:ea,kind:`workspace`,name:`agents`});const na=[{path:`tsconfig.json`,type:`config`}],Q=G(`./typescript`),ra={extends:Q},ia=["Adamantite leaves the root `tsconfig.json` unchanged in a monorepo.",`To use the TypeScript preset, add \`"extends": "${Q}"\` to each package's \`tsconfig.json\` or to a shared base config.`];function aa(e){return F.isString(e)?e===Q?e:[e,Q]:O.isArray(e)?e.includes(Q)?e:[...e,Q]:Q}var oa=W({assess:({cwd:e,packageJson:n,workspace:r})=>E.gen(function*(){let i=t(n);if(!y(i,`oxlint`))return{applicable:!1};if(r.isMonorepo)return{applicable:!0,findings:[],packageActions:[],warnings:ia};let a=(yield*P.Path).join(e,na[0].path),o=yield*C(a);if(N.isNone(o))return{applicable:!0,findings:[{currentState:"`tsconfig.json` is missing.",goal:["Create `tsconfig.json` and set `extends` to include `adamantite/typescript`."],id:`missing-tsconfig`,integration:`tsconfig`,reference:{content:`${yield*Be(ra)}\n`,language:`json`},title:`Missing TypeScript configuration`}],packageActions:[],warnings:[]};let s=yield*w(o.value,a);return{applicable:!0,findings:F.isObject(s)&&(s.extends===Q||O.isArray(s.extends)&&s.extends.includes(Q))?[]:[{currentState:"`tsconfig.json` does not extend `adamantite/typescript`.",goal:["Add `adamantite/typescript` to `extends`. Preserve every existing TypeScript option and existing base config."],id:`missing-adamantite-tsconfig-extends`,integration:`tsconfig`,reference:{content:`${yield*Be(ra)}\n`,language:`json`},title:`TypeScript preset is not configured`}],packageActions:[],warnings:[]}}),config:na[0].path,create:e=>E.gen(function*(){let t=yield*P.Path;yield*se(t.join(e,na[0].path),ra)}),detect:e=>E.gen(function*(){let t=yield*R.FileSystem,n=yield*P.Path;return yield*t.exists(n.join(e,na[0].path))}),files:na,kind:`workspace`,name:`tsconfig`,update:e=>E.gen(function*(){let t=(yield*P.Path).join(e,na[0].path),n=yield*r(t),i=yield*w(n,t);if(!F.isObject(i))return yield*new Pe({path:t});let a=yield*m({fallback:ra,preferred:i}),o=Object.fromEntries([...Object.entries(a),[`extends`,aa(`extends`in i?i.extends:void 0)]]);yield*S(t,le(n,o))})});const sa=[tr,q,J,Ji,...Zi,Er,$i,oa,ta,mi,Ti,Fi],ca=E.fn(`assessProject`)(function*(e){let t=yield*E.forEach(sa,t=>E.gen(function*(){let n=yield*t.assess(e);return n.applicable?[{assessment:n,name:t.name}]:[]}),{concurrency:`unbounded`}),n=O.flatten(t);return{applicableIntegrations:n.map(({name:e})=>e),findings:n.flatMap(({assessment:e})=>e.findings),packageActions:n.flatMap(({assessment:e})=>e.packageActions),warnings:n.flatMap(({assessment:e})=>e.warnings)}});function la(e,t){return e.findings.length===0?ua(e.warnings,t):da(e.findings,e.warnings,t)}function ua(e,t){return Rr(`# Adamantite doctor warnings
103
+ `,da=T.fn(`readRulesFolder`)(function*(e){return(yield*rt(e)).pipe(M.map(t=>({dir:e,ruleFiles:t.filter(e=>Qt(e))})))});var fa=G({assess:({customRules:e,cwd:t,workspace:n})=>T.gen(function*(){let i=yield*P.Path,a=e=>i.relative(t,e)||`.`,o=[t,...n.packageDirectories],{calls:s,legacyImports:c,unresolvedCalls:l,unresolvedImports:u}=e,d=ca(e),f=o.map(e=>i.join(e,q)),p=D.dedupe(s.map(e=>e.dir)),m=o.map(e=>i.join(e,`.adamantite/rules`)),h=yield*T.forEach(D.dedupe([...f,...m,...p]),e=>da(e),{concurrency:`unbounded`}),g=D.getSomes(h),_=g.filter(e=>e.ruleFiles.length>0),v=D.dedupeWith(s.filter(e=>e.dir!==i.join(i.dirname(e.source),`.adamantite/lint`)&&!g.some(t=>t.dir===e.dir)),(e,t)=>e.dir===t.dir),ee=_.filter(e=>d&&m.includes(e.dir)&&!p.includes(e.dir));if(d&&s.length===0&&_.length===0&&c.length===0)return{applicable:!1};let y=s.filter(e=>M.isNone(e.name)),te=[...u.map(({from:e,specifier:t})=>`Doctor cannot resolve the import of \`${t}\` in \`${a(e)}\`, so it does not check the \`custom()\` calls and rules folders behind it. For a workspace package, install the dependencies and run Doctor again.`),...l.map(e=>`Doctor cannot read the \`dir\` of a \`custom()\` call in \`${a(e)}\`, because it is not a string literal. Doctor does not check that rules folder.`),...y.map(e=>`Doctor cannot read the \`name\` of a \`custom()\` call in \`${a(e.source)}\`, because it is not a string literal. Doctor does not check that its plugin name differs from the other rules folders.`)],b=v.map(e=>({currentState:`The \`custom()\` call in \`${a(e.source)}\` loads \`${a(e.dir)}\`, but that folder does not exist, so Oxlint runs none of its rules.`,goal:[`Set \`dir\` to the folder that holds the rules, or move the rules to \`${a(e.dir)}\`. A relative \`dir\` resolves from the file that calls \`custom()\`.`,`Preserve every other setting in the Oxlint config.`],id:`custom-rules-folder-missing:${a(e.dir)}`,integration:la,title:`The rules folder \`${a(e.dir)}\` does not exist`}));if(d)for(let e of _)p.includes(e.dir)||ee.includes(e)||b.push({currentState:`No \`custom()\` call loads the rules in \`${a(e.dir)}\`, so Oxlint does not run them.`,goal:[`Load \`${a(e.dir)}\` with \`custom()\` from \`adamantite/rules\` in the Oxlint config of \`${a(i.dirname(i.dirname(e.dir)))}\`. A relative \`dir\` resolves from the file that calls \`custom()\`.`,"Give each rules folder its own plugin name with the `name` option, because Oxlint rejects two plugins with the same name in one run.",`Preserve every other setting in the Oxlint config.`],id:`custom-rules-not-loaded:${a(e.dir)}`,integration:la,reference:{content:ua,language:`ts`},title:`Custom rules in \`${a(e.dir)}\` are not loaded`});let ne=yield*T.forEach(_.flatMap(e=>e.ruleFiles.map(t=>i.join(e.dir,t))),e=>r(e).pipe(T.map(t=>({legacyImports:on(e,t),problems:_n(e,t),rulePath:e}))),{concurrency:`unbounded`}),x=D.dedupe([...c,...ne.filter(e=>e.legacyImports).map(e=>e.rulePath)]);(x.length>0||ee.length>0)&&b.push({currentState:[...x.map(e=>`\`${a(e)}\` imports the old custom-rules API.`),...ee.map(e=>`\`${a(e.dir)}\` is the previous default rules folder, and no current \`custom()\` call loads it.`)].join(`
104
+ `),goal:['Import the rules-folder preset as `import custom from "adamantite/rules"`. Replace `adamantite/lint/custom` imports and keep `custom()` in the Oxlint config extends.',"Import `definePlugin`, `defineRule`, `eslintCompatPlugin`, and the Oxlint authoring types from `adamantite/rules/plugin`. Keep `RuleTester` at `adamantite/rules/testing`.",'Move `.adamantite/rules` to `.adamantite/lint`, or keep its path with `custom({ dir: ".adamantite/rules" })` and `rule add --dir .adamantite/rules`. A relative `dir` resolves from the file that calls `custom()`.',"If you keep `.adamantite/rules` or another explicit rules folder, add its rule and optional test patterns to Knip oxlint.entry. The preset defaults cover only `.adamantite/lint`.",`Update relative imports, tsconfig include paths, and Knip oxlint.entry patterns when a folder moves. Keep explicit rules folders and their options.`,"Keep optional saved tests beside their rules as `<name>.test.ts`, and update their relative imports. For tests saved elsewhere, use `adamantite rule test --path <file>` and keep their Knip entry settings. Add a test only on request with `adamantite rule test add [name]`.",`Saved RuleTester tests use node:test. Exclude them from Vitest/Jest discovery. If TypeScript checks them, enable compilerOptions.allowImportingTsExtensions for .ts rule imports.`,"Agents verify rules with RuleTester from `adamantite/rules/testing`, using stdin or a temporary file, and remove their temporary cases and fixtures. Preserve user-owned optional tests and CI steps. `adamantite rule test` runs saved tests only when explicitly invoked.","Preserve rule behavior, plugin names, rule severity, rule options, and all other config settings. Run `adamantite check`, then run Doctor again."],id:`custom-rules-api-migration`,integration:la,reference:{content:ua,language:`ts`},title:`Custom rules need migration to the current agent workflow`});for(let{problems:e,rulePath:t}of ne)e.length!==0&&b.push({currentState:`\`${a(t)}\` cannot load as a rule, so the whole lint run fails with "Failed to parse oxlint configuration file":\n${e.map(e=>` - ${e}`).join(`
105
+ `)}`,goal:["The file parses, uses only TypeScript that type stripping can erase (no `enum`, `namespace` with values, parameter properties, or `import x = require()`), and exports the rule as default.",`Keep the behavior of the rule.`],id:`custom-rule-cannot-load:${a(t)}`,integration:la,notes:["A file that starts with `_` is a helper, not a rule. Rename a helper file so that it starts with `_`."],title:`Custom rule \`${a(t)}\` cannot load`});let re=s.flatMap(({dir:e,name:t,source:n})=>M.isSome(t)&&_.some(t=>t.dir===e)?[{dir:e,name:t.value,source:n}]:[]);for(let[e,t]of Object.entries(D.groupBy(re,e=>e.name))){let n=D.dedupe(t.map(e=>e.dir));n.length<2||b.push({currentState:`${n.length.toLocaleString(`en-US`)} rules folders use the plugin name \`${e}\`: ${n.map(e=>`\`${a(e)}\``).join(`, `)}. Oxlint rejects two plugins with the same name in one run.`,goal:[`Each \`custom()\` call that loads one of these folders passes a \`name\` that no other rules folder uses, such as \`custom({ name: "web" })\`. The calls are in ${D.dedupe(t.map(e=>`\`${a(e.source)}\``)).join(`, `)}.`,"Rule names in `oxlint-disable` comments and `rules` settings use the new plugin name."],id:`custom-rules-duplicate-name:${e}`,integration:la,title:`Rules folders share the plugin name \`${e}\``})}return{applicable:!0,findings:b,packageActions:[],warnings:te}}),kind:`tooling`,name:la});function pa(e){let{assess:t,name:n,preset:r,version:i,...a}=e,o=qt({isRequired:({lintConfig:e})=>On(e,r),name:n,purpose:`the \`adamantite/lint/${r}\` preset`,scripts:Oe(`oxlint`),version:i});return{...a,...o,assess:e=>T.gen(function*(){let n=yield*o.assess(e);if(!n.applicable||t===void 0)return n;let r=yield*t(e);return{...n,findings:[...n.findings,...r.findings],warnings:[...n.warnings,...r.warnings]}}),preset:r}}const ma={"@effect/tsgo":`0.67.3`,"@shadcn/lint":`0.2.1`,"oxlint-plugin-react-doctor":`0.9.18`},ha=be.flatMap(e=>`plugin`in e?[pa({...e.plugin,preset:e.name,version:ma[e.plugin.name]})]:[]),ga=`oxlint-tsgolint`;var _a=qt({legacyFindings:e=>e.devDependencies?.[ga]??e.dependencies?.[ga]?[{currentState:`\`package.json\` lists \`${ga}\`, which Adamantite no longer uses.`,goal:[`Remove \`${ga}\` from \`package.json\`, and install again.`],id:`legacy-${ga}`,integration:`tsrs`,notes:[`Adamantite runs the type-aware rules on tsrs, so Oxlint does not start oxlint-tsgolint.`],title:`Legacy ${ga}`}]:[],name:`tsrs`,purpose:`the type-aware rules of the managed lint scripts`,scripts:Oe(`oxlint`),version:`0.21.0-ts7.1.0-beta`});const va=[{path:`AGENTS.md`,type:`config`}];var ya=G({assess:({cwd:e,packageJson:n})=>T.gen(function*(){let r=t(n);if(r.length===0)return{applicable:!1};let i=yield*R.FileSystem,a=yield*P.Path;return{applicable:!0,findings:(yield*i.exists(a.join(e,va[0].path)))?[]:[{currentState:"The project root has no `AGENTS.md`.",goal:["Create `AGENTS.md` at the project root with the instructions that coding agents must follow in this project.","Run `adamantite doctor` again. It must not report this finding."],id:`missing-agents-md`,integration:`agents`,notes:["`AGENTS.md` is where coding agents start. It points to the other documentation of the project.",`To create the file with an Adamantite section that lists the package scripts, run \`${Ni({agents:!0,scripts:r})}\`.`],title:`Missing AGENTS.md`}],packageActions:[],warnings:[]}}),files:va,kind:`workspace`,name:`agents`});const Z=[{path:`tsconfig.json`,type:`config`}],ba=[`typescript`,`tsconfig`],Q={tsconfig:K(`./tsconfig`),typescript:K(`./typescript`)},xa=Object.values(Q);function Sa(e){let t=["Adamantite leaves the root `tsconfig.json` unchanged in a monorepo.",`Add \`"extends": "${Q[e]}"\` to each package's \`tsconfig.json\` or to a shared base config.`];return e===`typescript`&&t.push(`In a library package, extend \`${Q.tsconfig}\` instead.`),t}function Ca(e,t){let n=Q[t];if(F.isString(e))return e===n||xa.includes(e)?n:[e,n];if(D.isArray(e)){let t=e.filter(e=>e===n||!F.isString(e)||!xa.includes(e));return t.includes(n)?t:[...t,n]}return n}const wa=z.Struct({files:z.optional(z.Array(z.String))}),Ta=z.decodeUnknownOption(wa),Ea=T.fn(`readLoadsResets`)(function*(e){let t=yield*P.Path,n=yield*we(e,`typescript`);if(M.isNone(n))return M.none();let r=yield*T.option(u(n.value)),i=M.flatMapNullishOr(r,({bin:e})=>F.isObject(e)?e.tsc:void 0);if(M.isNone(i)||!F.isString(i.value))return M.none();let a=yield*(yield*E.ChildProcessSpawner).spawn(dt.make(`node`,[t.join(n.value,i.value),`--showConfig`,`--project`,e],{cwd:e,stdin:`ignore`})),[o,,s]=yield*T.all([H.mkString(H.decodeText(a.stdout)),H.runDrain(a.stderr),a.exitCode],{concurrency:`unbounded`});if(s!==0)return M.none();let c=yield*T.option(w(o,t.join(e,Z[0].path)));return M.flatMap(c,e=>M.map(Ta(e),e=>(e.files??[]).some(e=>e.endsWith(`/dist/presets/typescript/resets/index.d.ts`))))},T.scoped,T.catchTag(`PlatformError`,()=>T.succeed(M.none())));function Da(e){return F.isObject(e)?(D.isArray(e.extends)?e.extends:[e.extends]).filter(F.isString):[]}function Oa(e){return e.private!==!0&&(e.exports!==void 0||e.types!==void 0)}function ka(e){return{currentState:`\`${e}\` loads the type resets of \`${Q.typescript}\`, directly or through a base config, and its \`package.json\` is not private and declares \`exports\` or \`types\`.`,goal:[`Make \`${e}\` extend \`${Q.tsconfig}\` instead of reaching \`${Q.typescript}\`, directly or through a base config. Keep a shared base for the packages that use it, and preserve every other setting.`],id:`typescript-preset-in-library`,integration:`tsconfig`,notes:[`\`${Q.typescript}\` adds the type resets. A declaration file that the library emits can name the global \`AdamantiteTypeScript\` helper types, which projects without the resets do not have.`],title:`Type resets in a library`}}var Aa=G({assess:({cwd:e,packageJson:t,workspace:n})=>T.gen(function*(){let r=yield*P.Path,i=(yield*T.forEach([e,...n.packageDirectories],e=>T.gen(function*(){let t=yield*C(r.join(e,Z[0].path));if(M.isNone(t))return[];let n=yield*T.option(w(t.value,r.join(e,Z[0].path))),i=M.match(n,{onNone:()=>[],onSome:Da}),a=i.length!==0&&M.getOrElse(yield*Ea(e),()=>!1);return i.some(e=>xa.includes(e))||a?[{directory:e,loadsResets:a}]:[]}),{concurrency:4})).flat();return i.length===0?{applicable:!1}:{applicable:!0,findings:(yield*T.forEach(i,({directory:n,loadsResets:i})=>i?(n===e?T.succeed(t):u(n)).pipe(T.map(t=>Oa(t)?[ka(r.relative(e,r.join(n,Z[0].path)))]:[])):T.succeed([]))).flat(),packageActions:[],warnings:[]}}),config:Z[0].path,create:(e,t)=>T.gen(function*(){let n=yield*P.Path;yield*se(n.join(e,Z[0].path),{extends:Q[t]})}),detect:e=>T.gen(function*(){let t=yield*R.FileSystem,n=yield*P.Path;return yield*t.exists(n.join(e,Z[0].path))}),files:Z,kind:`workspace`,name:`tsconfig`,update:(e,t)=>T.gen(function*(){let n=(yield*P.Path).join(e,Z[0].path),i=yield*r(n),a=yield*w(i,n);if(!F.isObject(a))return yield*new Fe({path:n});let o=yield*m({fallback:{extends:Q[t]},preferred:a}),s=Object.fromEntries([...Object.entries(o),[`extends`,Ca(`extends`in a?a.extends:void 0,t)]]);yield*S(n,le(i,s))})});const ja=[tr,or,br,fa,...ha,Sr,_a,Aa,ya,Mi,Ui,$i],Ma=T.fn(`assessProject`)(function*(e){let t=yield*T.forEach(ja,t=>T.gen(function*(){let n=yield*t.assess(e);return n.applicable?[{assessment:n,name:t.name}]:[]}),{concurrency:`unbounded`}),n=D.flatten(t);return{applicableIntegrations:n.map(({name:e})=>e),findings:n.flatMap(({assessment:e})=>e.findings),packageActions:n.flatMap(({assessment:e})=>e.packageActions),warnings:n.flatMap(({assessment:e})=>e.warnings)}});function Na(e,t){return e.findings.length===0?Pa(e.warnings,t):Fa(e.findings,e.warnings,t)}function Pa(e,t){return Hr(`# Adamantite doctor warnings
108
106
 
109
107
  Adamantite {{version}} detected no repair findings. The assessment reported these warnings:
110
108
 
@@ -120,10 +118,10 @@ The review is complete when each warning has an observed result or a stated limi
120
118
  - Every warning is accounted for, including missing tools or sources.
121
119
  - A successful Doctor exit is not reported as proof that all project checks pass.
122
120
  `,{version:t,warnings:e.map(e=>`- ${e}`).join(`
123
- `)})}function da(e,t,n){let r=e.map((e,t)=>{let n=e.goal.map(e=>` - ${e}`).join(`
121
+ `)})}function Fa(e,t,n){let r=e.map((e,t)=>{let n=e.goal.map(e=>` - ${e}`).join(`
124
122
  `),r=e.reference?`\n- **Reference:**\n\n\`\`\`${e.reference.language}\n${e.reference.content.trimEnd()}\n\`\`\``:``,i=e.notes&&e.notes.length>0?`\n- **Notes:**\n${e.notes.map(e=>` - ${e}`).join(`
125
123
  `)}`:``;return`## ${t+1}. ${e.title}\n\n- **Current state:** ${e.currentState}\n- **Goal:**\n${n}${r}${i}`}),i=t.length>0?[`## Assessment warnings`,``,`Review these warnings before making repairs:`,``,...t.map(e=>`- ${e}`),``,``].join(`
126
- `):``;return Rr(`# Adamantite doctor findings
124
+ `):``;return Hr(`# Adamantite doctor findings
127
125
 
128
126
  Repair the findings below for the target project that uses Adamantite {{version}}.
129
127
  Total findings: {{findingCount}}.
@@ -157,23 +155,23 @@ Total findings: {{findingCount}}.
157
155
  - The report separates findings, warnings, and checks that could not be verified.
158
156
  `,{findingCount:e.length.toLocaleString(`en-US`),findings:r.join(`
159
157
 
160
- `),version:n,warnings:i})}const fa=E.fn(`readProject`)(function*(e){let t=yield*P.Path,[n,r,i]=yield*E.all([u(e),re(e),C(t.join(e,`oxlint.config.ts`))],{concurrency:`unbounded`});return{customRules:yield*Ui([e,...r.packageDirectories]),cwd:e,lintConfig:i,packageJson:n,workspace:r}});var pa=class extends ct.Service()(`TerminalCapabilities`){static layer=A.succeed(this)({copyToClipboard:e=>E.sync(()=>{let t=Buffer.from(e).toString(`base64`);j.stdout.write(`\u001B]52;c;${t}\u0007`)}),isInteractive:E.sync(()=>j.stdin.isTTY&&j.stdout.isTTY)})},$=class extends ct.Service()(`Prompter`){static layerWithSpinner(e){return A.succeed(this)({cancel:e=>E.sync(()=>{H.cancel(e)}),confirm:e=>E.promise(()=>H.confirm(e)).pipe(E.filterOrFail(e=>!H.isCancel(e),()=>new $e({}))),intro:e=>E.sync(()=>{H.intro(e)}),log:{error:e=>E.sync(()=>{H.log.error(e)}),info:e=>E.sync(()=>{H.log.info(e)}),success:e=>E.sync(()=>{H.log.success(e)}),warning:e=>E.sync(()=>{H.log.warning(e)})},message:e=>E.sync(()=>{H.log.message(e,{spacing:0,withGuide:!1})}),multiselect:e=>E.promise(()=>H.multiselect(e)).pipe(E.filterOrFail(e=>!H.isCancel(e),()=>new $e({}))),note:(e,t)=>E.sync(()=>{H.note(e,t)}),outro:e=>E.sync(()=>{H.outro(e)}),select:e=>E.promise(()=>H.select(e)).pipe(E.filterOrFail(e=>!H.isCancel(e),()=>new $e({}))),withSpinner:(t,n)=>E.acquireUseRelease(E.sync(()=>{let t=e();return t.start(n.start),t}),e=>t({message:t=>E.sync(()=>{e.message(t)})}),(e,t)=>E.sync(()=>{it.match(t,{onFailure:t=>{Tt.hasInterruptsOnly(t)?e.cancel(n.failure):e.error(n.failure)},onSuccess:t=>{e.stop(F.isFunction(n.success)?n.success(t):n.success)}})}))})}static layer=this.layerWithSpinner(H.spinner)};function ma(e){let t=[`Current state\n${e.currentState}`,`Goal\n${e.goal.map(e=>`โ€ข ${e}`).join(`
158
+ `),version:n,warnings:i})}const Ia=T.fn(`readProject`)(function*(e){let t=yield*P.Path,[n,r,i]=yield*T.all([u(e),re(e),C(t.join(e,`oxlint.config.ts`))],{concurrency:`unbounded`});return{customRules:yield*sa([e,...r.packageDirectories]),cwd:e,lintConfig:i,packageJson:n,workspace:r}});var La=class extends N.Service()(`TerminalCapabilities`){static layer=k.succeed(this)({copyToClipboard:e=>T.sync(()=>{let t=Buffer.from(e).toString(`base64`);A.stdout.write(`\u001B]52;c;${t}\u0007`)}),isInteractive:T.sync(()=>A.stdin.isTTY&&A.stdout.isTTY)})},$=class extends N.Service()(`Prompter`){static layerWithSpinner(e){return k.succeed(this)({cancel:e=>T.sync(()=>{U.cancel(e)}),confirm:e=>T.promise(()=>U.confirm(e)).pipe(T.filterOrFail(e=>!U.isCancel(e),()=>new et({}))),intro:e=>T.sync(()=>{U.intro(e)}),log:{error:e=>T.sync(()=>{U.log.error(e)}),info:e=>T.sync(()=>{U.log.info(e)}),success:e=>T.sync(()=>{U.log.success(e)}),warning:e=>T.sync(()=>{U.log.warning(e)})},message:e=>T.sync(()=>{U.log.message(e,{spacing:0,withGuide:!1})}),multiselect:e=>T.promise(()=>U.multiselect(e)).pipe(T.filterOrFail(e=>!U.isCancel(e),()=>new et({}))),note:(e,t)=>T.sync(()=>{U.note(e,t)}),outro:e=>T.sync(()=>{U.outro(e)}),select:e=>T.promise(()=>U.select(e)).pipe(T.filterOrFail(e=>!U.isCancel(e),()=>new et({}))),withSpinner:(t,n)=>T.acquireUseRelease(T.sync(()=>{let t=e();return t.start(n.start),t}),e=>t({message:t=>T.sync(()=>{e.message(t)})}),(e,t)=>T.sync(()=>{at.match(t,{onFailure:t=>{Et.hasInterruptsOnly(t)?e.cancel(n.failure):e.error(n.failure)},onSuccess:t=>{e.stop(F.isFunction(n.success)?n.success(t):n.success)}})}))})}static layer=this.layerWithSpinner(U.spinner)};function Ra(e){let t=[`Current state\n${e.currentState}`,`Goal\n${e.goal.map(e=>`โ€ข ${e}`).join(`
161
159
  `)}`];return e.reference&&t.push(`Reference\n${e.reference.content.trimEnd()}`),e.notes&&e.notes.length>0&&t.push(`Notes\n${e.notes.map(e=>`โ€ข ${e}`).join(`
162
160
  `)}`),t.join(`
163
161
 
164
- `)}const ha=E.fn(`printFindings`)(function*(e){let t=yield*$;for(let[n,r]of e.entries())yield*t.note(ma(r),`${n+1}. ${r.title}`)}),ga=[{command:`claude`,name:`Claude Code`,seedArguments:e=>[e],skillsFolder:`.claude/skills`},{command:`codex`,name:`Codex`,seedArguments:e=>[e],skillsFolder:`.agents/skills`},{command:`cursor-agent`,name:`Cursor`,seedArguments:e=>[e],skillsFolder:`.agents/skills`},{command:`gemini`,name:`Gemini CLI`,seedArguments:e=>[`-i`,e],skillsFolder:`.agents/skills`},{command:`grok`,name:`Grok Build`,probeArguments:[`version`],seedArguments:e=>[e],skillsFolder:`.grok/skills`},{command:`opencode`,name:`OpenCode`,seedArguments:e=>[`--prompt`,e],skillsFolder:`.agents/skills`}];var _a=class extends I.TaggedError(`HandoffFailed`){};const va=()=>{},ya=E.acquireRelease(E.sync(()=>{let e=j.listeners(`SIGINT`);return j.removeAllListeners(`SIGINT`),j.on(`SIGINT`,va),e}),e=>E.sync(()=>{j.removeAllListeners(`SIGINT`);for(let t of e)j.on(`SIGINT`,t)}));var ba=class e extends ct.Service()(`CodingAgents`){static layer=A.effect(this,E.gen(function*(){let t=yield*Pt,n=(e,n)=>t.exitCode({args:[...e.probeArguments??[`--version`]],command:e.command,cwd:n,stderr:`ignore`,stdout:`ignore`}).pipe(E.timeout(`10 seconds`),E.isSuccess);return e.of({detectInstalled:E.fn(`CodingAgents.detectInstalled`)(e=>E.filter(ga,t=>n(t,e),{concurrency:`unbounded`})),handoff:E.fn(`CodingAgents.handoff`)(function*({agent:e,cwd:n,prompt:r}){yield*ya,yield*t.exitCode({args:e.seedArguments(r),command:e.command,cwd:n,stderr:`inherit`,stdin:`inherit`,stdout:`inherit`})},E.scoped,E.mapError(e=>new _a({cause:e,reason:F.isTagged(e,`CliNotFound`)?`not-found`:`spawn-failed`})))})}))},xa=class extends I.TaggedClass(`Copied`){},Sa=class extends I.TaggedClass(`Declined`){},Ca=class extends I.TaggedClass(`Ended`){},wa=class extends I.TaggedClass(`Failed`){};const Ta=E.fn(`copyPrompt`)(function*(e){let t=yield*$,n=yield*pa;yield*t.message(e),yield*n.copyToClipboard(e),yield*t.log.success(`The agent prompt is printed above and sent to the terminal clipboard.`)}),Ea=E.fn(`offerPromptCopy`)(function*(e){(yield*(yield*$).confirm({initialValue:!0,message:`Copy the agent prompt?`}))&&(yield*Ta(e))}),Da=E.fn(`chooseResolution`)(function*(e){let t=yield*ba,n=yield*$,r=yield*n.withSpinner(()=>t.detectInstalled(e.cwd),{failure:`Could not check for installed coding agents.`,start:`Checking for installed coding agents...`,success:e=>e.length===0?`No supported coding agent was found on PATH.`:`Found ${e.map(e=>e.name).join(`, `)}.`});r.length===0&&(yield*n.log.info(`${e.command} can hand ${e.subject} off when one of these CLIs is installed: ${ga.map(e=>`\`${e.command}\``).join(`, `)}.`));let i=yield*n.select({message:e.message,options:[...r.map(e=>({label:`Hand off to ${e.name}`,value:e})),{label:`Copy the agent prompt`,value:`copy`},{label:`Finish without an agent`,value:`done`}]});if(i===`done`)return new Sa;if(i===`copy`)return yield*Ta(e.prompt),new xa;let a=i;return yield*n.log.info(`Handing the terminal to ${a.name}. Exit the agent to return to ${e.command}.`),(yield*t.handoff({agent:a,cwd:e.cwd,prompt:e.prompt}).pipe(E.as(!0),E.catchTag(`HandoffFailed`,e=>n.log.error(e.reason===`not-found`?`\`${a.command}\` was not found on PATH. Install ${a.name} or copy the prompt instead.`:`Failed to start ${a.name}: ${e.cause.message}`).pipe(E.as(!1)))))?new Ca({agent:a}):(yield*Ea(e.prompt),new wa({agent:a}))}),Oa=`0.46.0`,ka="`adamantite` is not installed in this project. Install it before running `adamantite doctor`.",{$match:Aa,Converged:ja,NeedsRepair:Ma,NotInstalled:Na,Unmanaged:Pa}=I.taggedEnum();function Fa(e){return e.applicableIntegrations.length===0?Pa():e.findings.length===0?ja({assessment:e}):Ma({assessment:e})}function Ia(){return new Ie({command:`doctor`,exitCode:D.ExitCode(1)})}var La=k.make(`doctor`).pipe(k.withDescription(`Check Adamantite setup and report what needs repair`),k.withHandler(()=>E.gen(function*(){let e=j.cwd(),t=yield*$,n=yield*(yield*pa).isInteractive;n&&(yield*t.intro(`๐Ÿ’  adamantite doctor`));let r=E.gen(function*(){return yield*t.outro(`โš ๏ธ Doctor found issues.`),yield*Ia()}),i=e=>E.gen(function*(){yield*t.log.success(e),yield*t.outro(`โœ… Doctor finished.`)}),a=e=>E.forEach(e.warnings,e=>t.log.warning(e),{discard:!0}),o=E.fn(`resolveFindings`)(function*(n){yield*a(n),yield*ha(n.findings);let o=yield*Da({command:`Doctor`,cwd:e,message:`How do you want to resolve these findings?`,prompt:la(n,Oa),subject:`findings`});if(!(o instanceof Ca))return yield*r;let{agent:s}=o,c=yield*ca(yield*fa(e));return c.findings.length===0?yield*i(`All findings were resolved by ${s.name}.`):(yield*t.log.warning(`Doctor still reports ${c.findings.length.toLocaleString(`en-US`)} unresolved ${c.findings.length===1?`finding`:`findings`} after the ${s.name} session.`),yield*ha(c.findings),yield*Ea(la(c,Oa)),yield*r)}),s=Aa({Converged:({assessment:e})=>a(e).pipe(E.andThen(i(`No setup repairs needed.`))),NeedsRepair:({assessment:e})=>o(e),NotInstalled:()=>t.log.warning(ka).pipe(E.andThen(r)),Unmanaged:()=>i("No Adamantite-managed setup found. Run `adamantite init` to configure the project.")}),c=Aa({Converged:({assessment:e})=>e.warnings.length>0?t.message(la(e,Oa)):E.void,NeedsRepair:({assessment:e})=>t.message(la(e,Oa)).pipe(E.andThen(Ia())),NotInstalled:()=>t.message(ka).pipe(E.andThen(Ia())),Unmanaged:()=>E.void}),l=yield*u(e),d=l.devDependencies?.adamantite||l.dependencies?.adamantite?Fa(yield*ca(yield*fa(e))):Na();yield*n?s(d):c(d)}).pipe(E.catchTag(`OperationCancelled`,()=>E.gen(function*(){return yield*(yield*$).cancel(`Doctor was cancelled. The findings remain.`),yield*Ia()})))));const Ra=V.File(`files`,{mustExist:!0}).pipe(V.withDescription(`Files to fix. Omit to fix the project`),V.variadic()),za=M.Boolean(`suggested`).pipe(M.withDefault(!1),M.withDescription(`Apply Oxlint's suggested fixes`)),Ba=M.Boolean(`dangerous`).pipe(M.withDefault(!1),M.withDescription(`Apply Oxlint's dangerous fixes`)),Va=M.Boolean(`all`).pipe(M.withDefault(!1),M.withDescription(`Apply all Oxlint fixes, including suggested and dangerous fixes`)),Ha=M.Literals(`only`,[`format`,`lint`]).pipe(M.optional,M.withDescription(`Run only format (Oxfmt) or lint (Oxlint). Pass tool arguments after --`));function Ua(e){return e.all||e.suggested&&e.dangerous?`all`:e.suggested?`suggested`:e.dangerous?`dangerous`:`safe`}var Wa=k.make(`fix`,{all:Va,dangerous:Ba,files:Ra,only:Ha,suggested:za}).pipe(k.withDescription(`Apply lint fixes and format code`),k.withHandler(({all:e,dangerous:t,files:n,only:r,suggested:i})=>E.gen(function*(){yield*Or({cwd:j.cwd(),files:n,forwardedArguments:yield*At,level:Ua({all:e,dangerous:t,suggested:i}),only:N.getOrUndefined(r)})})));const Ga=/\.(?:md|mdx|mdc)$/u,Ka=/^ {0,3}((`|~)\2{2,})[^\n]*\n[\s\S]*?(?:^ {0,3}\1\2*[\t ]*$|(?![\s\S]))/gmu,qa=/`([^`\n]+)`/gu,Ja=/\]\(\s*<?([^\s)>]+)>?(?:\s[^)]*)?\)/gu,Ya=/^ {0,3}\[[^\]]+\]:\s*<?([^\s>]+)>?/gmu,Xa=/^[a-z][\d+.a-z-]*:/iu;function Za(e){let[t=``]=e.split(/[#?]/u);try{return decodeURI(t)}catch{return t}}function Qa(e,t){return[...e.matchAll(t)].map(e=>e[1]??``)}const $a=E.fn(`readAgentReach`)(function*(e,t,n){let r=yield*R.FileSystem,i=yield*P.Path,a=new Set(t),o=new Map(yield*E.forEach(t,t=>f(i.join(e,t)).pipe(E.map(e=>[t,N.getOrElse(e,()=>``).replaceAll(Ka,``)])),{concurrency:`unbounded`})),s=e=>{let n=e.flatMap(e=>{let t=U.normalize(e);return t!==`.`&&!t.startsWith(`..`)?[t]:[]}),r=n.find(e=>a.has(e));if(r!==void 0)return[r];let i=n.find(e=>t.some(t=>U.dirname(t)===e));return i===void 0?[]:t.filter(e=>U.dirname(e)===i)},c=e=>{let t=(o.get(e)??``).replaceAll(qa,``);return[...Qa(t,Ja),...Qa(t,Ya)].flatMap(t=>{if(Xa.test(t)||t.startsWith(`#`))return[];let n=Za(t);return n.length===0?[]:[U.normalize(n.startsWith(`/`)?n.slice(1):U.join(U.dirname(e),n))]})},l=e=>[...c(e).flatMap(e=>s([e])),...Qa(o.get(e)??``,qa).flatMap(t=>s([U.join(U.dirname(e),t),t]))],u=new Set(n),d=[...n];for(let e=d.shift();e!==void 0;e=d.shift())for(let t of l(e))u.has(t)||(u.add(t),d.push(t));let p=t.flatMap(e=>c(e).filter(e=>Ga.test(e)&&!a.has(e)).map(t=>({file:e,target:t})));return{brokenLinks:yield*E.filter(p,t=>r.exists(i.join(e,t.target)).pipe(E.map(e=>!e),E.orElseSucceed(()=>!0)),{concurrency:`unbounded`}),unreached:t.filter(e=>!u.has(e))}}),eo=/^\{/mu,to=z.String.pipe(z.decodeTo(z.String,gt.transform({decode:e=>e.replaceAll(`\\`,`/`),encode:e=>e}))),no=z.Struct({diagnostics:z.Array(z.Struct({code:z.optional(z.String),filename:to,labels:z.Array(z.Struct({span:z.Struct({column:z.Int,line:z.Int})})),message:z.String})),number_of_files:z.Int}),ro=z.decodeUnknownOption(z.fromJsonString(no)),io=z.Array(z.Struct({scope:z.String,value:z.String})),ao=z.decodeUnknownOption(z.fromJsonString(io)),oo=z.Struct({rules:z.Record(z.String,z.Unknown)}),so=z.decodeUnknownOption(z.fromJsonString(oo)),co=ct.Reference(`adamantite/OxlintCommand`,{defaultValue:()=>et});function lo(e){let t=e.lastIndexOf(`/`);return t===-1?{name:e,plugin:`eslint`}:{name:e.slice(t+1),plugin:e.slice(0,t)}}function uo(e,t){return e===`${t.plugin}(${t.name})`}function fo(){return[j.env.NODE_OPTIONS,`--disable-warning=MODULE_TYPELESS_PACKAGE_JSON`].filter(Boolean).join(` `)}const po=E.fn(`runOxlint`)(function*(e,t,n=e){let r=yield*D.ChildProcessSpawner,i=(yield*co)(n),a=yield*r.spawn(dt.make(i.command,[...i.args,...t],{cwd:e,env:{...i.env,NODE_OPTIONS:fo()},extendEnv:!0,stdin:`ignore`})),[o,s,c]=yield*E.all([Dt.mkString(Dt.decodeText(a.stdout)),Dt.mkString(Dt.decodeText(a.stderr)),a.exitCode],{concurrency:`unbounded`});return{exitCode:c,output:`${o}${s}`.trim(),stdout:o}},E.scoped,E.catchReason(`PlatformError`,`NotFound`,()=>E.fail(new Ke({command:`node`})),(e,t)=>E.fail(new Ae({output:t.message}))));function mo(e){let t=e.search(eo);return t===-1?N.none():ro(e.slice(t))}const ho=E.fn(`lintFiles`)(function*(e,t){let{output:n,stdout:r}=yield*po(e,[`-f`,`json`,...t]),i=mo(r);return N.isNone(i)?yield*new Ae({output:n}):i.value}),go=E.fn(`listLintedFiles`)(function*(e,t=[]){let{exitCode:n,output:r,stdout:i}=yield*po(e,[`--debug=files`,...t]);return n===0?i.split(`
165
- `).map(e=>e.trim().replaceAll(`\\`,`/`)).filter(e=>e.length>0):yield*new Ae({output:r})}),_o=E.fn(`resolveRule`)(function*(e,t){let n=yield*R.FileSystem,r=yield*P.Path,i=yield*n.makeTempDirectoryScoped({prefix:`adamantite-rules-`}),a=yield*po(i,[`--rules`,`-f`,`json`],t),o=ao(a.stdout);if(N.isNone(o))return yield*new Ae({output:a.output});let s=O.dedupe(o.value.map(e=>e.scope.replaceAll(`_`,`-`))),{name:c,plugin:l}=lo(e);yield*S(r.join(i,`.oxlintrc.json`),yield*ce({categories:{correctness:`off`},plugins:s,rules:{[e]:`error`}}));let u=yield*po(i,[`--print-config`],t),d=so(u.stdout).pipe(N.flatMap(e=>O.findFirst(Object.keys(e.rules),e=>lo(e).name===c)),N.map(e=>lo(e)));return N.match(d,{onNone:()=>({builtIn:!1,name:c,plugin:l}),onSome:e=>({builtIn:!0,name:e.name,plugin:e.plugin.replaceAll(`_`,`-`)})})},E.scoped),vo=Ot.nominal();function yo(e,t,n){return vo((e.relative(t,n)||`.`).split(e.sep).join(`/`))}const bo=E.fn(`listGitFiles`)(function*(e,t){let n=yield*(yield*D.ChildProcessSpawner).spawn(dt.make(`git`,[`ls-files`,`-z`,...t],{cwd:e,stderr:`ignore`,stdin:`ignore`})),[r,i]=yield*E.all([Dt.mkString(Dt.decodeText(n.stdout)),n.exitCode],{concurrency:`unbounded`}),a=L(r,pt.split(`\0`),O.filter(e=>pt.isNonEmpty(e)));return N.liftPredicate(a,()=>i===0)},E.scoped,E.orElseSucceed(()=>N.none()));function xo(e,t=[]){return bo(e,[`--cached`,`--others`,`--exclude-standard`,`--`,...t])}function So(e,t){return bo(e,[`--others`,`--ignored`,`--exclude-standard`,`--`,t,`:(exclude,glob)**/node_modules/**`])}var Co=class extends I.TaggedClass(`Current`){},wo=class extends I.TaggedClass(`Error`){};function To(e,t){let n=e.indexOf(`=`),r=n===-1?e:e.slice(0,n),i=N.liftPredicate(e.slice(n+1),()=>n!==-1),a=U.normalize(r.replaceAll(`\\`,`/`));return r.length===0||N.exists(i,e=>e.length===0)?E.fail(new Ye({reason:"Give a path, or `<path>=<file>`.",value:e})):U.isAbsolute(a)||Et.isAbsolute(a)||a===`..`||a.startsWith(`../`)||a===`.`?E.fail(new Ye({reason:`The path must be a file inside the project, relative to the project root.`,value:e})):E.succeed({expected:t,path:a,source:i})}function Eo(e){let t={files:e.files,...N.match(e.plugin,{onNone:()=>({}),onSome:e=>({plugins:[e]})}),rules:{[e.rule]:[`error`,...e.settingOptions]}};return["// `adamantite rule try` wrote this file in a copy of the project.",`import config from ${JSON.stringify(`./${e.config}`)}`,``,`export default {`,` ...config,`,` overrides: [...(config.overrides ?? []), ${JSON.stringify(t)}],`,`}`,``].join(`
166
- `)}const Do=Ot.nominal(),Oo=E.fn(`replaceConfigs`)(function*(e,t){let n=yield*R.FileSystem,r=yield*P.Path;for(let[i,a]of t){let t=r.join(e,i),o=`oxlint.trial-base.config${r.extname(i)}`;yield*n.rename(t,r.join(r.dirname(t),o)),yield*S(t,a(o))}});function ko(e){return["// `adamantite harden` wrote this file in a copy of the project.",`import config from ${JSON.stringify(`./${e.config}`)}`,``,`const removals = new Map(${JSON.stringify([...e.removals])})`,``,`export default {`,` ...config,`,` overrides: (config.overrides ?? []).map((override, index) => ({`,` ...override,`,` rules: Object.fromEntries(`,` Object.entries(override.rules ?? {}).filter(`,` ([rule]) => !(removals.get(index) ?? []).includes(rule)`,` )`,` ),`,` })),`,`}`,``].join(`
167
- `)}const Ao=E.fn(`makeProjectCopy`)(function*(e,t){let r=yield*R.FileSystem,i=yield*P.Path,a=yield*xo(e);if(N.isNone(a))return yield*new n({cwd:e});let o=yield*r.makeTempDirectoryScoped({prefix:`adamantite-trial-`}),s=O.dedupe(a.value.map(e=>i.dirname(i.join(o,e))));yield*E.forEach(s,e=>r.makeDirectory(e,{recursive:!0}),{concurrency:16,discard:!0}),yield*E.forEach(a.value,t=>r.copyFile(i.join(e,t),i.join(o,t)).pipe(E.catchReason(`PlatformError`,`NotFound`,()=>E.void)),{concurrency:16,discard:!0});let c=[e,...t.packageDirectories],l=yield*r.realPath(e),u=e=>{let t=i.relative(l,e);return N.liftPredicate(t,()=>t!==``&&t!==`..`&&!t.startsWith(`..${i.sep}`)&&!i.isAbsolute(t)&&!t.split(i.sep).includes(`node_modules`))},d=E.fnUntraced(function*(e){let t=yield*nt(e),n=yield*E.forEach(N.getOrElse(t,()=>[]).filter(e=>e!==`.cache`),E.fnUntraced(function*(t){let n=t.startsWith(`@`)&&!(yield*r.readLink(i.join(e,t)).pipe(E.as(!0),E.orElseSucceed(()=>!1)))?yield*nt(i.join(e,t)):N.none();return N.match(n,{onNone:()=>[t],onSome:e=>e.map(e=>`${t}/${e}`)})}),{concurrency:`unbounded`});return t.pipe(N.as(n.flat()))}),f=yield*E.forEach(c,E.fnUntraced(function*(t){let n=i.join(t,`node_modules`),a=i.join(o,i.relative(e,t),`node_modules`),s=yield*d(n);return N.isSome(s)&&(yield*r.makeDirectory(a,{recursive:!0})),yield*E.forEach(N.getOrElse(s,()=>[]),E.fnUntraced(function*(e){let t=i.join(n,e),s=(yield*r.realPath(t).pipe(E.option)).pipe(N.flatMap(e=>u(e)));return yield*r.makeDirectory(i.dirname(i.join(a,e)),{recursive:!0}),yield*r.symlink(N.match(s,{onNone:()=>t,onSome:e=>i.join(o,e)}),i.join(a,e)),s}),{concurrency:1})}),{concurrency:1}),p=yield*E.forEach(O.dedupe(O.getSomes(f.flat())),t=>So(e,t.split(i.sep).join(`/`)).pipe(E.map(e=>N.getOrElse(e,()=>[]))),{concurrency:`unbounded`});return yield*E.forEach(O.dedupe(p.flat()),t=>r.makeDirectory(i.dirname(i.join(o,t)),{recursive:!0}).pipe(E.andThen(r.copyFile(i.join(e,t),i.join(o,t)))),{concurrency:16,discard:!0}),Do(o)},E.catchTag(`PlatformError`,e=>E.fail(new Ze({cause:e})))),jo=E.fn(`findConfig`)(function*(e,t){let n=yield*P.Path,r=[];for(let i=n.dirname(n.join(e,t));i===e||i.startsWith(`${e}${n.sep}`);i=n.dirname(i))r.push(...Ii.map(e=>n.join(i,e)));return yield*E.findFirst(r,e=>g(e))});function Mo(e){let t=[];for(let n of e){let e=t.find(e=>e.every(e=>e.case.path!==n.case.path));e===void 0?t.push([n]):e.push(n)}return t}const No=E.fn(`tryRule`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path,{cases:i,cwd:a,rule:o,setting:c,workspace:u}=e,{name:d,plugin:f}=lo(o),p=yield*_o(o,a),m=yield*Ao(a,u),h=e=>n.relative(m,e).split(n.sep).join(`/`),g=e=>{let t=[`Rule '${d}' not found in plugin '${f}'`,`Plugin '${f}' not found`].find(t=>F.isTagged(e,`TrialLintFailed`)&&e.output.includes(t));return c instanceof wo&&t!==void 0?new Oe({detail:t,rule:o}):e},_=yield*E.forEach(i,E.fnUntraced(function*(e){if(N.isNone(e.source)&&!(yield*t.exists(n.join(m,e.path))))return yield*new Ye({reason:(yield*t.exists(n.join(a,e.path)))?"Git ignores this file, so the copy of the project does not have it. Use `<path>=<file>` to lint its content.":"The project has no such file. Use `<path>=<file>` to lint other content.",value:e.path});let r=yield*jo(m,e.path);return N.isNone(r)?yield*new te({path:e.path}):{case:e,config:r.value,configFile:n.relative(n.dirname(r.value),n.join(m,e.path)).split(n.sep).join(`/`)}}),{concurrency:1});c instanceof wo&&(yield*Oo(m,new Map(O.dedupe(_.map(e=>e.config)).map(e=>[n.relative(m,e),t=>Eo({config:t,files:O.dedupe(_.filter(t=>t.config===e).map(e=>e.configFile)),plugin:N.liftPredicate(p.plugin,e=>p.builtIn&&e!==`eslint`),rule:o,settingOptions:c.options})]))));let v=/* @__PURE__ */ new Map;for(let e of Mo(_)){let i=e.flatMap(e=>N.match(e.case.source,{onNone:()=>[],onSome:t=>[{source:n.resolve(a,t),target:n.join(m,e.case.path)}]})),o=yield*E.forEach(i,({target:e})=>t.readFileString(e).pipe(E.option),{concurrency:`unbounded`});for(let{source:e,target:a}of i)yield*t.makeDirectory(n.dirname(a),{recursive:!0}),yield*S(a,yield*r(e));let c=e.map(e=>e.case.path),u=yield*ho(m,c).pipe(E.mapError(e=>g(e)));if(u.number_of_files<c.length){let e=new Set(yield*go(m,c));return yield*new l({path:c.find(t=>!e.has(t))??c[0]??``})}yield*E.forEach(i,({target:e},n)=>N.match(o[n]??N.none(),{onNone:()=>t.remove(e),onSome:n=>t.writeFileString(e,n)}),{concurrency:1,discard:!0});for(let t of e){let e=u.diagnostics.filter(e=>e.filename===t.case.path),n=e.filter(e=>e.code===void 0);if(n.length>0)return yield*new s({errors:n.map(e=>e.message),path:t.case.path});v.set(t.case,{case:t.case,config:h(t.config),diagnostics:e.filter(e=>e.code!==void 0&&uo(e.code,p)).map(e=>({column:e.labels[0]?.span.column??1,line:e.labels[0]?.span.line??1,message:e.message}))})}}return O.getSomes(i.map(e=>N.fromUndefinedOr(v.get(e))))},E.scoped,E.catchTag(`PlatformError`,e=>E.fail(new Ze({cause:e}))));var Po=class extends I.TaggedClass(`Linted`){},Fo=class extends I.TaggedClass(`Failed`){};const Io=/[!*?[\]{}]/u;function Lo(e){return e===null?null:e.type===`Literal`&&F.isString(e.value)?e.value:e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0]?.value.cooked??null:null}function Ro(e){return e.computed?null:e.key.type===`Identifier`?e.key.name:e.key.type===`Literal`&&F.isString(e.key.value)?e.key.value:null}function zo(e,t){let n=e.properties.find(e=>e.type===`Property`&&Ro(e)===t);return n?.type===`Property`?n.value:void 0}function Bo(e){if(e.type===`ArrayExpression`){let[t]=e.elements;return t!=null&&t.type!==`SpreadElement`&&Bo(t)}return e.type===`Literal`&&(e.value===`off`||e.value===`allow`||e.value===0)}function Vo(e){let[t]=e.body.flatMap(e=>e.type===`ExportDefaultDeclaration`?[e]:[]);if(t===void 0)return;let n=t=>{if(t.type===`ObjectExpression`)return t;if(t.type===`CallExpression`){let[e]=t.arguments;return e!==void 0&&e.type!==`SpreadElement`?n(e):void 0}if(t.type===`Identifier`){let r=e.body.flatMap(e=>e.type===`VariableDeclaration`?e.declarations:e.type===`ExportNamedDeclaration`&&e.declaration?.type===`VariableDeclaration`?e.declaration.declarations:[]).find(e=>e.id.type===`Identifier`&&e.id.name===t.name);return r?.init?n(r.init):void 0}if(t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`)return n(t.expression)},r=t.declaration;return r.type===`ObjectExpression`||r.type===`CallExpression`||r.type===`Identifier`||r.type===`TSAsExpression`||r.type===`TSSatisfiesExpression`?n(r):void 0}function Ho(e,t){let{errors:n,program:r}=bt(e,t,{sourceType:`module`});if(n.length>0)return[];let i=Vo(r),a=i===void 0?void 0:zo(i,`overrides`);if(a?.type!==`ArrayExpression`)return[];let o=a.elements.findIndex(e=>e?.type===`SpreadElement`);return(o===-1?a.elements:a.elements.slice(0,o)).flatMap((e,t)=>{if(e?.type!==`ObjectExpression`)return[];let n=zo(e,`files`),r=zo(e,`rules`);if(n?.type!==`ArrayExpression`||r?.type!==`ObjectExpression`)return[];let i=n.elements.map(e=>Lo(e)),a=r.properties.flatMap(e=>{let t=e.type===`Property`?Ro(e):null;return e.type===`Property`&&t!==null&&Bo(e.value)?[t]:[]});return i.every(e=>e!==null)&&a.length>0?[{files:i,index:t,rules:a}]:[]})}const Uo=E.fn(`readOverrides`)(function*(e,t,n,i){let a=yield*P.Path,o=e=>i===null||i===`.`||e===i||e.startsWith(`${i}/`),s=(t,n)=>a.relative(e,a.join(e,a.dirname(t),n)).split(a.sep).join(`/`),c=(yield*E.forEach(n,t=>r(a.join(e,t)).pipe(E.map(e=>({config:t,overrides:Ho(t,e)}))),{concurrency:`unbounded`})).flatMap(({config:e,overrides:t})=>t.flatMap(t=>t.rules.map(n=>({config:e,globs:t.files.filter(e=>Io.test(e)),index:t.index,literals:t.files.filter(e=>!Io.test(e)).map(t=>s(e,t)).filter(e=>o(e)),rule:n})))),l=new Set(yield*E.filter(O.dedupe(c.flatMap(e=>e.literals)),t=>g(a.join(e,t)),{concurrency:`unbounded`})),u=c.filter(e=>e.literals.some(e=>l.has(e))),d=/* @__PURE__ */ new Map;if(u.length>0){let n=new Map(yield*E.forEach(O.dedupe(u.map(e=>e.rule)),t=>_o(t,e).pipe(E.map(e=>[t,e])),{concurrency:`unbounded`})),r=yield*Ao(e,t);yield*Oo(r,new Map(O.dedupe(u.map(e=>e.config)).map(e=>{let t=/* @__PURE__ */ new Map;for(let n of u.filter(t=>t.config===e))t.set(n.index,[...t.get(n.index)??[],n.rule]);return[e,e=>ko({config:e,removals:t})]})));let i=O.dedupe(u.flatMap(e=>e.literals)).filter(e=>l.has(e)),a=yield*ho(r,i),o=new Set(a.number_of_files<i.length?yield*go(r,i):i),s=new Set(a.diagnostics.filter(e=>e.code===void 0).map(e=>e.filename));for(let e of u){let t=n.get(e.rule);for(let n of e.literals.filter(e=>l.has(e))){let r=a.diagnostics.some(e=>e.filename===n&&e.code!==void 0&&t!==void 0&&uo(e.code,t)),i=o.has(n)?s.has(n)?`unparsable`:r?`breaks`:`clean`:`ignored`;d.set(`${e.rule}\0${n}`,i)}}}return new Po({rules:c.filter(e=>e.literals.length>0||e.globs.length>0).map(e=>({config:e.config,files:e.literals.map(t=>({file:t,mark:d.get(`${e.rule}\0${t}`)??`missing`})),globs:e.globs,rule:e.rule}))})},E.scoped,E.catch(e=>E.succeed(new Fo({reason:e.message})))),Wo=`Custom rules`,Go=`AGENTS.md`;function Ko(e){let t=e.split(`/`);return!t.includes(`.changeset`)&&t.at(-1)!==`CHANGELOG.md`}function qo(e,t,n,r){let i=(t,n)=>{let r=e.relative(t,n);return r!==`..`&&!r.startsWith(`..${e.sep}`)&&!e.isAbsolute(r)},a=B.mapInput(B.flip(B.Number),e=>e.length),o=[t,...n.packageDirectories],s=o.filter(e=>i(r,e)),c=O.sort(o.filter(e=>i(e,r)),a).slice(0,1),l=s.length>0?s:c;return{contains:i,isSelectedFile:n=>{let[r=t]=O.sort(o.filter(r=>i(r,e.join(t,n))),a);return r===t||l.includes(r)},packageDirectories:o,selectedPackages:l}}const Jo=E.fn(`readScopedDocumentation`)(function*(e,t,n){let r=yield*P.Path,{contains:i,isSelectedFile:a}=qo(r,e,t,n),o=t=>{let a=r.dirname(r.join(e,t));return i(a,n)||i(n,a)},s=yield*E.transposeOption((yield*xo(e,[`*.md`,`*.mdx`,`*.mdc`])).pipe(N.map(t=>E.forEach(t.filter(e=>Ko(e)),t=>g(r.join(e,t)).pipe(E.map(e=>e?[t]:[])),{concurrency:`unbounded`}).pipe(E.map(e=>e.flat())))));return{agentReach:(yield*E.transposeOption(s.pipe(N.map(t=>$a(e,t,t.filter(e=>r.basename(e)===Go&&o(e))))))).pipe(N.map(e=>({brokenLinks:e.brokenLinks.filter(e=>a(e.file)),unreached:e.unreached.filter(e=>a(e))}))),documentationFiles:s.pipe(N.map(e=>e.filter(e=>a(e))))}}),Yo=E.fn(`readHardenReach`)(function*(e,t,n=e){return(yield*Jo(e,t,n)).agentReach}),Xo=E.fn(`readHardenContext`)(function*(e,t,n=e){let r=yield*P.Path,i=t=>r.relative(e,t)||`.`,{packageDirectories:a,selectedPackages:o}=qo(r,e,t,n),s=[.../* @__PURE__ */ new Set([e,...o])].map(e=>r.join(e,Go)),[{calls:c,configs:l,unresolvedCalls:u},d,f]=yield*E.all([Ui(a,o),E.filter(s,e=>g(e),{concurrency:`unbounded`}),Jo(e,t,n)],{concurrency:`unbounded`});return{agentReach:f.agentReach,configs:l.map(t=>yo(r,e,t)),documentationFiles:f.documentationFiles,instructionFiles:d.map(e=>i(e)),rulesFolders:[...new Set(c.map(e=>i(e.dir)))],scope:n===e?null:yo(r,e,n),unresolvedCalls:[...new Set(u.map(e=>i(e)))]}}),Zo=/^[\w./-]+$/u;function Qo(e){return Zo.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`}function $o(e,t){return e.length===0?t:e.map(e=>`- \`${e}\``).join(`
168
- `)}function es(e){return[e.unreached.length===0?"Links and code spans from each `AGENTS.md` reach each Markdown file.":`No chain of links or code spans from an \`AGENTS.md\` reaches these Markdown files:\n\n${$o(e.unreached,``)}`,...e.brokenLinks.length===0?[]:[`These links go to Markdown files that do not exist:\n\n${e.brokenLinks.map(e=>`- \`${e.file}\` links to \`${e.target}\``).join(`
162
+ `)}const za=T.fn(`printFindings`)(function*(e){let t=yield*$;for(let[n,r]of e.entries())yield*t.note(Ra(r),`${n+1}. ${r.title}`)}),Ba=[{command:`claude`,name:`Claude Code`,seedArguments:e=>[e],skillsFolder:`.claude/skills`},{command:`codex`,name:`Codex`,seedArguments:e=>[e],skillsFolder:`.agents/skills`},{command:`cursor-agent`,name:`Cursor`,seedArguments:e=>[e],skillsFolder:`.agents/skills`},{command:`gemini`,name:`Gemini CLI`,seedArguments:e=>[`-i`,e],skillsFolder:`.agents/skills`},{command:`grok`,name:`Grok Build`,probeArguments:[`version`],seedArguments:e=>[e],skillsFolder:`.grok/skills`},{command:`opencode`,name:`OpenCode`,seedArguments:e=>[`--prompt`,e],skillsFolder:`.agents/skills`}];var Va=class extends I.TaggedError(`HandoffFailed`){};const Ha=()=>{},Ua=T.acquireRelease(T.sync(()=>{let e=A.listeners(`SIGINT`);return A.removeAllListeners(`SIGINT`),A.on(`SIGINT`,Ha),e}),e=>T.sync(()=>{A.removeAllListeners(`SIGINT`);for(let t of e)A.on(`SIGINT`,t)}));var Wa=class e extends N.Service()(`CodingAgents`){static layer=k.effect(this,T.gen(function*(){let t=yield*Pt,n=(e,n)=>t.exitCode({args:[...e.probeArguments??[`--version`]],command:e.command,cwd:n,stderr:`ignore`,stdout:`ignore`}).pipe(T.timeout(`10 seconds`),T.isSuccess);return e.of({detectInstalled:T.fn(`CodingAgents.detectInstalled`)(e=>T.filter(Ba,t=>n(t,e),{concurrency:`unbounded`})),handoff:T.fn(`CodingAgents.handoff`)(function*({agent:e,cwd:n,prompt:r}){yield*Ua,yield*t.exitCode({args:e.seedArguments(r),command:e.command,cwd:n,stderr:`inherit`,stdin:`inherit`,stdout:`inherit`})},T.scoped,T.mapError(e=>new Va({cause:e,reason:F.isTagged(e,`CliNotFound`)?`not-found`:`spawn-failed`})))})}))},Ga=class extends I.TaggedClass(`Copied`){},Ka=class extends I.TaggedClass(`Declined`){},qa=class extends I.TaggedClass(`Ended`){},Ja=class extends I.TaggedClass(`Failed`){};const Ya=T.fn(`copyPrompt`)(function*(e){let t=yield*$,n=yield*La;yield*t.message(e),yield*n.copyToClipboard(e),yield*t.log.success(`The agent prompt is printed above and sent to the terminal clipboard.`)}),Xa=T.fn(`offerPromptCopy`)(function*(e){(yield*(yield*$).confirm({initialValue:!0,message:`Copy the agent prompt?`}))&&(yield*Ya(e))}),Za=T.fn(`chooseResolution`)(function*(e){let t=yield*Wa,n=yield*$,r=yield*n.withSpinner(()=>t.detectInstalled(e.cwd),{failure:`Could not check for installed coding agents.`,start:`Checking for installed coding agents...`,success:e=>e.length===0?`No supported coding agent was found on PATH.`:`Found ${e.map(e=>e.name).join(`, `)}.`});r.length===0&&(yield*n.log.info(`${e.command} can hand ${e.subject} off when one of these CLIs is installed: ${Ba.map(e=>`\`${e.command}\``).join(`, `)}.`));let i=yield*n.select({message:e.message,options:[...r.map(e=>({label:`Hand off to ${e.name}`,value:e})),{label:`Copy the agent prompt`,value:`copy`},{label:`Finish without an agent`,value:`done`}]});if(i===`done`)return new Ka;if(i===`copy`)return yield*Ya(e.prompt),new Ga;let a=i;return yield*n.log.info(`Handing the terminal to ${a.name}. Exit the agent to return to ${e.command}.`),(yield*t.handoff({agent:a,cwd:e.cwd,prompt:e.prompt}).pipe(T.as(!0),T.catchTag(`HandoffFailed`,e=>n.log.error(e.reason===`not-found`?`\`${a.command}\` was not found on PATH. Install ${a.name} or copy the prompt instead.`:`Failed to start ${a.name}: ${e.cause.message}`).pipe(T.as(!1)))))?new qa({agent:a}):(yield*Xa(e.prompt),new Ja({agent:a}))}),Qa=`0.47.0`,$a="`adamantite` is not installed in this project. Install it before running `adamantite doctor`.",{$match:eo,Converged:to,NeedsRepair:no,NotInstalled:ro,Unmanaged:io}=I.taggedEnum();function ao(e){return e.applicableIntegrations.length===0?io():e.findings.length===0?to({assessment:e}):no({assessment:e})}function oo(){return new Le({command:`doctor`,exitCode:E.ExitCode(1)})}var so=O.make(`doctor`).pipe(O.withDescription(`Check Adamantite setup and report what needs repair`),O.withHandler(()=>T.gen(function*(){let e=A.cwd(),t=yield*$,n=yield*(yield*La).isInteractive;n&&(yield*t.intro(`๐Ÿ’  adamantite doctor`));let r=T.gen(function*(){return yield*t.outro(`โš ๏ธ Doctor found issues.`),yield*oo()}),i=e=>T.gen(function*(){yield*t.log.success(e),yield*t.outro(`โœ… Doctor finished.`)}),a=e=>T.forEach(e.warnings,e=>t.log.warning(e),{discard:!0}),o=T.fn(`resolveFindings`)(function*(n){yield*a(n),yield*za(n.findings);let o=yield*Za({command:`Doctor`,cwd:e,message:`How do you want to resolve these findings?`,prompt:Na(n,Qa),subject:`findings`});if(!(o instanceof qa))return yield*r;let{agent:s}=o,c=yield*Ma(yield*Ia(e));return c.findings.length===0?yield*i(`All findings were resolved by ${s.name}.`):(yield*t.log.warning(`Doctor still reports ${c.findings.length.toLocaleString(`en-US`)} unresolved ${c.findings.length===1?`finding`:`findings`} after the ${s.name} session.`),yield*za(c.findings),yield*Xa(Na(c,Qa)),yield*r)}),s=eo({Converged:({assessment:e})=>a(e).pipe(T.andThen(i(`No setup repairs needed.`))),NeedsRepair:({assessment:e})=>o(e),NotInstalled:()=>t.log.warning($a).pipe(T.andThen(r)),Unmanaged:()=>i("No Adamantite-managed setup found. Run `adamantite init` to configure the project.")}),c=eo({Converged:({assessment:e})=>e.warnings.length>0?t.message(Na(e,Qa)):T.void,NeedsRepair:({assessment:e})=>t.message(Na(e,Qa)).pipe(T.andThen(oo())),NotInstalled:()=>t.message($a).pipe(T.andThen(oo())),Unmanaged:()=>T.void}),l=yield*u(e),d=l.devDependencies?.adamantite||l.dependencies?.adamantite?ao(yield*Ma(yield*Ia(e))):ro();yield*n?s(d):c(d)}).pipe(T.catchTag(`OperationCancelled`,()=>T.gen(function*(){return yield*(yield*$).cancel(`Doctor was cancelled. The findings remain.`),yield*oo()})))));const co=V.File(`files`,{mustExist:!0}).pipe(V.withDescription(`Files to fix. Omit to fix the project`),V.variadic()),lo=j.Boolean(`suggested`).pipe(j.withDefault(!1),j.withDescription(`Apply Oxlint's suggested fixes`)),uo=j.Boolean(`dangerous`).pipe(j.withDefault(!1),j.withDescription(`Apply Oxlint's dangerous fixes`)),fo=j.Boolean(`all`).pipe(j.withDefault(!1),j.withDescription(`Apply all Oxlint fixes, including suggested and dangerous fixes`)),po=j.Literals(`only`,[`format`,`lint`]).pipe(j.optional,j.withDescription(`Run only format (Oxfmt) or lint (Oxlint). Pass tool arguments after --`));function mo(e){return e.all||e.suggested&&e.dangerous?`all`:e.suggested?`suggested`:e.dangerous?`dangerous`:`safe`}var ho=O.make(`fix`,{all:fo,dangerous:uo,files:co,only:po,suggested:lo}).pipe(O.withDescription(`Apply lint fixes and format code`),O.withHandler(({all:e,dangerous:t,files:n,only:r,suggested:i})=>T.gen(function*(){yield*wr({cwd:A.cwd(),files:n,forwardedArguments:yield*At,level:mo({all:e,dangerous:t,suggested:i}),only:M.getOrUndefined(r)})})));const go=/\.(?:md|mdx|mdc)$/u,_o=/^ {0,3}((`|~)\2{2,})[^\n]*\n[\s\S]*?(?:^ {0,3}\1\2*[\t ]*$|(?![\s\S]))/gmu,vo=/`([^`\n]+)`/gu,yo=/\]\(\s*<?([^\s)>]+)>?(?:\s[^)]*)?\)/gu,bo=/^ {0,3}\[[^\]]+\]:\s*<?([^\s>]+)>?/gmu,xo=/^[a-z][\d+.a-z-]*:/iu;function So(e){let[t=``]=e.split(/[#?]/u);try{return decodeURI(t)}catch{return t}}function Co(e,t){return[...e.matchAll(t)].map(e=>e[1]??``)}const wo=T.fn(`readAgentReach`)(function*(e,t,n){let r=yield*R.FileSystem,i=yield*P.Path,a=new Set(t),o=new Map(yield*T.forEach(t,t=>f(i.join(e,t)).pipe(T.map(e=>[t,M.getOrElse(e,()=>``).replaceAll(_o,``)])),{concurrency:`unbounded`})),s=e=>{let n=e.flatMap(e=>{let t=W.normalize(e);return t!==`.`&&!t.startsWith(`..`)?[t]:[]}),r=n.find(e=>a.has(e));if(r!==void 0)return[r];let i=n.find(e=>t.some(t=>W.dirname(t)===e));return i===void 0?[]:t.filter(e=>W.dirname(e)===i)},c=e=>{let t=(o.get(e)??``).replaceAll(vo,``);return[...Co(t,yo),...Co(t,bo)].flatMap(t=>{if(xo.test(t)||t.startsWith(`#`))return[];let n=So(t);return n.length===0?[]:[W.normalize(n.startsWith(`/`)?n.slice(1):W.join(W.dirname(e),n))]})},l=e=>[...c(e).flatMap(e=>s([e])),...Co(o.get(e)??``,vo).flatMap(t=>s([W.join(W.dirname(e),t),t]))],u=new Set(n),d=[...n];for(let e=d.shift();e!==void 0;e=d.shift())for(let t of l(e))u.has(t)||(u.add(t),d.push(t));let p=t.flatMap(e=>c(e).filter(e=>go.test(e)&&!a.has(e)).map(t=>({file:e,target:t})));return{brokenLinks:yield*T.filter(p,t=>r.exists(i.join(e,t.target)).pipe(T.map(e=>!e),T.orElseSucceed(()=>!0)),{concurrency:`unbounded`}),unreached:t.filter(e=>!u.has(e))}}),To=/^\{/mu,Eo=z.String.pipe(z.decodeTo(z.String,gt.transform({decode:e=>e.replaceAll(`\\`,`/`),encode:e=>e}))),Do=z.Struct({diagnostics:z.Array(z.Struct({code:z.optional(z.String),filename:Eo,labels:z.Array(z.Struct({span:z.Struct({column:z.Int,line:z.Int})})),message:z.String})),number_of_files:z.Int}),Oo=z.decodeUnknownOption(z.fromJsonString(Do)),ko=z.Array(z.Struct({scope:z.String,value:z.String})),Ao=z.decodeUnknownOption(z.fromJsonString(ko)),jo=z.Struct({rules:z.Record(z.String,z.Unknown)}),Mo=z.decodeUnknownOption(z.fromJsonString(jo)),No=N.Reference(`adamantite/OxlintCommand`,{defaultValue:()=>tt});function Po(e){let t=e.lastIndexOf(`/`);return t===-1?{name:e,plugin:`eslint`}:{name:e.slice(t+1),plugin:e.slice(0,t)}}function Fo(e,t){return e===`${t.plugin}(${t.name})`}function Io(){return[A.env.NODE_OPTIONS,`--disable-warning=MODULE_TYPELESS_PACKAGE_JSON`].filter(Boolean).join(` `)}const Lo=T.fn(`runOxlint`)(function*(e,t,n=e){let r=yield*E.ChildProcessSpawner,i=(yield*No)(n),a=yield*r.spawn(dt.make(i.command,[...i.args,...t],{cwd:e,env:{...i.env,NODE_OPTIONS:Io()},extendEnv:!0,stdin:`ignore`})),[o,s,c]=yield*T.all([H.mkString(H.decodeText(a.stdout)),H.mkString(H.decodeText(a.stderr)),a.exitCode],{concurrency:`unbounded`});return{exitCode:c,output:`${o}${s}`.trim(),stdout:o}},T.scoped,T.catchReason(`PlatformError`,`NotFound`,()=>T.fail(new qe({command:`node`})),(e,t)=>T.fail(new je({output:t.message}))));function Ro(e){let t=e.search(To);return t===-1?M.none():Oo(e.slice(t))}const zo=T.fn(`lintFiles`)(function*(e,t){let{output:n,stdout:r}=yield*Lo(e,[`-f`,`json`,...t]),i=Ro(r);return M.isNone(i)?yield*new je({output:n}):i.value}),Bo=T.fn(`listLintedFiles`)(function*(e,t=[]){let{exitCode:n,output:r,stdout:i}=yield*Lo(e,[`--debug=files`,...t]);return n===0?i.split(`
163
+ `).map(e=>e.trim().replaceAll(`\\`,`/`)).filter(e=>e.length>0):yield*new je({output:r})}),Vo=T.fn(`resolveRule`)(function*(e,t){let n=yield*R.FileSystem,r=yield*P.Path,i=yield*n.makeTempDirectoryScoped({prefix:`adamantite-rules-`}),a=yield*Lo(i,[`--rules`,`-f`,`json`],t),o=Ao(a.stdout);if(M.isNone(o))return yield*new je({output:a.output});let s=D.dedupe(o.value.map(e=>e.scope.replaceAll(`_`,`-`))),{name:c,plugin:l}=Po(e);yield*S(r.join(i,`.oxlintrc.json`),yield*ce({categories:{correctness:`off`},plugins:s,rules:{[e]:`error`}}));let u=yield*Lo(i,[`--print-config`],t),d=Mo(u.stdout).pipe(M.flatMap(e=>D.findFirst(Object.keys(e.rules),e=>Po(e).name===c)),M.map(e=>Po(e)));return M.match(d,{onNone:()=>({builtIn:!1,name:c,plugin:l}),onSome:e=>({builtIn:!0,name:e.name,plugin:e.plugin.replaceAll(`_`,`-`)})})},T.scoped),Ho=Ot.nominal();function Uo(e,t,n){return Ho((e.relative(t,n)||`.`).split(e.sep).join(`/`))}const Wo=T.fn(`listGitFiles`)(function*(e,t){let n=yield*(yield*E.ChildProcessSpawner).spawn(dt.make(`git`,[`ls-files`,`-z`,...t],{cwd:e,stderr:`ignore`,stdin:`ignore`})),[r,i]=yield*T.all([H.mkString(H.decodeText(n.stdout)),n.exitCode],{concurrency:`unbounded`}),a=L(r,pt.split(`\0`),D.filter(e=>pt.isNonEmpty(e)));return M.liftPredicate(a,()=>i===0)},T.scoped,T.orElseSucceed(()=>M.none()));function Go(e,t=[]){return Wo(e,[`--cached`,`--others`,`--exclude-standard`,`--`,...t])}function Ko(e,t){return Wo(e,[`--others`,`--ignored`,`--exclude-standard`,`--`,t,`:(exclude,glob)**/node_modules/**`])}var qo=class extends I.TaggedClass(`Current`){},Jo=class extends I.TaggedClass(`Error`){};function Yo(e,t){let n=e.indexOf(`=`),r=n===-1?e:e.slice(0,n),i=M.liftPredicate(e.slice(n+1),()=>n!==-1),a=W.normalize(r.replaceAll(`\\`,`/`));return r.length===0||M.exists(i,e=>e.length===0)?T.fail(new Xe({reason:"Give a path, or `<path>=<file>`.",value:e})):W.isAbsolute(a)||Dt.isAbsolute(a)||a===`..`||a.startsWith(`../`)||a===`.`?T.fail(new Xe({reason:`The path must be a file inside the project, relative to the project root.`,value:e})):T.succeed({expected:t,path:a,source:i})}function Xo(e){let t={files:e.files,...M.match(e.plugin,{onNone:()=>({}),onSome:e=>({plugins:[e]})}),rules:{[e.rule]:[`error`,...e.settingOptions]}};return["// `adamantite rule try` wrote this file in a copy of the project.",`import config from ${JSON.stringify(`./${e.config}`)}`,``,`export default {`,` ...config,`,` overrides: [...(config.overrides ?? []), ${JSON.stringify(t)}],`,`}`,``].join(`
164
+ `)}const Zo=Ot.nominal(),Qo=T.fn(`replaceConfigs`)(function*(e,t){let n=yield*R.FileSystem,r=yield*P.Path;for(let[i,a]of t){let t=r.join(e,i),o=`oxlint.trial-base.config${r.extname(i)}`;yield*n.rename(t,r.join(r.dirname(t),o)),yield*S(t,a(o))}});function $o(e){return["// `adamantite harden` wrote this file in a copy of the project.",`import config from ${JSON.stringify(`./${e.config}`)}`,``,`const removals = new Map(${JSON.stringify([...e.removals])})`,``,`export default {`,` ...config,`,` overrides: (config.overrides ?? []).map((override, index) => ({`,` ...override,`,` rules: Object.fromEntries(`,` Object.entries(override.rules ?? {}).filter(`,` ([rule]) => !(removals.get(index) ?? []).includes(rule)`,` )`,` ),`,` })),`,`}`,``].join(`
165
+ `)}const es=T.fn(`makeProjectCopy`)(function*(e,t){let r=yield*R.FileSystem,i=yield*P.Path,a=yield*Go(e);if(M.isNone(a))return yield*new n({cwd:e});let o=yield*r.makeTempDirectoryScoped({prefix:`adamantite-trial-`}),s=D.dedupe(a.value.map(e=>i.dirname(i.join(o,e))));yield*T.forEach(s,e=>r.makeDirectory(e,{recursive:!0}),{concurrency:16,discard:!0}),yield*T.forEach(a.value,t=>r.copyFile(i.join(e,t),i.join(o,t)).pipe(T.catchReason(`PlatformError`,`NotFound`,()=>T.void)),{concurrency:16,discard:!0});let c=[e,...t.packageDirectories],l=yield*r.realPath(e),u=e=>{let t=i.relative(l,e);return M.liftPredicate(t,()=>t!==``&&t!==`..`&&!t.startsWith(`..${i.sep}`)&&!i.isAbsolute(t)&&!t.split(i.sep).includes(`node_modules`))},d=T.fnUntraced(function*(e){let t=yield*rt(e),n=yield*T.forEach(M.getOrElse(t,()=>[]).filter(e=>e!==`.cache`),T.fnUntraced(function*(t){let n=t.startsWith(`@`)&&!(yield*r.readLink(i.join(e,t)).pipe(T.as(!0),T.orElseSucceed(()=>!1)))?yield*rt(i.join(e,t)):M.none();return M.match(n,{onNone:()=>[t],onSome:e=>e.map(e=>`${t}/${e}`)})}),{concurrency:`unbounded`});return t.pipe(M.as(n.flat()))}),f=yield*T.forEach(c,T.fnUntraced(function*(t){let n=i.join(t,`node_modules`),a=i.join(o,i.relative(e,t),`node_modules`),s=yield*d(n);return M.isSome(s)&&(yield*r.makeDirectory(a,{recursive:!0})),yield*T.forEach(M.getOrElse(s,()=>[]),T.fnUntraced(function*(e){let t=i.join(n,e),s=(yield*r.realPath(t).pipe(T.option)).pipe(M.flatMap(e=>u(e)));return yield*r.makeDirectory(i.dirname(i.join(a,e)),{recursive:!0}),yield*r.symlink(M.match(s,{onNone:()=>t,onSome:e=>i.join(o,e)}),i.join(a,e)),s}),{concurrency:1})}),{concurrency:1}),p=yield*T.forEach(D.dedupe(D.getSomes(f.flat())),t=>Ko(e,t.split(i.sep).join(`/`)).pipe(T.map(e=>M.getOrElse(e,()=>[]))),{concurrency:`unbounded`});return yield*T.forEach(D.dedupe(p.flat()),t=>r.makeDirectory(i.dirname(i.join(o,t)),{recursive:!0}).pipe(T.andThen(r.copyFile(i.join(e,t),i.join(o,t)))),{concurrency:16,discard:!0}),Zo(o)},T.catchTag(`PlatformError`,e=>T.fail(new Qe({cause:e})))),ts=T.fn(`findConfig`)(function*(e,t){let n=yield*P.Path,r=[];for(let i=n.dirname(n.join(e,t));i===e||i.startsWith(`${e}${n.sep}`);i=n.dirname(i))r.push(...ea.map(e=>n.join(i,e)));return yield*T.findFirst(r,e=>g(e))});function ns(e){let t=[];for(let n of e){let e=t.find(e=>e.every(e=>e.case.path!==n.case.path));e===void 0?t.push([n]):e.push(n)}return t}const rs=T.fn(`tryRule`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path,{cases:i,cwd:a,rule:o,setting:c,workspace:u}=e,{name:d,plugin:f}=Po(o),p=yield*Vo(o,a),m=yield*es(a,u),h=e=>n.relative(m,e).split(n.sep).join(`/`),g=e=>{let t=[`Rule '${d}' not found in plugin '${f}'`,`Plugin '${f}' not found`].find(t=>F.isTagged(e,`TrialLintFailed`)&&e.output.includes(t));return c instanceof Jo&&t!==void 0?new ke({detail:t,rule:o}):e},_=yield*T.forEach(i,T.fnUntraced(function*(e){if(M.isNone(e.source)&&!(yield*t.exists(n.join(m,e.path))))return yield*new Xe({reason:(yield*t.exists(n.join(a,e.path)))?"Git ignores this file, so the copy of the project does not have it. Use `<path>=<file>` to lint its content.":"The project has no such file. Use `<path>=<file>` to lint other content.",value:e.path});let r=yield*ts(m,e.path);return M.isNone(r)?yield*new te({path:e.path}):{case:e,config:r.value,configFile:n.relative(n.dirname(r.value),n.join(m,e.path)).split(n.sep).join(`/`)}}),{concurrency:1});c instanceof Jo&&(yield*Qo(m,new Map(D.dedupe(_.map(e=>e.config)).map(e=>[n.relative(m,e),t=>Xo({config:t,files:D.dedupe(_.filter(t=>t.config===e).map(e=>e.configFile)),plugin:M.liftPredicate(p.plugin,e=>p.builtIn&&e!==`eslint`),rule:o,settingOptions:c.options})]))));let v=/* @__PURE__ */ new Map;for(let e of ns(_)){let i=e.flatMap(e=>M.match(e.case.source,{onNone:()=>[],onSome:t=>[{source:n.resolve(a,t),target:n.join(m,e.case.path)}]})),o=yield*T.forEach(i,({target:e})=>t.readFileString(e).pipe(T.option),{concurrency:`unbounded`});for(let{source:e,target:a}of i)yield*t.makeDirectory(n.dirname(a),{recursive:!0}),yield*S(a,yield*r(e));let c=e.map(e=>e.case.path),u=yield*zo(m,c).pipe(T.mapError(e=>g(e)));if(u.number_of_files<c.length){let e=new Set(yield*Bo(m,c));return yield*new l({path:c.find(t=>!e.has(t))??c[0]??``})}yield*T.forEach(i,({target:e},n)=>M.match(o[n]??M.none(),{onNone:()=>t.remove(e),onSome:n=>t.writeFileString(e,n)}),{concurrency:1,discard:!0});for(let t of e){let e=u.diagnostics.filter(e=>e.filename===t.case.path),n=e.filter(e=>e.code===void 0);if(n.length>0)return yield*new s({errors:n.map(e=>e.message),path:t.case.path});v.set(t.case,{case:t.case,config:h(t.config),diagnostics:e.filter(e=>e.code!==void 0&&Fo(e.code,p)).map(e=>({column:e.labels[0]?.span.column??1,line:e.labels[0]?.span.line??1,message:e.message}))})}}return D.getSomes(i.map(e=>M.fromUndefinedOr(v.get(e))))},T.scoped,T.catchTag(`PlatformError`,e=>T.fail(new Qe({cause:e}))));var is=class extends I.TaggedClass(`Linted`){},as=class extends I.TaggedClass(`Failed`){};const os=/[!*?[\]{}]/u;function ss(e){return e===null?null:e.type===`Literal`&&F.isString(e.value)?e.value:e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0]?.value.cooked??null:null}function cs(e){return e.computed?null:e.key.type===`Identifier`?e.key.name:e.key.type===`Literal`&&F.isString(e.key.value)?e.key.value:null}function ls(e,t){let n=e.properties.find(e=>e.type===`Property`&&cs(e)===t);return n?.type===`Property`?n.value:void 0}function us(e){if(e.type===`ArrayExpression`){let[t]=e.elements;return t!=null&&t.type!==`SpreadElement`&&us(t)}return e.type===`Literal`&&(e.value===`off`||e.value===`allow`||e.value===0)}function ds(e){let[t]=e.body.flatMap(e=>e.type===`ExportDefaultDeclaration`?[e]:[]);if(t===void 0)return;let n=t=>{if(t.type===`ObjectExpression`)return t;if(t.type===`CallExpression`){let[e]=t.arguments;return e!==void 0&&e.type!==`SpreadElement`?n(e):void 0}if(t.type===`Identifier`){let r=e.body.flatMap(e=>e.type===`VariableDeclaration`?e.declarations:e.type===`ExportNamedDeclaration`&&e.declaration?.type===`VariableDeclaration`?e.declaration.declarations:[]).find(e=>e.id.type===`Identifier`&&e.id.name===t.name);return r?.init?n(r.init):void 0}if(t.type===`TSAsExpression`||t.type===`TSSatisfiesExpression`)return n(t.expression)},r=t.declaration;return r.type===`ObjectExpression`||r.type===`CallExpression`||r.type===`Identifier`||r.type===`TSAsExpression`||r.type===`TSSatisfiesExpression`?n(r):void 0}function fs(e,t){let{errors:n,program:r}=bt(e,t,{sourceType:`module`});if(n.length>0)return[];let i=ds(r),a=i===void 0?void 0:ls(i,`overrides`);if(a?.type!==`ArrayExpression`)return[];let o=a.elements.findIndex(e=>e?.type===`SpreadElement`);return(o===-1?a.elements:a.elements.slice(0,o)).flatMap((e,t)=>{if(e?.type!==`ObjectExpression`)return[];let n=ls(e,`files`),r=ls(e,`rules`);if(n?.type!==`ArrayExpression`||r?.type!==`ObjectExpression`)return[];let i=n.elements.map(e=>ss(e)),a=r.properties.flatMap(e=>{let t=e.type===`Property`?cs(e):null;return e.type===`Property`&&t!==null&&us(e.value)?[t]:[]});return i.every(e=>e!==null)&&a.length>0?[{files:i,index:t,rules:a}]:[]})}const ps=T.fn(`readOverrides`)(function*(e,t,n,i){let a=yield*P.Path,o=e=>i===null||i===`.`||e===i||e.startsWith(`${i}/`),s=(t,n)=>a.relative(e,a.join(e,a.dirname(t),n)).split(a.sep).join(`/`),c=(yield*T.forEach(n,t=>r(a.join(e,t)).pipe(T.map(e=>({config:t,overrides:fs(t,e)}))),{concurrency:`unbounded`})).flatMap(({config:e,overrides:t})=>t.flatMap(t=>t.rules.map(n=>({config:e,globs:t.files.filter(e=>os.test(e)),index:t.index,literals:t.files.filter(e=>!os.test(e)).map(t=>s(e,t)).filter(e=>o(e)),rule:n})))),l=new Set(yield*T.filter(D.dedupe(c.flatMap(e=>e.literals)),t=>g(a.join(e,t)),{concurrency:`unbounded`})),u=c.filter(e=>e.literals.some(e=>l.has(e))),d=/* @__PURE__ */ new Map;if(u.length>0){let n=new Map(yield*T.forEach(D.dedupe(u.map(e=>e.rule)),t=>Vo(t,e).pipe(T.map(e=>[t,e])),{concurrency:`unbounded`})),r=yield*es(e,t);yield*Qo(r,new Map(D.dedupe(u.map(e=>e.config)).map(e=>{let t=/* @__PURE__ */ new Map;for(let n of u.filter(t=>t.config===e))t.set(n.index,[...t.get(n.index)??[],n.rule]);return[e,e=>$o({config:e,removals:t})]})));let i=D.dedupe(u.flatMap(e=>e.literals)).filter(e=>l.has(e)),a=yield*zo(r,i),o=new Set(a.number_of_files<i.length?yield*Bo(r,i):i),s=new Set(a.diagnostics.filter(e=>e.code===void 0).map(e=>e.filename));for(let e of u){let t=n.get(e.rule);for(let n of e.literals.filter(e=>l.has(e))){let r=a.diagnostics.some(e=>e.filename===n&&e.code!==void 0&&t!==void 0&&Fo(e.code,t)),i=o.has(n)?s.has(n)?`unparsable`:r?`breaks`:`clean`:`ignored`;d.set(`${e.rule}\0${n}`,i)}}}return new is({rules:c.filter(e=>e.literals.length>0||e.globs.length>0).map(e=>({config:e.config,files:e.literals.map(t=>({file:t,mark:d.get(`${e.rule}\0${t}`)??`missing`})),globs:e.globs,rule:e.rule}))})},T.scoped,T.catch(e=>T.succeed(new as({reason:e.message})))),ms=`Custom rules`,hs=`AGENTS.md`;function gs(e){let t=e.split(`/`);return!t.includes(`.changeset`)&&t.at(-1)!==`CHANGELOG.md`}function _s(e,t,n,r){let i=(t,n)=>{let r=e.relative(t,n);return r!==`..`&&!r.startsWith(`..${e.sep}`)&&!e.isAbsolute(r)},a=B.mapInput(B.flip(B.Number),e=>e.length),o=[t,...n.packageDirectories],s=o.filter(e=>i(r,e)),c=D.sort(o.filter(e=>i(e,r)),a).slice(0,1),l=s.length>0?s:c;return{contains:i,isSelectedFile:n=>{let[r=t]=D.sort(o.filter(r=>i(r,e.join(t,n))),a);return r===t||l.includes(r)},packageDirectories:o,selectedPackages:l}}const vs=T.fn(`readScopedDocumentation`)(function*(e,t,n){let r=yield*P.Path,{contains:i,isSelectedFile:a}=_s(r,e,t,n),o=t=>{let a=r.dirname(r.join(e,t));return i(a,n)||i(n,a)},s=yield*T.transposeOption((yield*Go(e,[`*.md`,`*.mdx`,`*.mdc`])).pipe(M.map(t=>T.forEach(t.filter(e=>gs(e)),t=>g(r.join(e,t)).pipe(T.map(e=>e?[t]:[])),{concurrency:`unbounded`}).pipe(T.map(e=>e.flat())))));return{agentReach:(yield*T.transposeOption(s.pipe(M.map(t=>wo(e,t,t.filter(e=>r.basename(e)===hs&&o(e))))))).pipe(M.map(e=>({brokenLinks:e.brokenLinks.filter(e=>a(e.file)),unreached:e.unreached.filter(e=>a(e))}))),documentationFiles:s.pipe(M.map(e=>e.filter(e=>a(e))))}}),ys=T.fn(`readHardenReach`)(function*(e,t,n=e){return(yield*vs(e,t,n)).agentReach}),bs=T.fn(`readHardenContext`)(function*(e,t,n=e){let r=yield*P.Path,i=t=>r.relative(e,t)||`.`,{packageDirectories:a,selectedPackages:o}=_s(r,e,t,n),s=[.../* @__PURE__ */ new Set([e,...o])].map(e=>r.join(e,hs)),[{calls:c,configs:l,unresolvedCalls:u},d,f]=yield*T.all([sa(a,o),T.filter(s,e=>g(e),{concurrency:`unbounded`}),vs(e,t,n)],{concurrency:`unbounded`});return{agentReach:f.agentReach,configs:l.map(t=>Uo(r,e,t)),documentationFiles:f.documentationFiles,instructionFiles:d.map(e=>i(e)),rulesFolders:[...new Set(c.map(e=>i(e.dir)))],scope:n===e?null:Uo(r,e,n),unresolvedCalls:[...new Set(u.map(e=>i(e)))]}}),xs=/^[\w./-]+$/u;function Ss(e){return xs.test(e)?e:`'${e.replaceAll(`'`,`'\\''`)}'`}function Cs(e,t){return e.length===0?t:e.map(e=>`- \`${e}\``).join(`
166
+ `)}function ws(e){return[e.unreached.length===0?"Links and code spans from each `AGENTS.md` reach each Markdown file.":`No chain of links or code spans from an \`AGENTS.md\` reaches these Markdown files:\n\n${Cs(e.unreached,``)}`,...e.brokenLinks.length===0?[]:[`These links go to Markdown files that do not exist:\n\n${e.brokenLinks.map(e=>`- \`${e.file}\` links to \`${e.target}\``).join(`
169
167
  `)}`]].join(`
170
168
 
171
- `)}function ts(e){return e.rulesFolders.length===0&&e.unresolvedCalls.length===0?`No \`custom()\` call loads a rules folder. Before you write the first custom rule, add \`custom()\` from \`adamantite/rules\` to the \`extends\` of the Oxlint config. It loads \`${K}\` by default.`:[...e.rulesFolders.map(e=>`- \`${e}\``),...e.unresolvedCalls.map(e=>`- A \`custom()\` call in \`${e}\` whose \`dir\` is not a string literal. Read the config to find its rules folder.`)].join(`
172
- `)}function ns(e){return N.match(e,{onNone:()=>'Adamantite could not count the comments that turn a rule off, because Oxlint could not list the files that it lints. Count them yourself, for example with `rg -n "(oxlint|eslint)-disable"`, and leave out the files that the config ignores.',onSome:e=>e.length===0?"No `oxlint-disable` or `eslint-disable` comment turns a rule off.":["Adamantite counted the `oxlint-disable` and `eslint-disable` comments of each rule in the files that Oxlint lints. Oxlint obeys both. A comment that names no rule turns off all rules.",``,...e.map(({locations:e,rule:t})=>{let n=N.match(t,{onNone:()=>`All rules`,onSome:e=>`\`${e}\``}),r=e.slice(0,5).map(e=>`\`${e}\``).join(`, `),i=e.length>5?`, and ${e.length-5} more`:``;return`- ${n}: ${e.length} ${e.length===1?`comment`:`comments`}, in ${r}${i}`})].join(`
173
- `)})}const rs={breaks:`still breaks the rule`,clean:`no longer breaks the rule`,ignored:`the config ignores it, so Oxlint did not lint it`,missing:`does not exist`,unparsable:`does not parse, so Oxlint did not lint it`};function is(e){return e instanceof Fo?[`Adamantite could not lint the files of the overrides that turn a rule off:`,``,"```text",e.reason,"```",``,`For each file in an override that turns a rule off, read the file and find the code that the rule reports.`].join(`
174
- `):e.rules.length===0?`No override in the Oxlint config turns a rule off for files that it names.`:[`Adamantite turned each rule on again in a copy of the project, and linted each file that an override names and turns the rule off for. Paths are relative to the project root. An override that code builds, such as a spread, is not in this list.`,``,...e.rules.map(({config:e,files:t,globs:n,rule:r})=>[`- \`${r}\` in \`${e}\`:`,...t.map(({file:e,mark:t})=>` - \`${e}\`: ${rs[t]}`),...n.map(e=>` - \`${e}\`: a glob, so Adamantite did not lint its files`)].join(`
169
+ `)}function Ts(e){return e.rulesFolders.length===0&&e.unresolvedCalls.length===0?`No \`custom()\` call loads a rules folder. Before you write the first custom rule, add \`custom()\` from \`adamantite/rules\` to the \`extends\` of the Oxlint config. It loads \`${q}\` by default.`:[...e.rulesFolders.map(e=>`- \`${e}\``),...e.unresolvedCalls.map(e=>`- A \`custom()\` call in \`${e}\` whose \`dir\` is not a string literal. Read the config to find its rules folder.`)].join(`
170
+ `)}function Es(e){return M.match(e,{onNone:()=>'Adamantite could not count the comments that turn a rule off, because Oxlint could not list the files that it lints. Count them yourself, for example with `rg -n "(oxlint|eslint)-disable"`, and leave out the files that the config ignores.',onSome:e=>e.length===0?"No `oxlint-disable` or `eslint-disable` comment turns a rule off.":["Adamantite counted the `oxlint-disable` and `eslint-disable` comments of each rule in the files that Oxlint lints. Oxlint obeys both. A comment that names no rule turns off all rules.",``,...e.map(({locations:e,rule:t})=>{let n=M.match(t,{onNone:()=>`All rules`,onSome:e=>`\`${e}\``}),r=e.slice(0,5).map(e=>`\`${e}\``).join(`, `),i=e.length>5?`, and ${e.length-5} more`:``;return`- ${n}: ${e.length} ${e.length===1?`comment`:`comments`}, in ${r}${i}`})].join(`
171
+ `)})}const Ds={breaks:`still breaks the rule`,clean:`no longer breaks the rule`,ignored:`the config ignores it, so Oxlint did not lint it`,missing:`does not exist`,unparsable:`does not parse, so Oxlint did not lint it`};function Os(e){return e instanceof as?[`Adamantite could not lint the files of the overrides that turn a rule off:`,``,"```text",e.reason,"```",``,`For each file in an override that turns a rule off, read the file and find the code that the rule reports.`].join(`
172
+ `):e.rules.length===0?`No override in the Oxlint config turns a rule off for files that it names.`:[`Adamantite turned each rule on again in a copy of the project, and linted each file that an override names and turns the rule off for. Paths are relative to the project root. An override that code builds, such as a spread, is not in this list.`,``,...e.rules.map(({config:e,files:t,globs:n,rule:r})=>[`- \`${r}\` in \`${e}\`:`,...t.map(({file:e,mark:t})=>` - \`${e}\`: ${Ds[t]}`),...n.map(e=>` - \`${e}\`: a glob, so Adamantite did not lint its files`)].join(`
175
173
  `))].join(`
176
- `)}function as(e,{adamantiteVersion:t,commits:n,overrides:r,suppressions:i}){let a=Qo(e.scope??`.`);return Rr(`# Adamantite harden
174
+ `)}function ks(e,{adamantiteVersion:t,commits:n,overrides:r,suppressions:i}){let a=Ss(e.scope??`.`);return Hr(`# Adamantite harden
177
175
 
178
176
  Find the coding standards that this target project already follows. Propose the highest step of the enforcement ladder that can enforce each standard. The project uses Adamantite {{version}}.
179
177
 
@@ -373,9 +371,9 @@ The report is complete when each approved candidate has a verified result or an
373
371
  - Temporary verification files are removed, and user-owned tests and CI steps remain.
374
372
  - Project checks and Doctor pass, or the report names each blocked check and remaining finding.
375
373
  - Approved discovery gaps are closed, and added documentation links resolve.
376
- `,{agentReach:N.match(e.agentReach,{onNone:()=>"Git could not list the files, so agent reach is unavailable. Follow the links from each `AGENTS.md` and record the files you checked. Report this fallback with the missing sources.",onSome:e=>es(e)}),configs:$o(e.configs,"No Oxlint config was found. When you show the candidates, tell the user to run `adamantite init` before step 9."),customRulesSection:Wo,documentationFiles:N.match(e.documentationFiles,{onNone:()=>`Git could not list project files. Find Markdown files with a file search, excluding dependencies, build output, changesets, and changelogs. Record the search scope and report this fallback with the missing sources.`,onSome:e=>$o(e,`The project has no Markdown file.`)}),fixHistoryCommand:`\`git log -n ${n} --no-merges --format="%h %s" -- ${a}\``,instructionFiles:$o(e.instructionFiles,"No `AGENTS.md` was found. Each file that states a standard is a discovery gap, and the root `AGENTS.md` must point to it."),overrides:is(r),rulesFolders:ts(e),scope:e.scope===null?`Adamantite found these files in the project and its workspace packages. Paths are relative to the project root.`:`Adamantite found these files for \`${e.scope}\`, the folder that \`--path\` selects. Survey only the code in this folder. Paths are relative to the project root.`,suppressions:ns(i),version:t})}const os=/\.[cm]?[jt]sx?$/u,ss=/^\s*(?:oxlint|eslint)-disable(?:-next-line|-line)?(?:\s(?<rules>[\s\S]*))?$/u,cs=/\s--[\s\S]*$/u;function ls(e,t){let{comments:n,errors:r}=bt(e,t);return r.length>0?[]:n.flatMap(e=>{let n=ss.exec(e.value);if(n===null)return[];let r=(n.groups?.rules??``).replace(cs,``).split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return[{line:t.slice(0,e.start).split(`
377
- `).length,rules:r}]})}const us=E.fn(`readSuppressions`)(function*(e,t){let n=yield*P.Path,r=yield*go(e).pipe(E.option),i=e=>t===null||t===`.`||e.startsWith(`${t}/`);return yield*E.transposeOption(r.pipe(N.map(t=>E.gen(function*(){let r=yield*E.forEach(t.filter(e=>os.test(e)&&i(e)),t=>f(n.join(e,t)).pipe(E.map(e=>N.match(e,{onNone:()=>[],onSome:e=>e.includes(`-disable`)?ls(t,e).flatMap(({line:e,rules:n})=>(n.length===0?[void 0]:n).map(n=>({location:`${t}:${e}`,rule:N.fromUndefinedOr(n)}))):[]}))),{concurrency:16}),a=O.groupBy(r.flat(),e=>N.getOrElse(e.rule,()=>``));return O.sort(Object.values(a).map(e=>({locations:e.map(e=>e.location),rule:e[0].rule})),B.combine(B.mapInput(B.flip(B.Number),e=>e.locations.length),B.mapInput(B.String,e=>N.getOrElse(e.rule,()=>``))))}))))}),ds=`0.46.0`,{$match:fs,BrokenLink:ps,CheckFailed:ms,Findings:hs}=I.taggedEnum();function gs(e){return`${e.file}\0${e.target}`}const _s=E.fn(`readInstalledVersion`)(function*(e){let t=yield*P.Path,n=yield*(yield*Ne).resolve(e,G(`./lint`));if(N.isNone(n))return N.none();for(let e=t.dirname(n.value);e!==t.dirname(e);e=t.dirname(e)){let t=yield*u(e).pipe(E.option);if(N.isSome(t)&&t.value.name===`adamantite`)return N.fromUndefinedOr(t.value.version)}return N.none()}),vs=M.Directory(`path`,{mustExist:!0}).pipe(M.optional,M.withDescription(`Limit the session to a project folder or workspace package. The path is relative to the current directory`)),ys=M.Int(`commits`).pipe(M.withSchema(z.Int.pipe(z.check(z.isGreaterThan(0,{message:"`--commits` must be a positive number"})))),M.withDefault(200),M.withDescription(`Set how many recent commits the agent reads to find past fixes`)),bs=E.fn(`preparePrompt`)(function*(e,t,n){let r=yield*re(e),i=yield*Xo(e,r,t),[a,o]=yield*E.all([Uo(e,r,i.configs,i.scope),us(e,i.scope)],{concurrency:`unbounded`});return{agentReach:i.agentReach,prompt:as(i,{adamantiteVersion:ds,commits:n,overrides:a,suppressions:o})}});var xs=k.make(`harden`,{commits:ys,scope:vs}).pipe(k.withDescription(`Ask a coding agent to turn project standards into custom rules and instructions`),k.withHandler(({commits:t,scope:n})=>E.gen(function*(){let r=j.cwd(),i=yield*R.FileSystem,a=yield*P.Path,o=yield*$,s=yield*(yield*pa).isInteractive;s&&(yield*o.intro(`๐Ÿ’  adamantite harden`));let c=yield*u(r),l=c.name===`adamantite`;if(!l&&!c.devDependencies?.adamantite&&!c.dependencies?.adamantite)return yield*new e({command:`harden`});let d=l?N.fromUndefinedOr(c.version):yield*_s(r);if(N.isNone(d))return yield*new ne({command:`harden`});if(d.value!==ds)return yield*new ye({command:`harden`,installed:d.value,running:ds});let f=N.isSome(n)?yield*i.realPath(a.resolve(r,n.value)).pipe(E.mapError(e=>new Je({cause:e,path:n.value}))):void 0;if(f!==void 0){let e=a.relative(r,f);if(e===`..`||e.startsWith(`..${a.sep}`)||a.isAbsolute(e))return yield*new oe({cwd:r,scope:f})}let{agentReach:p,prompt:m}=yield*bs(r,f,t);if(!s){yield*o.message(m);return}let h=yield*Da({command:`Harden`,cwd:r,message:`How do you want to harden this project?`,prompt:m,subject:`the prompt`});if(!(h instanceof Ca)){yield*o.outro(`Harden ended without an agent session.`);return}let{agent:g}=h,_=yield*Dr({cwd:r}).pipe(E.as([]),E.catchTags({CliNotFound:e=>o.log.error(e.message).pipe(E.as([ms()])),CommandFailed:()=>E.succeed([ms()])})),v=yield*fa(r),[ee,y]=yield*E.all([Yo(r,v.workspace,f),ca(v)],{concurrency:`unbounded`}),te=new Set(N.match(p,{onNone:()=>[],onSome:e=>e.brokenLinks.map(e=>gs(e))})),b=N.match(ee,{onNone:()=>[],onSome:e=>e.brokenLinks.filter(e=>!te.has(gs(e)))}),x=[..._,...y.findings.length>0?[hs({findings:y.findings})]:[],...b.map(e=>ps({link:e}))];for(let e of y.warnings)yield*o.log.warning(e);if(yield*E.forEach(x,fs({BrokenLink:({link:e})=>o.log.error(`\`${e.file}\` links to \`${e.target}\`, which does not exist, after the ${g.name} session.`),CheckFailed:()=>o.log.error(`\`adamantite check\` failed after the ${g.name} session.`),Findings:({findings:e})=>o.log.warning(`Doctor found issues after the ${g.name} session.`).pipe(E.andThen(ha(e)))}),{discard:!0}),x.length>0)return yield*o.outro(`โš ๏ธ Harden verification failed.`),yield*new Ie({command:`harden`,exitCode:D.ExitCode(1)});yield*o.log.success(`\`adamantite check\` and Doctor pass after the ${g.name} session.`),yield*o.outro(`โœ… Harden checks passed.`)}).pipe(E.catchTag([`AdamantiteNotInstalled`,`AdamantiteNotInNodeModules`,`AdamantiteVersionMismatch`,`ScopeOutsideProject`],e=>E.gen(function*(){let t=yield*$;return(yield*(yield*pa).isInteractive)?(yield*t.log.warning(e.message),yield*t.outro(`โš ๏ธ Harden did not start.`)):yield*t.message(e.message),yield*new Ie({command:`harden`,exitCode:D.ExitCode(1)})})),E.catchTag(`OperationCancelled`,()=>E.gen(function*(){return yield*(yield*$).cancel(`Harden was cancelled.`),yield*new Ie({command:`harden`,exitCode:D.ExitCode(1)})})))));const Ss=' .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 ',Cs=E.gen(function*(){let e=yield*(yield*kt.Terminal).columns,t=Ss.split(`
378
- `).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*ut.info(Ss))}),ws=[`vscode`,`zed`],Ts={vscode:`VS Code / Cursor / Windsurf`,zed:`Zed`},Es=E.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:O.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:O.dedupe(e.presets),scripts:O.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new T({reason:"Select at least one script with `--script <name>`."});let r=y(n.scripts,`oxlint`);if(n.presets.length>0&&!r)return yield*new T({reason:"`--preset` requires the `check` or `fix` script."});let i=O.head(_e(n.presets));if(N.isSome(i)){let{required:e,requiredBy:t}=i.value;return yield*new T({reason:`\`--preset ${t}\` requires \`--preset ${e}\`.`})}return n.typescript&&!r?yield*new T({reason:"`--typescript` requires the `check` or `fix` script."}):n.installExtensions&&n.editors.length===0?yield*new T({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!Vr(n.scripts)?yield*new T({reason:"`--github-actions` requires --script check or --script analyze."}):n.githubActions&&!o(t)?yield*new T({reason:`\`--github-actions\` does not support the detected package manager \`${t}\`. Use ${_(`disjunction`)}.`}):{agents:n.agents,editors:O.isReadonlyArrayNonEmpty(n.editors)?N.some({installExtensions:n.installExtensions,names:n.editors}):N.none(),githubActions:n.githubActions?N.liftPredicate(t,o):N.none(),lint:r?N.some({presets:n.presets,typescript:n.typescript}):N.none(),overwriteScripts:n.overwriteScripts,scripts:n.scripts}}),Ds=M.Boolean(Y.nonInteractive).pipe(M.withDefault(!1),M.withDescription(`Configure without prompts. Select at least one --script`)),Os=M.Literals(Y.script,ae).pipe(M.atMost(ae.length),M.withDescription(`Add a package script. Repeat --script to add more. Required with --non-interactive`)),ks=M.Literals(Y.preset,he).pipe(M.atMost(he.length),M.withDescription(`Select an Oxlint preset. Repeat --preset to add more. Requires --script check or --script fix`)),As=M.Literals(Y.editor,ws).pipe(M.atMost(ws.length),M.withDescription(`Configure an editor. Repeat --editor to add more`)),js=M.Boolean(`typescript`).pipe(M.withDefault(!1),M.withDescription(`Use the TypeScript preset. Requires --script check or --script fix`)),Ms=M.Boolean(`install-extensions`).pipe(M.withDefault(!1),M.withDescription(`Install recommended editor extensions. Select at least one --editor`)),Ns=M.Boolean(`github-actions`).pipe(M.withDefault(!1),M.withDescription(`Add a GitHub Actions workflow. Requires --script check or --script analyze and ${_(`disjunction`)}`)),Ps={agents:M.Boolean(Y.agents).pipe(M.withDefault(!1),M.withDescription(`Add Adamantite guidance to AGENTS.md and the Adamantite skill to the skill folders of your coding agents`)),editors:As,githubActions:Ns,installExtensions:Ms,nonInteractive:Ds,overwriteScripts:M.Boolean(`overwrite-scripts`).pipe(M.withDefault(!1),M.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),presets:ks,scripts:Os,typescript:js},Fs=e=>`\`${e.script}\` runs \`${e.command}\`. Adamantite would replace it with \`${Xe[e.script]}\`.`,Is=E.gen(function*(){let e=yield*$,t=yield*e.multiselect({message:`Which presets should Adamantite use with the core preset?`,options:be.map(e=>({hint:qe(e),label:e.label,value:e.name})),required:!1}),n=_e(t);for(let{required:t,requiredBy:r}of n)yield*e.log.info(`Added the \`${t}\` preset, which \`${r}\` requires.`);return[...n.map(({required:e})=>e),...t]}),Ls=E.fn(`collectInteractiveInitOptions`)(function*(e,t,n){let r=yield*$,i=yield*r.multiselect({message:"Which scripts should Adamantite add to `package.json`?",options:[{hint:`recommended`,label:`check - find formatting, lint, and type errors`,value:`check`},{hint:`recommended`,label:`fix - apply safe lint fixes and format code`,value:`fix`},{label:t?`analyze - find unused code and check monorepo consistency`:`analyze - find unused dependencies, exports, and files`,value:`analyze`}]}),a=yield*u(e),s=ke(a,i);for(let e of s)yield*r.log.warning(Fs(e));let c=s.length>0?yield*r.confirm({initialValue:!1,message:s.length===1?`Replace this script with Adamantite's command?`:`Replace these scripts with Adamantite's commands?`}):!1,l=y(i,`oxlint`),d=l?yield*Is:[],f=l?yield*r.confirm({initialValue:!0,message:t?`Show how to use the TypeScript preset in each workspace package?`:`Use the Adamantite TypeScript preset?`}):!1,p=yield*r.multiselect({message:`Which editors should Adamantite configure?`,options:ws.map(e=>({label:Ts[e],value:e})),required:!1}),m=p.length>0?yield*r.confirm({initialValue:!0,message:`Install the recommended editor extensions?`}):!1,h=o(n),g=c?[]:s.map(e=>e.script),v=i.filter(e=>!g.includes(e));Vr(v)&&!h&&(yield*r.log.info(`Adamantite cannot generate a GitHub Actions workflow for \`${n}\`. It supports ${_(`conjunction`)}.`));let ee=Vr(v)&&h?yield*r.confirm({message:`Add a GitHub Actions workflow to run the selected checks?`}):!1;return{agents:yield*r.confirm({initialValue:!0,message:`Teach coding agents to use Adamantite? This adds an AGENTS.md section and the Adamantite skill.`}),editors:p,githubActions:ee,installExtensions:m,overwriteScripts:c,presets:d,scripts:i,typescript:f}}),Rs=`adamantite`,zs={"SKILL.md":`---
374
+ `,{agentReach:M.match(e.agentReach,{onNone:()=>"Git could not list the files, so agent reach is unavailable. Follow the links from each `AGENTS.md` and record the files you checked. Report this fallback with the missing sources.",onSome:e=>ws(e)}),configs:Cs(e.configs,"No Oxlint config was found. When you show the candidates, tell the user to run `adamantite init` before step 9."),customRulesSection:ms,documentationFiles:M.match(e.documentationFiles,{onNone:()=>`Git could not list project files. Find Markdown files with a file search, excluding dependencies, build output, changesets, and changelogs. Record the search scope and report this fallback with the missing sources.`,onSome:e=>Cs(e,`The project has no Markdown file.`)}),fixHistoryCommand:`\`git log -n ${n} --no-merges --format="%h %s" -- ${a}\``,instructionFiles:Cs(e.instructionFiles,"No `AGENTS.md` was found. Each file that states a standard is a discovery gap, and the root `AGENTS.md` must point to it."),overrides:Os(r),rulesFolders:Ts(e),scope:e.scope===null?`Adamantite found these files in the project and its workspace packages. Paths are relative to the project root.`:`Adamantite found these files for \`${e.scope}\`, the folder that \`--path\` selects. Survey only the code in this folder. Paths are relative to the project root.`,suppressions:Es(i),version:t})}const As=/\.[cm]?[jt]sx?$/u,js=/^\s*(?:oxlint|eslint)-disable(?:-next-line|-line)?(?:\s(?<rules>[\s\S]*))?$/u,Ms=/\s--[\s\S]*$/u;function Ns(e,t){let{comments:n,errors:r}=bt(e,t);return r.length>0?[]:n.flatMap(e=>{let n=js.exec(e.value);if(n===null)return[];let r=(n.groups?.rules??``).replace(Ms,``).split(`,`).map(e=>e.trim()).filter(e=>e.length>0);return[{line:t.slice(0,e.start).split(`
375
+ `).length,rules:r}]})}const Ps=T.fn(`readSuppressions`)(function*(e,t){let n=yield*P.Path,r=yield*Bo(e).pipe(T.option),i=e=>t===null||t===`.`||e.startsWith(`${t}/`);return yield*T.transposeOption(r.pipe(M.map(t=>T.gen(function*(){let r=yield*T.forEach(t.filter(e=>As.test(e)&&i(e)),t=>f(n.join(e,t)).pipe(T.map(e=>M.match(e,{onNone:()=>[],onSome:e=>e.includes(`-disable`)?Ns(t,e).flatMap(({line:e,rules:n})=>(n.length===0?[void 0]:n).map(n=>({location:`${t}:${e}`,rule:M.fromUndefinedOr(n)}))):[]}))),{concurrency:16}),a=D.groupBy(r.flat(),e=>M.getOrElse(e.rule,()=>``));return D.sort(Object.values(a).map(e=>({locations:e.map(e=>e.location),rule:e[0].rule})),B.combine(B.mapInput(B.flip(B.Number),e=>e.locations.length),B.mapInput(B.String,e=>M.getOrElse(e.rule,()=>``))))}))))}),Fs=`0.47.0`,{$match:Is,BrokenLink:Ls,CheckFailed:Rs,Findings:zs}=I.taggedEnum();function Bs(e){return`${e.file}\0${e.target}`}const Vs=T.fn(`readInstalledVersion`)(function*(e){let t=yield*P.Path,n=yield*(yield*Pe).resolve(e,K(`./lint`));if(M.isNone(n))return M.none();for(let e=t.dirname(n.value);e!==t.dirname(e);e=t.dirname(e)){let t=yield*u(e).pipe(T.option);if(M.isSome(t)&&t.value.name===`adamantite`)return M.fromUndefinedOr(t.value.version)}return M.none()}),Hs=j.Directory(`path`,{mustExist:!0}).pipe(j.optional,j.withDescription(`Limit the session to a project folder or workspace package. The path is relative to the current directory`)),Us=j.Int(`commits`).pipe(j.withSchema(z.Int.pipe(z.check(z.isGreaterThan(0,{message:"`--commits` must be a positive number"})))),j.withDefault(200),j.withDescription(`Set how many recent commits the agent reads to find past fixes`)),Ws=T.fn(`preparePrompt`)(function*(e,t,n){let r=yield*re(e),i=yield*bs(e,r,t),[a,o]=yield*T.all([ps(e,r,i.configs,i.scope),Ps(e,i.scope)],{concurrency:`unbounded`});return{agentReach:i.agentReach,prompt:ks(i,{adamantiteVersion:Fs,commits:n,overrides:a,suppressions:o})}});var Gs=O.make(`harden`,{commits:Us,scope:Hs}).pipe(O.withDescription(`Ask a coding agent to turn project standards into custom rules and instructions`),O.withHandler(({commits:t,scope:n})=>T.gen(function*(){let r=A.cwd(),i=yield*R.FileSystem,a=yield*P.Path,o=yield*$,s=yield*(yield*La).isInteractive;s&&(yield*o.intro(`๐Ÿ’  adamantite harden`));let c=yield*u(r),l=c.name===`adamantite`;if(!l&&!c.devDependencies?.adamantite&&!c.dependencies?.adamantite)return yield*new e({command:`harden`});let d=l?M.fromUndefinedOr(c.version):yield*Vs(r);if(M.isNone(d))return yield*new ne({command:`harden`});if(d.value!==Fs)return yield*new ye({command:`harden`,installed:d.value,running:Fs});let f=M.isSome(n)?yield*i.realPath(a.resolve(r,n.value)).pipe(T.mapError(e=>new Ye({cause:e,path:n.value}))):void 0;if(f!==void 0){let e=a.relative(r,f);if(e===`..`||e.startsWith(`..${a.sep}`)||a.isAbsolute(e))return yield*new oe({cwd:r,scope:f})}let{agentReach:p,prompt:m}=yield*Ws(r,f,t);if(!s){yield*o.message(m);return}let h=yield*Za({command:`Harden`,cwd:r,message:`How do you want to harden this project?`,prompt:m,subject:`the prompt`});if(!(h instanceof qa)){yield*o.outro(`Harden ended without an agent session.`);return}let{agent:g}=h,_=yield*Cr({cwd:r}).pipe(T.as([]),T.catchTags({CliNotFound:e=>o.log.error(e.message).pipe(T.as([Rs()])),CommandFailed:()=>T.succeed([Rs()])})),v=yield*Ia(r),[ee,y]=yield*T.all([ys(r,v.workspace,f),Ma(v)],{concurrency:`unbounded`}),te=new Set(M.match(p,{onNone:()=>[],onSome:e=>e.brokenLinks.map(e=>Bs(e))})),b=M.match(ee,{onNone:()=>[],onSome:e=>e.brokenLinks.filter(e=>!te.has(Bs(e)))}),x=[..._,...y.findings.length>0?[zs({findings:y.findings})]:[],...b.map(e=>Ls({link:e}))];for(let e of y.warnings)yield*o.log.warning(e);if(yield*T.forEach(x,Is({BrokenLink:({link:e})=>o.log.error(`\`${e.file}\` links to \`${e.target}\`, which does not exist, after the ${g.name} session.`),CheckFailed:()=>o.log.error(`\`adamantite check\` failed after the ${g.name} session.`),Findings:({findings:e})=>o.log.warning(`Doctor found issues after the ${g.name} session.`).pipe(T.andThen(za(e)))}),{discard:!0}),x.length>0)return yield*o.outro(`โš ๏ธ Harden verification failed.`),yield*new Le({command:`harden`,exitCode:E.ExitCode(1)});yield*o.log.success(`\`adamantite check\` and Doctor pass after the ${g.name} session.`),yield*o.outro(`โœ… Harden checks passed.`)}).pipe(T.catchTag([`AdamantiteNotInstalled`,`AdamantiteNotInNodeModules`,`AdamantiteVersionMismatch`,`ScopeOutsideProject`],e=>T.gen(function*(){let t=yield*$;return(yield*(yield*La).isInteractive)?(yield*t.log.warning(e.message),yield*t.outro(`โš ๏ธ Harden did not start.`)):yield*t.message(e.message),yield*new Le({command:`harden`,exitCode:E.ExitCode(1)})})),T.catchTag(`OperationCancelled`,()=>T.gen(function*(){return yield*(yield*$).cancel(`Harden was cancelled.`),yield*new Le({command:`harden`,exitCode:E.ExitCode(1)})})))));const Ks=' .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 ',qs=T.gen(function*(){let e=yield*(yield*kt.Terminal).columns,t=Ks.split(`
376
+ `).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*ut.info(Ks))}),Js=[`vscode`,`zed`],Ys={vscode:`VS Code / Cursor / Windsurf`,zed:`Zed`},Xs=T.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:D.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:D.dedupe(e.presets),scripts:D.dedupe(e.scripts),typescript:e.typescript},r=y(n.scripts,`oxlint`);if(n.presets.length>0&&!r)return yield*new Ce({reason:"`--preset` requires the `check` or `fix` script."});let i=D.head(_e(n.presets));if(M.isSome(i)){let{required:e,requiredBy:t}=i.value;return yield*new Ce({reason:`\`--preset ${t}\` requires \`--preset ${e}\`.`})}return n.installExtensions&&n.editors.length===0?yield*new Ce({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!Gr(n.scripts)?yield*new Ce({reason:"`--github-actions` requires --script check or --script analyze."}):n.githubActions&&!o(t)?yield*new Ce({reason:`\`--github-actions\` does not support the detected package manager \`${t}\`. Use ${_(`disjunction`)}.`}):{agents:n.agents,editors:D.isReadonlyArrayNonEmpty(n.editors)?M.some({installExtensions:n.installExtensions,names:n.editors}):M.none(),githubActions:n.githubActions?M.liftPredicate(t,o):M.none(),lint:r?M.some({presets:n.presets}):M.none(),overwriteScripts:n.overwriteScripts,scripts:n.scripts,typescript:n.typescript}}),Zs=j.Boolean(J.nonInteractive).pipe(j.withDefault(!1),j.withDescription(`Configure without prompts. Select at least one --script or --typescript`)),Qs=j.Literals(J.script,ae).pipe(j.atMost(ae.length),j.withDescription(`Add a package script. Repeat --script to add more`)),$s=j.Literals(J.preset,he).pipe(j.atMost(he.length),j.withDescription(`Select an Oxlint preset. Repeat --preset to add more. Requires --script check or --script fix`)),ec=j.Literals(J.editor,Js).pipe(j.atMost(Js.length),j.withDescription(`Configure an editor. Repeat --editor to add more`)),tc=j.Literals(`typescript`,ba).pipe(j.optional,j.withDescription(`Use a TypeScript preset: typescript for strict types, tsconfig for strict config`)),nc=j.Boolean(`install-extensions`).pipe(j.withDefault(!1),j.withDescription(`Install recommended editor extensions. Select at least one --editor`)),rc=j.Boolean(`github-actions`).pipe(j.withDefault(!1),j.withDescription(`Add a GitHub Actions workflow. Requires --script check or --script analyze and ${_(`disjunction`)}`)),ic={agents:j.Boolean(J.agents).pipe(j.withDefault(!1),j.withDescription(`Add Adamantite guidance to AGENTS.md and the Adamantite skill to the skill folders of your coding agents`)),editors:ec,githubActions:rc,installExtensions:nc,nonInteractive:Zs,overwriteScripts:j.Boolean(`overwrite-scripts`).pipe(j.withDefault(!1),j.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),presets:$s,scripts:Qs,typescript:tc},ac=e=>`\`${e.script}\` runs \`${e.command}\`. Adamantite would replace it with \`${Ze[e.script]}\`.`,oc=T.gen(function*(){let e=yield*$,t=yield*e.multiselect({message:`Which presets should Adamantite use with the core preset?`,options:be.map(e=>({hint:Je(e),label:e.label,value:e.name})),required:!1}),n=_e(t);for(let{required:t,requiredBy:r}of n)yield*e.log.info(`Added the \`${t}\` preset, which \`${r}\` requires.`);return[...n.map(({required:e})=>e),...t]}),sc=T.fn(`collectInteractiveInitOptions`)(function*(e,t,n){let r=yield*$,i=yield*r.multiselect({message:"Which scripts should Adamantite add to `package.json`?",options:[{hint:`recommended`,label:`check - find formatting, lint, and type errors`,value:`check`},{hint:`recommended`,label:`fix - apply safe lint fixes and format code`,value:`fix`},{label:t?`analyze - find unused code and check monorepo consistency`:`analyze - find unused dependencies, exports, and files`,value:`analyze`}],required:!1}),a=yield*u(e),s=Ae(a,i);for(let e of s)yield*r.log.warning(ac(e));let c=s.length>0?yield*r.confirm({initialValue:!1,message:s.length===1?`Replace this script with Adamantite's command?`:`Replace these scripts with Adamantite's commands?`}):!1,l=y(i,`oxlint`)?yield*oc:[],d=(yield*r.confirm({initialValue:!0,message:`Use an Adamantite TypeScript preset?`}))?M.some(yield*r.select({message:`Which TypeScript preset should Adamantite use?`,options:[{hint:`JSON.parse() returns unknown, not any. Avoid in libraries.`,label:`Strict types`,value:`typescript`},{hint:`No changes to built-in types. Use for libraries.`,label:`Strict config`,value:`tsconfig`}]})):M.none(),f=yield*r.multiselect({message:`Which editors should Adamantite configure?`,options:Js.map(e=>({label:Ys[e],value:e})),required:!1}),p=f.length>0?yield*r.confirm({initialValue:!0,message:`Install the recommended editor extensions?`}):!1,m=o(n),h=c?[]:s.map(e=>e.script),g=i.filter(e=>!h.includes(e));Gr(g)&&!m&&(yield*r.log.info(`Adamantite cannot generate a GitHub Actions workflow for \`${n}\`. It supports ${_(`conjunction`)}.`));let v=Gr(g)&&m?yield*r.confirm({message:`Add a GitHub Actions workflow to run the selected checks?`}):!1;return{agents:yield*r.confirm({initialValue:!0,message:`Teach coding agents to use Adamantite? This adds an AGENTS.md section and the Adamantite skill.`}),editors:f,githubActions:v,installExtensions:p,overwriteScripts:c,presets:l,scripts:i,typescript:d}}),cc=`adamantite`,lc={"SKILL.md":`---
379
377
  name: adamantite
380
378
  description: Use when setting up Adamantite, running its checks, repairing Doctor findings, updating managed dependencies, hardening coding standards, or writing and testing custom rules.
381
379
  metadata:
@@ -449,8 +447,6 @@ The task is complete when the affected checks exit 0 and you have read their out
449
447
  Run \`adamantite doctor\`. It assesses managed integrations without changing files.
450
448
  Without a terminal, it prints a Markdown repair prompt and exits 1 when findings remain.
451
449
  Follow each finding's current state, goal, reference, and verification command.
452
- For old layer-map declarations, use the migration step in
453
- [Configure layer maps and import owners](references/lint-rules.md#configure-layer-maps-and-import-owners).
454
450
  For a finding about the previous custom-rules API, use the migration step in
455
451
  [How to write and verify custom rules](references/custom-rules.md#repair-an-existing-rules-folder).
456
452
 
@@ -586,12 +582,6 @@ parent's actual matched folder, including when the top root is a glob. Declare e
586
582
  concrete scope once. Keep separate option objects for roots that cannot nest without a
587
583
  new intermediate map.
588
584
 
589
- If the config uses the previous array-valued declarations, run \`adamantite doctor\` and
590
- follow its migration instructions. Preserve every dependency and map setting. Nest only
591
- existing compatible child scopes. Verify allowed and forbidden imports with
592
- \`adamantite check\`, then run Doctor again. Continue when the migrated maps preserve the
593
- project's intended imports and Doctor reports no layer-map migration finding.
594
-
595
585
  For an import that belongs to one file or folder, set \`adamantite/import-owners\`:
596
586
 
597
587
  \`\`\`ts
@@ -659,7 +649,7 @@ Exit code 2 means the trial could not supply evidence, such as when the rule doe
659
649
  - The changed code or configuration follows the project's coding standard.
660
650
  - The affected lint check passes without a broader exception added only to silence it.
661
651
  - Each requested trial ran successfully and gave the expected results.
662
- `,"references/setup.md":"# How to set up Adamantite\n\n## Select the setup\n\nRead `adamantite init --help` for the available scripts, presets, and editors.\nUse explicit `--non-interactive` setup as an agent. Include at least one `--script`.\nFor example, to configure checks, fixes, TypeScript, and agent instructions, run:\n\n```sh\nnpx adamantite init --non-interactive --script check --script fix --typescript --agents\n```\n\nAdapt the selected options to the request. Omitted boolean flags are disabled.\n`--agents` adds instructions to `AGENTS.md` and writes this skill to `.agents/skills`, and\nto `.claude/skills` or `.grok/skills` when the project has `.claude/` or `.grok/`.\n\nBefore selecting `react-strict`, tell the user about its modified MIT license.\nThe installed `oxlint-plugin-react-doctor` license requires written permission for use as\nmachine learning training or evaluation data, and for certain paid or hosted services.\nRead that license for the exact restrictions.\n\nContinue when each selected option serves the requested setup.\n\n## Create the selected setup\n\nRun `init` with those options. It preserves existing package scripts whose commands differ\nfrom its managed commands. Use `--overwrite-scripts` only when the task includes replacing them.\nRead the output for preserved configuration that needs a Doctor repair.\n\nAdamantite requires TypeScript 7 or later in the target project's own `package.json`.\nCheck that declaration if npm cannot install or update a managed plugin.\n\nContinue when the selected dependencies are installed and the generated files match the request.\n\n## Complete managed plugin setup\n\nIf the selected presets include a managed plugin, check its setup:\n\n- For `react-strict`, include the `react` preset and keep `oxlint-plugin-react-doctor`\n installed. Init installs the pinned package, and Doctor and update maintain it.\n Its React Doctor checks also apply in hook modules.\n- For `effect`, run Oxlint through Adamantite. A plain `oxlint` call cannot load the\n `effecttsgo` rules and stops with `Unknown plugin: 'effecttsgo'`. Replace that call with\n `adamantite check --only lint` instead of removing the preset.\n Keep `{ \"name\": \"@effect/language-service\", \"diagnostics\": true }` in\n `compilerOptions.plugins`. In a monorepo, add it to each package's tsconfig or a shared base.\n Use `ignoreDependencies.effect` from `adamantite/analyze` in `knip.config.ts`.\n- For Effect editor support, follow Doctor's editor findings. After a dependency install or\n update, run `adamantite init --non-interactive --script check --editor vscode` to prepare\n or refresh the VS Code SDK cache. Keep the project's other setup options when needed.\n Select the workspace TypeScript version in VS Code. Zed uses the installed Effect CLI.\n- For `tailwind`, check that the project uses Tailwind v4. Init installs `@shadcn/lint`.\n If components are outside the directories that `components.json` identifies, set\n `settings.shadcn.ui` in `oxlint.config.ts`.\n Without `components.json`, the plugin looks in `components/ui` or `src/components/ui`.\n For another component directory, copy the preset's component-owned rule override to that directory.\n\nContinue when Doctor reports no findings for the selected plugins and editors.\n\n## Check the setup\n\n- Each selected managed script runs successfully.\n- Doctor reports no findings, and its assessment warnings are recorded.\n- Existing scripts and configuration are preserved unless the task includes replacing them.\n"},Bs=O.sort(O.dedupe(ga.map(e=>e.skillsFolder)),B.String),Vs=E.fn(`detectSkillFolders`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path;return yield*E.filter(Bs,r=>{let i=n.join(e,n.dirname(r));return r===`.agents/skills`?E.succeed(!0):t.exists(i).pipe(E.mapError(e=>new Je({cause:e,path:i})))},{concurrency:`unbounded`})}),Hs=E.fn(`readSkillCopy`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path,i=yield*nt(e,{recursive:!0});if(N.isNone(i))return N.none();let a=yield*E.forEach(i.value,i=>E.gen(function*(){let a=n.join(e,i);return(yield*t.stat(a).pipe(E.mapError(e=>new Je({cause:e,path:a})))).type===`File`?N.some([i.split(n.sep).join(`/`),yield*r(a)]):N.none()}),{concurrency:`unbounded`});return N.some(Object.fromEntries(O.getSomes(a)))});function Us(e){let t=Object.entries(zs);return Object.keys(e).length===t.length&&t.every(([t,n])=>e[t]===n)}const Ws=E.fn(`getSkillDirectory`)(function*(e,t){return(yield*P.Path).join(e,t,Rs)}),Gs=E.fn(`findStaleSkillFolders`)(function*(e){return(yield*E.forEach(Bs,t=>Ws(e,t).pipe(E.flatMap(e=>Hs(e)),E.map(e=>({copy:e,folder:t}))),{concurrency:`unbounded`})).filter(({copy:e})=>N.isSome(e)&&!Us(e.value)).map(({folder:e})=>e)}),Ks=E.fn(`writeSkill`)(function*(e,t){let n=yield*R.FileSystem,r=yield*P.Path;for(let i of t){let t=yield*Ws(e,i),a=yield*Hs(t);if(!(N.isSome(a)&&Us(a.value))){yield*n.remove(t,{force:!0,recursive:!0}).pipe(E.mapError(e=>new ve({cause:e,path:t})));for(let[e,n]of Object.entries(zs)){let i=r.join(t,...e.split(`/`));yield*x(r.dirname(i)),yield*S(i,n)}}}}),qs=E.fn(`removeSkillsLockEntry`)(function*(e){let t=yield*R.FileSystem,n=(yield*P.Path).join(e,`skills-lock.json`),r=yield*C(n);if(N.isNone(r))return!1;let i=yield*w(r.value,n);if(!h(i)||!h(i.skills))return!1;let{[Rs]:a,...o}=i.skills;return F.isUndefined(a)?!1:Object.keys(o).length===0?(yield*t.remove(n).pipe(E.mapError(e=>new ve({cause:e,path:n}))),!0):(yield*se(n,{...i,skills:o}),!0)}),Js=`<!-- ADAMANTITE:START -->`,Ys=`<!-- ADAMANTITE:END -->`;function Xs(e,t,n){let r=wt(e,t);switch(t){case`analyze`:return`- Run \`${r}\` after changing dependencies, imports, or exports.${n?` It also checks monorepo package consistency.`:``}`;case`check`:return`- Run \`${r}\` to catch formatting, lint, and type issues.`;case`fix`:return`- Run \`${r}\` to apply safe lint fixes and format code.`}}function Zs({isMonorepo:e,packageManager:t,scripts:n}){let r=ae.flatMap(r=>n.includes(r)?[Xs(t,r,e)]:[]);return Rr(`{{start}}
652
+ `,"references/setup.md":"# How to set up Adamantite\n\n## Select the setup\n\nRead `adamantite init --help` for the available scripts, presets, and editors.\nUse explicit `--non-interactive` setup as an agent. Include at least one `--script` or `--typescript`.\nFor example, to configure checks, fixes, TypeScript, and agent instructions, run:\n\n```sh\nnpx adamantite init --non-interactive --script check --script fix --typescript typescript --agents\n```\n\n`--typescript typescript` writes `adamantite/typescript`, which adds type resets, so\n`JSON.parse()` returns `unknown`. Use `--typescript tsconfig` for a library that publishes\ndeclaration files, because those files can name reset helper types that consumers do not have.\nA project that already has ts-reset can delete its `reset.d.ts` files and the\n`@total-typescript/ts-reset` dependency after it extends `adamantite/typescript`.\n\nAdapt the selected options to the request. Omitted boolean flags are disabled.\n`--agents` adds instructions to `AGENTS.md` and writes this skill to `.agents/skills`, and\nto `.claude/skills` or `.grok/skills` when the project has `.claude/` or `.grok/`.\n\nBefore selecting `react-strict`, tell the user about its modified MIT license.\nThe installed `oxlint-plugin-react-doctor` license requires written permission for use as\nmachine learning training or evaluation data, and for certain paid or hosted services.\nRead that license for the exact restrictions.\n\nContinue when each selected option serves the requested setup.\n\n## Create the selected setup\n\nRun `init` with those options. It preserves existing package scripts whose commands differ\nfrom its managed commands. Use `--overwrite-scripts` only when the task includes replacing them.\nRead the output for preserved configuration that needs a Doctor repair.\n\nAdamantite requires TypeScript 7 or later in the target project's own `package.json`.\nCheck that declaration if npm cannot install or update a managed plugin.\n\nContinue when the selected dependencies are installed and the generated files match the request.\n\n## Complete managed plugin setup\n\nIf the selected presets include a managed plugin, check its setup:\n\n- For `react-strict`, include the `react` preset and keep `oxlint-plugin-react-doctor`\n installed. Init installs the pinned package, and Doctor and update maintain it.\n Its React Doctor checks also apply in hook modules.\n- For `effect`, run Oxlint through Adamantite. A plain `oxlint` call cannot load the\n `effecttsgo` rules and stops with `Unknown plugin: 'effecttsgo'`. Replace that call with\n `adamantite check --only lint` instead of removing the preset.\n Keep `{ \"name\": \"@effect/language-service\", \"diagnostics\": true }` in\n `compilerOptions.plugins`. In a monorepo, add it to each package's tsconfig or a shared base.\n Use `ignoreDependencies.effect` from `adamantite/analyze` in `knip.config.ts`.\n- For Effect editor support, follow Doctor's editor findings. After a dependency install or\n update, run `adamantite init --non-interactive --script check --editor vscode` to prepare\n or refresh the VS Code SDK cache. Keep the project's other setup options when needed.\n Select the workspace TypeScript version in VS Code. Zed uses the installed Effect CLI.\n- For `tailwind`, check that the project uses Tailwind v4. Init installs `@shadcn/lint`.\n If components are outside the directories that `components.json` identifies, set\n `settings.shadcn.ui` in `oxlint.config.ts`.\n Without `components.json`, the plugin looks in `components/ui` or `src/components/ui`.\n For another component directory, copy the preset's component-owned rule override to that directory.\n\nContinue when Doctor reports no findings for the selected plugins and editors.\n\n## Check the setup\n\n- Each selected managed script runs successfully.\n- Doctor reports no findings, and its assessment warnings are recorded.\n- Existing scripts and configuration are preserved unless the task includes replacing them.\n"},uc=D.sort(D.dedupe(Ba.map(e=>e.skillsFolder)),B.String),dc=T.fn(`detectSkillFolders`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path;return yield*T.filter(uc,r=>{let i=n.join(e,n.dirname(r));return r===`.agents/skills`?T.succeed(!0):t.exists(i).pipe(T.mapError(e=>new Ye({cause:e,path:i})))},{concurrency:`unbounded`})}),fc=T.fn(`readSkillCopy`)(function*(e){let t=yield*R.FileSystem,n=yield*P.Path,i=yield*rt(e,{recursive:!0});if(M.isNone(i))return M.none();let a=yield*T.forEach(i.value,i=>T.gen(function*(){let a=n.join(e,i);return(yield*t.stat(a).pipe(T.mapError(e=>new Ye({cause:e,path:a})))).type===`File`?M.some([i.split(n.sep).join(`/`),yield*r(a)]):M.none()}),{concurrency:`unbounded`});return M.some(Object.fromEntries(D.getSomes(a)))});function pc(e){let t=Object.entries(lc);return Object.keys(e).length===t.length&&t.every(([t,n])=>e[t]===n)}const mc=T.fn(`getSkillDirectory`)(function*(e,t){return(yield*P.Path).join(e,t,cc)}),hc=T.fn(`findStaleSkillFolders`)(function*(e){return(yield*T.forEach(uc,t=>mc(e,t).pipe(T.flatMap(e=>fc(e)),T.map(e=>({copy:e,folder:t}))),{concurrency:`unbounded`})).filter(({copy:e})=>M.isSome(e)&&!pc(e.value)).map(({folder:e})=>e)}),gc=T.fn(`writeSkill`)(function*(e,t){let n=yield*R.FileSystem,r=yield*P.Path;for(let i of t){let t=yield*mc(e,i),a=yield*fc(t);if(!(M.isSome(a)&&pc(a.value))){yield*n.remove(t,{force:!0,recursive:!0}).pipe(T.mapError(e=>new ve({cause:e,path:t})));for(let[e,n]of Object.entries(lc)){let i=r.join(t,...e.split(`/`));yield*x(r.dirname(i)),yield*S(i,n)}}}}),_c=T.fn(`removeSkillsLockEntry`)(function*(e){let t=yield*R.FileSystem,n=(yield*P.Path).join(e,`skills-lock.json`),r=yield*C(n);if(M.isNone(r))return!1;let i=yield*w(r.value,n);if(!h(i)||!h(i.skills))return!1;let{[cc]:a,...o}=i.skills;return F.isUndefined(a)?!1:Object.keys(o).length===0?(yield*t.remove(n).pipe(T.mapError(e=>new ve({cause:e,path:n}))),!0):(yield*se(n,{...i,skills:o}),!0)}),vc=`<!-- ADAMANTITE:START -->`,yc=`<!-- ADAMANTITE:END -->`;function bc(e,t,n){let r=Tt(e,t);switch(t){case`analyze`:return`- Run \`${r}\` after changing dependencies, imports, or exports.${n?` It also checks monorepo package consistency.`:``}`;case`check`:return`- Run \`${r}\` to catch formatting, lint, and type issues.`;case`fix`:return`- Run \`${r}\` to apply safe lint fixes and format code.`}}function xc({isMonorepo:e,packageManager:t,scripts:n}){let r=ae.flatMap(r=>n.includes(r)?[bc(t,r,e)]:[]);return Hr(`{{start}}
663
653
 
664
654
  ## Adamantite
665
655
 
@@ -673,15 +663,15 @@ Use the Adamantite skill for managed setup, Doctor repairs, and hardening. If th
673
663
  - Report unresolved Doctor findings and assessment warnings separately.
674
664
 
675
665
  {{end}}
676
- `,{customRules:y(n,`oxlint`)?`- For custom rules, follow the "${Wo}" section and linked guide in the Adamantite skill. Complete its verification and cleanup checks.\n`:``,end:Ys,scripts:r.length>0?[`- Prefer the package scripts Adamantite added for this workspace.`,...r,``].join(`
677
- `):``,start:Js})}const Qs=(e,t)=>E.gen(function*(){let n=(yield*P.Path).join(e,`AGENTS.md`),r=L(yield*C(n),N.getOrElse(()=>``)),i=L(r,pt.indexOf(Js)),a=L(r,pt.indexOf(Ys)),o=L(N.all({end:a,start:i}),N.filter(({end:e,start:t})=>t<e)),s=Zs(t);if(N.isSome(o)){let{end:e,start:t}=o.value,i=e+23,a=`${r.slice(0,t)}${s.trimEnd()}${r.slice(i)}`;return yield*S(n,a.endsWith(`
678
- `)?a:`${a}\n`),`updated`}if(N.isSome(i)||N.isSome(a))return`malformed`;let c=r.length===0||r.endsWith(`
666
+ `,{customRules:y(n,`oxlint`)?`- For custom rules, follow the "${ms}" section and linked guide in the Adamantite skill. Complete its verification and cleanup checks.\n`:``,end:yc,scripts:r.length>0?[`- Prefer the package scripts Adamantite added for this workspace.`,...r,``].join(`
667
+ `):``,start:vc})}const Sc=(e,t)=>T.gen(function*(){let n=(yield*P.Path).join(e,`AGENTS.md`),r=L(yield*C(n),M.getOrElse(()=>``)),i=L(r,pt.indexOf(vc)),a=L(r,pt.indexOf(yc)),o=L(M.all({end:a,start:i}),M.filter(({end:e,start:t})=>t<e)),s=xc(t);if(M.isSome(o)){let{end:e,start:t}=o.value,i=e+23,a=`${r.slice(0,t)}${s.trimEnd()}${r.slice(i)}`;return yield*S(n,a.endsWith(`
668
+ `)?a:`${a}\n`),`updated`}if(M.isSome(i)||M.isSome(a))return`malformed`;let c=r.length===0||r.endsWith(`
679
669
 
680
670
  `)?``:r.endsWith(`
681
671
  `)?`
682
672
  `:`
683
673
 
684
- `;return yield*S(n,`${r}${c}${s}`),`updated`}),$s=(e,t)=>E.gen(function*(){yield*(yield*$).withSpinner(()=>Wr(e,t),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function ec(e,t,n){return E.gen(function*(){let r=yield*$,i=yield*r.withSpinner(i=>E.gen(function*(){let a=yield*t.detect(e);for(let e of a.warnings)yield*r.log.warning(e);return a.active instanceof Ft?(yield*i.message(`\`${t.config}\` not found, creating...`),yield*n):yield*i.message(`Found \`${a.active.file.file}\`, keeping it.`),a.active}),{failure:`Failed to set up ${t.name} config.`,start:`Setting up ${t.name} config...`,success:e=>e instanceof Ft?`${t.name} config created.`:`Existing ${t.name} config kept.`});i instanceof Lt&&(yield*r.log.info(`Legacy \`${i.file.file}\` was kept during \`adamantite init\`. Run \`adamantite doctor\` for instructions to migrate to the current ${t.name} config.`))})}const tc=(e,n,r)=>E.gen(function*(){let i=yield*$,a=yield*u(e),o=r.overwriteScripts?[]:ke(a,n),s=new Set(o.map(e=>e.script)),c=n.filter(e=>!s.has(e));yield*i.withSpinner(()=>E.gen(function*(){if(c.length!==0){a.scripts??={};for(let e of c)a.scripts[e]=Xe[e];yield*p(e,a)}}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:o.length===0?"Scripts added to `package.json`.":c.length===0?"Existing `package.json` scripts kept.":"Scripts added to `package.json`. Existing conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Run `adamantite init` again and choose to replace the script.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${Xe[e.script]}\`. ${l}`);return o.length>0&&(yield*i.log.info("Pass custom tool arguments after `--`, such as `adamantite analyze -- --directory packages/app`.")),t(a)}),nc=(e,t)=>E.gen(function*(){let n=yield*$;t?yield*L(ia,E.forEach(e=>n.log.info(e))):yield*n.withSpinner(t=>E.gen(function*(){return(yield*oa.detect(e))?(yield*t.message(`\`${oa.config}\` found, updating...`),yield*oa.update(e),!1):(yield*t.message(`\`${oa.config}\` not found, creating...`),yield*oa.create(e),!0)}),{failure:`Failed to set up TypeScript config.`,start:`Setting up TypeScript config...`,success:e=>e?`\`${oa.config}\` created.`:`\`${oa.config}\` updated.`})}),rc=e=>E.gen(function*(){let t=yield*$,n=yield*Re.update(e);n===`monorepo`&&(yield*t.log.info("In a monorepo, add the Effect language service entry to each package's `tsconfig.json` or to a shared base config. Run `adamantite doctor` for the reference entry.")),n===`missing`&&(yield*t.log.warning("No `tsconfig.json` found, so the Effect language service is not configured. Run `adamantite doctor` for the reference entry."))}),ic={vscode:{integration:Ti,name:`VS Code`},zed:{integration:Fi,name:`Zed`}},ac=(e,t)=>E.gen(function*(){let n=yield*$;for(let r of ws.filter(e=>t.includes(e))){let{integration:t,name:i}=ic[r];yield*n.withSpinner(n=>E.gen(function*(){let r=yield*t.detect(e);return yield*n.message(`\`${t.config}\` ${r?`found, updating`:`not found, creating`}...`),yield*r?t.update(e):t.create(e),!r}),{failure:`Failed to set up ${i} config.`,start:`Checking for \`${t.config}\`...`,success:e=>`\`${t.config}\` ${e?`created`:`updated`} with Adamantite preset.`})}}),oc=(e,t,n=[])=>E.gen(function*(){let r=yield*$,i=e.includes(`zed`),a=e.includes(`vscode`);yield*r.withSpinner(e=>E.gen(function*(){return a&&(yield*e.message(`Installing VS Code extension...`),yield*Ti.extension(t,n)),!0}),{failure:`Failed to install editor extensions.`,start:`Installing editor extensions...`,success:i&&!a?`Install the Zed extensions using the links below.`:`Editor extensions installed.`}).pipe(E.catchTags({FailedToInstallExtension:e=>E.gen(function*(){return yield*r.log.warning(`โš ๏ธ ${e.message}`),yield*r.log.warning(`Install the extension manually after setup finishes.`),!1}),VscodeCliNotFound:()=>E.gen(function*(){return yield*r.log.error("VS Code's `code` command was not found on PATH."),yield*r.log.info(`Add the code command to PATH:`),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"),n.includes(`effect`)&&(yield*r.log.info(`Install the Zed TypeScript language server extension: zed://extension/tsgo`)))}),sc=(e,t,n)=>E.gen(function*(){let r=yield*$,i=mi.files[0].path;if(!Vr(n))return yield*r.log.warning("No CI script runs an Adamantite command, so `adamantite init` did not set up the GitHub Actions workflow.");(yield*r.withSpinner(r=>E.gen(function*(){let a=yield*mi.detect(e);return yield*r.message(a?`\`${i}\` found, updating...`:`Creating \`${i}\`...`),a?yield*mi.update(e,{packageManager:t,scripts:n}):(yield*mi.create(e,{packageManager:t,scripts:n}),`created`)}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e}.`}))===`kept`&&(yield*r.log.info(`\`${i}\` has changes that Adamantite did not make, so \`adamantite init\` kept it. Run \`adamantite doctor\` to see what to update.`))}).pipe(E.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>E.gen(function*(){let t=yield*$;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.")}))),cc=(e,t,n,r)=>E.gen(function*(){let i=yield*$,a=yield*i.withSpinner(()=>Qs(e,{isMonorepo:r,packageManager:t,scripts:n}),{failure:`Failed to update AGENTS.md.`,start:`Updating AGENTS.md...`,success:`AGENTS.md check complete.`}).pipe(E.catchTag([`FailedToReadFile`,`FailedToWriteFile`],e=>E.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("AGENTS.md has an incomplete ADAMANTITE marker. Remove the incomplete marker and run `adamantite init` again."))}),lc=new Intl.ListFormat(`en`,{type:`conjunction`}),uc=e=>E.gen(function*(){let t=yield*$;yield*Vs(e).pipe(E.flatMap(n=>t.withSpinner(()=>Ks(e,n),{failure:`Failed to add the Adamantite skill.`,start:`Adding the Adamantite skill...`,success:`Adamantite skill added to ${lc.format(n.map(e=>`\`${e}\``))}.`})),E.catchTag([`FailedToCreateDirectory`,`FailedToReadFile`,`FailedToWriteFile`],e=>t.log.warning(`Could not add the Adamantite skill. ${e.message} Adamantite will continue initialization.`)))});var dc=k.make(`init`,Ps).pipe(k.withDescription(`Configure Adamantite in the current directory. Use --non-interactive with setup flags and select each optional feature explicitly`),k.withExamples([{command:`adamantite init --non-interactive --script check`,description:`Configure linting without prompts`},{command:`adamantite init --non-interactive --script check --preset react --editor vscode --typescript --install-extensions --github-actions --agents`,description:`Configure a React project with VS Code, TypeScript, CI, agent guidance, and the Adamantite skill`},{command:`adamantite init --non-interactive --script analyze`,description:`Configure analysis, including Sherif checks for a monorepo`}]),k.withHandler(e=>E.gen(function*(){let t=j.cwd(),n=yield*$;yield*Cs,yield*n.intro(`๐Ÿ’  adamantite init`);let r=yield*(yield*Hr).detectPackageManager(t);if(!r)return yield*new me({});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*Qe(t);if(i&&(yield*n.log.info(`This project is a monorepo.`)),!e.nonInteractive&&O.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],F.isTruthy))return yield*new T({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*Ls(t,i,r.name),o=yield*Es(a,r.name),s=[...o.scripts],{lint:c}=o,l=N.match(c,{onNone:()=>[],onSome:e=>e.presets}),d=y(s,`knip`),f=y(s,`sherif`)&&i,p=yield*u(t),m=F.isNotUndefined(p.devDependencies?.adamantite??p.dependencies?.adamantite)?[]:[`adamantite`];N.isSome(c)&&m.push(`${J.name}@${J.version}`,`${$i.name}@${$i.version}`,`${q.name}@${q.version}`,...Zi.filter(e=>l.includes(e.preset)).map(e=>`${e.name}@${e.version}`)),f&&m.push(`${Er.name}@${Er.version}`),d&&m.push(`${tr.name}@${tr.version}`),yield*$s(t,m),N.isSome(c)&&(yield*ec(t,q,q.create(t)),yield*ec(t,J,J.create(t,l))),d&&(yield*ec(t,tr,tr.create(t)));let h=yield*tc(t,s,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(o.agents&&(yield*cc(t,r.name,h,i),yield*uc(t)),N.exists(c,e=>e.typescript)&&(yield*nc(t,i)),l.includes(`effect`)&&(yield*rc(t)),N.isSome(o.editors)){let{installExtensions:e,names:n}=o.editors.value;yield*ac(t,n),e&&(yield*oc(n,s,l))}N.isSome(o.githubActions)&&(yield*sc(t,o.githubActions.value,h)),yield*n.outro(`๐Ÿ’  Setup finished.`)}).pipe(E.catchTags({OperationCancelled:()=>E.gen(function*(){yield*(yield*$).cancel(`Setup was cancelled.`)})}))));const fc=/^[a-z][\da-z]*(?:-[\da-z]+)*$/;function pc(e){return`import { defineRule } from "adamantite/rules/plugin"
674
+ `;return yield*S(n,`${r}${c}${s}`),`updated`}),Cc=(e,t)=>T.gen(function*(){yield*(yield*$).withSpinner(()=>Jr(e,t),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function wc(e,t,n){return T.gen(function*(){let r=yield*$,i=yield*r.withSpinner(i=>T.gen(function*(){let a=yield*t.detect(e);for(let e of a.warnings)yield*r.log.warning(e);return a.active instanceof Ft?(yield*i.message(`\`${t.config}\` not found, creating...`),yield*n):yield*i.message(`Found \`${a.active.file.file}\`, keeping it.`),a.active}),{failure:`Failed to set up ${t.name} config.`,start:`Setting up ${t.name} config...`,success:e=>e instanceof Ft?`${t.name} config created.`:`Existing ${t.name} config kept.`});i instanceof Lt&&(yield*r.log.info(`Legacy \`${i.file.file}\` was kept during \`adamantite init\`. Run \`adamantite doctor\` for instructions to migrate to the current ${t.name} config.`))})}const Tc=(e,n,r)=>T.gen(function*(){let i=yield*$,a=yield*u(e);if(n.length===0)return t(a);let o=r.overwriteScripts?[]:Ae(a,n),s=new Set(o.map(e=>e.script)),c=n.filter(e=>!s.has(e));yield*i.withSpinner(()=>T.gen(function*(){if(c.length!==0){a.scripts??={};for(let e of c)a.scripts[e]=Ze[e];yield*p(e,a)}}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:o.length===0?"Scripts added to `package.json`.":c.length===0?"Existing `package.json` scripts kept.":"Scripts added to `package.json`. Existing conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Run `adamantite init` again and choose to replace the script.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${Ze[e.script]}\`. ${l}`);return o.length>0&&(yield*i.log.info("Pass custom tool arguments after `--`, such as `adamantite analyze -- --directory packages/app`.")),t(a)}),Ec=(e,t,n)=>T.gen(function*(){let r=yield*$;t?yield*L(Sa(n),T.forEach(e=>r.log.info(e))):yield*r.withSpinner(t=>T.gen(function*(){return(yield*Aa.detect(e))?(yield*t.message(`\`${Aa.config}\` found, updating...`),yield*Aa.update(e,n),!1):(yield*t.message(`\`${Aa.config}\` not found, creating...`),yield*Aa.create(e,n),!0)}),{failure:`Failed to set up TypeScript config.`,start:`Setting up TypeScript config...`,success:e=>`\`${Aa.config}\` ${e?`created`:`updated`} with \`${Q[n]}\`.`})}),Dc=e=>T.gen(function*(){let t=yield*$,n=yield*ze.update(e);n===`monorepo`&&(yield*t.log.info("In a monorepo, add the Effect language service entry to each package's `tsconfig.json` or to a shared base config. Run `adamantite doctor` for the reference entry.")),n===`missing`&&(yield*t.log.warning("No `tsconfig.json` found, so the Effect language service is not configured. Run `adamantite doctor` for the reference entry."))}),Oc={vscode:{integration:Ui,name:`VS Code`},zed:{integration:$i,name:`Zed`}},kc=(e,t)=>T.gen(function*(){let n=yield*$;for(let r of Js.filter(e=>t.includes(e))){let{integration:t,name:i}=Oc[r];yield*n.withSpinner(n=>T.gen(function*(){let r=yield*t.detect(e);return yield*n.message(`\`${t.config}\` ${r?`found, updating`:`not found, creating`}...`),yield*r?t.update(e):t.create(e),!r}),{failure:`Failed to set up ${i} config.`,start:`Checking for \`${t.config}\`...`,success:e=>`\`${t.config}\` ${e?`created`:`updated`} with Adamantite preset.`})}}),Ac=(e,t,n=[])=>T.gen(function*(){let r=yield*$,i=e.includes(`zed`),a=e.includes(`vscode`);yield*r.withSpinner(e=>T.gen(function*(){return a&&(yield*e.message(`Installing VS Code extension...`),yield*Ui.extension(t,n)),!0}),{failure:`Failed to install editor extensions.`,start:`Installing editor extensions...`,success:i&&!a?`Install the Zed extensions using the links below.`:`Editor extensions installed.`}).pipe(T.catchTags({FailedToInstallExtension:e=>T.gen(function*(){return yield*r.log.warning(`โš ๏ธ ${e.message}`),yield*r.log.warning(`Install the extension manually after setup finishes.`),!1}),VscodeCliNotFound:()=>T.gen(function*(){return yield*r.log.error("VS Code's `code` command was not found on PATH."),yield*r.log.info(`Add the code command to PATH:`),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"),n.includes(`effect`)&&(yield*r.log.info(`Install the Zed TypeScript language server extension: zed://extension/tsgo`)))}),jc=(e,t,n)=>T.gen(function*(){let r=yield*$;if(!Gr(n))return yield*r.log.warning("No CI script runs an Adamantite command, so `adamantite init` did not set up the GitHub Actions workflow.");let i=yield*Mi.detect(e),a=yield*r.withSpinner(r=>{let a=({path:i})=>r.message(`\`${i}\` found, updating...`).pipe(T.andThen(Mi.update(e,{packageManager:t,scripts:n})));return St.valueTags(i,{Legacy:a,Malformed:()=>T.succeed(`kept`),Managed:a,Missing:()=>r.message(`Creating \`${Mi.files[0].path}\`...`).pipe(T.andThen(Mi.create(e,{packageManager:t,scripts:n})),T.as(`created`))})},{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e}.`}),o=e=>a===`kept`?r.log.info(`\`${e}\` has changes that Adamantite did not make, so \`adamantite init\` kept it. Run \`adamantite doctor\` to see what to update.`):T.void;yield*St.valueTags(i,{Legacy:({path:e})=>o(e),Malformed:({paths:e,reason:t})=>r.log.warning(`Adamantite cannot read the managed block in ${e.map(e=>`\`${e}\``).join(`, `)}, so \`adamantite init\` kept the workflow. ${t} Run \`adamantite doctor\` for the repair.`),Managed:({path:e})=>o(e),Missing:()=>T.void})}).pipe(T.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`],e=>T.gen(function*(){let t=yield*$;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.")}))),Mc=(e,t,n,r)=>T.gen(function*(){let i=yield*$,a=yield*i.withSpinner(()=>Sc(e,{isMonorepo:r,packageManager:t,scripts:n}),{failure:`Failed to update AGENTS.md.`,start:`Updating AGENTS.md...`,success:`AGENTS.md check complete.`}).pipe(T.catchTag([`FailedToReadFile`,`FailedToWriteFile`],e=>T.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("AGENTS.md has an incomplete ADAMANTITE marker. Remove the incomplete marker and run `adamantite init` again."))}),Nc=new Intl.ListFormat(`en`,{type:`conjunction`}),Pc=e=>T.gen(function*(){let t=yield*$;yield*dc(e).pipe(T.flatMap(n=>t.withSpinner(()=>gc(e,n),{failure:`Failed to add the Adamantite skill.`,start:`Adding the Adamantite skill...`,success:`Adamantite skill added to ${Nc.format(n.map(e=>`\`${e}\``))}.`})),T.catchTag([`FailedToCreateDirectory`,`FailedToReadFile`,`FailedToWriteFile`],e=>t.log.warning(`Could not add the Adamantite skill. ${e.message} Adamantite will continue initialization.`)))});var Fc=O.make(`init`,ic).pipe(O.withDescription(`Configure Adamantite in the current directory. Use --non-interactive with setup flags and select each optional feature explicitly`),O.withExamples([{command:`adamantite init --non-interactive --script check`,description:`Configure linting without prompts`},{command:`adamantite init --non-interactive --script check --preset react --editor vscode --typescript typescript --install-extensions --github-actions --agents`,description:`Configure a React project with VS Code, TypeScript, CI, agent guidance, and the Adamantite skill`},{command:`adamantite init --non-interactive --script analyze`,description:`Configure analysis, including Sherif checks for a monorepo`}]),O.withHandler(e=>T.gen(function*(){let t=A.cwd(),n=yield*$;yield*qs,yield*n.intro(`๐Ÿ’  adamantite init`);let r=yield*(yield*Kr).detectPackageManager(t);if(!r)return yield*new me({});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*$e(t);if(i&&(yield*n.log.info(`This project is a monorepo.`)),!e.nonInteractive&&D.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,M.isSome(e.typescript),e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],F.isTruthy))return yield*new Ce({reason:"Setup flags require `--non-interactive`."});if(e.nonInteractive&&e.scripts.length===0&&M.isNone(e.typescript))return yield*new Ce({reason:"Select at least one script with `--script <name>`, or a TypeScript preset with `--typescript <preset>`."});let a=e.nonInteractive?e:yield*sc(t,i,r.name),o=yield*Xs(a,r.name);if(o.scripts.length===0&&M.isNone(o.typescript)&&M.isNone(o.editors)&&!o.agents){yield*n.outro(`๐Ÿ’  No setup selected, so Adamantite made no changes.`);return}let s=[...o.scripts],{lint:c}=o,l=M.match(c,{onNone:()=>[],onSome:e=>e.presets}),d=y(s,`knip`),f=y(s,`sherif`)&&i,p=yield*u(t),m=F.isNotUndefined(p.devDependencies?.adamantite??p.dependencies?.adamantite)?[]:[`adamantite`];M.isSome(c)&&m.push(`${br.name}@${br.version}`,`${_a.name}@${_a.version}`,`${or.name}@${or.version}`,...ha.filter(e=>l.includes(e.preset)).map(e=>`${e.name}@${e.version}`)),f&&m.push(`${Sr.name}@${Sr.version}`),d&&m.push(`${tr.name}@${tr.version}`),yield*Cc(t,m),M.isSome(c)&&(yield*wc(t,or,or.create(t)),yield*wc(t,br,br.create(t,l))),d&&(yield*wc(t,tr,tr.create(t)));let h=yield*Tc(t,s,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(o.agents&&(yield*Mc(t,r.name,h,i),yield*Pc(t)),M.isSome(o.typescript)&&(yield*Ec(t,i,o.typescript.value)),l.includes(`effect`)&&(yield*Dc(t)),M.isSome(o.editors)){let{installExtensions:e,names:n}=o.editors.value;yield*kc(t,n),e&&(yield*Ac(n,s,l))}M.isSome(o.githubActions)&&(yield*jc(t,o.githubActions.value,h)),yield*n.outro(`๐Ÿ’  Setup finished.`)}).pipe(T.catchTags({OperationCancelled:()=>T.gen(function*(){yield*(yield*$).cancel(`Setup was cancelled.`)})}))));const Ic=/^[a-z][\da-z]*(?:-[\da-z]+)*$/;function Lc(e){return`import { defineRule } from "adamantite/rules/plugin"
685
675
 
686
676
  export default defineRule({
687
677
  createOnce(context) {
@@ -699,7 +689,7 @@ export default defineRule({
699
689
  type: "problem",
700
690
  },
701
691
  })
702
- `.replaceAll(`{{name}}`,e)}const mc=E.fn(`addCustomRule`)(function*(e,t,n=K){if(!fc.test(t))return yield*new de({rule:t});let r=yield*P.Path,i=r.resolve(e,n),a=r.join(i,`${t}.ts`),o=(yield*hc(e,n)).filter(e=>e.slice(0,-r.extname(e).length)===t);return o.length>0?yield*new He({paths:o.map(e=>r.join(i,e))}):(yield*x(i),yield*S(a,pc(t)),a)}),hc=E.fn(`listCustomRules`)(function*(e,t=K){let n=yield*P.Path,r=yield*R.FileSystem,i=n.resolve(e,t),a=yield*nt(i),o=yield*E.filter(N.getOrElse(a,()=>[]).filter(e=>Qt(e)),e=>r.stat(n.join(i,e)).pipe(E.mapBoth({onFailure:t=>new Je({cause:t,path:n.join(i,e)}),onSuccess:e=>e.type===`File`})));return O.sort(o,B.String)}),gc=E.fn(`addCustomRuleTest`)(function*(e,t,n=K,r){if(!fc.test(t))return yield*new de({rule:t});let i=yield*P.Path,a=yield*R.FileSystem,o=i.resolve(e,n),s=(yield*hc(e,n)).find(e=>e.slice(0,-i.extname(e).length)===t);if(s===void 0)return yield*new Ee({directory:o,rule:t});let c=r===void 0?i.join(o,`${t}.test.ts`):i.resolve(e,r);if(yield*a.exists(c).pipe(E.mapError(e=>new Je({cause:e,path:c}))))return yield*new He({paths:[c]});yield*x(i.dirname(c));let l=e=>a.realPath(e).pipe(E.mapError(t=>new Je({cause:t,path:e}))),[u,d]=yield*E.all([l(i.dirname(c)),l(i.join(o,s))]),f=i.relative(u,d).split(i.sep).join(`/`),p=f.startsWith(`../`)?f:`./${f}`,m=yield*ce(p);return yield*S(c,`import { RuleTester } from "adamantite/rules/testing"
692
+ `.replaceAll(`{{name}}`,e)}const Rc=T.fn(`addCustomRule`)(function*(e,t,n=q){if(!Ic.test(t))return yield*new de({rule:t});let r=yield*P.Path,i=r.resolve(e,n),a=r.join(i,`${t}.ts`),o=(yield*zc(e,n)).filter(e=>e.slice(0,-r.extname(e).length)===t);return o.length>0?yield*new Ue({paths:o.map(e=>r.join(i,e))}):(yield*x(i),yield*S(a,Lc(t)),a)}),zc=T.fn(`listCustomRules`)(function*(e,t=q){let n=yield*P.Path,r=yield*R.FileSystem,i=n.resolve(e,t),a=yield*rt(i),o=yield*T.filter(M.getOrElse(a,()=>[]).filter(e=>Qt(e)),e=>r.stat(n.join(i,e)).pipe(T.mapBoth({onFailure:t=>new Ye({cause:t,path:n.join(i,e)}),onSuccess:e=>e.type===`File`})));return D.sort(o,B.String)}),Bc=T.fn(`addCustomRuleTest`)(function*(e,t,n=q,r){if(!Ic.test(t))return yield*new de({rule:t});let i=yield*P.Path,a=yield*R.FileSystem,o=i.resolve(e,n),s=(yield*zc(e,n)).find(e=>e.slice(0,-i.extname(e).length)===t);if(s===void 0)return yield*new De({directory:o,rule:t});let c=r===void 0?i.join(o,`${t}.test.ts`):i.resolve(e,r);if(yield*a.exists(c).pipe(T.mapError(e=>new Ye({cause:e,path:c}))))return yield*new Ue({paths:[c]});yield*x(i.dirname(c));let l=e=>a.realPath(e).pipe(T.mapError(t=>new Ye({cause:t,path:e}))),[u,d]=yield*T.all([l(i.dirname(c)),l(i.join(o,s))]),f=i.relative(u,d).split(i.sep).join(`/`),p=f.startsWith(`../`)?f:`./${f}`,m=yield*ce(p);return yield*S(c,`import { RuleTester } from "adamantite/rules/testing"
703
693
  import rule from {{ruleImport}}
704
694
 
705
695
  const tester = new RuleTester({ languageOptions: { parserOptions: { lang: "ts" } } })
@@ -710,7 +700,7 @@ tester.run("{{name}}", rule, {
710
700
  invalid: [{ code: "debugger", errors: [{ messageId: "unexpected" }] }],
711
701
  valid: ["const value: number = 1"],
712
702
  })
713
- `.replaceAll(`{{name}}`,t).replace(`{{ruleImport}}`,m)),c}),_c=E.fn(`findCustomRuleTests`)(function*(e){let t=yield*P.Path,n=O.dedupe(e.calls.map(e=>e.dir)),r=yield*E.forEach(n,e=>nt(e).pipe(E.map(n=>N.getOrElse(n,()=>[]).filter(e=>$t(e)).map(n=>t.join(e,n)))),{concurrency:`unbounded`});return O.sort(r.flat(),B.String)}),vc=E.fn(`readCustomRuleTestCommand`)(function*({customRules:e,cwd:t}){let n=yield*P.Path,r=yield*_c(e);return{command:r.length===0?N.none():N.some({args:[`--test`,...r.map(e=>n.relative(t,e))],command:`node`}),unresolvedCalls:O.dedupe(e.unresolvedCalls),unresolvedImports:e.unresolvedImports}}),yc=V.File(`file`,{mustExist:!0}).pipe(V.withDescription(`The JavaScript or TypeScript file to parse`)),bc=k.make(`ast`,{file:yc}).pipe(k.withDescription(`Print the syntax tree Oxlint rules use, with node names for custom rules`),k.withHandler(({file:e})=>E.gen(function*(){let t=yield*$,n=yield*r(e),i=bt(e,n,{preserveParens:!1});if(i.errors.length>0)return yield*new ge({errors:i.errors.map(e=>e.message),path:e});yield*t.message(yield*Be(i.program))}))),xc=V.String(`name`).pipe(V.withDescription(`The rule name in kebab-case, such as no-process-env`)),Sc=M.String(`dir`).pipe(M.optional,M.withDescription(`The rules folder, relative to the current directory. Default: ${K}. Pass the folder that \`custom({ dir })\` loads, such as a rules folder in a monorepo tooling package`)),Cc=M.String(`path`).pipe(M.optional,M.withDescription(`The test file path, relative to the current directory`)),wc=k.make(`add`,{dir:Sc,name:xc}).pipe(k.withDescription(`Create a custom rule file. See the Adamantite skill for authoring instructions`),k.withHandler(({dir:e,name:t})=>E.gen(function*(){let n=yield*$,r=yield*P.Path,i=j.cwd(),a=yield*mc(i,t,N.getOrUndefined(e));yield*n.log.success(`Wrote ${r.relative(i,a)}.`),yield*n.log.info(`\`custom()\` from \`adamantite/rules\` loads the rule. Run \`adamantite doctor\` to check the wiring. The "${Wo}" section of the Adamantite skill tells agents how to verify the rule with temporary cases.`)}))),Tc=k.make(`add`,{dir:Sc,name:xc.pipe(V.optional),path:Cc}).pipe(k.withDescription(`Create a test for an existing rule. Omit the name to choose a rule`),k.withHandler(({dir:e,name:t,path:n})=>E.gen(function*(){let r=yield*$,i=yield*P.Path,a=yield*pa,o=N.getOrElse(e,()=>K),s=j.cwd(),c=N.getOrUndefined(t);if(c===void 0){let e=(yield*hc(s,o)).map(e=>e.slice(0,-i.extname(e).length));if(e.length===0)return yield*r.log.info(`No custom rules were found in \`${o}\`. Run \`adamantite rule add <name>\` first.`);if(!(yield*a.isInteractive))return yield*r.message(e.join(`
714
- `)),yield*r.log.info("Pass a rule name with `adamantite rule test add <name>`.");c=yield*r.select({message:`Which rule needs a test?`,options:e.map(e=>({label:e,value:e}))})}let l=yield*gc(s,c,o,N.getOrUndefined(n));yield*r.log.success(`Wrote ${i.relative(s,l)}.`),yield*r.log.info(`Adapt the valid and invalid cases to the rule, then run \`adamantite rule test\`${N.isSome(n)?" with `--path` and the test file path.":`.`}`),yield*r.log.info(`RuleTester uses node:test. Exclude this test from Vitest and Jest discovery. See Custom rules in the Adamantite README.`)}))),Ec=k.make(`test`,{path:Cc}).pipe(k.withDescription(`Run custom rule tests with node --test. Use --path for a test outside the rules folder`),k.withHandler(({path:e})=>E.gen(function*(){let t=yield*$,n=yield*P.Path,r=yield*Pt,i=j.cwd();if(N.isSome(e))return yield*r.run({args:[`--test`,n.resolve(i,e.value)],command:`node`,title:`๐Ÿงช Testing custom rules`});let{command:a,unresolvedCalls:o,unresolvedImports:s}=yield*vc(yield*fa(i));for(let e of o)yield*t.log.warning(`\`rule test\` cannot read the \`dir\` of a \`custom()\` call in \`${n.relative(i,e)}\`, because it is not a string literal. It does not run the tests of that rules folder.`);for(let{from:e,specifier:r}of s)yield*t.log.warning(`\`rule test\` cannot resolve the import of \`${r}\` in \`${n.relative(i,e)}\`, so it does not run the tests of the rules folders behind it.`);if(N.isNone(a))return yield*t.log.info("No tests were found for loaded custom rules. Run `adamantite doctor` to check rule setup, or `adamantite rule test add` to add a test.");yield*r.run({...a.value,title:`๐Ÿงช Testing custom rules`})})),k.withSubcommands([Tc])),Dc=V.String(`rule`).pipe(V.withDescription(`The full rule name, such as no-restricted-imports, typescript/no-explicit-any, or project/no-foo`)),Oc=M.String(`report`).pipe(M.atLeast(1),M.withDescription(`Add a case the rule must report. Use a project path, or <path>=<file> to lint file contents at another path. Repeat --report for more cases`)),kc=M.String(`accept`).pipe(M.atLeast(0),M.withDescription(`Add a case the rule must accept, using the same path format as --report`)),Ac=M.String(`options`).pipe(M.withSchema(z.fromJsonString(z.Array(z.Json))),M.optional,M.withDescription(`The rule options that come after the severity, as a JSON array, such as '[{"paths":["node:fs"]}]'. The trial sets the rule to error`)),jc=M.Boolean(`current`).pipe(M.withDefault(!1),M.withDescription(`Use the project's current rule setting to see what it reports`));function Mc(e,t){return t instanceof Co?`\`${e}\` as the project config sets it`:`\`${e}\` at ${JSON.stringify([`error`,...t.options])}`}function Nc(e){return e.diagnostics.length>0==(e.case.expected===`reported`)}function Pc(e,t,n){let r=[...new Set(n.map(e=>`\`${e.config}\``))].join(`, `),i=n.map(e=>{let t=N.match(e.case.source,{onNone:()=>`\`${e.case.path}\``,onSome:t=>`\`${e.case.path}\` from \`${t}\``}),n=e.diagnostics.length>0?`reported`:`accepted`;return[Nc(e)?`โœ“ ${t}: ${n}, as expected.`:`โœ— ${t}: ${n}, but it must be ${e.case.expected}.`,...e.diagnostics.map(e=>` ${e.line}:${e.column} ${e.message}`)].join(`
715
- `)}),a=n.filter(e=>!Nc(e)).length,o=a===0?`All cases produced the expected result.`:n.length===1?`The case did not produce the expected result.`:`${a.toLocaleString(`en-US`)} of ${n.length.toLocaleString(`en-US`)} cases ${a===1?`is`:`are`} different from the expected result.`;return[`Trial of ${Mc(e,t)}, in ${r}.`,``,...i,``,o].join(`
716
- `)}const Fc=k.make(`try`,{accept:kc,current:jc,options:Ac,report:Oc,rule:Dc}).pipe(k.withDescription(`Test a rule against cases in a project copy. Exit codes: 0 for expected results, 1 for a mismatch, and 2 if a case could not be checked. Project files stay unchanged`),k.withHandler(({accept:e,current:t,options:n,report:r,rule:i})=>E.gen(function*(){let a=yield*$,o=t?new Co:new wo({options:N.getOrElse(n,()=>[])}),s=yield*E.gen(function*(){if(t&&N.isSome(n))return yield*new tt({reason:"Give `--options` or `--current`, not both."});let a=yield*E.all([...r.map(e=>To(e,`reported`)),...e.map(e=>To(e,`accepted`))]),s=j.cwd();return yield*No({cases:a,cwd:s,rule:i,setting:o,workspace:yield*re(s)})}).pipe(E.catch(e=>a.log.error(e.message).pipe(E.andThen(E.fail(new Ie({command:`rule try`,exitCode:D.ExitCode(2)}))))));if(yield*a.message(Pc(i,o,s)),!s.every(e=>Nc(e)))return yield*new Ie({command:`rule try`,exitCode:D.ExitCode(1)})})));var Ic=k.make(`rule`).pipe(k.withDescription(`Create and inspect custom Oxlint rules, try them against cases, and run saved tests`),k.withSubcommands([wc,bc,Ec,Fc]));const Lc=[J,$i,q,Er,tr];var Rc=k.make(`update`).pipe(k.withDescription(`Update managed packages and the Adamantite skill, then report setup issues`),k.withHandler(()=>E.gen(function*(){let e=j.cwd(),t=yield*$;yield*t.intro(`๐Ÿ’  adamantite update`);let n=yield*fa(e),r=yield*ca(n),i=r.packageActions,a=new Set(i.map(e=>e.package)),o=Lc.flatMap(e=>a.has(e.name)?[]:[Wt(n,e,`Adamantite`,`adamantite`)]),s=[...i,...o.flatMap(e=>e.packageActions).filter(e=>e.type===`update_package`)],c=o.filter(e=>e.packageActions.length===0);if(s.length>0){yield*t.log.info(`Packages to install or update:`);for(let e of s){let n=e.type===`install_package`?`not installed`:e.currentVersion;yield*t.log.info(` ${e.package}: ${n} โ†’ ${e.targetVersion}`)}yield*t.withSpinner(()=>Wr(e,s.map(e=>`${e.package}@${e.targetVersion}`)),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated.`})}let l=s.length===0?`idle`:`applied`,u=yield*Gs(e).pipe(E.flatMap(n=>n.length===0?E.succeed(`idle`):t.withSpinner(()=>Ks(e,n),{failure:`Failed to refresh the Adamantite skill.`,start:`Refreshing the Adamantite skill...`,success:`Adamantite skill refreshed.`}).pipe(E.as(`applied`),E.catchTag([`FailedToCreateDirectory`,`FailedToReadFile`,`FailedToWriteFile`],e=>t.log.warning(`Could not refresh the Adamantite skill. ${e.message}`).pipe(E.as(`applyFailed`))))),E.catchTag(`FailedToReadFile`,e=>t.log.warning(`Could not check the Adamantite skill. ${e.message}`).pipe(E.as(`checkFailed`)))),d=e=>t.log.warning(`Could not update \`skills-lock.json\`. ${e.message}`),f=yield*qs(e).pipe(E.flatMap(e=>e?t.log.info("Removed the `adamantite` entry from `skills-lock.json`.").pipe(E.as(`applied`)):E.succeed(`idle`)),E.catchTag([`FailedToParseFile`,`FailedToReadFile`],e=>d(e).pipe(E.as(`checkFailed`))),E.catchTag(`FailedToWriteFile`,e=>d(e).pipe(E.as(`applyFailed`)))),p=l===`idle`?r:yield*ca(yield*fa(e)),m=new Set(p.findings.map(e=>e.id)),h=O.dedupe([...p.warnings,...c.flatMap(e=>e.warnings)]);for(let e of h)yield*t.log.warning(e);let g=[...p.findings,...c.flatMap(e=>e.findings).filter(e=>!m.has(e.id))];return g.length>0&&(yield*ha(g),yield*t.log.info("Run `adamantite doctor` for the remaining repairs and an agent prompt.")),![l,u,f].some(e=>e===`applied`||e===`applyFailed`)&&g.length===0?`no-changes`:`success`}).pipe(E.tapError(()=>E.gen(function*(){yield*(yield*$).outro(`โŒ Update failed`)})),E.tap(e=>E.gen(function*(){yield*(yield*$).outro(e===`no-changes`?`โœ… No managed updates were applied.`:`โœ… Update finished.`)})))));const zc=[Nr,Lr,Wa],Bc=[Nr,Lr,La,Wa,xs,dc,Ic,Rc],Vc=new Set(Bc.map(e=>e.name)),Hc=new Set(zc.map(e=>e.name)),Uc=k.make(`adamantite`).pipe(k.withDescription(`Configure code checks for TypeScript projects`),k.withSubcommands(Bc)),Wc=e=>A.mergeAll(st.layer,ti.layer.pipe(A.provide(st.layer)),Ne.layer,$.layer,ba.layer.pipe(A.provideMerge(e),A.provide(st.layer)),Hr.layer,pa.layer),Gc=E.fn(`runCli`)(function*(e,t){let[n,r]=O.splitWhere(e,e=>e===`--`),i=O.drop(r,1),o=n.find(e=>Vc.has(e));if(i.length>0&&o!==void 0&&!Hc.has(o))return yield*new a({command:o});yield*k.runWith(Uc,{version:t})(n).pipe(E.provideService(At,i))}),Kc=E.gen(function*(){let e=yield*(yield*ot.Stdio).args;yield*Gc(e,`0.46.0`)}).pipe(E.as(0),E.catchTag(`CommandFailed`,e=>E.succeed(e.exitCode)),E.catch(e=>E.service($).pipe(E.flatMap(t=>t.log.error(e.message)),E.as(D.ExitCode(1)))),E.provide(Wc(Pt.layer)));rt.runMain(Kc,{teardown:(e,t)=>{it.isSuccess(e)?t(Number(e.value)):at.defaultTeardown(e,t)}});export{};
703
+ `.replaceAll(`{{name}}`,t).replace(`{{ruleImport}}`,m)),c}),Vc=T.fn(`findCustomRuleTests`)(function*(e){let t=yield*P.Path,n=D.dedupe(e.calls.map(e=>e.dir)),r=yield*T.forEach(n,e=>rt(e).pipe(T.map(n=>M.getOrElse(n,()=>[]).filter(e=>$t(e)).map(n=>t.join(e,n)))),{concurrency:`unbounded`});return D.sort(r.flat(),B.String)}),Hc=T.fn(`readCustomRuleTestCommand`)(function*({customRules:e,cwd:t}){let n=yield*P.Path,r=yield*Vc(e);return{command:r.length===0?M.none():M.some({args:[`--test`,...r.map(e=>n.relative(t,e))],command:`node`}),unresolvedCalls:D.dedupe(e.unresolvedCalls),unresolvedImports:e.unresolvedImports}}),Uc=V.File(`file`,{mustExist:!0}).pipe(V.withDescription(`The JavaScript or TypeScript file to parse`)),Wc=O.make(`ast`,{file:Uc}).pipe(O.withDescription(`Print the syntax tree Oxlint rules use, with node names for custom rules`),O.withHandler(({file:e})=>T.gen(function*(){let t=yield*$,n=yield*r(e),i=bt(e,n,{preserveParens:!1});if(i.errors.length>0)return yield*new ge({errors:i.errors.map(e=>e.message),path:e});yield*t.message(yield*Ve(i.program))}))),Gc=V.String(`name`).pipe(V.withDescription(`The rule name in kebab-case, such as no-process-env`)),Kc=j.String(`dir`).pipe(j.optional,j.withDescription(`The rules folder, relative to the current directory. Default: ${q}. Pass the folder that \`custom({ dir })\` loads, such as a rules folder in a monorepo tooling package`)),qc=j.String(`path`).pipe(j.optional,j.withDescription(`The test file path, relative to the current directory`)),Jc=O.make(`add`,{dir:Kc,name:Gc}).pipe(O.withDescription(`Create a custom rule file. See the Adamantite skill for authoring instructions`),O.withHandler(({dir:e,name:t})=>T.gen(function*(){let n=yield*$,r=yield*P.Path,i=A.cwd(),a=yield*Rc(i,t,M.getOrUndefined(e));yield*n.log.success(`Wrote ${r.relative(i,a)}.`),yield*n.log.info(`\`custom()\` from \`adamantite/rules\` loads the rule. Run \`adamantite doctor\` to check the wiring. The "${ms}" section of the Adamantite skill tells agents how to verify the rule with temporary cases.`)}))),Yc=O.make(`add`,{dir:Kc,name:Gc.pipe(V.optional),path:qc}).pipe(O.withDescription(`Create a test for an existing rule. Omit the name to choose a rule`),O.withHandler(({dir:e,name:t,path:n})=>T.gen(function*(){let r=yield*$,i=yield*P.Path,a=yield*La,o=M.getOrElse(e,()=>q),s=A.cwd(),c=M.getOrUndefined(t);if(c===void 0){let e=(yield*zc(s,o)).map(e=>e.slice(0,-i.extname(e).length));if(e.length===0)return yield*r.log.info(`No custom rules were found in \`${o}\`. Run \`adamantite rule add <name>\` first.`);if(!(yield*a.isInteractive))return yield*r.message(e.join(`
704
+ `)),yield*r.log.info("Pass a rule name with `adamantite rule test add <name>`.");c=yield*r.select({message:`Which rule needs a test?`,options:e.map(e=>({label:e,value:e}))})}let l=yield*Bc(s,c,o,M.getOrUndefined(n));yield*r.log.success(`Wrote ${i.relative(s,l)}.`),yield*r.log.info(`Adapt the valid and invalid cases to the rule, then run \`adamantite rule test\`${M.isSome(n)?" with `--path` and the test file path.":`.`}`),yield*r.log.info(`RuleTester uses node:test. Exclude this test from Vitest and Jest discovery. See Custom rules in the Adamantite README.`)}))),Xc=O.make(`test`,{path:qc}).pipe(O.withDescription(`Run custom rule tests with node --test. Use --path for a test outside the rules folder`),O.withHandler(({path:e})=>T.gen(function*(){let t=yield*$,n=yield*P.Path,r=yield*Pt,i=A.cwd();if(M.isSome(e))return yield*r.run({args:[`--test`,n.resolve(i,e.value)],command:`node`,title:`๐Ÿงช Testing custom rules`});let{command:a,unresolvedCalls:o,unresolvedImports:s}=yield*Hc(yield*Ia(i));for(let e of o)yield*t.log.warning(`\`rule test\` cannot read the \`dir\` of a \`custom()\` call in \`${n.relative(i,e)}\`, because it is not a string literal. It does not run the tests of that rules folder.`);for(let{from:e,specifier:r}of s)yield*t.log.warning(`\`rule test\` cannot resolve the import of \`${r}\` in \`${n.relative(i,e)}\`, so it does not run the tests of the rules folders behind it.`);if(M.isNone(a))return yield*t.log.info("No tests were found for loaded custom rules. Run `adamantite doctor` to check rule setup, or `adamantite rule test add` to add a test.");yield*r.run({...a.value,title:`๐Ÿงช Testing custom rules`})})),O.withSubcommands([Yc])),Zc=V.String(`rule`).pipe(V.withDescription(`The full rule name, such as no-restricted-imports, typescript/no-explicit-any, or project/no-foo`)),Qc=j.String(`report`).pipe(j.atLeast(1),j.withDescription(`Add a case the rule must report. Use a project path, or <path>=<file> to lint file contents at another path. Repeat --report for more cases`)),$c=j.String(`accept`).pipe(j.atLeast(0),j.withDescription(`Add a case the rule must accept, using the same path format as --report`)),el=j.String(`options`).pipe(j.withSchema(z.fromJsonString(z.Array(z.Json))),j.optional,j.withDescription(`The rule options that come after the severity, as a JSON array, such as '[{"paths":["node:fs"]}]'. The trial sets the rule to error`)),tl=j.Boolean(`current`).pipe(j.withDefault(!1),j.withDescription(`Use the project's current rule setting to see what it reports`));function nl(e,t){return t instanceof qo?`\`${e}\` as the project config sets it`:`\`${e}\` at ${JSON.stringify([`error`,...t.options])}`}function rl(e){return e.diagnostics.length>0==(e.case.expected===`reported`)}function il(e,t,n){let r=[...new Set(n.map(e=>`\`${e.config}\``))].join(`, `),i=n.map(e=>{let t=M.match(e.case.source,{onNone:()=>`\`${e.case.path}\``,onSome:t=>`\`${e.case.path}\` from \`${t}\``}),n=e.diagnostics.length>0?`reported`:`accepted`;return[rl(e)?`โœ“ ${t}: ${n}, as expected.`:`โœ— ${t}: ${n}, but it must be ${e.case.expected}.`,...e.diagnostics.map(e=>` ${e.line}:${e.column} ${e.message}`)].join(`
705
+ `)}),a=n.filter(e=>!rl(e)).length,o=a===0?`All cases produced the expected result.`:n.length===1?`The case did not produce the expected result.`:`${a.toLocaleString(`en-US`)} of ${n.length.toLocaleString(`en-US`)} cases ${a===1?`is`:`are`} different from the expected result.`;return[`Trial of ${nl(e,t)}, in ${r}.`,``,...i,``,o].join(`
706
+ `)}const al=O.make(`try`,{accept:$c,current:tl,options:el,report:Qc,rule:Zc}).pipe(O.withDescription(`Test a rule against cases in a project copy. Exit codes: 0 for expected results, 1 for a mismatch, and 2 if a case could not be checked. Project files stay unchanged`),O.withHandler(({accept:e,current:t,options:n,report:r,rule:i})=>T.gen(function*(){let a=yield*$,o=t?new qo:new Jo({options:M.getOrElse(n,()=>[])}),s=yield*T.gen(function*(){if(t&&M.isSome(n))return yield*new nt({reason:"Give `--options` or `--current`, not both."});let a=yield*T.all([...r.map(e=>Yo(e,`reported`)),...e.map(e=>Yo(e,`accepted`))]),s=A.cwd();return yield*rs({cases:a,cwd:s,rule:i,setting:o,workspace:yield*re(s)})}).pipe(T.catch(e=>a.log.error(e.message).pipe(T.andThen(T.fail(new Le({command:`rule try`,exitCode:E.ExitCode(2)}))))));if(yield*a.message(il(i,o,s)),!s.every(e=>rl(e)))return yield*new Le({command:`rule try`,exitCode:E.ExitCode(1)})})));var ol=O.make(`rule`).pipe(O.withDescription(`Create and inspect custom Oxlint rules, try them against cases, and run saved tests`),O.withSubcommands([Jc,Wc,Xc,al]));const sl=[br,_a,or,Sr,tr];var cl=O.make(`update`).pipe(O.withDescription(`Update managed packages and the Adamantite skill, then report setup issues`),O.withHandler(()=>T.gen(function*(){let e=A.cwd(),t=yield*$;yield*t.intro(`๐Ÿ’  adamantite update`);let n=yield*Ia(e),r=yield*Ma(n),i=r.packageActions,a=new Set(i.map(e=>e.package)),o=sl.flatMap(e=>a.has(e.name)?[]:[Wt(n,e,`Adamantite`,`adamantite`)]),s=[...i,...o.flatMap(e=>e.packageActions).filter(e=>e.type===`update_package`)],c=o.filter(e=>e.packageActions.length===0);if(s.length>0){yield*t.log.info(`Packages to install or update:`);for(let e of s){let n=e.type===`install_package`?`not installed`:e.currentVersion;yield*t.log.info(` ${e.package}: ${n} โ†’ ${e.targetVersion}`)}yield*t.withSpinner(()=>Jr(e,s.map(e=>`${e.package}@${e.targetVersion}`)),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated.`})}let l=s.length===0?`idle`:`applied`,u=yield*hc(e).pipe(T.flatMap(n=>n.length===0?T.succeed(`idle`):t.withSpinner(()=>gc(e,n),{failure:`Failed to refresh the Adamantite skill.`,start:`Refreshing the Adamantite skill...`,success:`Adamantite skill refreshed.`}).pipe(T.as(`applied`),T.catchTag([`FailedToCreateDirectory`,`FailedToReadFile`,`FailedToWriteFile`],e=>t.log.warning(`Could not refresh the Adamantite skill. ${e.message}`).pipe(T.as(`applyFailed`))))),T.catchTag(`FailedToReadFile`,e=>t.log.warning(`Could not check the Adamantite skill. ${e.message}`).pipe(T.as(`checkFailed`)))),d=e=>t.log.warning(`Could not update \`skills-lock.json\`. ${e.message}`),f=yield*_c(e).pipe(T.flatMap(e=>e?t.log.info("Removed the `adamantite` entry from `skills-lock.json`.").pipe(T.as(`applied`)):T.succeed(`idle`)),T.catchTag([`FailedToParseFile`,`FailedToReadFile`],e=>d(e).pipe(T.as(`checkFailed`))),T.catchTag(`FailedToWriteFile`,e=>d(e).pipe(T.as(`applyFailed`)))),p=l===`idle`?r:yield*Ma(yield*Ia(e)),m=new Set(p.findings.map(e=>e.id)),h=D.dedupe([...p.warnings,...c.flatMap(e=>e.warnings)]);for(let e of h)yield*t.log.warning(e);let g=[...p.findings,...c.flatMap(e=>e.findings).filter(e=>!m.has(e.id))];return g.length>0&&(yield*za(g),yield*t.log.info("Run `adamantite doctor` for the remaining repairs and an agent prompt.")),![l,u,f].some(e=>e===`applied`||e===`applyFailed`)&&g.length===0?`no-changes`:`success`}).pipe(T.tapError(()=>T.gen(function*(){yield*(yield*$).outro(`โŒ Update failed`)})),T.tap(e=>T.gen(function*(){yield*(yield*$).outro(e===`no-changes`?`โœ… No managed updates were applied.`:`โœ… Update finished.`)})))));const ll=[kr,Nr,ho],ul=[kr,Nr,so,ho,Gs,Fc,ol,cl],dl=new Set(ul.map(e=>e.name)),fl=new Set(ll.map(e=>e.name)),pl=O.make(`adamantite`).pipe(O.withDescription(`Configure code checks for TypeScript projects`),O.withSubcommands(ul)),ml=e=>k.mergeAll(ct.layer,ai.layer.pipe(k.provide(ct.layer)),Pe.layer,$.layer,Wa.layer.pipe(k.provideMerge(e),k.provide(ct.layer)),Kr.layer,La.layer),hl=T.fn(`runCli`)(function*(e,t){let[n,r]=D.splitWhere(e,e=>e===`--`),i=D.drop(r,1),o=n.find(e=>dl.has(e));if(i.length>0&&o!==void 0&&!fl.has(o))return yield*new a({command:o});yield*O.runWith(pl,{version:t})(n).pipe(T.provideService(At,i))}),gl=T.gen(function*(){let e=yield*(yield*st.Stdio).args;yield*hl(e,`0.47.0`)}).pipe(T.as(0),T.catchTag(`CommandFailed`,e=>T.succeed(e.exitCode)),T.catch(e=>T.service($).pipe(T.flatMap(t=>t.log.error(e.message)),T.as(E.ExitCode(1)))),T.provide(ml(Pt.layer)));it.runMain(gl,{teardown:(e,t)=>{at.isSuccess(e)?t(Number(e.value)):ot.defaultTeardown(e,t)}});export{};