adamantite 0.41.0 → 0.43.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 (39) hide show
  1. package/README.md +393 -35
  2. package/dist/index.js +47 -28
  3. package/dist/presets/analyze.d.ts +6 -2
  4. package/dist/presets/analyze.js +7 -1
  5. package/dist/presets/lint/core.d.ts +5 -3
  6. package/dist/presets/lint/core.js +1 -0
  7. package/dist/presets/lint/custom.d.ts +60 -0
  8. package/dist/presets/lint/custom.js +142 -0
  9. package/dist/presets/lint/effect.d.ts +5 -0
  10. package/dist/presets/lint/effect.js +106 -0
  11. package/dist/presets/lint/plugin/imports.d.ts +19 -0
  12. package/dist/presets/lint/plugin/imports.js +53 -0
  13. package/dist/presets/lint/plugin/index.d.ts +17 -0
  14. package/dist/presets/lint/plugin/index.js +20 -0
  15. package/dist/presets/lint/plugin/options.d.ts +11 -0
  16. package/dist/presets/lint/plugin/options.js +33 -0
  17. package/dist/presets/lint/plugin/rules/no-overzealous-destructuring.d.ts +5 -0
  18. package/dist/presets/lint/plugin/rules/no-overzealous-destructuring.js +92 -0
  19. package/dist/presets/lint/plugin/rules/no-query-data-in-state.d.ts +5 -0
  20. package/dist/presets/lint/plugin/rules/no-query-data-in-state.js +85 -0
  21. package/dist/presets/lint/plugin/rules/no-react-state-hooks.d.ts +10 -0
  22. package/dist/presets/lint/plugin/rules/no-react-state-hooks.js +128 -0
  23. package/dist/presets/lint/plugin/rules/query-from-loader.d.ts +5 -0
  24. package/dist/presets/lint/plugin/rules/query-from-loader.js +110 -0
  25. package/dist/presets/lint/react-doctor.d.ts +5 -0
  26. package/dist/presets/lint/react-doctor.js +20 -0
  27. package/dist/presets/lint/react-strict.d.ts +5 -0
  28. package/dist/presets/lint/react-strict.js +11 -0
  29. package/dist/presets/lint/shadcn.d.ts +5 -0
  30. package/dist/presets/lint/shadcn.js +22 -0
  31. package/dist/presets/lint/strict.d.ts +5 -0
  32. package/dist/presets/lint/strict.js +18 -0
  33. package/dist/presets/lint/tanstack.d.ts +5 -0
  34. package/dist/presets/lint/tanstack.js +14 -0
  35. package/dist/presets/lint/vendor/antislop/plugin.d.mts +18 -2
  36. package/dist/presets/rules/index.d.ts +9 -0
  37. package/dist/presets/rules/index.js +29 -0
  38. package/package.json +31 -22
  39. package/skills/adamantite/SKILL.md +105 -11
package/dist/index.js CHANGED
@@ -1,20 +1,12 @@
1
- import*as e from"@effect/platform-node/NodeRuntime";import*as t from"effect/Effect";import*as n from"effect/Exit";import*as r from"effect/Runtime";import*as i from"effect/Stdio";import*as a from"effect/unstable/process/ChildProcessSpawner";import*as o from"@effect/platform-node/NodeServices";import*as s from"effect/Array";import*as c from"effect/Layer";import*as l from"effect/unstable/cli/Command";import*as u from"effect/Option";import*as d from"effect/unstable/cli/Flag";import f from"node:process";import{stripVTControlCharacters as p,styleText as m}from"node:util";import*as h from"effect/Console";import*as g from"effect/Context";import*as _ from"effect/Result";import*as ee from"effect/unstable/process/ChildProcess";import*as v from"effect/Data";import{pipe as y}from"effect/Function";import*as b from"effect/Predicate";import*as x from"effect/String";import{parse as te,printParseErrorCode as ne}from"jsonc-parser";import*as S from"effect/FileSystem";import*as C from"effect/Path";import*as re from"effect/Record";import{defu as ie}from"defu";import*as ae from"effect/Order";import{Visitor as oe,parseSync as se}from"oxc-parser";import*as w from"effect/unstable/cli/Argument";import{print as ce}from"esrap";import le from"esrap/languages/ts";import{addDevDependency as ue,detectPackageManager as de,runScriptCommand as fe}from"nypm";import*as T from"effect/Schema";import*as E from"@clack/prompts";import*as pe from"effect/Terminal";function me(e){return b.isError(e)?y(p(e.message),x.split(/\r\n|[\r\n]/),s.map(e=>x.trimEnd(e)),s.filter(e=>x.isNonEmpty(e))):[]}function D(e){return y(me(e),s.head,u.map(e=>{let t=x.trim(e);return/[.!?]$/.test(t)?` Cause: ${t}`:` Cause: ${t}.`}),u.getOrElse(()=>``))}function he(e){let t=me(e);if(!s.isReadonlyArrayNonEmpty(t))return``;let n=s.takeRight(t,20);return`\n${(n.length<t.length?[`…`,...n]:n).join(`
2
- `)}`}function ge(e=[]){return e.length===0?`- Unknown JSON/JSONC parsing error`:e.slice(0,3).map(e=>`- ${ne(e.error)} (offset: ${e.offset})`).join(`
3
- `)}var _e=class extends v.TaggedError(`CliNotFound`){get message(){return`Command \`${this.command}\` not found. ${this.hint??`Please install it and try again.`}`}},O=class extends v.TaggedError(`CommandFailed`){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}},ve=class extends v.TaggedError(`FailedToCreateDirectory`){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:`the target directory`}.${D(this.cause)}`}},ye=class extends v.TaggedError(`FailedToInstallDependency`){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(`, `)}`:``}.${he(this.cause)}`}},be=class extends v.TaggedError(`FailedToInstallExtension`){get message(){let e=this.extension?`\`${this.extension}\``:`the target extension`;return b.isNumber(this.cause)?`Failed to install ${e}. The \`code\` CLI exited with code ${this.cause}.`:`Failed to install ${e}.${D(this.cause)}`}},xe=class extends v.TaggedError(`FailedToMergeConfig`){get message(){return`Failed to merge configuration.${D(this.cause)}`}},Se=class extends v.TaggedError(`FailedToParseFile`){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:`the target file`}.`,`Please fix the JSON/JSONC syntax and run the command again.`,``,`Parse details:`,ge(this.errors)].join(`
4
- `)}},Ce=class extends v.TaggedError(`FailedToReadFile`){get message(){return`Failed to read ${this.path?`\`${this.path}\``:`the target file`}.${D(this.cause)}`}},we=class extends v.TaggedError(`FailedToWriteFile`){get message(){return`Failed to write ${this.path?`\`${this.path}\``:`the target file`}.${D(this.cause)}`}},Te=class extends v.TaggedError(`FileNotFound`){get message(){return this.path?`File not found: \`${this.path}\`.`:`File not found.`}},Ee=class extends v.TaggedError(`InvalidConfigFormat`){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:`the target config file`}. The config must be a JSON object (for example: {}).`}},De=class extends v.TaggedError(`InvalidAnalyzeOptions`){get message(){return`Invalid analyze options. ${this.reason}`}},k=class extends v.TaggedError(`InvalidInitOptions`){get message(){return`Invalid init options. ${this.reason}`}},Oe=class extends v.TaggedError(`UnsupportedConfigState`){get message(){return`Unsupported config state in ${this.path?`\`${this.path}\``:`the target config file`}.${this.reason?` ${this.reason}`:``}`}},ke=class extends v.TaggedError(`NoPackageManager`){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${D(this.cause)}`}};v.TaggedError(`MissingPackageVersion`);var Ae=class extends v.TaggedError(`OperationCancelled`){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:``}`}},je=class extends v.TaggedError(`PassthroughNotSupported`){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}},Me=class extends v.TaggedError(`VscodeCliNotFound`){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${D(this.cause)}`}};const Ne=(e,t)=>h.log(`${m(`bold`,e)} ${m(`dim`,`· adamantite (${t})`)}`),Pe=()=>[f.env.NODE_OPTIONS,`--disable-warning=MODULE_TYPELESS_PACKAGE_JSON`].filter(Boolean).join(` `),Fe=t.fn(`CommandRunner.exitCode`)(function*({args:e,command:n,cwd:r,detached:i,stderr:a=`inherit`,stdin:o=`ignore`,stdout:s=`inherit`}){return yield*t.scoped(t.gen(function*(){return yield*(yield*ee.make(n,e,{cwd:r,detached:i,env:{NODE_OPTIONS:Pe()},extendEnv:!0,stderr:a,stdin:o,stdout:s})).exitCode})).pipe(t.mapError(e=>e.reason._tag===`NotFound`?new _e({command:n}):e))});var A=class e extends g.Service()(`CommandRunner`){static make(e){let n=t.fn(`CommandRunner.run`)(function*(t){t.title!==void 0&&(yield*Ne(t.title,t.command));let n=yield*e(t);n!==a.ExitCode(0)&&(yield*new O({command:t.command,exitCode:n}))}),r=e=>e.map((e,r)=>r===0?n(e):t.andThen(h.log(``),n(e)));return{exitCode:e,run:n,runAll:t.fn(`CommandRunner.runAll`)(function*(e){let n=yield*t.all(r(e),{concurrency:1,mode:`result`});yield*t.fromResult(_.all(n))}),runUntilFailure:t.fn(`CommandRunner.runUntilFailure`)(function*(e){yield*t.all(r(e),{concurrency:1,discard:!0})})}}static layer=c.effect(this)(t.gen(function*(){let n=yield*a.ChildProcessSpawner;return e.make(e=>Fe(e).pipe(t.provideService(a.ChildProcessSpawner,n)))}))};const j=g.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]});function M(e){return e}const Ie=e=>S.FileSystem.pipe(t.flatMap(t=>t.makeDirectory(e,{recursive:!0})),t.mapError(t=>new ve({cause:t,path:e}))),N=e=>S.FileSystem.pipe(t.flatMap(t=>t.readFileString(e)),t.mapError(t=>new Ce({cause:t,path:e}))),P=e=>S.FileSystem.pipe(t.flatMap(t=>t.readFileString(e)),t.map(e=>y(e,u.some)),t.catch(n=>n.reason._tag===`NotFound`?t.succeedNone:t.fail(new Ce({cause:n,path:e})))),F=(e,n)=>S.FileSystem.pipe(t.flatMap(t=>t.writeFileString(e,n)),t.mapError(t=>new we({cause:t,path:e}))),I=(e,t)=>F(e,`${JSON.stringify(t,null,2)}\n`),L=(e,n)=>t.suspend(()=>{let r=[],i=te(e,r,{allowTrailingComma:!0});return r.length>0?t.fail(new Se({errors:r,path:n})):t.succeed(i)}),R=e=>b.isObject(e),Le=e=>Array.isArray(e);function Re(e){return e===`__proto__`?`["__proto__"]`:/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function ze(e,t={}){let{continuationIndent:n,indentation:r=2}=t,i=JSON.stringify(e,null,r).replaceAll(/(?<!\\)"__proto__":/g,`["__proto__"]:`).replaceAll(/(?<!\\)"([A-Za-z_$][\w$]*)":/g,`$1:`);return n?i.replaceAll(`
5
- `,`\n${n}`):i}const Be=(e,n)=>t.try({catch:e=>new xe({cause:e}),try:()=>ie(e,n)}),Ve=/^workspace:/,He=/^[\^~]/;function Ue(e){return e.trim().replace(Ve,``).replace(He,``)}const z=(e=f.cwd())=>t.gen(function*(){let t=(yield*C.Path).join(e,`package.json`),n=yield*N(t);return yield*L(n,t)}),We=(e,n)=>t.gen(function*(){let t=yield*C.Path;yield*I(t.join(e,`package.json`),n)});function Ge(e){return e===`bun`||e===`deno`||e===`npm`||e===`pnpm`||e===`yarn`}const B={analyze:`adamantite analyze`,check:`adamantite check`,"check:monorepo":`adamantite monorepo`,fix:`adamantite fix`,"fix:monorepo":`adamantite monorepo --fix`,format:`adamantite format`};function Ke(e){let t=e.scripts??{};return y(re.keys(B),s.filter(e=>t[e]===B[e]))}function qe(e,t){let n=e.scripts??{};return s.filterMap(t,e=>{let t=n[e];return t!==void 0&&t!==``&&t!==B[e]?_.succeed({command:t,script:e}):_.failVoid})}const Je=/^(?:packages|"packages"|'packages')\s*:/u;function Ye(e){return e.replace(/(?:^|\s+)#.*$/u,``).trim()}function Xe(e){let t=e.replace(/^\uFEFF/u,``).split(/\r?\n/u),n=t.findIndex(e=>Je.test(e));if(n===-1)return!1;let r=Ye((t[n]??``).replace(Je,``));if(r===`[`){for(let e of t.slice(n+1)){let t=Ye(e);if(t.length!==0)return t!==`]`}return!1}if(r&&!r.startsWith(`#`))return!/^\[\s*\]$/u.test(r);for(let e of t.slice(n+1)){if(/^\s*-\s*[^#\s]/u.test(e))return!0;if(/^\S/u.test(e)&&!e.startsWith(`#`))return!1}return!1}const V=(e=f.cwd())=>t.gen(function*(){let t=yield*C.Path,n=yield*P(t.join(e,`pnpm-workspace.yaml`));if(u.isSome(n)&&Xe(n.value))return!0;let r=(yield*z(e)).workspaces;return((s.isArray(r)?r:r?.packages)?.length??0)>0});function Ze(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function Qe(e,t){return s.findFirst(e.legacyConfigs,e=>Ze(e)===t)}function $e(e){let t=Qe(e,`json`),n=Qe(e,`jsonc`);return y(u.zipWith(t,n,e=>`${e}(c)`),u.orElse(()=>n),u.orElse(()=>t),u.getOrElse(()=>``))}function et(e,t,n,r){return n===null||r.length===0?[]:n.format===`ts`?[`Found both \`${t.config}\` and \`${$e(t)}\`. Adamantite will use \`${t.config}\`.`]:y(u.zipWith(Qe(t,`json`),Qe(t,`jsonc`),(t,n)=>`Found both \`${t}\` and \`${n}\`. Multiple legacy ${e} configs exist; Adamantite will treat \`${n}\` as the source of truth in its findings.`),u.toArray)}const tt=t.fn(`detectToolingConfig`)(function*(e,n,r){let i=yield*S.FileSystem,a=yield*C.Path,o=[r.config,...r.legacyConfigs].map(t=>({file:t,format:Ze(t),path:a.join(e,t)})),c=yield*t.forEach(o,e=>i.exists(e.path),{concurrency:`unbounded`}),l=o.filter((e,t)=>c[t]),d=y(s.findFirst(l,e=>e.format===`ts`),u.orElse(()=>s.findFirst(l,e=>e.format===`jsonc`)),u.orElse(()=>s.findFirst(l,e=>e.format===`json`)),u.getOrNull),f=l.filter(e=>e!==d&&e.format!==`ts`);return{active:d,legacy:f,warnings:et(n,r,d,f)}});function nt(e,t,n){let r=e.devDependencies?.[t.name]??e.dependencies?.[t.name];return r?Ue(r)===t.version?[]:[{currentVersion:r,description:`Update \`${t.name}\` from \`${r}\` to \`${t.version}\`.`,package:t.name,targetVersion:t.version,type:`update_package`}]:[{description:`Install \`${t.name}@${t.version}\` for ${n}.`,package:t.name,targetVersion:t.version,type:`install_package`}]}function rt(e,t){return e.map(e=>({currentState:e.type===`install_package`?`The required package \`${e.package}\` is not installed.`:`The installed \`${e.package}\` version is \`${e.currentVersion}\`, but Adamantite requires \`${e.targetVersion}\`.`,goal:[`Run \`adamantite update\` so \`${e.package}@${e.targetVersion}\` is installed.`],id:`${e.type===`install_package`?`missing`:`outdated`}-${e.package}`,integration:t,title:e.type===`install_package`?`Missing ${e.package}`:`Outdated ${e.package}`}))}function it(e,t){if(e.active===null)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.format!==`ts`)return[{currentState:`Legacy \`${e.active.file}\` is the active ${t.toolName} configuration.`,goal:[`Port 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.invalidGoal??t.inspection.goal??`Update \`${t.configFile}\` so it includes the required Adamantite preset while preserving project-specific settings.`],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 at(e,t){let n=Ke(e);return t.some(e=>n.includes(e))}function ot(e){return M({assess:(n,r)=>t.gen(function*(){let t=at(r,e.scripts)||at(r,e.monorepoOnlyScripts??[])&&(yield*V(n)),i=e.legacyFindings?.(r)??[];if(!t)return i.length>0?{applicable:!0,findings:[...i],packageActions:[],warnings:[]}:{applicable:!1,warnings:[]};let a=nt(r,e,e.purpose);return{applicable:!0,findings:[...rt(a,e.name),...i],packageActions:a,warnings:[]}}),kind:`tooling`,name:e.name,version:e.version})}function st(e){let n=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],r=t=>tt(t,e.name,e.configFiles);return M({assess:(n,i)=>t.gen(function*(){let t=e.legacyScript&&at(i,[e.legacyScript.script])?[e.legacyScript.finding]:[];if(!at(i,e.scripts))return t.length>0?{applicable:!0,findings:t,packageActions:[],warnings:[]}:{applicable:!1,warnings:[]};let a=yield*r(n),o=nt(i,e,e.purpose),s={isMonorepo:yield*V(n)},c=e.configContent(s),l=a.active?.format===`ts`?e.inspectConfig(yield*N(a.active.path),s):void 0;return{applicable:!0,findings:[...rt(o,e.name),...it(a,{configContent:c,configFile:e.configFiles.config,inspection:l,toolName:e.name}),...t],packageActions:o,warnings:a.warnings}}),config:e.configFiles.config,create:n=>t.gen(function*(){let t=yield*C.Path;yield*F(t.join(n,e.configFiles.config),e.configContent({isMonorepo:yield*V(n)}))}),detect:r,files:n,kind:`tooling`,name:e.name,version:e.version})}function ct(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 lt(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 ut(e,t,n){let r=!1;return new oe({Identifier:e=>{e.start>=n.start&&e.end<=n.end&&e.name===t&&(r=!0)}}).visit(e),r}function dt(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 ut(e,t,r);if(r.name===t)return!0;let i=lt(e,r.name);return i!==null&&ut(e,t,i)}function ft(e,t){let n=se(`config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`});if(n.errors.length>0)return{kind:`invalid`,reason:`The file is not valid TypeScript.`};let r=ct(n.program,t.moduleName);return r?dt(n.program,r)?{kind:`configured`}:{kind:`invalid`,reason:`The imported ${t.presetName} preset is not used by the exported configuration.`}:{kind:`invalid`,reason:`The file must import the ${t.presetName} preset from \`${t.moduleName}\`.`}}const pt={monorepo:[`sherif`]},mt={isMonorepo:!1},ht=ae.mapInput(ae.String,e=>e[0]),gt=/ignoreDependencies\s*:\s*\[[^\]]*?sherif/u,_t=/ignoreDependencies\s*:\s*(?:ignoreDependencies\.monorepo|\[[^\]]*?ignoreDependencies\.monorepo)/u,vt=/import\s[^;]*?\{[^}]*\bignoreDependencies\b[^}]*\}\s*from\s*["']adamantite\/analyze["']/u;function yt(e){return gt.test(e)||_t.test(e)&&vt.test(e)}function bt(e,t){let n=ft(e,{moduleName:`adamantite/analyze`,presetName:`Adamantite analyze`});return n.kind!==`configured`||!t.isMonorepo||yt(e)?n:{goal:"Set `ignoreDependencies: ignoreDependencies.monorepo` in `knip.config.ts`, with the named `ignoreDependencies` import from `adamantite/analyze`, and keep the other settings.",kind:`invalid`,reason:"The file must set `ignoreDependencies: ignoreDependencies.monorepo` from `adamantite/analyze`, because Knip cannot see that `adamantite analyze` runs Sherif in a monorepo."}}function xt(e){let t=(s.isArray(e)?e:[]).filter(e=>!(b.isString(e)&&pt.monorepo.includes(e)));return t.length===0?`ignoreDependencies.monorepo`:`[...ignoreDependencies.monorepo, ${t.map(e=>JSON.stringify(e)).join(`, `)}]`}function St(e={},t=mt){let{ignoreDependencies:n,...r}=e,i=t.isMonorepo?r:e,a=Object.entries(i).map(([e,t])=>e===`rules`&&R(t)?[e,[` rules: {`,` ...analyze.rules,`,...Object.entries(t).map(([e,t])=>` ${Re(e)}: ${ze(t,{continuationIndent:` `,indentation:` `})},`),` },`].join(`
6
- `)]:[e,` ${Re(e)}: ${ze(t,{continuationIndent:` `})},`]);t.isMonorepo&&a.push([`ignoreDependencies`,` ignoreDependencies: ${xt(n)},`]);let o=s.sort(a,ht).map(([,e])=>e);return o.length===0?[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = analyze`,``,`export default config`,``].join(`
7
- `):[`import type { KnipConfig } from "knip"`,t.isMonorepo?`import analyze, { ignoreDependencies } from "adamantite/analyze"`:`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = {`,` ...analyze,`,...o,`}`,``,`export default config`,``].join(`
8
- `)}var H=st({configContent:e=>St({},e),configFiles:{config:`knip.config.ts`,legacyConfigs:[`knip.json`,`knip.jsonc`]},inspectConfig:bt,name:`knip`,purpose:"the managed `analyze` script",scripts:[`analyze`],version:`6.32.2`});const Ct=new Set([`check:monorepo`,`fix:monorepo`]),wt=/^adamantite\s+monorepo(?:\s|$)/u,Tt=new Map([[`--fail-on-warnings`,{key:`failOnWarnings`,takesValue:!1}],[`--ignore-dependency`,{key:`ignoreDependency`,takesValue:!0}],[`--ignore-package`,{key:`ignorePackage`,takesValue:!0}],[`--ignore-rule`,{key:`ignoreRule`,takesValue:!0}],[`--no-install`,{key:`noInstall`,takesValue:!1}],[`--select`,{key:`select`,takesValue:!0}],[`-i`,{key:`ignoreDependency`,takesValue:!0}],[`-p`,{key:`ignorePackage`,takesValue:!0}],[`-r`,{key:`ignoreRule`,takesValue:!0}],[`-s`,{key:`select`,takesValue:!0}]]);function Et(e){return Object.entries(e.scripts??{}).flatMap(([e,t])=>t!==void 0&&(Ct.has(e)||wt.test(t.trim()))?[{command:t,name:e}]:[])}function Dt(e){let t=e.command.trim().split(/\s+/u),n=[];for(let[e,r]of t.entries()){let[i=r,a]=r.split(`=`,2),o=Tt.get(i);if(!o)continue;if(!o.takesValue){n.push(`Set \`sherif.${o.key}\` to \`true\` in the root \`package.json\`.`);continue}let s=a??t[e+1];s!==void 0&&n.push(o.key===`select`?`Set \`sherif.select\` to \`"${s}"\` in the root \`package.json\`.`:`Add \`"${s}"\` to the \`sherif.${o.key}\` array in the root \`package.json\`.`)}return n}function Ot(e){let t=Et(e);if(t.length===0)return[];let n=Ke(e).includes(`analyze`);return[{currentState:`Legacy monorepo scripts are present in \`package.json\`: ${t.map(({command:e,name:t})=>`\`${t}\` (\`${e}\`)`).join(`, `)}.${n?``:" The project has no managed `analyze` script."}`,goal:[...n?[]:["Adopt the managed `analyze` script with `adamantite init --non-interactive --script analyze`. It runs Sherif in a detected monorepo."],...s.dedupe(t.flatMap(e=>Dt(e))),...t.map(({name:e})=>`Remove the \`${e}\` script from \`package.json\`.`)],id:`legacy-monorepo-scripts`,integration:`sherif`,notes:["`adamantite analyze` replaces `check:monorepo`, and `adamantite analyze --only monorepo --fix` replaces `fix:monorepo`. `adamantite analyze --fix` without `--only` also lets Knip remove unused files and dependencies.","`adamantite analyze` runs Sherif without flags. Sherif reads project exceptions from the `sherif` field of the root `package.json`, with the CLI options in camelCase: `ignoreDependency`, `ignoreRule`, `ignorePackage`, `select`, `noInstall`, and `failOnWarnings`.","Doctor does not assess `AGENTS.md`. Remove the lines that mention the monorepo scripts from its Adamantite section."],title:`Legacy monorepo scripts`}]}var U=ot({legacyFindings:Ot,monorepoOnlyScripts:[`analyze`],name:`sherif`,purpose:"the managed `analyze` script in a monorepo and the managed monorepo scripts",scripts:[`check:monorepo`,`fix:monorepo`],version:`1.13.0`});const kt=[{command:U.name,fixArguments:[`--fix`],name:`monorepo`,stdin:`inherit`,strictArguments:[],title:`📦 Analyzing the monorepo`},{command:H.name,fixArguments:[`--fix`,`--allow-remove-files`],name:`unused`,stdin:`ignore`,strictArguments:[`--production`,`--strict`],title:`🧹 Analyzing unused code`}],At=d.Boolean(`fix`).pipe(d.withDefault(!1),d.withDescription(`Automatically fix issues in every stage that runs`)),jt=d.Boolean(`strict`).pipe(d.withDefault(!1),d.withDescription(`Enable strict mode for the unused stage (knip)`)),Mt=d.Literals(`only`,[`monorepo`,`unused`]).pipe(d.optional,d.withDescription("Run one stage: `monorepo` (sherif, monorepos only) or `unused` (knip). Arguments after `--` go to that stage"));var Nt=l.make(`analyze`,{fix:At,only:Mt,strict:jt}).pipe(l.withDescription(`Find monorepo issues using sherif, then unused dependencies, exports, and files using knip`),l.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run knip from a specific directory`},{command:`adamantite analyze --only monorepo --fix -- --select highest`,description:`Fix only the monorepo issues and use the highest version on a mismatch`}]),l.withHandler(({fix:e,only:n,strict:r})=>t.gen(function*(){let i=yield*j,a=yield*A,o=u.getOrUndefined(n),s=yield*V().pipe(t.catchTags({FailedToParseFile:()=>t.succeed(!1),FailedToReadFile:()=>t.succeed(!1)}));if(o===`monorepo`){if(r)return yield*new De({reason:"`--strict` applies to the unused stage. Remove it or `--only monorepo`."});if(!s)return yield*new De({reason:"`--only monorepo` needs a monorepo, and no monorepo was detected."})}let c=kt.filter(e=>o===void 0?e.name===`unused`||s:e.name===o),l=o??`unused`,d=c.map(t=>({args:[...e?t.fixArguments:[],...r?t.strictArguments:[],...t.name===l?i:[]],command:t.command,stdin:t.stdin,title:t.title}));yield*(e?a.runUntilFailure(d):a.runAll(d)).pipe(t.mapError(e=>e._tag===`CliNotFound`&&e.command===U.name?new _e({command:e.command,hint:"Run `adamantite update` to install it."}):e))})));const Pt=new Set([`sortImports`,`sortPackageJson`,`sortTailwindcss`]);function Ft(e){return ft(e,{moduleName:`adamantite/format`,presetName:`Adamantite format`})}function It(e){let t=e.split(`
9
- `);return t.length===1?e.slice(1,-1).trim():t.slice(1,-1).map(e=>` ${e.trimStart()}`).join(`
10
- `)}function Lt(e,t){let n=It(ze(t));return[` ${e}: {`,` ...format.${e},`,...n===``?[]:[n],` },`].join(`
11
- `)}function Rt(e={}){let t=Object.entries(e).map(([e,t])=>{if(Pt.has(e)&&R(t))return Lt(e,t);let n=ze(t,{continuationIndent:` `});return` ${Re(e)}: ${n},`});return t.length===0?[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig(format)`,``].join(`
12
- `):[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig({`,` ...format,`,...t,`})`,``].join(`
13
- `)}var W=st({configContent:()=>Rt(),configFiles:{config:`oxfmt.config.ts`,legacyConfigs:[`.oxfmtrc.json`,`.oxfmtrc.jsonc`]},inspectConfig:Ft,legacyScript:{finding:{currentState:"The legacy managed `format` script is present in `package.json`.",goal:["Remove the `format` script from `package.json`."],id:`legacy-format-script`,integration:`oxfmt`,notes:["The managed `check` script verifies formatting and the managed `fix` script applies it.","Doctor does not assess `AGENTS.md`. Remove the `format` line from its Adamantite section."],title:`Legacy format script`},script:`format`},name:`oxfmt`,purpose:"the managed `check` and `fix` scripts",scripts:[`check`,`fix`],version:`0.65.0`});const zt=`**/node_modules,**/.yarn,**/.git,**/dist,**/build,**/out,**/.next,**/.open-next,**/.nuxt,**/.output,**/.svelte-kit,**/.vitepress/cache,**/.turbo,**/.vercel,**/.netlify,**/.wrangler,**/.docusaurus,**/.cache,**/.parcel-cache,**/.vite,**/.astro,**/_astro,**/storybook-static,**/_generated,**/__generated__,**/*.gen.*,**/*.generated.*,**/generated,**/codegen,**/graphql-types.*,**/*.d.ts.map,**/coverage,**/.nyc_output,**/.expo,**/.expo-shared,**/next-env.d.ts,**/worker-configuration.d.ts`.split(`,`),Bt=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],Vt="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",Ht="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",Ut="`oxlint.config.ts` has an `options` object Adamantite cannot patch safely. Make sure each required option is a plain `key: true | false` property—avoid spreads (`...rest`), computed keys (`[name]: ...`), duplicate keys, methods/getters/setters, and non-boolean-literal values.";function Wt(e=[]){return e.includes(`core`)?e:[`core`,...e]}function Gt(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}const Kt=ae.mapInput(ae.String,e=>e[0]);function qt(e){let t=(s.isArray(e)?e:[]).filter(e=>b.isString(e)).filter(e=>!zt.includes(e));return t.length===0?`core.ignorePatterns`:`[...core.ignorePatterns, ${t.map(e=>JSON.stringify(e)).join(`, `)}]`}function Jt(e,t,n=[]){let{ignorePatterns:r,options:i,...a}=e,o=[`import { defineConfig } from "oxlint"`,...t.map(e=>`import ${Gt(e)} from "${e===`core`?`adamantite/lint`:`adamantite/lint/${e}`}"`)],c=[...t.map(e=>Gt(e)),...n.map(e=>JSON.stringify(e))],l=b.isObject(i)?{...i}:{};l.respectEslintDisableDirectives=!0,l.typeAware=!0,l.typeCheck=!0;let u=JSON.stringify(Object.fromEntries(s.sort(Object.entries(l),Kt)),null,2),d=Object.entries(a).map(([e,t])=>[e,JSON.stringify(t,null,2)]),f=[[`extends`,`[${c.join(`, `)}]`],[`ignorePatterns`,qt(r)],[`options`,u],...d],p=s.sort(f,Kt).map(([e,t])=>` ${e}: ${t},`).join(`
14
- `);return[...o,``,`export default defineConfig({`,p,`})`,``].join(`
15
- `)}const Yt=u.liftThrowable(e=>se(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function Xt(e){return Yt(e).pipe(u.flatMap(e=>e.errors.length===0?u.fromNullishOr(e.program):u.none()))}function Zt(e){let{code:t}=ce(e,le({quotes:`double`}));return t.endsWith(`
16
- `)?t:`${t}\n`}function Qt(e){return e.type===`Identifier`?y(e.name,u.some):e.type===`Literal`&&b.isString(e.value)?y(e.value,u.some):u.none()}function $t(e){return e.type===`ObjectExpression`?y(e,u.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?u.none():y(e.arguments.length===1?s.head(e.arguments):u.none(),u.filter(e=>e.type===`ObjectExpression`))}function en(e){return y(e.body,s.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?s.head(e):u.none(),u.flatMap(e=>$t(e.declaration)))}function tn(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`manual`};let e=u.contains(Qt(r.key),t);if(r.method||r.kind!==`init`){if(e)return{status:`manual`};continue}if(e){if(n)return{status:`manual`};n=r}}return n?{property:n,status:`found`}:{status:`missing`}}function nn(e){return{computed:!1,end:0,key:{end:0,name:e,start:0,type:`Identifier`},kind:`init`,method:!1,shorthand:!1,start:0,type:`Property`,value:{end:0,raw:`true`,start:0,type:`Literal`,value:!0}}}function rn(){return{computed:!1,end:0,key:{end:0,name:`options`,start:0,type:`Identifier`},kind:`init`,method:!1,shorthand:!1,start:0,type:`Property`,value:{end:0,properties:Bt.map(e=>nn(e)),start:0,type:`ObjectExpression`}}}function an(e,t){let n=[],r=!1;for(let e of Bt){let i=tn(t,e);if(i.status===`manual`)return{kind:`manual`,reason:Ut};if(i.status===`missing`){n.push(e);continue}let a=i.property.value;if(a.type!==`Literal`||!b.isBoolean(a.value))return{kind:`manual`,reason:Ut};a.value||(a.raw=`true`,a.value=!0,r=!0)}return n.length>0&&(t.properties.unshift(...n.map(e=>nn(e))),r=!0),r?{kind:`patchable`,updatedContent:Zt(e)}:{kind:`configured`}}function on(e){let t=Xt(e);if(u.isNone(t))return{kind:`manual`,reason:Vt};let n=en(t.value);if(u.isNone(n))return{kind:`manual`,reason:Vt};let r=tn(n.value,`options`);return r.status===`manual`?{kind:`manual`,reason:Ht}:r.status===`missing`?(n.value.properties.unshift(rn()),{kind:`patchable`,updatedContent:Zt(t.value)}):r.property.value.type===`ObjectExpression`?an(t.value,r.property.value):{kind:`manual`,reason:Ht}}const G=`oxlint.config.ts`,sn=`.oxlintrc.json`,cn=[{path:G,type:`config`},{path:sn,type:`legacy_config`}],ln={config:G,legacyConfigs:[sn]},un=`1.83.0`,dn=e=>tt(e,`oxlint`,ln);var K=M({assess:(e,n)=>t.gen(function*(){let t=Ke(n);if(!t.includes(`check`)&&!t.includes(`fix`))return{applicable:!1,warnings:[]};let r=yield*dn(e),i=nt(n,{name:`oxlint`,version:un},`the managed lint scripts`),a=r.active,o;if(a?.format===`ts`){let e=on(yield*N(a.path));o=e.kind===`configured`?{kind:`configured`}:{kind:`invalid`,reason:e.kind===`manual`?e.reason:`The required Oxlint options are missing or set to false.`}}let s=Jt({},Wt());return{applicable:!0,findings:[...rt(i,`oxlint`),...it(r,{configContent:s,configFile:G,inspection:o,invalidGoal:"Set `respectEslintDisableDirectives`, `typeAware`, and `typeCheck` to `true` in the `options` object. Preserve every other project setting.",toolName:`oxlint`})],packageActions:i,warnings:r.warnings}}),config:G,create:(e,n=[])=>t.gen(function*(){let t=yield*C.Path,r=Jt({},Wt(n));yield*F(t.join(e,G),r)}),detect:dn,files:cn,kind:`tooling`,name:`oxlint`,update:e=>t.gen(function*(){let t=yield*S.FileSystem,n=(yield*C.Path).join(e,G);if(!(yield*t.exists(n)))return yield*new Te({path:G});let r=on(yield*N(n));if(r.kind!==`configured`){if(r.kind===`manual`)return yield*new Oe({path:G,reason:r.reason});yield*F(n,r.updatedContent)}}),version:un});const fn=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to check (optional)`),w.variadic());var pn=l.make(`check`,{files:fn}).pipe(l.withDescription(`Check formatting, code issues, and type errors`),l.withHandler(({files:e})=>t.gen(function*(){let t=yield*j;yield*(yield*A).runAll([{args:[`--check`,...e],command:W.name,title:`✨ Checking formatting`},{args:[...e,...t],command:K.name,title:`🔍 Linting`}])})));const mn=[{command:`claude`,name:`Claude Code`,seedArguments:e=>[e]},{command:`codex`,name:`Codex`,seedArguments:e=>[e]},{command:`cursor-agent`,name:`Cursor`,seedArguments:e=>[e]},{command:`gemini`,name:`Gemini CLI`,seedArguments:e=>[`-i`,e]},{command:`grok`,name:`Grok Build`,probeArguments:[`version`],seedArguments:e=>[e]},{command:`opencode`,name:`OpenCode`,seedArguments:e=>[`--prompt`,e]}],hn=e=>t.gen(function*(){let n=yield*A;return(yield*t.forEach(mn,r=>n.exitCode({args:[...r.probeArguments??[`--version`]],command:r.command,cwd:e,stderr:`ignore`,stdout:`ignore`}).pipe(t.timeout(`10 seconds`),t.as(r),t.catch(()=>t.succeed(null))),{concurrency:mn.length})).filter(e=>e!==null)});var gn=class extends v.TaggedError(`AgentSessionFailed`){};const _n=()=>{},vn=e=>t.acquireUseRelease(t.sync(()=>{let e=f.listeners(`SIGINT`);return f.removeAllListeners(`SIGINT`),f.on(`SIGINT`,_n),e}),()=>e,e=>t.sync(()=>{f.removeAllListeners(`SIGINT`);for(let t of e)f.on(`SIGINT`,t)})),yn=({agent:e,cwd:n})=>t.gen(function*(){let t=yield*A;yield*vn(t.exitCode({args:e.seedArguments("Run `adamantite doctor` — through your package runner, such as `npx` or `pnpm exec`, if it is not on PATH — and resolve every finding it reports. Rerun `adamantite doctor` until it exits 0."),command:e.command,cwd:n,detached:!1,stderr:`inherit`,stdin:`inherit`,stdout:`inherit`}))}).pipe(t.asVoid,t.mapError(e=>new gn({cause:e,reason:e._tag===`CliNotFound`?`not-found`:`spawn-failed`}))),bn=e=>t.gen(function*(){let t=yield*(yield*A).exitCode({args:[`diff`,`--quiet`,`HEAD`],command:`git`,cwd:e,stderr:`ignore`,stdout:`ignore`});return t===a.ExitCode(0)?`clean`:t===a.ExitCode(1)?`dirty`:`unknown`}).pipe(t.catch(()=>t.succeed(`unknown`))),xn=[{name:`check`,script:`check`},{name:`analyze`,script:`analyze`}];function Sn(e,t){let n=[];for(let r of xn)t.includes(r.script)&&n.push({command:fe(e,r.script),name:r.name});return n}function Cn(e){return xn.some(t=>e.includes(t.script))}var wn=class extends g.Service()(`DependencyInstaller`){static layer=c.succeed(this)({addDevDependencies:t.fn(`DependencyInstaller.addDevDependencies`)((e,n,r)=>t.tryPromise({catch:t=>new ye({cause:t,packages:e}),try:()=>ue(e,{...r,cwd:n})}).pipe(t.asVoid)),detectPackageManager:t.fn(`DependencyInstaller.detectPackageManager`)(e=>t.tryPromise({catch:e=>new ke({cause:e}),try:()=>de(e)}).pipe(t.map(e=>e??null)))})};function Tn(e,t){return t&&e!==`npm`}const En=(e,n)=>t.gen(function*(){let t=yield*wn,r=yield*V(e),i=yield*t.detectPackageManager(e);yield*t.addDevDependencies(n,e,{silent:!0,workspace:Tn(i?.name,r)})});function Dn(e){return{_tag:`File`,path:e}}function On(e){return{_tag:`Version`,value:e}}const kn=[`.node-version`,`.nvmrc`],An=T.Struct({volta:T.Struct({node:T.NonEmptyString})}),jn=T.Struct({engines:T.Struct({node:T.NonEmptyString})}),Mn=T.Struct({name:T.NonEmptyString,version:T.NonEmptyString});function Nn(e){return e.split(`
17
- `).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function Pn(e){return T.is(Mn)(e)&&e.name.toLowerCase()===`node`}function Fn(e){if(T.is(An)(e))return!0;if(b.isObject(e)&&b.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>Pn(e)))return!0}return T.is(jn)(e)}var In=class extends g.Service()(`NodeVersionResolver`){static layer=c.effect(this,t.gen(function*(){let e=yield*S.FileSystem,n=yield*C.Path,r=(r,i)=>P(n.join(r,i)).pipe(t.provideService(S.FileSystem,e));return{resolve:t.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of kn){let n=yield*r(e,t);if(u.exists(n,e=>x.isNonEmpty(e.trim())))return Dn(t)}let t=yield*r(e,`.tool-versions`);if(u.exists(t,e=>Nn(e)))return Dn(`.tool-versions`);let i=yield*r(e,`package.json`);return u.isSome(i)&&Fn(yield*L(i.value,n.join(e,`package.json`)))?Dn(`package.json`):On(`lts/*`)})}}))};const Ln=/^\s*node-version:\s*"?\d/m,Rn=/^[>|](?:[1-9][+-]?|[+-][1-9]?)?(?:\s+#.*)?$/,zn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+check|deno(?:\s+(?!task\b)\S+)*\s+task\s+check)\b/,Bn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+format|deno(?:\s+(?!task\b)\S+)*\s+task\s+format)(?:\s+--)?\s+--check\b/,Vn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+(?:check|fix):monorepo|deno(?:\s+(?!task\b)\S+)*\s+task\s+(?:check|fix):monorepo|adamantite\s+monorepo)(?=\s|$)/,Hn=/^(\s*)(?:-\s*)?(?:command|run):\s*(.*)$/;function Un(e,t){let n=e.split(`
1
+ import*as e from"@effect/platform-node/NodeRuntime";import*as t from"effect/Effect";import*as n from"effect/Exit";import*as r from"effect/process/ChildProcessSpawner";import*as i from"effect/Runtime";import*as a from"effect/Stdio";import*as o from"@effect/platform-node/NodeServices";import*as s from"effect/Array";import*as c from"effect/cli/Command";import*as l from"effect/Layer";import*as u from"effect/cli/Flag";import*as d from"effect/Option";import f from"node:process";import{stripVTControlCharacters as p,styleText as m}from"node:util";import*as h from"effect/Console";import*as g from"effect/Context";import*as ee from"effect/process/ChildProcess";import*as _ from"effect/Result";import*as v from"effect/Data";import{pipe as y}from"effect/Function";import*as b from"effect/Predicate";import*as x from"effect/String";import{parse as te,printParseErrorCode as ne}from"jsonc-parser";import*as S from"effect/FileSystem";import*as C from"effect/Path";import*as re from"effect/Record";import{defu as ie}from"defu";import{Visitor as ae,parseSync as oe}from"oxc-parser";import*as w from"effect/cli/Argument";import{addDevDependency as se,detectPackageManager as ce,runScriptCommand as le}from"nypm";import*as T from"effect/Schema";import*as E from"effect/Order";import{delimiter as ue}from"node:path";import*as de from"effect/Config";import*as D from"@clack/prompts";import*as fe from"effect/Terminal";function pe(e){return b.isError(e)?y(p(e.message),x.split(/\r\n|[\r\n]/),s.map(e=>x.trimEnd(e)),s.filter(e=>x.isNonEmpty(e))):[]}function O(e){return y(pe(e),s.head,d.map(e=>{let t=x.trim(e);return/[.!?]$/.test(t)?` Cause: ${t}`:` Cause: ${t}.`}),d.getOrElse(()=>``))}function me(e){let t=pe(e);if(!s.isReadonlyArrayNonEmpty(t))return``;let n=s.takeRight(t,20);return`\n${(n.length<t.length?[`…`,...n]:n).join(`
2
+ `)}`}function he(e=[]){return e.length===0?`- Unknown JSON/JSONC parsing error`:e.slice(0,3).map(e=>`- ${ne(e.error)} (offset: ${e.offset})`).join(`
3
+ `)}var ge=class extends v.TaggedError(`CliNotFound`){get message(){return`Command \`${this.command}\` not found. ${this.hint??`Please install it and try again.`}`}},_e=class extends v.TaggedError(`CommandFailed`){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}},ve=class extends v.TaggedError(`CustomRuleExists`){get message(){return`The custom rule \`${this.path}\` already exists. Choose another name or edit the file.`}},ye=class extends v.TaggedError(`FailedToCreateDirectory`){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:`the target directory`}.${O(this.cause)}`}},be=class extends v.TaggedError(`FailedToInstallDependency`){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(`, `)}`:``}.${me(this.cause)}`}},xe=class extends v.TaggedError(`FailedToInstallExtension`){get message(){let e=this.extension?`\`${this.extension}\``:`the target extension`;return b.isNumber(this.cause)?`Failed to install ${e}. The \`code\` CLI exited with code ${this.cause}.`:`Failed to install ${e}.${O(this.cause)}`}},Se=class extends v.TaggedError(`FailedToMergeConfig`){get message(){return`Failed to merge configuration.${O(this.cause)}`}},Ce=class extends v.TaggedError(`FailedToParseFile`){get message(){return[`Failed to parse ${this.path?`\`${this.path}\``:`the target file`}.`,`Please fix the JSON/JSONC syntax and run the command again.`,``,`Parse details:`,he(this.errors)].join(`
4
+ `)}},we=class extends v.TaggedError(`FailedToParseSource`){get message(){return[`Failed to parse \`${this.path}\`.`,...this.errors.map(e=>`- ${e}`)].join(`
5
+ `)}},Te=class extends v.TaggedError(`FailedToReadFile`){get message(){return`Failed to read ${this.path?`\`${this.path}\``:`the target file`}.${O(this.cause)}`}},Ee=class extends v.TaggedError(`FailedToWriteFile`){get message(){return`Failed to write ${this.path?`\`${this.path}\``:`the target file`}.${O(this.cause)}`}},De=class extends v.TaggedError(`InvalidConfigFormat`){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:`the target config file`}. The config must be a JSON object (for example: {}).`}},Oe=class extends v.TaggedError(`InvalidAnalyzeOptions`){get message(){return`Invalid analyze options. ${this.reason}`}},ke=class extends v.TaggedError(`InvalidFixOptions`){get message(){return`Invalid fix options. ${this.reason}`}},k=class extends v.TaggedError(`InvalidInitOptions`){get message(){return`Invalid init options. ${this.reason}`}},Ae=class extends v.TaggedError(`InvalidRuleName`){get message(){return`Invalid rule name \`${this.name}\`. Use kebab-case that starts with a letter, such as \`no-process-env\`.`}},je=class extends v.TaggedError(`NoPackageManager`){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${O(this.cause)}`}};v.TaggedError(`MissingPackageVersion`);var Me=class extends v.TaggedError(`OperationCancelled`){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:``}`}},Ne=class extends v.TaggedError(`PassthroughNotSupported`){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}},Pe=class extends v.TaggedError(`VscodeCliNotFound`){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${O(this.cause)}`}};const Fe=(e,t)=>h.log(`${m(`bold`,e)} ${m(`dim`,`· adamantite (${t})`)}`),Ie=()=>[f.env.NODE_OPTIONS,`--disable-warning=MODULE_TYPELESS_PACKAGE_JSON`].filter(Boolean).join(` `),Le=t.fn(`CommandRunner.exitCode`)(function*({args:e,command:n,cwd:r,detached:i,env:a,stderr:o=`inherit`,stdin:s=`ignore`,stdout:c=`inherit`}){return yield*t.scoped(t.gen(function*(){return yield*(yield*ee.make(n,e,{cwd:r,detached:i,env:{...a,NODE_OPTIONS:Ie()},extendEnv:!0,stderr:o,stdin:s,stdout:c})).exitCode})).pipe(t.mapError(e=>e.reason._tag===`NotFound`?new ge({command:n}):e))});var A=class e extends g.Service()(`CommandRunner`){static make(e){let n=t.fn(`CommandRunner.run`)(function*(t){t.title!==void 0&&(yield*Fe(t.title,t.command));let n=yield*e(t);if(n!==r.ExitCode(0))return yield*new _e({command:t.command,exitCode:n})}),i=e=>e.map((e,r)=>r===0?n(e):t.andThen(h.log(``),n(e)));return{exitCode:e,run:n,runAll:t.fn(`CommandRunner.runAll`)(function*(e){let n=yield*t.all(i(e),{concurrency:1,mode:`result`});yield*t.fromResult(_.all(n))}),runUntilFailure:t.fn(`CommandRunner.runUntilFailure`)(function*(e){yield*t.all(i(e),{concurrency:1,discard:!0})})}}static layer=l.effect(this)(t.gen(function*(){let n=yield*r.ChildProcessSpawner;return e.make(e=>Le(e).pipe(t.provideService(r.ChildProcessSpawner,n)))}))};const Re=g.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]});function j(e){return e}const ze=e=>S.FileSystem.pipe(t.flatMap(t=>t.makeDirectory(e,{recursive:!0})),t.mapError(t=>new ye({cause:t,path:e}))),M=e=>S.FileSystem.pipe(t.flatMap(t=>t.readFileString(e)),t.mapError(t=>new Te({cause:t,path:e}))),N=e=>S.FileSystem.pipe(t.flatMap(t=>t.readFileString(e)),t.map(e=>y(e,d.some)),t.catch(n=>n.reason._tag===`NotFound`?t.succeedNone:t.fail(new Te({cause:n,path:e})))),Be=e=>S.FileSystem.pipe(t.flatMap(t=>t.readDirectory(e)),t.map(e=>y(e,d.some)),t.catch(n=>n.reason._tag===`NotFound`||n.reason._tag===`BadResource`?t.succeed(d.none()):t.fail(new Te({cause:n,path:e})))),P=(e,n)=>S.FileSystem.pipe(t.flatMap(t=>t.writeFileString(e,n)),t.mapError(t=>new Ee({cause:t,path:e}))),F=(e,t)=>P(e,`${JSON.stringify(t,null,2)}\n`),I=(e,n)=>t.suspend(()=>{let r=[],i=te(e,r,{allowTrailingComma:!0});return r.length>0?t.fail(new Ce({errors:r,path:n})):t.succeed(i)}),L=e=>b.isObject(e),Ve=e=>Array.isArray(e),He=(e,n)=>t.try({catch:e=>new Se({cause:e}),try:()=>ie(e,n)}),Ue=/^workspace:/,We=/^[\^~]/;function Ge(e){return e.trim().replace(Ue,``).replace(We,``)}const R=(e=f.cwd())=>t.gen(function*(){let t=(yield*C.Path).join(e,`package.json`),n=yield*M(t);return yield*I(n,t)}),Ke=(e,n)=>t.gen(function*(){let t=yield*C.Path;yield*F(t.join(e,`package.json`),n)});function qe(e){return e===`bun`||e===`deno`||e===`npm`||e===`pnpm`||e===`yarn`}const z={analyze:`adamantite analyze`,check:`adamantite check`,fix:`adamantite fix`};function Je(e){let t=e.scripts??{};return y(re.keys(z),s.filter(e=>t[e]===z[e]))}function Ye(e,t){let n=e.scripts??{};return s.filterMap(t,e=>{let t=n[e];return t!==void 0&&t!==``&&t!==z[e]?_.succeed({command:t,script:e}):_.failVoid})}const Xe=/^(?:packages|"packages"|'packages')\s*:/u;function Ze(e){return e.replace(/(?:^|\s+)#.*$/u,``).trim()}function Qe(e){let t=e.replace(/^\uFEFF/u,``).split(/\r?\n/u),n=t.findIndex(e=>Xe.test(e));if(n===-1)return!1;let r=Ze((t[n]??``).replace(Xe,``));if(r===`[`){for(let e of t.slice(n+1)){let t=Ze(e);if(t.length!==0)return t!==`]`}return!1}if(r&&!r.startsWith(`#`))return!/^\[\s*\]$/u.test(r);for(let e of t.slice(n+1)){if(/^\s*-\s*[^#\s]/u.test(e))return!0;if(/^\S/u.test(e)&&!e.startsWith(`#`))return!1}return!1}const B=(e=f.cwd())=>t.gen(function*(){let t=yield*C.Path,n=yield*N(t.join(e,`pnpm-workspace.yaml`));if(d.isSome(n)&&Qe(n.value))return!0;let r=(yield*R(e)).workspaces;return((s.isArray(r)?r:r?.packages)?.length??0)>0});function $e(e){return e.replace(/^(["'])(.*)\1$/u,`$2`)}function et(e){let t=e.replace(/^\uFEFF/u,``).split(/\r?\n/u),n=t.findIndex(e=>Xe.test(e));if(n===-1)return[];let r=Ze((t[n]??``).replace(Xe,``));if(r.startsWith(`[`)){let e=[r,...t.slice(n+1).map(e=>Ze(e))].join(` `),i=e.indexOf(`]`);return e.slice(1,i===-1?void 0:i).split(`,`).map(e=>$e(e.trim())).filter(e=>e.length>0)}let i=[];for(let e of t.slice(n+1)){let t=/^\s*-\s*(.+)$/u.exec(Ze(e))?.[1];if(t!==void 0)i.push($e(t.trim()));else if(/^\S/u.test(e)&&!e.startsWith(`#`))break}return i}function tt(e){return e.replaceAll(/[$()+.[\\\]^{|}]/gu,String.raw`\$&`)}function nt(e){let t=e.replace(/^\.\//u,``).replace(/\/+$/u,``).split(`/`),n=``;for(let[e,r]of t.entries()){let i=e===0||t[e-1]===`**`?``:`/`;r===`**`?e<t.length-1?n+=`${i}(?:[^/]+/)*`:n+=e===0?`(?:[^/]+(?:/[^/]+)*)?`:`(?:/[^/]+)*`:n+=`${i}${tt(r).replaceAll(`*`,`[^/]*`).replaceAll(`?`,`[^/]`)}`}return RegExp(`^${n}$`,`u`)}function rt(e){let t=e.replace(/^\.\//u,``).replace(/\/+$/u,``).split(`/`),n=t.findIndex(e=>/[*?]/u.test(e));return n===-1?{base:t.join(`/`),depth:0}:{base:t.slice(0,n).join(`/`),depth:t.includes(`**`)?1/0:t.length-n}}const it=/* @__PURE__ */ new Set([`node_modules`]),at=(e,n,r)=>t.gen(function*(){let i=yield*C.Path,a=yield*Be(i.resolve(e,n));return d.isNone(a)?[]:r===0?[n]:[n,...(yield*t.forEach(a.value.filter(e=>!e.startsWith(`.`)&&!it.has(e)),t=>at(e,n===``?t:`${n}/${t}`,r-1),{concurrency:`unbounded`})).flat()]}),ot=(e=f.cwd())=>t.gen(function*(){let n=yield*C.Path,r=yield*N(n.join(e,`pnpm-workspace.yaml`)),i=(yield*R(e)).workspaces,a=d.match(r,{onNone:()=>s.isArray(i)?i:i?.packages??[],onSome:e=>et(e)}),o=a.filter(e=>!e.startsWith(`!`)),c=a.filter(e=>e.startsWith(`!`)).map(e=>nt(e.slice(1))),l=yield*t.forEach(o,n=>t.gen(function*(){let{base:t,depth:r}=rt(n),i=nt(n);return(yield*at(e,t,r)).filter(e=>e!==``&&i.test(e))}),{concurrency:`unbounded`}),u=s.dedupe(l.flat()).filter(e=>!c.some(t=>t.test(e)));return(yield*t.forEach(u,r=>N(n.join(e,r,`package.json`)).pipe(t.map(t=>d.isSome(t)?[n.resolve(e,r)]:[])),{concurrency:`unbounded`})).flat()});function st(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function ct(e,t){return s.findFirst(e.legacyConfigs,e=>st(e)===t)}function lt(e){let t=ct(e,`json`),n=ct(e,`jsonc`);return y(d.zipWith(t,n,e=>`${e}(c)`),d.orElse(()=>n),d.orElse(()=>t),d.getOrElse(()=>``))}function ut(e,t,n,r){return n===null||r.length===0?[]:n.format===`ts`?[`Found both \`${t.config}\` and \`${lt(t)}\`. Adamantite will use \`${t.config}\`.`]:y(d.zipWith(ct(t,`json`),ct(t,`jsonc`),(t,n)=>`Found both \`${t}\` and \`${n}\`. Multiple legacy ${e} configs exist; Adamantite will treat \`${n}\` as the source of truth in its findings.`),d.toArray)}const dt=t.fn(`detectToolingConfig`)(function*(e,n,r){let i=yield*S.FileSystem,a=yield*C.Path,o=[r.config,...r.legacyConfigs].map(t=>({file:t,format:st(t),path:a.join(e,t)})),c=yield*t.forEach(o,e=>i.exists(e.path),{concurrency:`unbounded`}),l=o.filter((e,t)=>c[t]),u=y(s.findFirst(l,e=>e.format===`ts`),d.orElse(()=>s.findFirst(l,e=>e.format===`jsonc`)),d.orElse(()=>s.findFirst(l,e=>e.format===`json`)),d.getOrNull),f=l.filter(e=>e!==u&&e.format!==`ts`);return{active:u,legacy:f,warnings:ut(n,r,u,f)}});function ft(e,t,n){let r=e.devDependencies?.[t.name]??e.dependencies?.[t.name];return r?Ge(r)===t.version?[]:[{currentVersion:r,description:`Update \`${t.name}\` from \`${r}\` to \`${t.version}\`.`,package:t.name,targetVersion:t.version,type:`update_package`}]:[{description:`Install \`${t.name}@${t.version}\` for ${n}.`,package:t.name,targetVersion:t.version,type:`install_package`}]}function pt(e,t){return e.map(e=>({currentState:e.type===`install_package`?`The required package \`${e.package}\` is not installed.`:`The installed \`${e.package}\` version is \`${e.currentVersion}\`, but Adamantite requires \`${e.targetVersion}\`.`,goal:[`Run \`adamantite update\` so \`${e.package}@${e.targetVersion}\` is installed.`],id:`${e.type===`install_package`?`missing`:`outdated`}-${e.package}`,integration:t,title:e.type===`install_package`?`Missing ${e.package}`:`Outdated ${e.package}`}))}function mt(e,t){if(e.active===null)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.format!==`ts`)return[{currentState:`Legacy \`${e.active.file}\` is the active ${t.toolName} configuration.`,goal:[`Port 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.invalidGoal??t.inspection.goal??`Update \`${t.configFile}\` so it includes the required Adamantite preset while preserving project-specific settings.`],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 ht(e,t){let n=Je(e);return t.some(e=>n.includes(e))}function gt(e){return j({assess:(n,r)=>t.gen(function*(){let t=ht(r,e.scripts)&&(!e.monorepoOnly||(yield*B(n)))&&(e.isRequired===void 0||(yield*e.isRequired(n))),i=e.legacyFindings?.(r)??[];if(!t)return i.length>0?{applicable:!0,findings:[...i],packageActions:[],warnings:[]}:{applicable:!1,warnings:[]};let a=ft(r,e,e.purpose);return{applicable:!0,findings:[...pt(a,e.name),...i],packageActions:a,warnings:[]}}),kind:`tooling`,name:e.name,version:e.version})}const _t=t.fn(`detectToolingWorkspace`)(function*(e){return{isMonorepo:yield*B(e)}});function vt(e){let n=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],r=t=>dt(t,e.name,e.configFiles);return j({assess:(n,i)=>t.gen(function*(){let t=e.legacyFindings?.(i)??[];if(!ht(i,e.scripts))return t.length>0?{applicable:!0,findings:t,packageActions:[],warnings:[]}:{applicable:!1,warnings:[]};let a=yield*r(n),o=ft(i,e,e.purpose),s=yield*e.detectWorkspace(n),c=e.configContent(s),l=a.active?.format===`ts`?e.inspectConfig(yield*M(a.active.path),s):void 0;return{applicable:!0,findings:[...pt(o,e.name),...mt(a,{configContent:c,configFile:e.configFiles.config,inspection:l,toolName:e.name}),...t],packageActions:o,warnings:a.warnings}}),config:e.configFiles.config,create:n=>t.gen(function*(){let t=yield*C.Path;yield*P(t.join(n,e.configFiles.config),e.configContent(yield*e.detectWorkspace(n)))}),detect:r,files:n,kind:`tooling`,name:e.name,version:e.version})}const yt=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],bt="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to inspect `options`.",xt="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can inspect.",St=[`react`,`react-strict`,`react-doctor`,`tanstack`,`nextjs`,`vue`,`effect`,`jest`,`vitest`,`node`,`strict`,`antislop`,`shadcn`];function Ct(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}function wt(e=[]){let t=e.includes(`core`)?e:[`core`,...e];return[`import { defineConfig } from "oxlint"`,...t.map(e=>`import ${Ct(e)} from "${e===`core`?`adamantite/lint`:`adamantite/lint/${e}`}"`),`import custom from "adamantite/lint/custom"`,``,`export default defineConfig({`,` extends: [${[...t.map(e=>Ct(e)),`custom()`].join(`, `)}],`,` ignorePatterns: core.ignorePatterns,`,` options: {`,...yt.map(e=>` ${e}: true,`),` },`,`})`,``].join(`
6
+ `)}const Tt=d.liftThrowable(e=>oe(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function Et(e){return Tt(e).pipe(d.flatMap(e=>e.errors.length===0?d.fromNullishOr(e.program):d.none()))}const Dt=`adamantite/lint/`,Ot=`${Dt}custom`;function kt(e){return y(Et(e),d.map(e=>e.body.flatMap(e=>e.type===`ImportDeclaration`&&e.source.value.startsWith(Dt)&&e.source.value!==Ot?[e.source.value.slice(16)]:[])),d.getOrElse(()=>[]))}function At(e){return e.type===`Identifier`?y(e.name,d.some):e.type===`Literal`&&b.isString(e.value)?y(e.value,d.some):d.none()}function jt(e){return e.type===`ObjectExpression`?y(e,d.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?d.none():y(e.arguments.length===1?s.head(e.arguments):d.none(),d.filter(e=>e.type===`ObjectExpression`))}function Mt(e){return y(e.body,s.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?s.head(e):d.none(),d.flatMap(e=>jt(e.declaration)))}function Nt(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`invalid`};let e=d.contains(At(r.key),t);if(r.method||r.kind!==`init`){if(e)return{status:`invalid`};continue}if(e){if(n)return{status:`invalid`};n=r}}return n?{property:n,status:`found`}:{status:`missing`}}function Pt(e){for(let t of yt){let n=Nt(e,t);if(n.status===`invalid`)return{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{kind:`invalid`,reason:`The required Oxlint options are missing or are not set to true.`}}return{kind:`configured`}}function Ft(e){let t=Et(e);if(d.isNone(t))return{kind:`invalid`,reason:bt};let n=Mt(t.value);if(d.isNone(n))return{kind:`invalid`,reason:bt};let r=Nt(n.value,`options`);return r.status===`invalid`?{kind:`invalid`,reason:xt}:r.status===`missing`?{kind:`invalid`,reason:`The required Oxlint options are missing.`}:r.property.value.type===`ObjectExpression`?Pt(r.property.value):{kind:`invalid`,reason:xt}}function It(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 Lt(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 Rt(e,t,n){let r=!1;return new ae({Identifier:e=>{e.start>=n.start&&e.end<=n.end&&e.name===t&&(r=!0)}}).visit(e),r}function zt(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 Rt(e,t,r);if(r.name===t)return!0;let i=Lt(e,r.name);return i!==null&&Rt(e,t,i)}function Bt(e,t){let n=oe(`config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`});if(n.errors.length>0)return{kind:`invalid`,reason:`The file is not valid TypeScript.`};let r=It(n.program,t.moduleName);return r?zt(n.program,r)?{kind:`configured`}:{kind:`invalid`,reason:`The imported ${t.presetName} preset is not used by the exported configuration.`}:{kind:`invalid`,reason:`The file must import the ${t.presetName} preset from \`${t.moduleName}\`.`}}const Vt={isMonorepo:!1,usesEffectPreset:!1},Ht={effect:/ignoreDependencies\s*:\s*\[[^\]]*?@effect\/language-service/u,monorepo:/ignoreDependencies\s*:\s*\[[^\]]*?sherif/u},Ut={effect:/ignoreDependencies\s*:\s*(?:ignoreDependencies\.effect|\[[^\]]*?ignoreDependencies\.effect)/u,monorepo:/ignoreDependencies\s*:\s*(?:ignoreDependencies\.monorepo|\[[^\]]*?ignoreDependencies\.monorepo)/u},Wt=/import\s[^;]*?\{[^}]*\bignoreDependencies\b[^}]*\}\s*from\s*["']adamantite\/analyze["']/u,Gt={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"};function Kt(e){return[`monorepo`,`effect`].filter(t=>t===`monorepo`?e.isMonorepo:e.usesEffectPreset)}function qt(e,t){return Ht[t].test(e)||Ut[t].test(e)&&Wt.test(e)}function Jt(e){let[t]=e;return e.length===1&&t!==void 0?`ignoreDependencies.${t}`:`[${e.map(e=>`...ignoreDependencies.${e}`).join(`, `)}]`}const Yt=t.fn(`detectKnipWorkspace`)(function*(e){let t=yield*C.Path,n=yield*N(t.join(e,`oxlint.config.ts`));return{...yield*_t(e),usesEffectPreset:d.match(n,{onNone:()=>!1,onSome:e=>kt(e).includes(`effect`)})}});function Xt(e,t){let n=Bt(e,{moduleName:`adamantite/analyze`,presetName:`Adamantite analyze`});if(n.kind!==`configured`)return n;let r=Kt(t),i=r.filter(t=>!qt(e,t));if(i.length===0)return n;let a=`\`ignoreDependencies: ${Jt(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=>Gt[e]).join(`, and `)}.`}}function Zt(e=Vt){let t=Kt(e);return[`import type { KnipConfig } from "knip"`,t.length>0?`import analyze, { ignoreDependencies } from "adamantite/analyze"`:`import analyze from "adamantite/analyze"`,``,...t.length>0?[`const config: KnipConfig = {`,` ...analyze,`,` ignoreDependencies: ${Jt(t)},`,`}`]:[`const config: KnipConfig = analyze`],``,`export default config`,``].join(`
7
+ `)}var V=vt({configContent:Zt,configFiles:{config:`knip.config.ts`,legacyConfigs:[`knip.json`,`knip.jsonc`]},detectWorkspace:Yt,inspectConfig:Xt,name:`knip`,purpose:"the managed `analyze` script",scripts:[`analyze`],version:`6.39.0`});const Qt=/* @__PURE__ */ new Set([`check:monorepo`,`fix:monorepo`]),$t=/^adamantite\s+monorepo(?:\s|$)/u,en=/* @__PURE__ */ new Map([[`--fail-on-warnings`,{key:`failOnWarnings`,takesValue:!1}],[`--ignore-dependency`,{key:`ignoreDependency`,takesValue:!0}],[`--ignore-package`,{key:`ignorePackage`,takesValue:!0}],[`--ignore-rule`,{key:`ignoreRule`,takesValue:!0}],[`--no-install`,{key:`noInstall`,takesValue:!1}],[`--select`,{key:`select`,takesValue:!0}],[`-i`,{key:`ignoreDependency`,takesValue:!0}],[`-p`,{key:`ignorePackage`,takesValue:!0}],[`-r`,{key:`ignoreRule`,takesValue:!0}],[`-s`,{key:`select`,takesValue:!0}]]);function tn(e){return Object.entries(e.scripts??{}).flatMap(([e,t])=>t!==void 0&&(Qt.has(e)||$t.test(t.trim()))?[{command:t,name:e}]:[])}function nn(e){let t=e.command.trim().split(/\s+/u),n=[];for(let[e,r]of t.entries()){let[i=r,a]=r.split(`=`,2),o=en.get(i);if(!o)continue;if(!o.takesValue){n.push(`Set \`sherif.${o.key}\` to \`true\` in the root \`package.json\`.`);continue}let s=a??t[e+1];s!==void 0&&n.push(o.key===`select`?`Set \`sherif.select\` to \`"${s}"\` in the root \`package.json\`.`:`Add \`"${s}"\` to the \`sherif.${o.key}\` array in the root \`package.json\`.`)}return n}function rn(e){let t=tn(e);if(t.length===0)return[];let n=Je(e).includes(`analyze`);return[{currentState:`Legacy monorepo scripts are present in \`package.json\`: ${t.map(({command:e,name:t})=>`\`${t}\` (\`${e}\`)`).join(`, `)}.${n?``:" The project has no managed `analyze` script."}`,goal:[...n?[]:["Adopt the managed `analyze` script with `adamantite init --non-interactive --script analyze`. It runs Sherif in a detected monorepo."],...s.dedupe(t.flatMap(e=>nn(e))),...t.map(({name:e})=>`Remove the \`${e}\` script from \`package.json\`.`)],id:`legacy-monorepo-scripts`,integration:`sherif`,notes:["`adamantite analyze` replaces `check:monorepo`, and `adamantite analyze --only monorepo --fix` replaces `fix:monorepo`. `adamantite analyze --fix` without `--only` also lets Knip remove unused files and dependencies.","`adamantite analyze` runs Sherif without flags. Sherif reads project exceptions from the `sherif` field of the root `package.json`, with the CLI options in camelCase: `ignoreDependency`, `ignoreRule`, `ignorePackage`, `select`, `noInstall`, and `failOnWarnings`.","Doctor does not assess `AGENTS.md`. Remove the lines that mention the monorepo scripts from its Adamantite section."],title:`Legacy monorepo scripts`}]}var H=gt({legacyFindings:rn,monorepoOnly:!0,name:`sherif`,purpose:"the managed `analyze` script in a monorepo",scripts:[`analyze`],version:`1.13.0`});const an=[{command:H.name,fixArguments:[`--fix`],name:`monorepo`,stdin:`inherit`,strictArguments:[],title:`📦 Analyzing the monorepo`},{command:V.name,fixArguments:[`--fix`,`--allow-remove-files`],name:`unused`,stdin:`ignore`,strictArguments:[`--production`,`--strict`],title:`🧹 Analyzing unused code`}],on=u.Boolean(`fix`).pipe(u.withDefault(!1),u.withDescription(`Automatically fix issues in every stage that runs`)),sn=u.Boolean(`strict`).pipe(u.withDefault(!1),u.withDescription(`Enable strict mode for the unused stage (knip)`)),cn=u.Literals(`only`,[`monorepo`,`unused`]).pipe(u.optional,u.withDescription("Run one stage: `monorepo` (sherif, monorepos only) or `unused` (knip). Arguments after `--` go to that stage"));var ln=c.make(`analyze`,{fix:on,only:cn,strict:sn}).pipe(c.withDescription(`Find monorepo issues using sherif, then unused dependencies, exports, and files using knip`),c.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run knip from a specific directory`},{command:`adamantite analyze --only monorepo --fix -- --select highest`,description:`Fix only the monorepo issues and use the highest version on a mismatch`}]),c.withHandler(({fix:e,only:n,strict:r})=>t.gen(function*(){let i=yield*Re,a=yield*A,o=d.getOrUndefined(n),s=yield*B().pipe(t.catchTags({FailedToParseFile:()=>t.succeed(!1),FailedToReadFile:()=>t.succeed(!1)}));if(o===`monorepo`){if(r)return yield*new Oe({reason:"`--strict` applies to the unused stage. Remove it or `--only monorepo`."});if(!s)return yield*new Oe({reason:"`--only monorepo` needs a monorepo, and no monorepo was detected."})}let c=an.filter(e=>o===void 0?e.name===`unused`||s:e.name===o),l=o??`unused`,u=c.map(t=>({args:[...e?t.fixArguments:[],...r?t.strictArguments:[],...t.name===l?i:[]],command:t.command,stdin:t.stdin,title:t.title}));yield*(e?a.runUntilFailure(u):a.runAll(u)).pipe(t.mapError(e=>e._tag===`CliNotFound`&&e.command===H.name?new ge({command:e.command,hint:"Run `adamantite update` to install it."}):e))})));function un(e){return Bt(e,{moduleName:`adamantite/format`,presetName:`Adamantite format`})}function dn(){return[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig(format)`,``].join(`
8
+ `)}var U=vt({configContent:dn,configFiles:{config:`oxfmt.config.ts`,legacyConfigs:[`.oxfmtrc.json`,`.oxfmtrc.jsonc`]},detectWorkspace:_t,inspectConfig:un,legacyFindings:e=>e.scripts?.format===`adamantite format`?[{currentState:"The legacy managed `format` script is present in `package.json`.",goal:["Remove the `format` script from `package.json`."],id:`legacy-format-script`,integration:`oxfmt`,notes:["The managed `check` script verifies formatting and the managed `fix` script applies it.","Doctor does not assess `AGENTS.md`. Remove the `format` line from its Adamantite section."],title:`Legacy format script`}]:[],name:`oxfmt`,purpose:"the managed `check` and `fix` scripts",scripts:[`check`,`fix`],version:`0.71.0`});const fn=`oxlint.config.ts`,pn=`.oxlintrc.json`,mn=[{path:fn,type:`config`},{path:pn,type:`legacy_config`}],hn={config:fn,legacyConfigs:[pn]},gn=`1.86.0`,_n=e=>dt(e,`oxlint`,hn);var W=j({assess:(e,n)=>t.gen(function*(){let t=Je(n);if(!t.includes(`check`)&&!t.includes(`fix`))return{applicable:!1,warnings:[]};let r=yield*_n(e),i=ft(n,{name:`oxlint`,version:gn},`the managed lint scripts`),a=r.active,o;a?.format===`ts`&&(o=Ft(yield*M(a.path)));let s=wt();return{applicable:!0,findings:[...pt(i,`oxlint`),...mt(r,{configContent:s,configFile:fn,inspection:o,invalidGoal:"Set `respectEslintDisableDirectives`, `typeAware`, and `typeCheck` to `true` in the `options` object. Preserve every other project setting.",toolName:`oxlint`})],packageActions:i,warnings:r.warnings}}),config:fn,create:(e,n=[])=>t.gen(function*(){let t=yield*C.Path,r=wt(n);yield*P(t.join(e,fn),r)}),detect:_n,files:mn,kind:`tooling`,name:`oxlint`,version:gn});const vn=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to check (optional)`),w.variadic()),yn=u.Literals(`only`,[`format`,`lint`]).pipe(u.optional,u.withDescription("Run one stage: `format` (oxfmt) or `lint` (oxlint). Arguments after `--` go to that stage"));var bn=c.make(`check`,{files:vn,only:yn}).pipe(c.withDescription(`Check formatting, code issues, and type errors`),c.withHandler(({files:e,only:n})=>t.gen(function*(){let t=yield*Re,r=yield*A,i=d.getOrUndefined(n),a=i??`lint`,o=[{args:[`--check`,...e],command:U.name,name:`format`,title:`✨ Checking formatting`},{args:[...e],command:W.name,name:`lint`,title:`🔍 Linting`}];yield*r.runAll(o.filter(e=>i===void 0||e.name===i).map(e=>({args:[...e.args,...e.name===a?t:[]],command:e.command,title:e.title})))})));const xn=[`check`,`analyze`];function Sn(e,t){return xn.filter(e=>t.includes(e)).map(t=>({command:le(e,t),name:t}))}function Cn(e){return xn.some(t=>e.includes(t))}var wn=class extends g.Service()(`DependencyInstaller`){static layer=l.succeed(this)({addDevDependencies:t.fn(`DependencyInstaller.addDevDependencies`)((e,n,r)=>t.tryPromise({catch:t=>new be({cause:t,packages:e}),try:()=>se(e,{...r,cwd:n})}).pipe(t.asVoid)),detectPackageManager:t.fn(`DependencyInstaller.detectPackageManager`)(e=>t.tryPromise({catch:e=>new je({cause:e}),try:()=>ce(e)}).pipe(t.map(e=>e??null)))})};function Tn(e,t){return t&&e!==`npm`}const En=(e,n)=>t.gen(function*(){let t=yield*wn,r=yield*B(e),i=yield*t.detectPackageManager(e);yield*t.addDevDependencies(n,e,{silent:!0,workspace:Tn(i?.name,r)})});function Dn(e){return{_tag:`File`,path:e}}function On(e){return{_tag:`Version`,value:e}}const kn=[`.node-version`,`.nvmrc`],An=T.Struct({volta:T.Struct({node:T.NonEmptyString})}),jn=T.Struct({engines:T.Struct({node:T.NonEmptyString})}),Mn=T.Struct({name:T.NonEmptyString,version:T.NonEmptyString});function Nn(e){return e.split(`
9
+ `).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function Pn(e){return T.is(Mn)(e)&&e.name.toLowerCase()===`node`}function Fn(e){if(T.is(An)(e))return!0;if(b.isObject(e)&&b.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>Pn(e)))return!0}return T.is(jn)(e)}var In=class extends g.Service()(`NodeVersionResolver`){static layer=l.effect(this,t.gen(function*(){let e=yield*S.FileSystem,n=yield*C.Path,r=(r,i)=>N(n.join(r,i)).pipe(t.provideService(S.FileSystem,e));return{resolve:t.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of kn){let n=yield*r(e,t);if(d.exists(n,e=>x.isNonEmpty(e.trim())))return Dn(t)}let t=yield*r(e,`.tool-versions`);if(d.exists(t,e=>Nn(e)))return Dn(`.tool-versions`);let i=yield*r(e,`package.json`);return d.isSome(i)&&Fn(yield*I(i.value,n.join(e,`package.json`)))?Dn(`package.json`):On(`lts/*`)})}}))};const Ln=/^\s*node-version:\s*"?\d/m,Rn=/^[>|](?:[1-9][+-]?|[+-][1-9]?)?(?:\s+#.*)?$/,zn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+check|deno(?:\s+(?!task\b)\S+)*\s+task\s+check)\b/,Bn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+format|deno(?:\s+(?!task\b)\S+)*\s+task\s+format)(?:\s+--)?\s+--check\b/,Vn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+(?:check|fix):monorepo|deno(?:\s+(?!task\b)\S+)*\s+task\s+(?:check|fix):monorepo|adamantite\s+monorepo)(?=\s|$)/,Hn=/^(\s*)(?:-\s*)?(?:command|run):\s*(.*)$/;function Un(e,t){let n=e.split(`
18
10
  `);for(let[e,r]of n.entries()){let i=Hn.exec(r);if(!i)continue;let a=i[1]?.length??0,o=(i[2]??``).trim();if(t.test(o))return!0;if(Rn.test(o))for(let r of n.slice(e+1)){let e=r.trim();if(e.length!==0){if(r.length-r.trimStart().length<=a)break;if(t.test(e))return!0}}}return!1}function Wn(e){return` - name: Setup Node.js
19
11
  uses: actions/setup-node@v7
20
12
  with:
@@ -88,24 +80,51 @@ ${r.map(e=>` - name: ${e.name}\n command: ${e.command}`).joi
88
80
  ${Gn(n)[e]}
89
81
 
90
82
  - name: Run \${{ matrix.name }}
91
- run: \${{ matrix.command }}`}\n`}const qn={currentState:"The workflow still runs the legacy `format` script with `--check`.",goal:["Remove the workflow step or matrix entry that runs the `format` script with `--check`."],id:`legacy-format-workflow-step`,integration:`github`,notes:["The managed `check` script verifies formatting. Preserve unrelated workflow jobs and project-specific settings."],title:`Legacy format workflow step`},Jn={currentState:"The workflow still runs a legacy monorepo script or `adamantite monorepo`.",goal:["Remove the workflow step or matrix entry that runs `check:monorepo`, `fix:monorepo`, or `adamantite monorepo`.","Make the workflow run the managed `analyze` script. It runs Sherif in a detected monorepo."],id:`legacy-monorepo-workflow-step`,integration:`github`,notes:[`Preserve unrelated workflow jobs and project-specific settings.`],title:`Legacy monorepo workflow step`},Yn=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],Xn=(e,n)=>t.gen(function*(){let t=yield*C.Path,r=yield*In,i=t.join(e,Yn[0].path),a=Kn(n,yield*r.resolve(e));a&&(yield*F(i,a))});var Zn=M({assess:(e,n)=>t.gen(function*(){let t=(yield*C.Path).join(e,Yn[0].path),r=yield*P(t);if(r._tag===`None`)return{applicable:!1,warnings:[]};let i=Ke(n),a=Ln.test(r.value),o=i.includes(`check`)&&!Un(r.value,zn),s=[...Un(r.value,Bn)?[qn]:[],...Un(r.value,Vn)?[Jn]:[]];if(!a&&!o)return{applicable:!0,findings:s,packageActions:[],warnings:[]};if(!Cn(i))return{applicable:!0,findings:s,packageActions:[],warnings:[`No CI-compatible managed scripts were found, so the GitHub Actions workflow cannot be regenerated.`]};let c=yield*(yield*wn).detectPackageManager(e);return c?Ge(c.name)?{applicable:!0,findings:[{currentState:[...a?[`The workflow contains a hard-coded Node.js version.`]:[],...o?["The workflow does not run the managed `check` script."]:[]].join(` `),goal:["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 \`${c.name}\`. Preserve unrelated workflow jobs and project-specific settings.`],title:`Outdated Adamantite workflow`},...s],packageActions:[],warnings:[]}:{applicable:!0,findings:s,packageActions:[],warnings:[`\`${c.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow cannot be regenerated.`]}:{applicable:!0,findings:s,packageActions:[],warnings:[`Could not detect a package manager, so the GitHub Actions workflow cannot be regenerated.`]}}),create:(e,n)=>t.gen(function*(){let t=yield*C.Path;yield*Ie(t.dirname(t.join(e,Yn[0].path))),yield*Xn(e,n)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,Yn[0].path))}),files:Yn,kind:`ci`,name:`github`,update:Xn});const q=[{path:`.zed/settings.json`,type:`config`}],Qn={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:{initialization_options:{settings:{configPath:null,fixKind:`safe_fix`,run:`onType`,typeAware:!0,unusedDisableDirectives:`deny`}}}}},$n={configPath:null,"fmt.experimental":!0,typeAware:!1,unusedDisableDirectives:!1};function er(e){let t=e.lsp,n=R(t)?t.oxfmt:void 0,r=R(n)?n.initialization_options:void 0,i=R(r)?r.settings:void 0;if(!R(i))return[];let a=Object.entries($n);return Object.entries(i).filter(([e,t])=>a.some(([n,r])=>n===e&&r===t)).map(([e])=>e)}function tr(e){return!R(e)||!Le(e.plugins)?e:Object.fromEntries([...Object.entries(e),[`plugins`,s.dedupe(e.plugins)]])}function nr(e){let t=e.languages;if(!R(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>!(e in Qn.languages)||!R(t)?[e,t]:[e,Object.fromEntries(Object.entries(t).map(([e,t])=>e===`formatter`&&Le(t)?[e,s.dedupe(t)]:e===`prettier`?[e,tr(t)]:[e,t]))]));return Object.fromEntries([...Object.entries(e),[`languages`,n]])}var J=M({assess:(e,n)=>t.gen(function*(){let t=(yield*C.Path).join(e,q[0].path),n=yield*P(t);if(n._tag===`None`)return{applicable:!1,warnings:[]};let r=yield*L(n.value,t),i=R(r)?er(r):[];return{applicable:!0,findings:i.length===0?[]:[{currentState:`\`${q[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`}],packageActions:[],warnings:[]}}),config:q[0].path,create:e=>t.gen(function*(){let t=yield*C.Path,n=t.join(e,q[0].path);yield*Ie(t.dirname(n)),yield*I(n,Qn)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,q[0].path))}),files:q,kind:`editor`,name:`zed`,update:e=>t.gen(function*(){let t=(yield*C.Path).join(e,q[0].path),n=yield*N(t),r=yield*L(n,t);if(!b.isObject(r))return yield*new Ee({path:t});let i=nr(yield*Be(Qn,r));yield*I(t,i)})}),rr=ot({name:`oxlint-tsgolint`,purpose:`the managed lint scripts`,scripts:[`check`,`fix`],version:`7.0.2001`});const Y=[{path:`tsconfig.json`,type:`config`}],X=`adamantite/typescript`,ir={extends:X},ar=["Skipping `tsconfig.json` setup: a root config in a monorepo makes TypeScript treat all packages as one project.",`To use the TypeScript preset, add \`"extends": "${X}"\` to each package's \`tsconfig.json\` or to a shared base config.`];function or(e){return b.isString(e)?e===X?e:[e,X]:s.isArray(e)?e.includes(X)?e:[...e,X]:X}var Z=M({assess:(e,n)=>t.gen(function*(){let t=Ke(n);if(!t.includes(`check`)&&!t.includes(`fix`))return{applicable:!1,warnings:[]};if(yield*V(e))return{applicable:!0,findings:[],packageActions:[],warnings:ar};let r=(yield*C.Path).join(e,Y[0].path),i=yield*P(r);if(i._tag===`None`)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:`${JSON.stringify(ir,null,2)}\n`,language:`json`},title:`Missing TypeScript configuration`}],packageActions:[],warnings:[]};let a=yield*L(i.value,r);return{applicable:!0,findings:b.isObject(a)&&(a.extends===X||s.isArray(a.extends)&&a.extends.includes(X))?[]:[{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:`${JSON.stringify(ir,null,2)}\n`,language:`json`},title:`TypeScript preset is not configured`}],packageActions:[],warnings:[]}}),config:Y[0].path,create:e=>t.gen(function*(){let t=yield*C.Path;yield*I(t.join(e,Y[0].path),ir)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,Y[0].path))}),files:Y,kind:`workspace`,name:`tsconfig`,update:e=>t.gen(function*(){let t=(yield*C.Path).join(e,Y[0].path),n=yield*N(t),r=yield*L(n,t);if(!b.isObject(r))return yield*new Ee({path:t});let i=yield*Be(ir,r),a=Object.fromEntries([...Object.entries(i),[`extends`,or(`extends`in r?r.extends:void 0)]]);yield*I(t,a)})});const sr=[H,W,K,U,rr,Z,Zn,J],cr=t.fn(`collectApplicableAssessments`)(function*(e,n,r){return yield*t.forEach(e,e=>e.assess(n,r).pipe(t.map(t=>t.applicable?u.some({assessment:t,name:e.name}):u.none())),{concurrency:`unbounded`}).pipe(t.map(e=>s.getSomes(e)))});function lr(e,t,n){return cr(e,t,n)}const ur=t.fn(`assessProject`)(function*(e,t){let n=t??(yield*z(e)),r=yield*lr(sr,e,n);return{applicableIntegrations:r.map(({name:e})=>e),findings:r.flatMap(({assessment:e})=>e.findings),packageActions:r.flatMap(({assessment:e})=>e.packageActions),warnings:r.flatMap(({assessment:e})=>e.warnings)}});function dr(e,t){return e.findings.length===0?fr(e.warnings,t):pr(e.findings,e.warnings,t)}function fr(e,t){return[`# Adamantite doctor warnings`,``,`This project uses Adamantite ${t} to manage linting, formatting, and type tooling.`,"`adamantite doctor` found no repair findings, but reported these warnings:",``,...e.map(e=>`- ${e}`),``].join(`
92
- `)}function pr(e,t,n){let r=e.map((e,t)=>{let n=e.goal.map(e=>` - ${e}`).join(`
83
+ run: \${{ matrix.command }}`}\n`}const qn={currentState:"The workflow still runs the legacy `format` script with `--check`.",goal:["Remove the workflow step or matrix entry that runs the `format` script with `--check`."],id:`legacy-format-workflow-step`,integration:`github`,notes:["The managed `check` script verifies formatting. Preserve unrelated workflow jobs and project-specific settings."],title:`Legacy format workflow step`},Jn={currentState:"The workflow still runs a legacy monorepo script or `adamantite monorepo`.",goal:["Remove the workflow step or matrix entry that runs `check:monorepo`, `fix:monorepo`, or `adamantite monorepo`.","Make the workflow run the managed `analyze` script. It runs Sherif in a detected monorepo."],id:`legacy-monorepo-workflow-step`,integration:`github`,notes:[`Preserve unrelated workflow jobs and project-specific settings.`],title:`Legacy monorepo workflow step`},Yn=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],Xn=(e,n)=>t.gen(function*(){let t=yield*C.Path,r=yield*In,i=t.join(e,Yn[0].path),a=Kn(n,yield*r.resolve(e));a&&(yield*P(i,a))});var Zn=j({assess:(e,n)=>t.gen(function*(){let t=(yield*C.Path).join(e,Yn[0].path),r=yield*N(t);if(r._tag===`None`)return{applicable:!1,warnings:[]};let i=Je(n),a=Ln.test(r.value),o=i.includes(`check`)&&!Un(r.value,zn),s=[...Un(r.value,Bn)?[qn]:[],...Un(r.value,Vn)?[Jn]:[]];if(!a&&!o)return{applicable:!0,findings:s,packageActions:[],warnings:[]};if(!Cn(i))return{applicable:!0,findings:s,packageActions:[],warnings:[`No CI-compatible managed scripts were found, so the GitHub Actions workflow cannot be regenerated.`]};let c=yield*(yield*wn).detectPackageManager(e);return c?qe(c.name)?{applicable:!0,findings:[{currentState:[...a?[`The workflow contains a hard-coded Node.js version.`]:[],...o?["The workflow does not run the managed `check` script."]:[]].join(` `),goal:["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 \`${c.name}\`. Preserve unrelated workflow jobs and project-specific settings.`],title:`Outdated Adamantite workflow`},...s],packageActions:[],warnings:[]}:{applicable:!0,findings:s,packageActions:[],warnings:[`\`${c.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow cannot be regenerated.`]}:{applicable:!0,findings:s,packageActions:[],warnings:[`Could not detect a package manager, so the GitHub Actions workflow cannot be regenerated.`]}}),create:(e,n)=>t.gen(function*(){let t=yield*C.Path;yield*ze(t.dirname(t.join(e,Yn[0].path))),yield*Xn(e,n)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,Yn[0].path))}),files:Yn,kind:`ci`,name:`github`,update:Xn});const G=[{path:`.zed/settings.json`,type:`config`}],Qn={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:{initialization_options:{settings:{configPath:null,fixKind:`safe_fix`,run:`onType`,typeAware:!0,unusedDisableDirectives:`deny`}}}}},$n={configPath:null,"fmt.experimental":!0,typeAware:!1,unusedDisableDirectives:!1};function er(e){let t=e.lsp,n=L(t)?t.oxfmt:void 0,r=L(n)?n.initialization_options:void 0,i=L(r)?r.settings:void 0;if(!L(i))return[];let a=Object.entries($n);return Object.entries(i).filter(([e,t])=>a.some(([n,r])=>n===e&&r===t)).map(([e])=>e)}function tr(e){return!L(e)||!Ve(e.plugins)?e:Object.fromEntries([...Object.entries(e),[`plugins`,s.dedupe(e.plugins)]])}function nr(e){let t=e.languages;if(!L(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>!(e in Qn.languages)||!L(t)?[e,t]:[e,Object.fromEntries(Object.entries(t).map(([e,t])=>e===`formatter`&&Ve(t)?[e,s.dedupe(t)]:e===`prettier`?[e,tr(t)]:[e,t]))]));return Object.fromEntries([...Object.entries(e),[`languages`,n]])}var K=j({assess:(e,n)=>t.gen(function*(){let t=(yield*C.Path).join(e,G[0].path),n=yield*N(t);if(n._tag===`None`)return{applicable:!1,warnings:[]};let r=yield*I(n.value,t),i=L(r)?er(r):[];return{applicable:!0,findings:i.length===0?[]:[{currentState:`\`${G[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`}],packageActions:[],warnings:[]}}),config:G[0].path,create:e=>t.gen(function*(){let t=yield*C.Path,n=t.join(e,G[0].path);yield*ze(t.dirname(n)),yield*F(n,Qn)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,G[0].path))}),files:G,kind:`editor`,name:`zed`,update:e=>t.gen(function*(){let t=(yield*C.Path).join(e,G[0].path),n=yield*M(t),r=yield*I(n,t);if(!b.isObject(r))return yield*new De({path:t});let i=nr(yield*He(Qn,r));yield*F(t,i)})});const rr=`project`,ir=`.adamantite/rules`,ar=/* @__PURE__ */ new Set([`.js`,`.mjs`,`.mts`,`.ts`]);function or(e){let t=/\.[^.]+$/.exec(e)?.[0]??``;return ar.has(t)&&!e.startsWith(`_`)&&!/\.d\.m?ts$/.test(e)}function sr(e,t){return oe(e,t,{preserveParens:!1,sourceType:`module`})}function cr(e,t){return e.body.flatMap(e=>e.type===`ImportDeclaration`&&e.source.value===t?e.specifiers:[]).find(e=>e.type===`ImportDefaultSpecifier`)?.local.name}function lr(e){return e.type===`Literal`&&b.isString(e.value)?e.value:e.type===`TemplateLiteral`&&e.expressions.length===0?e.quasis[0]?.value.cooked??null:null}function ur(e){return e.type===`Literal`&&b.isString(e.value)?e.value:null}function dr(e){let t=ir,n=rr;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{dir:null,name:null};let e=r.key.type===`Identifier`?r.key.name:ur(r.key);e===`dir`?t=lr(r.value):e===`name`&&(n=lr(r.value))}return{dir:t,name:n}}function fr(e,t){let n=sr(e,t),r=cr(n.program,`adamantite/lint/custom`);if(n.errors.length>0||r===void 0)return[];let i=[];return new ae({CallExpression(e){if(e.callee.type!==`Identifier`||e.callee.name!==r)return;let[t]=e.arguments;t===void 0?i.push({dir:ir,name:rr}):t.type===`ObjectExpression`?i.push(dr(t)):i.push({dir:null,name:null})}}).visit(n.program),i}function pr(e,t){return e.slice(0,t).split(`
84
+ `).length}function mr(e){switch(e.type){case`TSInterfaceDeclaration`:case`TSTypeAliasDeclaration`:return!0;case`TSModuleDeclaration`:return hr(e);case`ClassDeclaration`:case`FunctionDeclaration`:case`TSEnumDeclaration`:case`VariableDeclaration`:return e.declare===!0;case`ExportNamedDeclaration`:return e.declaration===null?e.exportKind===`type`:mr(e.declaration);default:return!1}}function hr(e){return e.kind===`global`||e.declare||e.body===null||e.body.body.every(e=>e.type!==`ExpressionStatement`&&mr(e))}function gr(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 _r(e,t){let n=sr(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 vr(e,t){let n=sr(e,t);if(n.errors.length>0)return n.errors.map(e=>`Syntax error: ${e.message}`);let r=[],i=(e,n)=>{r.push(`Line ${pr(t,e)}: ${n} needs a TypeScript transform, which type stripping does not do.`)};return new ae({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){hr(e)||i(e.start,"A `namespace` with values")},TSParameterProperty(e){i(e.start,`A parameter property`)}}).visit(n.program),gr(n.program)||r.push(`The file has no default export. Export the rule as default.`),r}const yr=`.adamantite/rules`,br=/^[a-z][\da-z]*(?:-[\da-z]+)*$/;function xr(e){return`import { defineRule } from "adamantite/rules"
85
+
86
+ export default defineRule({
87
+ meta: {
88
+ docs: { description: "TODO: describe what ${e} reports." },
89
+ messages: { unexpected: "TODO: tell the author what to do instead." },
90
+ schema: [],
91
+ type: "problem",
92
+ },
93
+ createOnce(context) {
94
+ return {
95
+ // Run \`adamantite rule ast <file>\` to find the node types to visit.
96
+ DebuggerStatement(node) {
97
+ context.report({ messageId: "unexpected", node })
98
+ },
99
+ }
100
+ },
101
+ })
102
+ `}const Sr=t.fn(`addCustomRule`)(function*(e,n,r=yr){if(!br.test(n))return yield*new Ae({name:n});let i=yield*S.FileSystem,a=yield*C.Path,o=a.resolve(e,r),s=a.join(o,`${n}.ts`),c=a.join(o,`AGENTS.md`),l=e=>i.exists(e).pipe(t.mapError(t=>new Te({cause:t,path:e})));return(yield*l(s))?yield*new ve({path:s}):(yield*ze(o),yield*P(s,xr(n)),(yield*l(c))?{agentsPath:void 0,rulePath:s}:(yield*P(c,'# Custom rules\n\nEach file in the rules folder, `.adamantite/rules/` by default, is an Oxlint rule that this\nproject owns. `custom()` from `adamantite/lint/custom` loads the folder and enables each\nrule as `error` under the `project` plugin: `no-process-env.ts` becomes\n`project/no-process-env`. Add a file to add a rule. Delete the file to remove the rule.\n`adamantite rule add <name>` writes a correct stub.\n\n- A file that starts with `_`, such as `_helpers.ts`, is a helper, not a rule. Subfolders are\n not read.\n- Export the rule as default with `defineRule` from `adamantite/rules`. The same module exports\n the `Context`, `Rule`, `Visitor`, and `ESTree` node types.\n- Use `createOnce`. It runs one time for each lint run, not one time for each file. Reset\n per-file state in `before`, and report collected results in `after`. `context.filename`,\n `context.sourceCode`, and `context.settings` are not available in the body of\n `createOnce`. Read them in `before` or in a visitor.\n- Write erasable TypeScript only. Oxlint loads rule files with Node.js type stripping, so\n `enum`, a `namespace` with values, parameter properties, and `import x = require()` stop\n the lint run.\n- Rules get no type information. Use only the AST and `context.sourceCode`.\n- Report with a `messageId`, and put each message in `meta.messages`. Describe the options in\n `meta.schema`, and read them from `context.options`.\n- A rule that throws prints an error for each file, and the lint run still exits 0. After you\n change a rule, run the lint and read all of its output.\n- To find node names, run `adamantite rule ast <file>` on real code. It prints the same\n ESTree-shaped AST that rules visit.\n- To test a rule, use `RuleTester` from `oxlint/plugins-dev`. Adamantite does not run rule\n tests.\n- Oxlint caches the rules for each run. Restart the editor language server after you change a\n rule.\n- TypeScript does not check `.adamantite/rules/` by default, because its name starts with a dot. Add\n `".adamantite/rules"` to `include` in `tsconfig.json` to check it.\n- In a monorepo, give each rules folder its own plugin name, such as `custom({ name: "web" })`:\n Oxlint rejects two plugins with the same name in one run. A relative `dir` resolves from the\n file that calls `custom()`, so a shared tooling package can own the rules with\n `custom({ dir: "rules", name: "acme" })`. A nested Oxlint config replaces the root config, so\n a package that needs the root rules extends the root config.\n'),{agentsPath:c,rulePath:s}))}),Cr=`custom-rules`,wr=[`oxlint.config.ts`,`oxlint.config.mts`,`oxlint.config.js`,`oxlint.config.mjs`],Tr=[`.ts`,`.mts`,`.cts`,`.js`,`.mjs`,`.cjs`],Er=/* @__PURE__ */ new Set([`default`,`import`,`node`]);function Dr(e){if(e!=null)return b.isString(e)?e:s.isArray(e)?e.map(e=>Dr(e)).find(e=>e!==void 0):Object.entries(e).filter(([e])=>Er.has(e)).map(([,e])=>Dr(e)).find(e=>e!==void 0)}const Or=E.combine(E.mapInput(E.flip(E.Number),([e])=>e.indexOf(`*`)),E.mapInput(E.flip(E.Number),([e])=>e.length));function kr(e,t){let{exports:n}=e;if(n===void 0)return t===``?e.main??`index`:t;let r=t===``?`.`:`./${t}`;if(n===null||b.isString(n)||s.isArray(n))return r===`.`?Dr(n):void 0;let i=Object.keys(n).some(e=>e.startsWith(`.`))?n:{".":n};if(r in i)return Dr(i[r]);let a=s.sort(Object.entries(i),Or).map(([e,t])=>{let[n,i,...a]=e.split(`*`);return n!==void 0&&i!==void 0&&a.length===0&&r.startsWith(n)&&r.endsWith(i)&&r.length>n.length+i.length?{match:r.slice(n.length,r.length-i.length),target:t}:null}).find(e=>e!==null);return a===void 0?void 0:Dr(a.target)?.replaceAll(`*`,a.match)}const Ar=t.fn(`readWorkspacePackage`)(function*(e){let t=yield*R(e);return t.name===void 0?d.none():d.some({directory:e,exports:t.exports,main:t.main,name:t.name})}),jr=t.fn(`readFirstFile`)(function*(e){for(let n of e){let e=yield*N(n).pipe(t.orElseSucceed(()=>d.none()));if(d.isSome(e))return d.some({content:e.value,file:n})}return d.none()}),Mr=t.fn(`resolveImport`)(function*(e,t,n){let r=yield*C.Path,i;if(t.startsWith(`.`)||r.isAbsolute(t))i=r.resolve(r.dirname(e),t);else{let e=n.find(e=>t===e.name||t.startsWith(`${e.name}/`));if(e===void 0)return{_tag:`external`};let a=kr(e,t.slice(e.name.length+1));if(a===void 0)return{_tag:`unresolved`};i=r.resolve(e.directory,a)}if(i.split(r.sep).includes(`node_modules`))return{_tag:`external`};let a=i,o=i.replace(/\.[cm]?js$/u,``),s=yield*jr([i,...Tr.map(e=>`${o}${e}`),...Tr.map(e=>r.join(a,`index${e}`))]);return d.match(s,{onNone:()=>({_tag:`unresolved`}),onSome:e=>({_tag:`found`,module:e})})}),Nr=t.fn(`findCustomRulesCalls`)(function*(e){let n=yield*C.Path,r=s.getSomes(yield*t.forEach(e,e=>Ar(e),{concurrency:`unbounded`})),i=s.getSomes(yield*t.forEach(e,e=>jr(wr.map(t=>n.join(e,t))),{concurrency:`unbounded`})),a=/* @__PURE__ */ new Set,o=[],c=[],l=i;for(;l.length>0;){let e=l.filter(e=>!a.has(e.file));for(let t of e)a.add(t.file),t.content.includes(`adamantite/lint/custom`)&&o.push(...fr(t.file,t.content).map(e=>({dir:e.dir===null?null:n.resolve(n.dirname(t.file),e.dir),name:e.name,source:t.file})));let i=e.flatMap(e=>_r(e.file,e.content).map(t=>({from:e.file,specifier:t}))),s=yield*t.forEach(i,({from:e,specifier:t})=>Mr(e,t,r),{concurrency:`unbounded`});l=[];for(let[e,t]of s.entries()){let n=i[e];t._tag===`found`?l.push(t.module):t._tag===`unresolved`&&n!==void 0&&c.push(n)}}return{calls:o,unresolvedImports:c}}),Pr=t.fn(`readRulesFolder`)(function*(e){return(yield*Be(e)).pipe(d.map(t=>({dir:e,ruleFiles:t.filter(e=>or(e))})))});var Fr=j({assess:e=>t.gen(function*(){let n=yield*C.Path,r=t=>n.relative(e,t)||`.`,i=[e,...(yield*B(e))?yield*ot(e):[]],{calls:a,unresolvedImports:o}=yield*Nr(i),c=i.map(e=>n.join(e,yr)),l=s.dedupe(a.flatMap(e=>e.dir===null?[]:[e.dir])),u=s.getSomes(yield*t.forEach(s.dedupe([...c,...l]),e=>Pr(e),{concurrency:`unbounded`})).filter(e=>e.ruleFiles.length>0);if(a.length===0&&u.length===0&&o.length===0)return{applicable:!1,warnings:[]};let d=a.filter(e=>e.dir===null||e.name===null),f=[...o.map(({from:e,specifier:t})=>`Doctor cannot resolve the import of \`${t}\` in \`${r(e)}\`, so it does not check the \`custom()\` calls and rules folders behind it.`),...d.map(e=>`Doctor cannot read the \`dir\` or \`name\` of a \`custom()\` call in \`${r(e.source)}\`, because it is not a string literal. Doctor does not check that rules folder.`)],p=[];if(d.length===0&&o.length===0)for(let e of u)l.includes(e.dir)||p.push({currentState:`\`${r(e.dir)}\` has ${e.ruleFiles.length} rule file(s), but no \`custom()\` call loads it, so Oxlint does not run them.`,goal:[`Load \`${r(e.dir)}\` with \`custom()\` from \`adamantite/lint/custom\` in the Oxlint config of \`${r(n.dirname(n.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:${r(e.dir)}`,integration:Cr,reference:{content:`import { defineConfig } from "oxlint"
103
+ import core from "adamantite/lint"
104
+ import custom from "adamantite/lint/custom"
105
+
106
+ export default defineConfig({
107
+ extends: [core, custom()],
108
+ })
109
+ `,language:`ts`},title:`Custom rules in \`${r(e.dir)}\` are not loaded`});for(let e of u)for(let t of e.ruleFiles){let i=n.join(e.dir,t),a=vr(i,yield*M(i));a.length!==0&&p.push({currentState:`\`${r(i)}\` cannot load as a rule, so the whole lint run fails with "Failed to parse oxlint configuration file":\n${a.map(e=>` - ${e}`).join(`
110
+ `)}`,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:${r(i)}`,integration:Cr,notes:["A file that starts with `_` is a helper, not a rule. Rename a helper file so that it starts with `_`."],title:`Custom rule \`${r(i)}\` cannot load`})}let m=a.filter(e=>e.dir!==null&&u.some(t=>t.dir===e.dir)&&e.name!==null);for(let[e,t]of Object.entries(s.groupBy(m,e=>e.name??``))){let n=s.dedupe(t.map(e=>e.dir??``));n.length<2||p.push({currentState:`${n.length} rules folders use the plugin name \`${e}\`: ${n.map(e=>`\`${r(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 ${s.dedupe(t.map(e=>`\`${r(e.source)}\``)).join(`, `)}.`,"Rule names in `oxlint-disable` comments and `rules` settings use the new plugin name."],id:`custom-rules-duplicate-name:${e}`,integration:Cr,title:`Rules folders share the plugin name \`${e}\``})}return{applicable:!0,findings:p,packageActions:[],warnings:f}}),kind:`tooling`,name:Cr});const Ir=t.fn(`checkImportsLintPreset`)(function*(e,t){let n=yield*C.Path,r=yield*N(n.join(e,`oxlint.config.ts`));return d.match(r,{onNone:()=>!1,onSome:e=>kt(e).includes(t)})});function Lr(e){let{assess:n,name:r,preset:i,version:a,...o}=e,s=gt({isRequired:e=>Ir(e,i),name:r,purpose:`the \`adamantite/lint/${i}\` preset`,scripts:[`check`,`fix`],version:a});return{...o,...s,assess:(e,r)=>t.gen(function*(){let t=yield*s.assess(e,r);if(!t.applicable||n===void 0)return t;let i=yield*n(e,r);return{...t,findings:[...t.findings,...i.findings],warnings:[...t.warnings,...i.warnings]}}),preset:i}}const Rr=[`patch`,`--oxlint`,`--typescript`],zr=t.fn(`runEffectTsgoPatch`)(function*(e,t){let n=yield*C.Path,r=yield*A,i=t.quiet?`ignore`:`inherit`,a=yield*de.String(`PATH`).pipe(de.withDefault(``)),o=[n.join(e,`node_modules`,`.bin`),a].filter(Boolean).join(ue);yield*r.run({args:Rr,command:`effect-tsgo`,cwd:e,env:{PATH:o},stderr:i,stdout:i})}),Br=`prepare`,q=`adamantite prepare`;function Vr(e){return e?.includes(q)??!1}function Hr(e,t){let n=e.scripts?.[Br];return Vr(n)?[]:[{currentState:n===void 0?`\`package.json\` has no \`${Br}\` script, so nothing patches Oxlint for the \`effecttsgo\` rules after an install.`:`The \`${Br}\` script (\`${n}\`) does not run \`${q}\`.`,goal:[`Make the \`${Br}\` script in \`package.json\` run \`${q}\`. Put it first, then \`&&\`, then the existing commands in parentheses, such as \`${q} && (husky || true)\`. A command such as \`cd ..\` then cannot move it out of the project directory, and a fallback such as \`|| true\` cannot hide a failed patch.`,`Run \`${q}\` once, so the installed Oxlint, oxlint-tsgolint, and TypeScript binaries are patched.`],id:`missing-effect-tsgo-prepare`,integration:t,notes:["Without the patch, Oxlint stops with `Unknown plugin: 'effecttsgo'`.","Package managers run `prepare` after a bare install, such as `npm install` or `npm ci`, which restores the unpatched binaries. `adamantite init` and `adamantite update` patch after the installs that they run.","A production-only install, such as `npm ci --omit=dev`, also runs `prepare` but does not install Adamantite. Use `--ignore-scripts` for those installs."],title:`Missing adamantite prepare step`}]}const Ur=t.fn(`updatePrepareScript`)(function*(e){let t=yield*R(e),n=t.scripts?.[Br]?.trim();if(Vr(n))return`present`;let r=n!==void 0&&n!==``;return t.scripts={...t.scripts,[Br]:r?`${q} && (${n})`:q},yield*Ke(e,t),r?`merged`:`added`}),J=`tsconfig.json`,Wr=`@effect/language-service`,Gr={diagnostics:!1,name:Wr},Kr=`${JSON.stringify({compilerOptions:{plugins:[Gr]}},null,2)}\n`;function qr(e){return Ve(e)?e.find(e=>L(e)&&e.name===Wr):void 0}const Jr=t.fn(`assessTsconfigPlugin`)(function*(e,n){if(yield*B(e))return{findings:[],warnings:[`Skipping the root \`${J}\` check for \`${n}\`: in a monorepo, add \`${JSON.stringify(Gr)}\` to \`compilerOptions.plugins\` in each package's \`${J}\` or in a shared base config.`]};let r=(yield*C.Path).join(e,J),i=yield*N(r),a=i._tag===`None`?void 0:yield*I(i.value,r).pipe(t.map(e=>L(e)&&L(e.compilerOptions)?qr(e.compilerOptions.plugins):void 0));return a?.diagnostics===!1?{findings:[],warnings:[]}:{findings:[{currentState:a===void 0?`\`${J}\` does not configure the \`${Wr}\` plugin.`:`The \`${Wr}\` plugin in \`${J}\` reports its own diagnostics, so \`tsc\` and the editor repeat every Oxlint report.`,goal:[`Add \`${JSON.stringify(Gr)}\` to \`compilerOptions.plugins\` in \`${J}\`, or set \`diagnostics\` to \`false\` in the existing entry. Keep every other plugin and option.`],id:`missing-effect-language-service-plugin`,integration:n,notes:["The `effecttsgo` rules read their options, such as `allowedUnstableApis`, from this entry."],reference:{content:Kr,language:`json`},title:`Effect language service is not configured`}],warnings:[]}}),Yr=t.fn(`updateTsconfigPlugin`)(function*(e){if(yield*B(e))return`monorepo`;let t=(yield*C.Path).join(e,J),n=yield*N(t);if(n._tag===`None`)return`missing`;let r=yield*I(n.value,t);if(!L(r))return yield*new De({path:t});let i=r.compilerOptions??{};if(!L(i))return yield*new De({path:t});let a=i.plugins??[];if(!Ve(a))return yield*new De({path:t});let o=qr(a),s=o?a.map(e=>e===o?{...o,diagnostics:!1}:e):[...a,Gr];return yield*F(t,{...r,compilerOptions:{...i,plugins:s}}),`updated`}),Xr=`@effect/tsgo`;var Y=Lr({assess:(e,n)=>t.gen(function*(){let t=yield*Jr(e,Xr);return{findings:[...Hr(n,Xr),...t.findings],warnings:t.warnings}}),detect:e=>Ir(e,`effect`),name:Xr,patch:zr,preset:`effect`,update:e=>t.gen(function*(){return{prepare:yield*Ur(e),tsconfig:yield*Yr(e)}}),version:`0.48.0`}),Zr=Lr({name:`oxlint-plugin-react-doctor`,preset:`react-doctor`,version:`0.9.14`});const Qr=[Lr({name:`@shadcn/lint`,preset:`shadcn`,version:`0.2.0`}),Zr,Y];var $r=gt({name:`oxlint-tsgolint`,purpose:`the managed lint scripts`,scripts:[`check`,`fix`],version:`7.0.2003`});const ei=[{path:`tsconfig.json`,type:`config`}],X=`adamantite/typescript`,ti={extends:X},ni=["Skipping `tsconfig.json` setup: a root config in a monorepo makes TypeScript treat all packages as one project.",`To use the TypeScript preset, add \`"extends": "${X}"\` to each package's \`tsconfig.json\` or to a shared base config.`];function ri(e){return b.isString(e)?e===X?e:[e,X]:s.isArray(e)?e.includes(X)?e:[...e,X]:X}var Z=j({assess:(e,n)=>t.gen(function*(){let t=Je(n);if(!t.includes(`check`)&&!t.includes(`fix`))return{applicable:!1,warnings:[]};if(yield*B(e))return{applicable:!0,findings:[],packageActions:[],warnings:ni};let r=(yield*C.Path).join(e,ei[0].path),i=yield*N(r);if(i._tag===`None`)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:`${JSON.stringify(ti,null,2)}\n`,language:`json`},title:`Missing TypeScript configuration`}],packageActions:[],warnings:[]};let a=yield*I(i.value,r);return{applicable:!0,findings:b.isObject(a)&&(a.extends===X||s.isArray(a.extends)&&a.extends.includes(X))?[]:[{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:`${JSON.stringify(ti,null,2)}\n`,language:`json`},title:`TypeScript preset is not configured`}],packageActions:[],warnings:[]}}),config:ei[0].path,create:e=>t.gen(function*(){let t=yield*C.Path;yield*F(t.join(e,ei[0].path),ti)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,ei[0].path))}),files:ei,kind:`workspace`,name:`tsconfig`,update:e=>t.gen(function*(){let t=(yield*C.Path).join(e,ei[0].path),n=yield*M(t),r=yield*I(n,t);if(!b.isObject(r))return yield*new De({path:t});let i=yield*He(ti,r),a=Object.fromEntries([...Object.entries(i),[`extends`,ri(`extends`in r?r.extends:void 0)]]);yield*F(t,a)})});const ii=[V,U,W,Fr,...Qr,H,$r,Z,Zn,K],ai=t.fn(`collectApplicableAssessments`)(function*(e,n,r){return yield*t.forEach(e,e=>e.assess(n,r).pipe(t.map(t=>t.applicable?d.some({assessment:t,name:e.name}):d.none())),{concurrency:`unbounded`}).pipe(t.map(e=>s.getSomes(e)))});function oi(e,t,n){return ai(e,t,n)}const si=t.fn(`assessProject`)(function*(e,t){let n=t??(yield*R(e)),r=yield*oi(ii,e,n);return{applicableIntegrations:r.map(({name:e})=>e),findings:r.flatMap(({assessment:e})=>e.findings),packageActions:r.flatMap(({assessment:e})=>e.packageActions),warnings:r.flatMap(({assessment:e})=>e.warnings)}});function ci(e,t){return e.findings.length===0?li(e.warnings,t):ui(e.findings,e.warnings,t)}function li(e,t){return[`# Adamantite doctor warnings`,``,`This project uses Adamantite ${t} to manage linting, formatting, and type tooling.`,"`adamantite doctor` found no repair findings, but reported these warnings:",``,...e.map(e=>`- ${e}`),``].join(`
111
+ `)}function ui(e,t,n){let r=e.map((e,t)=>{let n=e.goal.map(e=>` - ${e}`).join(`
93
112
  `),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(`
94
- `)}`:``;return`## ${t+1}. ${e.title}\n\n- **Current state:** ${e.currentState}\n- **Goal:**\n${n}${r}${i}`}),i=t.length>0?[`## Assessment warnings`,``,`Account for these warnings while fixing the findings:`,``,...t.map(e=>`- ${e}`),``]:[];return[`# Adamantite doctor findings`,``,`This project uses Adamantite ${n} to manage linting, formatting, and type tooling.`,`\`adamantite doctor\` found ${e.length} issue(s). Fix them so that \`adamantite doctor\` exits 0.`,`Before editing, make sure the working tree is clean or the user has accepted the risk.`,``,...i,r.join(`
113
+ `)}`:``;return`## ${t+1}. ${e.title}\n\n- **Current state:** ${e.currentState}\n- **Goal:**\n${n}${r}${i}`}),i=t.length>0?[`## Assessment warnings`,``,`Account for these warnings while fixing the findings:`,``,...t.map(e=>`- ${e}`),``]:[];return[`# Adamantite doctor findings`,``,`This project uses Adamantite ${n} to manage linting, formatting, and type tooling.`,`\`adamantite doctor\` found ${e.length} issue(s). Fix them so that \`adamantite doctor\` exits 0.`,``,...i,r.join(`
95
114
 
96
- `),``,`## Verify`,``,"Run `adamantite doctor`. All findings above must be gone and it must exit 0.",`Do not suppress or work around checks; fix the underlying state.`,``].join(`
97
- `)}var mr=class extends g.Service()(`TerminalCapabilities`){static layer=c.succeed(this)({copyToClipboard:e=>t.sync(()=>{let t=Buffer.from(e).toString(`base64`);f.stdout.write(`\u001B]52;c;${t}\u0007`)}),isInteractive:t.sync(()=>f.stdin.isTTY&&f.stdout.isTTY)})},Q=class extends g.Service()(`Prompter`){static layerWithSpinner(e){return c.succeed(this)({cancel:e=>t.sync(()=>{E.cancel(e)}),confirm:e=>t.promise(()=>E.confirm(e)).pipe(t.filterOrFail(e=>!E.isCancel(e),()=>new Ae({}))),intro:e=>t.sync(()=>{E.intro(e)}),log:{error:e=>t.sync(()=>{E.log.error(e)}),info:e=>t.sync(()=>{E.log.info(e)}),success:e=>t.sync(()=>{E.log.success(e)}),warning:e=>t.sync(()=>{E.log.warning(e)})},message:e=>t.sync(()=>{E.log.message(e,{spacing:0,withGuide:!1})}),multiselect:e=>t.promise(()=>E.multiselect(e)).pipe(t.filterOrFail(e=>!E.isCancel(e),()=>new Ae({}))),note:(e,n)=>t.sync(()=>{E.note(e,n)}),outro:e=>t.sync(()=>{E.outro(e)}),select:e=>t.promise(()=>E.select(e)).pipe(t.filterOrFail(e=>!E.isCancel(e),()=>new Ae({}))),withSpinner:(r,i)=>t.acquireUseRelease(t.sync(()=>{let t=e();return t.start(i.start),t}),e=>r({message:n=>t.sync(()=>{e.message(n)})}),(e,r)=>t.sync(()=>{e.stop(n.match(r,{onFailure:()=>i.failure,onSuccess:e=>b.isFunction(i.success)?i.success(e):i.success}))}))})}static layer=this.layerWithSpinner(E.spinner)};function hr(e){let t=[`Current state\n${e.currentState}`,`Goal\n${e.goal.map(e=>`• ${e}`).join(`
115
+ `),``,`## Verify`,``,"Run `adamantite doctor` — through your package runner, such as `npx` or `pnpm exec`, if it is not on PATH.",`All findings above must be gone and it must exit 0.`,`Do not suppress or work around checks; fix the underlying state.`,``].join(`
116
+ `)}const di=[{command:`claude`,name:`Claude Code`,seedArguments:e=>[e]},{command:`codex`,name:`Codex`,seedArguments:e=>[e]},{command:`cursor-agent`,name:`Cursor`,seedArguments:e=>[e]},{command:`gemini`,name:`Gemini CLI`,seedArguments:e=>[`-i`,e]},{command:`grok`,name:`Grok Build`,probeArguments:[`version`],seedArguments:e=>[e]},{command:`opencode`,name:`OpenCode`,seedArguments:e=>[`--prompt`,e]}];var fi=class extends v.TaggedError(`AgentSessionFailed`){};const pi=()=>{},mi=t.acquireRelease(t.sync(()=>{let e=f.listeners(`SIGINT`);return f.removeAllListeners(`SIGINT`),f.on(`SIGINT`,pi),e}),e=>t.sync(()=>{f.removeAllListeners(`SIGINT`);for(let t of e)f.on(`SIGINT`,t)}));var hi=class e extends g.Service()(`CodingAgents`){static layer=l.effect(this,t.gen(function*(){let n=yield*A,r=(e,r)=>n.exitCode({args:[...e.probeArguments??[`--version`]],command:e.command,cwd:r,stderr:`ignore`,stdout:`ignore`}).pipe(t.timeout(`10 seconds`),t.isSuccess);return e.of({detectInstalled:t.fn(`CodingAgents.detectInstalled`)(e=>t.forEach(di,t=>r(t,e),{concurrency:`unbounded`}).pipe(t.map(e=>di.filter((t,n)=>e[n])))),runSession:t.fn(`CodingAgents.runSession`)(function*({agent:e,cwd:t,prompt:r}){yield*mi,yield*n.exitCode({args:e.seedArguments(r),command:e.command,cwd:t,detached:!1,stderr:`inherit`,stdin:`inherit`,stdout:`inherit`})},t.scoped,t.mapError(e=>new fi({cause:e,reason:e._tag===`CliNotFound`?`not-found`:`spawn-failed`})))})}))},gi=class extends g.Service()(`TerminalCapabilities`){static layer=l.succeed(this)({copyToClipboard:e=>t.sync(()=>{let t=Buffer.from(e).toString(`base64`);f.stdout.write(`\u001B]52;c;${t}\u0007`)}),isInteractive:t.sync(()=>f.stdin.isTTY&&f.stdout.isTTY)})},Q=class extends g.Service()(`Prompter`){static layerWithSpinner(e){return l.succeed(this)({cancel:e=>t.sync(()=>{D.cancel(e)}),confirm:e=>t.promise(()=>D.confirm(e)).pipe(t.filterOrFail(e=>!D.isCancel(e),()=>new Me({}))),intro:e=>t.sync(()=>{D.intro(e)}),log:{error:e=>t.sync(()=>{D.log.error(e)}),info:e=>t.sync(()=>{D.log.info(e)}),success:e=>t.sync(()=>{D.log.success(e)}),warning:e=>t.sync(()=>{D.log.warning(e)})},message:e=>t.sync(()=>{D.log.message(e,{spacing:0,withGuide:!1})}),multiselect:e=>t.promise(()=>D.multiselect(e)).pipe(t.filterOrFail(e=>!D.isCancel(e),()=>new Me({}))),note:(e,n)=>t.sync(()=>{D.note(e,n)}),outro:e=>t.sync(()=>{D.outro(e)}),select:e=>t.promise(()=>D.select(e)).pipe(t.filterOrFail(e=>!D.isCancel(e),()=>new Me({}))),withSpinner:(r,i)=>t.acquireUseRelease(t.sync(()=>{let t=e();return t.start(i.start),t}),e=>r({message:n=>t.sync(()=>{e.message(n)})}),(e,r)=>t.sync(()=>{e.stop(n.match(r,{onFailure:()=>i.failure,onSuccess:e=>b.isFunction(i.success)?i.success(e):i.success}))}))})}static layer=this.layerWithSpinner(D.spinner)};function _i(e){let t=[`Current state\n${e.currentState}`,`Goal\n${e.goal.map(e=>`• ${e}`).join(`
98
117
  `)}`];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(`
99
118
  `)}`),t.join(`
100
119
 
101
- `)}const gr=t.fn(`printFindings`)(function*(e){let t=yield*Q;for(let[n,r]of e.entries())yield*t.note(hr(r),`${n+1}. ${r.title}`)}),_r=`0.41.0`;var vr=l.make(`doctor`).pipe(l.withDescription(`Assess Adamantite-managed integrations in the current project`),l.withHandler(()=>t.gen(function*(){let e=f.cwd(),n=yield*Q,r=yield*mr,i=yield*r.isInteractive;i&&(yield*n.intro(`💠 adamantite doctor`));let o=t.gen(function*(){return yield*n.outro(`⚠️ Doctor found issues.`),yield*new O({command:`doctor`,exitCode:a.ExitCode(1)})}),s=yield*z(e);if(!s.devDependencies?.adamantite&&!s.dependencies?.adamantite){let e="`adamantite` is not installed in this project. Install it before running `adamantite doctor`.";return i?(yield*n.log.warning(e),yield*n.outro(`⚠️ Doctor found issues.`)):yield*n.message(e),yield*new O({command:`doctor`,exitCode:a.ExitCode(1)})}let c=yield*ur(e);if(i)for(let e of c.warnings)yield*n.log.warning(e);if(c.applicableIntegrations.length===0){i&&(yield*n.log.success(`No applicable integrations found.`),yield*n.outro(`✅ Doctor completed successfully!`));return}if(c.findings.length===0){i?(yield*n.log.success(`No issues found.`),yield*n.outro(`✅ Doctor completed successfully!`)):c.warnings.length>0&&(yield*n.message(dr(c,_r)));return}if(!i)return yield*n.message(dr(c,_r)),yield*new O({command:`doctor`,exitCode:a.ExitCode(1)});let l=e=>t.gen(function*(){(yield*n.confirm({initialValue:!0,message:`Copy the Markdown prompt for a coding agent?`}))&&(yield*n.message(e),yield*r.copyToClipboard(e),yield*n.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`))});yield*gr(c.findings);let u=yield*n.withSpinner(()=>hn(e),{start:`Checking for installed coding agents...`,success:e=>e.length===0?`No supported coding agent CLI was found on PATH.`:`Found ${e.map(e=>e.name).join(`, `)}.`});u.length===0&&(yield*n.log.info(`Doctor can hand findings off when one of these CLIs is installed: ${mn.map(e=>`\`${e.command}\``).join(`, `)}.`));let d=dr(c,_r),p=yield*n.select({message:`How do you want to resolve these findings?`,options:[...u.map(e=>({label:`Hand off to ${e.name}`,value:e})),{label:`Copy the Markdown prompt for a coding agent`,value:`copy`},{label:`Do nothing`,value:`done`}]});if(p===`done`)return yield*o;if(p===`copy`)return yield*n.message(d),yield*r.copyToClipboard(d),yield*n.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`),yield*o;let m=p,h=yield*bn(e);if(h!==`clean`&&(yield*n.log.warning(h===`dirty`?`The Git working tree has uncommitted changes. The agent will edit files on top of them.`:`Doctor could not confirm a clean Git working tree. The agent will edit files without a checkpoint to return to.`),!(yield*n.confirm({initialValue:!1,message:`Hand off to ${m.name} anyway?`})))||(yield*n.log.info(`Handing the terminal to ${m.name}. Exit the agent to return to Doctor.`),!(yield*yn({agent:m,cwd:e}).pipe(t.as(!0),t.catchTag(`AgentSessionFailed`,e=>n.log.error(e.reason===`not-found`?`\`${m.command}\` was not found on PATH. Install ${m.name} or copy the prompt instead.`:`Failed to start ${m.name}: ${e.cause.message}`).pipe(t.as(!1)))))))return yield*l(d),yield*o;let g=yield*ur(e);if(g.findings.length===0){yield*n.log.success(`All findings were resolved by ${m.name}.`),yield*n.outro(`✅ Doctor completed successfully!`);return}return yield*n.log.warning(`${g.findings.length} of ${c.findings.length} findings remain after the ${m.name} session.`),yield*gr(g.findings),yield*l(dr(g,_r)),yield*o}).pipe(t.catchTag(`OperationCancelled`,()=>t.gen(function*(){return yield*(yield*Q).cancel(`Doctor was cancelled. The findings remain.`),yield*new O({command:`doctor`,exitCode:a.ExitCode(1)})})))));const yr=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to fix (optional)`),w.variadic()),br=d.Boolean(`suggested`).pipe(d.withDefault(!1),d.withDescription(`Apply suggested fixes`)),xr=d.Boolean(`dangerous`).pipe(d.withDefault(!1),d.withDescription(`Apply dangerous fixes`)),Sr=d.Boolean(`all`).pipe(d.withDefault(!1),d.withDescription(`Apply all fixes, including suggested and dangerous fixes`));var Cr=l.make(`fix`,{all:Sr,dangerous:xr,files:yr,suggested:br}).pipe(l.withDescription(`Fix lint and formatting issues in code`),l.withHandler(({all:e,dangerous:n,files:r,suggested:i})=>t.gen(function*(){let t=yield*j,a=yield*A,o=s.dedupe(r),c=s.dedupe([`--fix`,...i||e?[`--fix-suggestions`]:[],...n||e?[`--fix-dangerously`]:[],...o]);yield*a.runAll([{args:[...c,...t],command:K.name,title:`🔧 Fixing lint issues`},{args:[`--write`,...o],command:W.name,title:`✨ Formatting`}])})));const wr=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to format (optional)`),w.variadic()),Tr=d.Boolean(`check`).pipe(d.withDefault(!1),d.withDescription(`Check if files are formatted without writing`));var Er=l.make(`format`,{check:Tr,files:wr}).pipe(l.withDescription("Deprecated: use `fix` or `check`. Format files using oxfmt"),l.withHandler(({check:e,files:n})=>t.gen(function*(){let t=yield*j,r=yield*A,i=[];yield*h.error("Warning: `adamantite format` is deprecated and will be removed in the next release. Use `adamantite fix` to apply formatting and `adamantite check` to verify it."),e&&i.push(`--check`),i.push(...n,...t),yield*r.run({args:i,command:W.name})})));const Dr=' .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 ',Or=()=>t.gen(function*(){let e=yield*(yield*pe.Terminal).columns,t=Dr.split(`
102
- `).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*h.info(Dr))}),kr=[`check`,`fix`,`format`,`check:monorepo`,`fix:monorepo`,`analyze`],Ar=[`react`,`nextjs`,`vue`,`jest`,`vitest`,`node`,`antislop`],jr=[`vscode`,`zed`],Mr=t.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:s.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:s.dedupe(e.presets),scripts:s.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new k({reason:"Select at least one script with `--script <name>`."});if(n.scripts.includes(`format`))return yield*new k({reason:"The `format` script is no longer available in init. Select `check` or `fix` instead."});if(n.scripts.includes(`check:monorepo`)||n.scripts.includes(`fix:monorepo`))return yield*new k({reason:"The `check:monorepo` and `fix:monorepo` scripts are no longer available in init. Select `analyze` instead; it runs Sherif in a detected monorepo."});let r=n.scripts.includes(`check`)||n.scripts.includes(`fix`);return n.presets.length>0&&!r?yield*new k({reason:"`--preset` requires the `check` or `fix` script."}):n.typescript&&!r?yield*new k({reason:"`--typescript` requires the `check` or `fix` script."}):n.installExtensions&&n.editors.length===0?yield*new k({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!Cn(n.scripts)?yield*new k({reason:"`--github-actions` requires a CI-compatible script."}):n.githubActions&&t.nonInteractive&&!Ge(t.packageManager)?yield*new k({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`}):n}),Nr=d.Boolean(`non-interactive`).pipe(d.withDefault(!1),d.withDescription(`Configure without prompts; requires at least one --script`)),Pr=d.Literals(`script`,kr).pipe(d.atMost(kr.length),d.withDescription(`Package script to configure; repeatable and required in non-interactive mode. The legacy format value is rejected; select check or fix instead. The legacy check:monorepo and fix:monorepo values are rejected; select analyze instead`)),Fr=d.Literals(`preset`,Ar).pipe(d.atMost(Ar.length),d.withDescription(`Oxlint preset to configure; repeatable and requires --script check or fix`)),Ir=d.Literals(`editor`,jr).pipe(d.atMost(jr.length),d.withDescription(`Editor to configure; may be specified multiple times`)),Lr=d.Boolean(`typescript`).pipe(d.withDefault(!1),d.withDescription(`Configure the TypeScript preset; requires --script check or fix`)),Rr=d.Boolean(`install-extensions`).pipe(d.withDefault(!1),d.withDescription(`Install recommended extensions; requires at least one --editor`)),zr=d.Boolean(`github-actions`).pipe(d.withDefault(!1),d.withDescription(`Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn`)),Br={agents:d.Boolean(`agents`).pipe(d.withDefault(!1),d.withDescription(`Add Adamantite guidance to AGENTS.md`)),editors:Ir,githubActions:zr,installExtensions:Rr,nonInteractive:Nr,overwriteScripts:d.Boolean(`overwrite-scripts`).pipe(d.withDefault(!1),d.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),presets:Fr,scripts:Pr,typescript:Lr},Vr=e=>`\`${e.script}\` is currently \`${e.command}\`; Adamantite would replace it with \`${B[e.script]}\`.`,Hr=t.fn(`collectInteractiveInitOptions`)(function*(e,t){let n=yield*Q,r=yield*n.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:`recommended`,label:`check - check formatting, lint issues, and type errors`,value:`check`},{hint:`recommended`,label:`fix - apply safe lint fixes and format code`,value:`fix`},{label:t?`analyze - check monorepo consistency using Sherif and find unused dependencies, exports, and files using knip`:`analyze - find unused dependencies, exports, and files using knip`,value:`analyze`}]}),i=qe(yield*z(e),r),a=!1;if(i.length>0){for(let e of i)yield*n.log.warning(Vr(e));a=yield*n.confirm({initialValue:!1,message:i.length===1?`Overwrite this existing script with Adamantite's command?`:`Overwrite these existing scripts with Adamantite's commands?`})}let o=r.includes(`check`)||r.includes(`fix`),s=[];o&&(s=yield*n.multiselect({message:`Which presets do you want to install? (core is always included)`,options:[{hint:`React correctness, JSX accessibility, and render performance rules`,label:`react`,value:`react`},{hint:`Next.js pitfalls around scripts, fonts, images, and document/head usage`,label:`next.js`,value:`nextjs`},{hint:`Vue 3 correctness rules and deprecated API detection`,label:`vue`,value:`vue`},{hint:`Jest test hygiene: focused/disabled tests, matcher and snapshot discipline`,label:`jest`,value:`jest`},{hint:`Vitest test hygiene: focused/disabled tests, matcher and snapshot discipline`,label:`vitest`,value:`vitest`},{hint:`Node.js callback and CommonJS pitfalls`,label:`node`,value:`node`},{hint:`Rejects low-signal escape hatches: unjustified assertions, unknown leaks, module mocks`,label:`antislop`,value:`antislop`}],required:!1}));let c=o?yield*n.confirm({initialValue:!0,message:t?"Adamantite provides a TypeScript preset to enforce strict type-safety. In a monorepo, each package's `tsconfig.json` must extend it. Would you like instructions on how to set it up?":`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?`}):!1,l=yield*n.multiselect({message:`Which editors do you want to configure? (optional)`,options:[{label:`VSCode / Cursor / Windsurf`,value:`vscode`},{label:`Zed`,value:`zed`}],required:!1}),u=l.length>0?yield*n.confirm({initialValue:!0,message:`Do you want to install the recommended editor extensions?`}):!1,d=Cn(r)?yield*n.confirm({message:`Do you want to add a GitHub Actions workflow to run checks in CI?`}):!1;return{agents:yield*n.confirm({initialValue:!0,message:`Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?`}),editors:l,githubActions:d,installExtensions:u,overwriteScripts:a,presets:s,scripts:r,typescript:c}}),Ur=[{path:`.vscode/settings.json`,type:`config`}],Wr={"[css]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[graphql]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[javascript]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[javascriptreact]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[json]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[jsonc]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[typescript]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[typescriptreact]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"editor.codeActionsOnSave":{"source.fixAll.oxc":`explicit`},"editor.defaultFormatter":`oxc.oxc-vscode`,"editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0};var $=M({config:Ur[0].path,create:e=>t.gen(function*(){let t=yield*C.Path,n=t.join(e,Ur[0].path);yield*Ie(t.dirname(n)),yield*I(n,Wr)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,Ur[0].path))}),extension:(e=[])=>t.gen(function*(){let n=[];(e.includes(`check`)||e.includes(`fix`))&&n.push(`oxc.oxc-vscode`),e.includes(`analyze`)&&n.push(`webpro.vscode-knip`);for(let e of n)yield*(yield*A).run({args:[`--install-extension`,e],command:`code`}).pipe(t.mapError(t=>t._tag===`CliNotFound`&&t.command===`code`?new Me({cause:t}):new be({cause:t._tag===`CommandFailed`?t.exitCode:t,extension:e})))}),files:Ur,kind:`editor`,name:`vscode`,update:e=>t.gen(function*(){let t=(yield*C.Path).join(e,Ur[0].path),n=yield*N(t),r=yield*L(n,t);if(!b.isObject(r))return yield*new Ee({path:t});let i=yield*Be(Wr,r);yield*I(t,i)})});const Gr=`<!-- ADAMANTITE:START -->`,Kr=`<!-- ADAMANTITE:END -->`;function qr(e,t,n){let r=fe(e,t),i=B[t];switch(t){case`analyze`:return`- Run \`${r}\` after changing dependencies, imports, or exports.${n?` It also checks monorepo package consistency.`:``} Direct command: \`${i}\`.`;case`check`:return`- Run \`${r}\` to catch formatting, lint, and type issues. Direct command: \`${i}\`.`;case`fix`:return`- Run \`${r}\` to apply safe lint fixes and format code. Direct command: \`${i}\`.`}}function Jr({isMonorepo:e,packageManager:t,scripts:n}){let r=[`check`,`fix`,`analyze`].filter(e=>n.includes(e)).map(n=>qr(t,n,e)),i=[`## Adamantite`,``,`This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.`,``,...r.length>0?[`- Prefer the package scripts Adamantite added for this workspace.`,...r]:[],"- Run `adamantite doctor` and follow its findings to repair managed setup."].join(`
103
- `);return[Gr,``,i,``,Kr,``].join(`
104
- `)}const Yr=(e,n)=>t.gen(function*(){let t=(yield*C.Path).join(e,`AGENTS.md`),r=y(yield*P(t),u.getOrElse(()=>``)),i=y(r,x.indexOf(Gr)),a=y(r,x.indexOf(Kr)),o=y(u.all({end:a,start:i}),u.filter(({end:e,start:t})=>t<e)),s=Jr(n);if(u.isSome(o)){let{end:e,start:n}=o.value,i=e+23,a=`${r.slice(0,n)}${s.trimEnd()}${r.slice(i)}`;return yield*F(t,a.endsWith(`
105
- `)?a:`${a}\n`),`updated`}if(u.isSome(i)||u.isSome(a))return`malformed`;let c=r.length===0||r.endsWith(`
120
+ `)}const vi=t.fn(`printFindings`)(function*(e){let t=yield*Q;for(let[n,r]of e.entries())yield*t.note(_i(r),`${n+1}. ${r.title}`)}),yi=`0.43.0`;var bi=c.make(`doctor`).pipe(c.withDescription(`Assess Adamantite-managed integrations in the current project`),c.withHandler(()=>t.gen(function*(){let e=f.cwd(),n=yield*hi,i=yield*Q,a=yield*gi,o=yield*a.isInteractive;o&&(yield*i.intro(`💠 adamantite doctor`));let s=t.gen(function*(){return yield*i.outro(`⚠️ Doctor found issues.`),yield*new _e({command:`doctor`,exitCode:r.ExitCode(1)})}),c=yield*R(e);if(!c.devDependencies?.adamantite&&!c.dependencies?.adamantite){let e="`adamantite` is not installed in this project. Install it before running `adamantite doctor`.";return o?(yield*i.log.warning(e),yield*i.outro(`⚠️ Doctor found issues.`)):yield*i.message(e),yield*new _e({command:`doctor`,exitCode:r.ExitCode(1)})}let l=yield*si(e);if(o)for(let e of l.warnings)yield*i.log.warning(e);if(l.applicableIntegrations.length===0){o&&(yield*i.log.success(`No applicable integrations found.`),yield*i.outro(`✅ Doctor completed successfully!`));return}if(l.findings.length===0){o?(yield*i.log.success(`No issues found.`),yield*i.outro(`✅ Doctor completed successfully!`)):l.warnings.length>0&&(yield*i.message(ci(l,yi)));return}if(!o)return yield*i.message(ci(l,yi)),yield*new _e({command:`doctor`,exitCode:r.ExitCode(1)});let u=e=>t.gen(function*(){(yield*i.confirm({initialValue:!0,message:`Copy the Markdown prompt for a coding agent?`}))&&(yield*i.message(e),yield*a.copyToClipboard(e),yield*i.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`))});yield*vi(l.findings);let d=yield*i.withSpinner(()=>n.detectInstalled(e),{start:`Checking for installed coding agents...`,success:e=>e.length===0?`No supported coding agent CLI was found on PATH.`:`Found ${e.map(e=>e.name).join(`, `)}.`});d.length===0&&(yield*i.log.info(`Doctor can hand findings off when one of these CLIs is installed: ${di.map(e=>`\`${e.command}\``).join(`, `)}.`));let p=ci(l,yi),m=yield*i.select({message:`How do you want to resolve these findings?`,options:[...d.map(e=>({label:`Hand off to ${e.name}`,value:e})),{label:`Copy the Markdown prompt for a coding agent`,value:`copy`},{label:`Do nothing`,value:`done`}]});if(m===`done`)return yield*s;if(m===`copy`)return yield*i.message(p),yield*a.copyToClipboard(p),yield*i.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`),yield*s;let h=m;if(yield*i.log.info(`Handing the terminal to ${h.name}. Exit the agent to return to Doctor.`),!(yield*n.runSession({agent:h,cwd:e,prompt:p}).pipe(t.as(!0),t.catchTag(`AgentSessionFailed`,e=>i.log.error(e.reason===`not-found`?`\`${h.command}\` was not found on PATH. Install ${h.name} or copy the prompt instead.`:`Failed to start ${h.name}: ${e.cause.message}`).pipe(t.as(!1))))))return yield*u(p),yield*s;let g=yield*si(e);if(g.findings.length===0){yield*i.log.success(`All findings were resolved by ${h.name}.`),yield*i.outro(`✅ Doctor completed successfully!`);return}return yield*i.log.warning(`${g.findings.length} of ${l.findings.length} findings remain after the ${h.name} session.`),yield*vi(g.findings),yield*u(ci(g,yi)),yield*s}).pipe(t.catchTag(`OperationCancelled`,()=>t.gen(function*(){return yield*(yield*Q).cancel(`Doctor was cancelled. The findings remain.`),yield*new _e({command:`doctor`,exitCode:r.ExitCode(1)})})))));const xi=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to fix (optional)`),w.variadic()),Si=u.Boolean(`suggested`).pipe(u.withDefault(!1),u.withDescription(`Apply suggested fixes`)),Ci=u.Boolean(`dangerous`).pipe(u.withDefault(!1),u.withDescription(`Apply dangerous fixes`)),wi=u.Boolean(`all`).pipe(u.withDefault(!1),u.withDescription(`Apply all fixes, including suggested and dangerous fixes`)),Ti=u.Literals(`only`,[`format`,`lint`]).pipe(u.optional,u.withDescription("Run one stage: `format` (oxfmt) or `lint` (oxlint). Arguments after `--` go to that stage"));var Ei=c.make(`fix`,{all:wi,dangerous:Ci,files:xi,only:Ti,suggested:Si}).pipe(c.withDescription(`Fix lint and formatting issues in code`),c.withHandler(({all:e,dangerous:n,files:r,only:i,suggested:a})=>t.gen(function*(){let t=yield*Re,o=yield*A,c=d.getOrUndefined(i);if(c===`format`&&(e||n||a))return yield*new ke({reason:"`--suggested`, `--dangerous`, and `--all` apply to the lint stage. Remove them or `--only format`."});let l=s.dedupe(r),u=c??`lint`,f=[{args:s.dedupe([`--fix`,...a||e?[`--fix-suggestions`]:[],...n||e?[`--fix-dangerously`]:[],...l]),command:W.name,name:`lint`,title:`🔧 Fixing lint issues`},{args:[`--write`,...l],command:U.name,name:`format`,title:`✨ Formatting`}];yield*o.runAll(f.filter(e=>c===void 0||e.name===c).map(e=>({args:[...e.args,...e.name===u?t:[]],command:e.command,title:e.title})))})));const Di=' .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 ',Oi=t.gen(function*(){let e=yield*(yield*fe.Terminal).columns,t=Di.split(`
121
+ `).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*h.info(Di))}),ki=[`check`,`fix`,`analyze`],Ai=[`vscode`,`zed`],ji=t.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:s.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:s.dedupe(e.presets),scripts:s.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new k({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes(`check`)||n.scripts.includes(`fix`);return n.presets.length>0&&!r?yield*new k({reason:"`--preset` requires the `check` or `fix` script."}):n.presets.includes(`react-doctor`)&&!n.presets.includes(`react`)?yield*new k({reason:"`--preset react-doctor` requires `--preset react`."}):n.typescript&&!r?yield*new k({reason:"`--typescript` requires the `check` or `fix` script."}):n.installExtensions&&n.editors.length===0?yield*new k({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!Cn(n.scripts)?yield*new k({reason:"`--github-actions` requires a CI-compatible script."}):n.githubActions&&t.nonInteractive&&!qe(t.packageManager)?yield*new k({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`}):n}),Mi=u.Boolean(`non-interactive`).pipe(u.withDefault(!1),u.withDescription(`Configure without prompts; requires at least one --script`)),Ni=u.Literals(`script`,ki).pipe(u.atMost(ki.length),u.withDescription(`Package script to configure; repeatable and required in non-interactive mode`)),Pi=u.Literals(`preset`,St).pipe(u.atMost(St.length),u.withDescription(`Oxlint preset to configure; repeatable and requires --script check or fix`)),Fi=u.Literals(`editor`,Ai).pipe(u.atMost(Ai.length),u.withDescription(`Editor to configure; may be specified multiple times`)),Ii=u.Boolean(`typescript`).pipe(u.withDefault(!1),u.withDescription(`Configure the TypeScript preset; requires --script check or fix`)),Li=u.Boolean(`install-extensions`).pipe(u.withDefault(!1),u.withDescription(`Install recommended extensions; requires at least one --editor`)),Ri=u.Boolean(`github-actions`).pipe(u.withDefault(!1),u.withDescription(`Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn`)),zi={agents:u.Boolean(`agents`).pipe(u.withDefault(!1),u.withDescription(`Add Adamantite guidance to AGENTS.md`)),editors:Fi,githubActions:Ri,installExtensions:Li,nonInteractive:Mi,overwriteScripts:u.Boolean(`overwrite-scripts`).pipe(u.withDefault(!1),u.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),presets:Pi,scripts:Ni,typescript:Ii},Bi=e=>`\`${e.script}\` is currently \`${e.command}\`; Adamantite would replace it with \`${z[e.script]}\`.`,Vi=t.fn(`collectInteractiveInitOptions`)(function*(e,t){let n=yield*Q,r=yield*n.multiselect({message:"Which scripts do you want to add to your `package.json`?",options:[{hint:`recommended`,label:`check - check formatting, lint issues, and type errors`,value:`check`},{hint:`recommended`,label:`fix - apply safe lint fixes and format code`,value:`fix`},{label:t?`analyze - check monorepo consistency using Sherif and find unused dependencies, exports, and files using knip`:`analyze - find unused dependencies, exports, and files using knip`,value:`analyze`}]}),i=Ye(yield*R(e),r),a=!1;if(i.length>0){for(let e of i)yield*n.log.warning(Bi(e));a=yield*n.confirm({initialValue:!1,message:i.length===1?`Overwrite this existing script with Adamantite's command?`:`Overwrite these existing scripts with Adamantite's commands?`})}let o=r.includes(`check`)||r.includes(`fix`),s=[];o&&(s=yield*n.multiselect({message:`Which presets do you want to install? (core is always included)`,options:[{hint:`React correctness, JSX accessibility, and render performance rules`,label:`react`,value:`react`},{hint:`Strict React feature code: no state, effect, or memoization hooks outside hook modules`,label:`react-strict`,value:`react-strict`},{hint:`React state and effect misuse, such as effects used as event handlers and fetches in effects; requires react`,label:`react-doctor`,value:`react-doctor`},{hint:`TanStack Query: queries defined once with queryOptions() so route loaders can preload them, no query data copied into state`,label:`tanstack`,value:`tanstack`},{hint:`Next.js pitfalls around scripts, fonts, images, and document/head usage`,label:`next.js`,value:`nextjs`},{hint:`Vue 3 correctness rules and deprecated API detection`,label:`vue`,value:`vue`},{hint:`Effect misuse, such as effects that never run and unhandled errors; installs @effect/tsgo and patches Oxlint and TypeScript`,label:`effect`,value:`effect`},{hint:`Jest test hygiene: focused/disabled tests, matcher and snapshot discipline`,label:`jest`,value:`jest`},{hint:`Vitest test hygiene: focused/disabled tests, matcher and snapshot discipline`,label:`vitest`,value:`vitest`},{hint:`Node.js callback and CommonJS pitfalls`,label:`node`,value:`node`},{hint:`Framework-neutral strictness: no deep or wide destructuring, no type assertions outside tests`,label:`strict`,value:`strict`},{hint:`Rejects low-signal escape hatches: unjustified assertions, unknown leaks, module mocks`,label:`antislop`,value:`antislop`},{hint:`Tailwind v4 design system: no restyled components, raw colors, arbitrary values, or unknown classes`,label:`shadcn`,value:`shadcn`}],required:!1}),s.includes(`react-doctor`)&&!s.includes(`react`)&&(s=[`react`,...s],yield*n.log.info("Added the `react` preset, which `react-doctor` requires.")));let c=o?yield*n.confirm({initialValue:!0,message:t?"Adamantite provides a TypeScript preset to enforce strict type-safety. In a monorepo, each package's `tsconfig.json` must extend it. Would you like instructions on how to set it up?":`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to use it?`}):!1,l=yield*n.multiselect({message:`Which editors do you want to configure? (optional)`,options:[{label:`VSCode / Cursor / Windsurf`,value:`vscode`},{label:`Zed`,value:`zed`}],required:!1}),u=l.length>0?yield*n.confirm({initialValue:!0,message:`Do you want to install the recommended editor extensions?`}):!1,d=Cn(r)?yield*n.confirm({message:`Do you want to add a GitHub Actions workflow to run checks in CI?`}):!1;return{agents:yield*n.confirm({initialValue:!0,message:`Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?`}),editors:l,githubActions:d,installExtensions:u,overwriteScripts:a,presets:s,scripts:r,typescript:c}}),Hi=[{path:`.vscode/settings.json`,type:`config`}],Ui={"[css]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[graphql]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[javascript]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[javascriptreact]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[json]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[jsonc]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[typescript]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"[typescriptreact]":{"editor.defaultFormatter":`oxc.oxc-vscode`},"editor.codeActionsOnSave":{"source.fixAll.oxc":`explicit`},"editor.defaultFormatter":`oxc.oxc-vscode`,"editor.formatOnPaste":!0,"editor.formatOnSave":!0,"oxc.typeAware":!0};var $=j({config:Hi[0].path,create:e=>t.gen(function*(){let t=yield*C.Path,n=t.join(e,Hi[0].path);yield*ze(t.dirname(n)),yield*F(n,Ui)}),detect:e=>t.gen(function*(){let t=yield*S.FileSystem,n=yield*C.Path;return yield*t.exists(n.join(e,Hi[0].path))}),extension:(e=[])=>t.gen(function*(){let n=[];(e.includes(`check`)||e.includes(`fix`))&&n.push(`oxc.oxc-vscode`),e.includes(`analyze`)&&n.push(`webpro.vscode-knip`);for(let e of n)yield*(yield*A).run({args:[`--install-extension`,e],command:`code`}).pipe(t.mapError(t=>t._tag===`CliNotFound`&&t.command===`code`?new Pe({cause:t}):new xe({cause:t._tag===`CommandFailed`?t.exitCode:t,extension:e})))}),files:Hi,kind:`editor`,name:`vscode`,update:e=>t.gen(function*(){let t=(yield*C.Path).join(e,Hi[0].path),n=yield*M(t),r=yield*I(n,t);if(!b.isObject(r))return yield*new De({path:t});let i=yield*He(Ui,r);yield*F(t,i)})});const Wi=`<!-- ADAMANTITE:START -->`,Gi=`<!-- ADAMANTITE:END -->`;function Ki(e,t,n){let r=le(e,t),i=z[t];switch(t){case`analyze`:return`- Run \`${r}\` after changing dependencies, imports, or exports.${n?` It also checks monorepo package consistency.`:``} Direct command: \`${i}\`.`;case`check`:return`- Run \`${r}\` to catch formatting, lint, and type issues. Direct command: \`${i}\`.`;case`fix`:return`- Run \`${r}\` to apply safe lint fixes and format code. Direct command: \`${i}\`.`}}function qi({isMonorepo:e,packageManager:t,scripts:n}){let r=[`check`,`fix`,`analyze`].filter(e=>n.includes(e)).map(n=>Ki(t,n,e)),i=[`## Adamantite`,``,`This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.`,``,...r.length>0?[`- Prefer the package scripts Adamantite added for this workspace.`,...r]:[],...n.includes(`check`)||n.includes(`fix`)?["- Write project-specific lint rules in `.adamantite/rules/`, one rule for each file. Run `adamantite rule add <name>` to start a rule with its authoring guidance."]:[],"- Run `adamantite doctor` and follow its findings to repair managed setup."].join(`
122
+ `);return[Wi,``,i,``,Gi,``].join(`
123
+ `)}const Ji=(e,n)=>t.gen(function*(){let t=(yield*C.Path).join(e,`AGENTS.md`),r=y(yield*N(t),d.getOrElse(()=>``)),i=y(r,x.indexOf(Wi)),a=y(r,x.indexOf(Gi)),o=y(d.all({end:a,start:i}),d.filter(({end:e,start:t})=>t<e)),s=qi(n);if(d.isSome(o)){let{end:e,start:n}=o.value,i=e+23,a=`${r.slice(0,n)}${s.trimEnd()}${r.slice(i)}`;return yield*P(t,a.endsWith(`
124
+ `)?a:`${a}\n`),`updated`}if(d.isSome(i)||d.isSome(a))return`malformed`;let c=r.length===0||r.endsWith(`
106
125
 
107
126
  `)?``:r.endsWith(`
108
127
  `)?`
109
128
  `:`
110
129
 
111
- `;return yield*F(t,`${r}${c}${s}`),`updated`}),Xr=(e,n)=>t.gen(function*(){yield*(yield*Q).withSpinner(()=>En(e,n),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function Zr(e,n,r){return t.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(a=>t.gen(function*(){let t=yield*n.detect(e);for(let e of t.warnings)yield*i.log.warning(e);return t.active===null?(yield*a.message(`\`${n.config}\` not found, creating...`),yield*r,{created:!0,legacyConfig:null}):t.active.format===`ts`?(yield*a.message(`Found \`${n.config}\`, keeping existing config.`),{created:!1,legacyConfig:null}):(yield*a.message(`Found \`${t.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:t.active.file})}),{failure:`Failed to set up ${n.name} config.`,start:`Setting up ${n.name} config...`,success:e=>e.created?`${n.name} config created successfully.`:`${n.name} config is ready.`});a.legacyConfig&&(yield*i.log.info(`Legacy \`${a.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor\` and follow its findings to migrate it to the latest ${n.name} config.`))})}const Qr=(e,n,r)=>t.gen(function*(){let i=yield*Q,a=yield*z(e),o=r.overwriteScripts?[]:qe(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]=B[e];yield*We(e,a)}}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:o.length===0?"Scripts added to your `package.json`":c.length===0?"Kept your existing `package.json` scripts.":"Scripts added to your `package.json`; conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Re-run `adamantite init` and confirm overwriting to replace it.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${B[e.script]}\`. ${l}`);return o.length>0&&(yield*i.log.info("Adamantite commands forward extra arguments after `--`, so custom flags can be kept, e.g. `adamantite analyze -- --directory packages/app`.")),c}),$r=(e,n)=>t.gen(function*(){let r=yield*Q;if(n){yield*y(ar,t.forEach(e=>r.log.info(e)));return}yield*r.withSpinner(n=>t.gen(function*(){return(yield*Z.detect(e))?(yield*n.message(`\`${Z.config}\` found, updating...`),yield*Z.update(e),!1):(yield*n.message(`\`${Z.config}\` not found, creating...`),yield*Z.create(e),!0)}),{failure:`Failed to set up TypeScript config.`,start:`Setting up TypeScript config...`,success:e=>e?`\`${Z.config}\` created successfully`:`\`${Z.config}\` updated successfully`})}),ei=(e,n)=>t.gen(function*(){let r=yield*Q;n.includes(`vscode`)&&(yield*r.withSpinner(n=>t.gen(function*(){let t=yield*$.detect(e);return yield*n.message(`\`${$.config}\` ${t?`found, updating`:`not found, creating`}...`),yield*t?$.update(e):$.create(e),!t}),{failure:`Failed to set up VS Code config.`,start:`Checking for \`${$.config}\`...`,success:e=>`\`${$.config}\` ${e?`created`:`updated`} with Adamantite preset.`})),n.includes(`zed`)&&(yield*r.withSpinner(n=>t.gen(function*(){let t=yield*J.detect(e);return yield*n.message(`\`${J.config}\` ${t?`found, updating`:`not found, creating`}...`),yield*t?J.update(e):J.create(e),!t}),{failure:`Failed to set up Zed config.`,start:`Checking for \`${J.config}\`...`,success:e=>`\`${J.config}\` ${e?`created`:`updated`} with Adamantite preset.`}))}),ti=(e,n)=>t.gen(function*(){let r=yield*Q,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*$.extension(n)),!0}),{start:`Installing editor extensions...`,success:i&&!a?`Zed extensions require manual install.`:`Editor extensions installed successfully.`}).pipe(t.catchTag(`FailedToInstallExtension`,e=>t.gen(function*(){return yield*r.log.warning(`⚠️ ${e.message}`),yield*r.log.warning(`Please install it manually after setup completes.`),!1})),t.catchTag(`VscodeCliNotFound`,()=>t.gen(function*(){return yield*r.log.error(`VSCode CLI ('code' command) not found.`),yield*r.log.info(`To install it:`),yield*r.log.info(` 1. Open VS Code`),yield*r.log.info(` 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)`),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),i&&(yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc"))}),ni=(e,n,r)=>t.gen(function*(){let i=yield*Q,a=Zn.files[0].path;yield*i.withSpinner(i=>t.gen(function*(){let t=yield*Zn.detect(e);return yield*i.message(t?`\`${a}\` found, updating...`:`Creating \`${a}\`...`),yield*t?Zn.update(e,{packageManager:n,scripts:r}):Zn.create(e,{packageManager:n,scripts:r}),!t}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e?`created`:`updated`} successfully.`})}).pipe(t.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>t.gen(function*(){let t=yield*Q;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.")}))),ri=(e,n,r,i)=>t.gen(function*(){let a=yield*Q,o=yield*a.withSpinner(()=>Yr(e,{isMonorepo:i,packageManager:n,scripts:r}),{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*a.log.warning(`Could not update AGENTS.md. ${e.message} Adamantite will continue initialization.`),`failed`})));o!==`failed`&&o===`malformed`&&(yield*a.log.warning(`Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.`))});var ii=l.make(`init`,Br).pipe(l.withDescription(`Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled`),l.withExamples([{command:`adamantite init --non-interactive --script check`,description:`Configure linting without prompts`},{command:`adamantite init --non-interactive --script check --preset react --editor vscode --typescript --install-extensions --github-actions --agents`,description:`Configure a React project with VS Code, TypeScript, CI, and agent guidance`},{command:`adamantite init --non-interactive --script analyze`,description:`Configure analysis; in a detected monorepo it includes Sherif`}]),l.withHandler(e=>t.gen(function*(){let t=f.cwd(),n=yield*Q;yield*Or(),yield*n.intro(`💠 adamantite init`);let r=yield*(yield*wn).detectPackageManager(t);if(!r)return yield*new ke({});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*V(t);if(i&&(yield*n.log.info(`We've detected a monorepo setup in your project.`)),!e.nonInteractive&&s.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],b.isTruthy))return yield*new k({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*Hr(t,i),o=yield*Mr(a,{nonInteractive:e.nonInteractive,packageManager:r.name}),c=o.scripts,l=o.presets,u=o.editors,d=o.typescript,p=o.installExtensions,m=o.githubActions,h=o.agents,g=c.includes(`check`)||c.includes(`fix`),_=c.includes(`analyze`),ee=_&&i,v=[`adamantite`];g&&v.push(`${K.name}@${K.version}`,`${rr.name}@${rr.version}`,`${W.name}@${W.version}`),ee&&v.push(`${U.name}@${U.version}`),_&&v.push(`${H.name}@${H.version}`),yield*Xr(t,v),g&&(yield*Zr(t,W,W.create(t)),yield*Zr(t,K,K.create(t,l))),_&&(yield*Zr(t,H,H.create(t)));let y=yield*Qr(t,c,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(h&&(yield*ri(t,r.name,y,i)),d&&(yield*$r(t,i)),yield*ei(t,u),p&&(yield*ti(u,c)),m){let e=r.name;Ge(e)?yield*ni(t,e,c):yield*n.log.warning(`Skipping GitHub Actions setup: \`${e}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success(`Your project is now configured`),yield*n.outro(`💠 Adamantite initialized successfully!`)}).pipe(t.catchTags({OperationCancelled:()=>t.gen(function*(){yield*(yield*Q).cancel(`You've cancelled the initialization process.`)})}))));const ai=d.Boolean(`fix`).pipe(d.withDefault(!1),d.withDescription(`Automatically fix issues`));function oi(e,t){return`Warning: \`adamantite monorepo\` is deprecated and will be removed in the next release. Use \`${[`adamantite analyze --only monorepo`,...e?[`--fix`]:[],...t.length>0?[`--`,...t]:[]].join(` `)}\` instead.`}var si=l.make(`monorepo`,{fix:ai}).pipe(l.withDescription("Deprecated: use `analyze`. Find and fix monorepo-specific issues using Sherif"),l.withHandler(({fix:e})=>t.gen(function*(){let t=yield*j,n=yield*A;yield*h.error(oi(e,t));let r=e?[`--fix`,...t]:[...t];yield*n.run({args:r,command:U.name,stdin:`inherit`})})));const ci=[K,rr,W,U,H];function li(e,t){return s.filterMap(ci,n=>{if(t.has(n.name))return _.failVoid;let r=e.devDependencies?.[n.name]??e.dependencies?.[n.name];return r&&Ue(r)!==n.version?_.succeed({currentVersion:r,name:n.name,targetVersion:n.version}):_.failVoid})}var ui=l.make(`update`).pipe(l.withDescription(`Update Adamantite-managed dependencies and report setup findings`),l.withHandler(()=>t.gen(function*(){let e=f.cwd(),t=yield*Q;yield*t.intro(`💠 adamantite update`);let n=yield*z(e),r=yield*ur(e,n),i=r.packageActions,a=new Set(i.map(e=>e.package)),o=[...i.map(e=>({currentVersion:e.type===`install_package`?`not installed`:e.currentVersion,name:e.package,targetVersion:e.targetVersion})),...li(n,a)];if(o.length>0){yield*t.log.info(`The following dependencies will be updated:`);for(let e of o)yield*t.log.info(` ${e.name}: ${e.currentVersion} → ${e.targetVersion}`);yield*t.withSpinner(()=>En(e,o.map(e=>`${e.name}@${e.targetVersion}`)),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated successfully`}),yield*t.log.success(`Dependencies updated successfully.`)}let s=o.length===0?r:yield*ur(e);for(let e of s.warnings)yield*t.log.warning(e);let c=s.findings;return c.length>0&&(yield*gr(c),yield*t.log.info("Run `adamantite doctor` to get the combined Markdown repair prompt.")),o.length===0&&c.length===0?(yield*t.log.success(`No changes needed.`),`no-changes`):`success`}).pipe(t.tapError(()=>t.gen(function*(){yield*(yield*Q).outro(`❌ Update failed`)})),t.tap(e=>t.gen(function*(){yield*(yield*Q).outro(e===`no-changes`?`✅ Adamantite is already up to date.`:`✅ Update completed successfully!`)})))));const di=[Nt,pn,Cr,Er,si],fi=[Nt,pn,vr,Cr,Er,ii,si,ui],pi=new Set(fi.map(e=>e.name)),mi=new Set(di.map(e=>e.name)),hi=l.make(`adamantite`).pipe(l.withDescription(`Opinionated preset package for modern TypeScript applications`),l.withSubcommands(fi)),gi=e=>c.mergeAll(o.layer,In.layer.pipe(c.provide(o.layer)),Q.layer,e.pipe(c.provide(o.layer)),wn.layer,mr.layer),_i=t.fn(`runCli`)(function*(e,n){let[r,i]=s.splitWhere(e,e=>e===`--`),a=s.drop(i,1),o=r.find(e=>pi.has(e));if(a.length>0&&o!==void 0&&!mi.has(o))return yield*new je({command:o});yield*l.runWith(hi,{version:n})(r).pipe(t.provideService(j,a))}),vi=t.gen(function*(){let e=yield*(yield*i.Stdio).args;yield*_i(e,`0.41.0`)}).pipe(t.as(0),t.catchTag(`CommandFailed`,e=>t.succeed(e.exitCode)),t.catch(e=>t.service(Q).pipe(t.flatMap(t=>t.log.error(e.message)),t.as(a.ExitCode(1)))),t.provide(gi(A.layer)));e.runMain(vi,{teardown:(e,t)=>{if(n.isSuccess(e)){t(Number(e.value));return}r.defaultTeardown(e,t)}});export{};
130
+ `;return yield*P(t,`${r}${c}${s}`),`updated`}),Yi=(e,n)=>t.gen(function*(){yield*(yield*Q).withSpinner(()=>En(e,n),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function Xi(e,n,r){return t.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(a=>t.gen(function*(){let t=yield*n.detect(e);for(let e of t.warnings)yield*i.log.warning(e);return t.active===null?(yield*a.message(`\`${n.config}\` not found, creating...`),yield*r,{created:!0,legacyConfig:null}):t.active.format===`ts`?(yield*a.message(`Found \`${n.config}\`, keeping existing config.`),{created:!1,legacyConfig:null}):(yield*a.message(`Found \`${t.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:t.active.file})}),{failure:`Failed to set up ${n.name} config.`,start:`Setting up ${n.name} config...`,success:e=>e.created?`${n.name} config created successfully.`:`${n.name} config is ready.`});a.legacyConfig&&(yield*i.log.info(`Legacy \`${a.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor\` and follow its findings to migrate it to the latest ${n.name} config.`))})}const Zi=(e,n,r)=>t.gen(function*(){let i=yield*Q,a=yield*R(e),o=r.overwriteScripts?[]:Ye(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]=z[e];yield*Ke(e,a)}}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:o.length===0?"Scripts added to your `package.json`":c.length===0?"Kept your existing `package.json` scripts.":"Scripts added to your `package.json`; conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Re-run `adamantite init` and confirm overwriting to replace it.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${z[e.script]}\`. ${l}`);return o.length>0&&(yield*i.log.info("Adamantite commands forward extra arguments after `--`, so custom flags can be kept, e.g. `adamantite analyze -- --directory packages/app`.")),c}),Qi=(e,n)=>t.gen(function*(){let r=yield*Q;if(n){yield*y(ni,t.forEach(e=>r.log.info(e)));return}yield*r.withSpinner(n=>t.gen(function*(){return(yield*Z.detect(e))?(yield*n.message(`\`${Z.config}\` found, updating...`),yield*Z.update(e),!1):(yield*n.message(`\`${Z.config}\` not found, creating...`),yield*Z.create(e),!0)}),{failure:`Failed to set up TypeScript config.`,start:`Setting up TypeScript config...`,success:e=>e?`\`${Z.config}\` created successfully`:`\`${Z.config}\` updated successfully`})}),$i=e=>t.gen(function*(){let t=yield*Q,n=yield*Y.update(e);n.prepare===`merged`&&(yield*t.log.info("Added `adamantite prepare` to the start of your existing `prepare` script.")),n.tsconfig===`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.tsconfig===`missing`&&(yield*t.log.warning("No `tsconfig.json` found, so the Effect language service is not configured. Run `adamantite doctor` for the reference entry."))}),ea=e=>t.gen(function*(){let n=yield*Q;(yield*Y.detect(e))&&(yield*n.withSpinner(()=>Y.patch(e,{quiet:!0}),{failure:`Failed to patch Oxlint and TypeScript.`,start:`Patching Oxlint and TypeScript with @effect/tsgo...`,success:`Oxlint and TypeScript patched with @effect/tsgo.`}).pipe(t.catchTag([`CommandFailed`,`CliNotFound`,`PlatformError`],()=>n.log.warning("Run `adamantite prepare` to see why the patch failed. Oxlint cannot load the `effect` preset until it succeeds."))))}),ta=(e,n)=>t.gen(function*(){let r=yield*Q;n.includes(`vscode`)&&(yield*r.withSpinner(n=>t.gen(function*(){let t=yield*$.detect(e);return yield*n.message(`\`${$.config}\` ${t?`found, updating`:`not found, creating`}...`),yield*t?$.update(e):$.create(e),!t}),{failure:`Failed to set up VS Code config.`,start:`Checking for \`${$.config}\`...`,success:e=>`\`${$.config}\` ${e?`created`:`updated`} with Adamantite preset.`})),n.includes(`zed`)&&(yield*r.withSpinner(n=>t.gen(function*(){let t=yield*K.detect(e);return yield*n.message(`\`${K.config}\` ${t?`found, updating`:`not found, creating`}...`),yield*t?K.update(e):K.create(e),!t}),{failure:`Failed to set up Zed config.`,start:`Checking for \`${K.config}\`...`,success:e=>`\`${K.config}\` ${e?`created`:`updated`} with Adamantite preset.`}))}),na=(e,n)=>t.gen(function*(){let r=yield*Q,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*$.extension(n)),!0}),{start:`Installing editor extensions...`,success:i&&!a?`Zed extensions require manual install.`:`Editor extensions installed successfully.`}).pipe(t.catchTags({FailedToInstallExtension:e=>t.gen(function*(){return yield*r.log.warning(`⚠️ ${e.message}`),yield*r.log.warning(`Please install it manually after setup completes.`),!1}),VscodeCliNotFound:()=>t.gen(function*(){return yield*r.log.error(`VSCode CLI ('code' command) not found.`),yield*r.log.info(`To install it:`),yield*r.log.info(` 1. Open VS Code`),yield*r.log.info(` 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)`),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1})})),i&&(yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc"))}),ra=(e,n,r)=>t.gen(function*(){let i=yield*Q,a=Zn.files[0].path;yield*i.withSpinner(i=>t.gen(function*(){let t=yield*Zn.detect(e);return yield*i.message(t?`\`${a}\` found, updating...`:`Creating \`${a}\`...`),yield*t?Zn.update(e,{packageManager:n,scripts:r}):Zn.create(e,{packageManager:n,scripts:r}),!t}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e?`created`:`updated`} successfully.`})}).pipe(t.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>t.gen(function*(){let t=yield*Q;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.")}))),ia=(e,n,r,i)=>t.gen(function*(){let a=yield*Q,o=yield*a.withSpinner(()=>Ji(e,{isMonorepo:i,packageManager:n,scripts:r}),{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*a.log.warning(`Could not update AGENTS.md. ${e.message} Adamantite will continue initialization.`),`failed`})));o!==`failed`&&o===`malformed`&&(yield*a.log.warning(`Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.`))});var aa=c.make(`init`,zi).pipe(c.withDescription(`Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled`),c.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, and agent guidance`},{command:`adamantite init --non-interactive --script analyze`,description:`Configure analysis; in a detected monorepo it includes Sherif`}]),c.withHandler(e=>t.gen(function*(){let t=f.cwd(),n=yield*Q;yield*Oi,yield*n.intro(`💠 adamantite init`);let r=yield*(yield*wn).detectPackageManager(t);if(!r)return yield*new je({});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*B(t);if(i&&(yield*n.log.info(`We've detected a monorepo setup in your project.`)),!e.nonInteractive&&s.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],b.isTruthy))return yield*new k({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*Vi(t,i),o=yield*ji(a,{nonInteractive:e.nonInteractive,packageManager:r.name}),c=o.scripts,l=o.presets,u=o.editors,d=o.typescript,p=o.installExtensions,m=o.githubActions,h=o.agents,g=c.includes(`check`)||c.includes(`fix`),ee=c.includes(`analyze`),_=ee&&i,v=[`adamantite`];g&&v.push(`${W.name}@${W.version}`,`${$r.name}@${$r.version}`,`${U.name}@${U.version}`,...Qr.filter(e=>l.includes(e.preset)).map(e=>`${e.name}@${e.version}`)),_&&v.push(`${H.name}@${H.version}`),ee&&v.push(`${V.name}@${V.version}`),yield*Yi(t,v),g&&(yield*Xi(t,U,U.create(t)),yield*Xi(t,W,W.create(t,l))),ee&&(yield*Xi(t,V,V.create(t)));let y=yield*Zi(t,c,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(h&&(yield*ia(t,r.name,y,i)),d&&(yield*Qi(t,i)),l.includes(`effect`)&&(yield*$i(t)),g&&(yield*ea(t)),yield*ta(t,u),p&&(yield*na(u,c)),m){let e=r.name;qe(e)?yield*ra(t,e,c):yield*n.log.warning(`Skipping GitHub Actions setup: \`${e}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success(`Your project is now configured`),yield*n.outro(`💠 Adamantite initialized successfully!`)}).pipe(t.catchTags({OperationCancelled:()=>t.gen(function*(){yield*(yield*Q).cancel(`You've cancelled the initialization process.`)})})))),oa=c.make(`prepare`).pipe(c.withDescription("Patch Oxlint and TypeScript for the effect preset. The `prepare` script runs it after each install"),c.withHandler(()=>t.gen(function*(){let e=f.cwd();(yield*Y.detect(e))&&(yield*Y.patch(e,{quiet:!1}))})));const sa=w.File(`file`,{mustExist:!0}).pipe(w.withDescription(`The JavaScript or TypeScript file to parse`)),ca=c.make(`ast`,{file:sa}).pipe(c.withDescription(`Print the ESTree-shaped AST that Oxlint rules visit, to find node names for a custom rule`),c.withHandler(({file:e})=>t.gen(function*(){let t=yield*Q,n=yield*M(e),r=oe(e,n,{preserveParens:!1});if(r.errors.length>0)return yield*new we({errors:r.errors.map(e=>e.message),path:e});yield*t.message(JSON.stringify(r.program,null,2))}))),la=w.String(`name`).pipe(w.withDescription(`The rule name in kebab-case, such as no-process-env`)),ua=u.String(`dir`).pipe(u.optional,u.withDescription(`The rules folder, relative to the current directory. Default: ${yr}. Pass the folder that \`custom({ dir })\` loads, such as a rules folder in a monorepo tooling package`)),da=c.make(`add`,{dir:ua,name:la}).pipe(c.withDescription(`Write a custom rule stub, and the authoring guidance when the rules folder has none`),c.withHandler(({dir:e,name:n})=>t.gen(function*(){let t=yield*Q,r=yield*C.Path,i=f.cwd(),a=yield*Sr(i,n,d.getOrUndefined(e));yield*t.log.success(`Wrote ${r.relative(i,a.rulePath)}.`),a.agentsPath!==void 0&&(yield*t.log.success(`Wrote ${r.relative(i,a.agentsPath)}.`)),yield*t.log.info("`custom()` from `adamantite/lint/custom` loads the rule. Run `adamantite doctor` to check the wiring.")})));var fa=c.make(`rule`).pipe(c.withDescription(`Write and inspect custom Oxlint rules`),c.withSubcommands([da,ca]));const pa=[W,$r,U,H,V];function ma(e,t){return s.filterMap(pa,n=>{if(t.has(n.name))return _.failVoid;let r=e.devDependencies?.[n.name]??e.dependencies?.[n.name];return r&&Ge(r)!==n.version?_.succeed({currentVersion:r,name:n.name,targetVersion:n.version}):_.failVoid})}var ha=c.make(`update`).pipe(c.withDescription(`Update Adamantite-managed dependencies and report setup findings`),c.withHandler(()=>t.gen(function*(){let e=f.cwd(),t=yield*Q;yield*t.intro(`💠 adamantite update`);let n=yield*R(e),r=yield*si(e,n),i=r.packageActions,a=new Set(i.map(e=>e.package)),o=[...i.map(e=>({currentVersion:e.type===`install_package`?`not installed`:e.currentVersion,name:e.package,targetVersion:e.targetVersion})),...ma(n,a)];if(o.length>0){yield*t.log.info(`The following dependencies will be updated:`);for(let e of o)yield*t.log.info(` ${e.name}: ${e.currentVersion} → ${e.targetVersion}`);yield*t.withSpinner(()=>En(e,o.map(e=>`${e.name}@${e.targetVersion}`)),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated successfully`}),yield*t.log.success(`Dependencies updated successfully.`),(yield*Y.detect(e))&&(yield*t.withSpinner(()=>Y.patch(e,{quiet:!0}),{failure:"Failed to patch Oxlint and TypeScript. Run `adamantite prepare` to see why.",start:`Patching Oxlint and TypeScript with @effect/tsgo...`,success:`Oxlint and TypeScript patched with @effect/tsgo.`}))}let s=o.length===0?r:yield*si(e);for(let e of s.warnings)yield*t.log.warning(e);let c=s.findings;return c.length>0&&(yield*vi(c),yield*t.log.info("Run `adamantite doctor` to get the combined Markdown repair prompt.")),o.length===0&&c.length===0?(yield*t.log.success(`No changes needed.`),`no-changes`):`success`}).pipe(t.tapError(()=>t.gen(function*(){yield*(yield*Q).outro(`❌ Update failed`)})),t.tap(e=>t.gen(function*(){yield*(yield*Q).outro(e===`no-changes`?`✅ Adamantite is already up to date.`:`✅ Update completed successfully!`)})))));const ga=[ln,bn,Ei],_a=[ln,bn,bi,Ei,aa,oa,fa,ha],va=new Set(_a.map(e=>e.name)),ya=new Set(ga.map(e=>e.name)),ba=c.make(`adamantite`).pipe(c.withDescription(`Opinionated preset package for modern TypeScript applications`),c.withSubcommands(_a)),xa=e=>l.mergeAll(o.layer,In.layer.pipe(l.provide(o.layer)),Q.layer,hi.layer.pipe(l.provideMerge(e),l.provide(o.layer)),wn.layer,gi.layer),Sa=t.fn(`runCli`)(function*(e,n){let[r,i]=s.splitWhere(e,e=>e===`--`),a=s.drop(i,1),o=r.find(e=>va.has(e));if(a.length>0&&o!==void 0&&!ya.has(o))return yield*new Ne({command:o});yield*c.runWith(ba,{version:n})(r).pipe(t.provideService(Re,a))}),Ca=t.gen(function*(){let e=yield*(yield*a.Stdio).args;yield*Sa(e,`0.43.0`)}).pipe(t.as(0),t.catchTag(`CommandFailed`,e=>t.succeed(e.exitCode)),t.catch(e=>t.service(Q).pipe(t.flatMap(t=>t.log.error(e.message)),t.as(r.ExitCode(1)))),t.provide(xa(A.layer)));e.runMain(Ca,{teardown:(e,t)=>{if(n.isSuccess(e)){t(Number(e.value));return}i.defaultTeardown(e,t)}});export{};
@@ -1,6 +1,7 @@
1
1
  import { KnipConfiguration } from "knip";
2
2
  //#region presets/analyze.d.ts
3
3
  interface SuggestedIgnoreDependencies {
4
+ effect: string[];
4
5
  monorepo: string[];
5
6
  }
6
7
  /**
@@ -10,6 +11,9 @@ interface SuggestedIgnoreDependencies {
10
11
  *
11
12
  * - `monorepo`: `adamantite analyze` runs Sherif in a monorepo, and Knip has no plugin that sees that
12
13
  * reference, so it reports Sherif as an unused devDependency.
14
+ * - `effect`: the `effect` lint preset names the `@effect/language-service` plugin in
15
+ * `tsconfig.json`. The patched TypeScript from `@effect/tsgo` supplies it, so no package has that
16
+ * name, and Knip reports it as an unlisted dependency.
13
17
  *
14
18
  * ```ts
15
19
  * import analyze, { ignoreDependencies } from "adamantite/analyze"
@@ -17,7 +21,7 @@ interface SuggestedIgnoreDependencies {
17
21
  * export default { ...analyze, ignoreDependencies: ignoreDependencies.monorepo }
18
22
  * ```
19
23
  */
20
- declare const ignoreDependencies: SuggestedIgnoreDependencies;
24
+ export declare const ignoreDependencies: SuggestedIgnoreDependencies;
21
25
  declare const config: KnipConfiguration;
22
26
  //#endregion
23
- export { config as default, ignoreDependencies };
27
+ export { config as default };
@@ -6,6 +6,9 @@
6
6
  *
7
7
  * - `monorepo`: `adamantite analyze` runs Sherif in a monorepo, and Knip has no plugin that sees that
8
8
  * reference, so it reports Sherif as an unused devDependency.
9
+ * - `effect`: the `effect` lint preset names the `@effect/language-service` plugin in
10
+ * `tsconfig.json`. The patched TypeScript from `@effect/tsgo` supplies it, so no package has that
11
+ * name, and Knip reports it as an unlisted dependency.
9
12
  *
10
13
  * ```ts
11
14
  * import analyze, { ignoreDependencies } from "adamantite/analyze"
@@ -13,7 +16,10 @@
13
16
  * export default { ...analyze, ignoreDependencies: ignoreDependencies.monorepo }
14
17
  * ```
15
18
  */
16
- const ignoreDependencies = { monorepo: ["sherif"] };
19
+ const ignoreDependencies = {
20
+ effect: ["@effect/language-service"],
21
+ monorepo: ["sherif"]
22
+ };
17
23
  const config = {
18
24
  ignoreExportsUsedInFile: true,
19
25
  rules: {
@@ -13,7 +13,9 @@ import { OxlintConfig } from "oxlint";
13
13
  * })
14
14
  * ```
15
15
  */
16
- declare const ignorePatterns: string[];
17
- declare const config: OxlintConfig;
16
+ export declare const ignorePatterns: string[];
17
+ declare const config: OxlintConfig & {
18
+ ignorePatterns: string[];
19
+ };
18
20
  //#endregion
19
- export { config as default, ignorePatterns };
21
+ export { config as default };
@@ -308,6 +308,7 @@ const config = {
308
308
  "typescript/no-extraneous-class": "error",
309
309
  "typescript/no-floating-promises": "error",
310
310
  "typescript/no-for-in-array": "error",
311
+ "typescript/no-generated-empty-object-type": "error",
311
312
  "typescript/no-implied-eval": "error",
312
313
  "typescript/no-import-type-side-effects": "error",
313
314
  "typescript/no-inferrable-types": "error",