adamantite 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +27 -27
  2. package/package.json +2 -2
  3. package/CHANGELOG.md +0 -1221
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import*as e from"@effect/platform-node/NodeRuntime";import*as t from"@effect/platform-node/NodeServices";import*as n from"effect/Effect";import*as r from"effect/Exit";import*as i from"effect/Layer";import*as a from"effect/Runtime";import*as o from"effect/Stdio";import*as s from"effect/unstable/process/ChildProcessSpawner";import*as c from"effect/Array";import*as l from"effect/unstable/cli/Command";import*as u from"effect/unstable/cli/Flag";import*as d from"effect/Context";import*as f from"effect/unstable/process/ChildProcess";import{stripVTControlCharacters as p}from"node:util";import*as m from"effect/Data";import{pipe as h}from"effect/Function";import*as g from"effect/Option";import*as _ from"effect/Predicate";import*as v from"effect/String";import{parse as ee,printParseErrorCode as y}from"jsonc-parser";import*as b from"effect/FileSystem";import*as x from"effect/Path";import S from"node:process";import*as te from"effect/Record";import*as C from"effect/Result";import{defu as ne}from"defu";import{Visitor as re,parseSync as ie}from"oxc-parser";import*as w from"effect/unstable/cli/Argument";import*as ae from"effect/Order";import{print as oe}from"esrap";import se from"esrap/languages/ts";import{addDevDependency as ce,detectPackageManager as le,runScriptCommand as ue}from"nypm";import*as T from"effect/Schema";import*as E from"@clack/prompts";import*as de from"effect/Console";import*as fe from"effect/Terminal";function pe(e){return _.isError(e)?h(p(e.message),v.split(/\r\n|[\r\n]/),c.map(e=>v.trimEnd(e)),c.filter(e=>v.isNonEmpty(e))):[]}function D(e){return h(pe(e),c.head,g.map(e=>{let t=v.trim(e);return/[.!?]$/.test(t)?` Cause: ${t}`:` Cause: ${t}.`}),g.getOrElse(()=>``))}function me(e){let t=pe(e);if(!c.isReadonlyArrayNonEmpty(t))return``;let n=c.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=>`- ${y(e.error)} (offset: ${e.offset})`).join(`
3
- `)}var ge=class extends m.TaggedError(`CliNotFound`){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}},O=class extends m.TaggedError(`CommandFailed`){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}},_e=class extends m.TaggedError(`FailedToCreateDirectory`){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:`the target directory`}.${D(this.cause)}`}},ve=class extends m.TaggedError(`FailedToInstallDependency`){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(`, `)}`:``}.${me(this.cause)}`}},ye=class extends m.TaggedError(`FailedToInstallExtension`){get message(){let e=this.extension?`\`${this.extension}\``:`the target extension`;return _.isNumber(this.cause)?`Failed to install ${e}. The \`code\` CLI exited with code ${this.cause}.`:`Failed to install ${e}.${D(this.cause)}`}},be=class extends m.TaggedError(`FailedToMergeConfig`){get message(){return`Failed to merge configuration.${D(this.cause)}`}},xe=class extends m.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
- `)}},Se=class extends m.TaggedError(`FailedToReadFile`){get message(){return`Failed to read ${this.path?`\`${this.path}\``:`the target file`}.${D(this.cause)}`}},Ce=class extends m.TaggedError(`FailedToWriteFile`){get message(){return`Failed to write ${this.path?`\`${this.path}\``:`the target file`}.${D(this.cause)}`}},we=class extends m.TaggedError(`FileNotFound`){get message(){return this.path?`File not found: \`${this.path}\`.`:`File not found.`}},Te=class extends m.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: {}).`}},k=class extends m.TaggedError(`InvalidInitOptions`){get message(){return`Invalid init options. ${this.reason}`}},Ee=class extends m.TaggedError(`UnsupportedConfigState`){get message(){return`Unsupported config state in ${this.path?`\`${this.path}\``:`the target config file`}.${this.reason?` ${this.reason}`:``}`}},De=class extends m.TaggedError(`NoPackageManager`){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${D(this.cause)}`}};m.TaggedError(`MissingPackageVersion`);var Oe=class extends m.TaggedError(`OperationCancelled`){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:``}`}},ke=class extends m.TaggedError(`PassthroughNotSupported`){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}},Ae=class extends m.TaggedError(`VscodeCliNotFound`){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${D(this.cause)}`}},A=class extends d.Service()(`CommandRunner`){static layer=i.succeed(this)({run:n.fn(`CommandRunner.run`)(function*({args:e,command:t,cwd:r,detached:i,stderr:a=`inherit`,stdin:o=`ignore`,stdout:s=`inherit`}){return yield*n.scoped(n.gen(function*(){return yield*(yield*f.make(t,e,{cwd:r,detached:i,stderr:a,stdin:o,stdout:s})).exitCode})).pipe(n.mapError(e=>e.reason._tag===`NotFound`?new ge({command:t}):e))})})};const j=d.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]});function M(e){return e}const je=e=>b.FileSystem.pipe(n.flatMap(t=>t.makeDirectory(e,{recursive:!0})),n.mapError(t=>new _e({cause:t,path:e}))),N=e=>b.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.mapError(t=>new Se({cause:t,path:e}))),P=e=>b.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.map(e=>h(e,g.some)),n.catch(t=>t.reason._tag===`NotFound`?n.succeedNone:n.fail(new Se({cause:t,path:e})))),F=(e,t)=>b.FileSystem.pipe(n.flatMap(n=>n.writeFileString(e,t)),n.mapError(t=>new Ce({cause:t,path:e}))),I=(e,t)=>F(e,`${JSON.stringify(t,null,2)}\n`),L=(e,t)=>n.suspend(()=>{let r=[],i=ee(e,r,{allowTrailingComma:!0});return r.length>0?n.fail(new xe({errors:r,path:t})):n.succeed(i)}),R=e=>_.isObject(e),Me=e=>Array.isArray(e);function Ne(e){return e===`__proto__`?`["__proto__"]`:/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function Pe(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 Fe=(e,t)=>n.try({catch:e=>new be({cause:e}),try:()=>ne(e,t)}),Ie=/^workspace:/,Le=/^[\^~]/;function Re(e){return e.trim().replace(Ie,``).replace(Le,``)}const z=(e=S.cwd())=>n.gen(function*(){let t=(yield*x.Path).join(e,`package.json`),n=yield*N(t);return yield*L(n,t)}),ze=(e,t)=>n.gen(function*(){let n=yield*x.Path;yield*I(n.join(e,`package.json`),t)});function Be(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 Ve(e){let t=e.scripts??{};return h(te.keys(B),c.filter(e=>t[e]===B[e]))}function He(e,t){let n=e.scripts??{};return c.filterMap(t,e=>{let t=n[e];return t!==void 0&&t!==``&&t!==B[e]?C.succeed({command:t,script:e}):C.failVoid})}function Ue(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function We(e,t){return c.findFirst(e.legacyConfigs,e=>Ue(e)===t)}function Ge(e){let t=We(e,`json`),n=We(e,`jsonc`);return h(g.zipWith(t,n,e=>`${e}(c)`),g.orElse(()=>n),g.orElse(()=>t),g.getOrElse(()=>``))}function Ke(e,t,n,r){return n===null||r.length===0?[]:n.format===`ts`?[`Found both \`${t.config}\` and \`${Ge(t)}\`. Adamantite will use \`${t.config}\`.`]:h(g.zipWith(We(t,`json`),We(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.`),g.toArray)}const qe=n.fn(`detectToolingConfig`)(function*(e,t,r){let i=yield*b.FileSystem,a=yield*x.Path,o=[r.config,...r.legacyConfigs].map(t=>({file:t,format:Ue(t),path:a.join(e,t)})),s=yield*n.forEach(o,e=>i.exists(e.path),{concurrency:`unbounded`}),l=o.filter((e,t)=>s[t]),u=h(c.findFirst(l,e=>e.format===`ts`),g.orElse(()=>c.findFirst(l,e=>e.format===`jsonc`)),g.orElse(()=>c.findFirst(l,e=>e.format===`json`)),g.getOrNull),d=l.filter(e=>e!==u&&e.format!==`ts`);return{active:u,legacy:d,warnings:Ke(t,r,u,d)}});function Je(e,t,n){let r=e.devDependencies?.[t.name]??e.dependencies?.[t.name];return r?Re(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 Ye(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 Xe(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??`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 Ze(e,t){let n=Ve(e);return t.some(e=>n.includes(e))}function Qe(e){return M({assess:(t,r)=>n.sync(()=>{if(!Ze(r,e.scripts))return{applicable:!1,warnings:[]};let t=Je(r,e,e.purpose);return{applicable:!0,findings:Ye(t,e.name),packageActions:t,warnings:[]}}),kind:`tooling`,name:e.name,version:e.version})}function $e(e){let t=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],r=t=>qe(t,e.name,e.configFiles);return M({assess:(t,i)=>n.gen(function*(){if(!Ze(i,e.scripts))return{applicable:!1,warnings:[]};let n=yield*r(t),a=Je(i,e,e.purpose),o=e.configContent(),s=n.active?.format===`ts`?e.inspectConfig(yield*N(n.active.path)):void 0;return{applicable:!0,findings:[...Ye(a,e.name),...Xe(n,{configContent:o,configFile:e.configFiles.config,inspection:s,toolName:e.name})],packageActions:a,warnings:n.warnings}}),config:e.configFiles.config,create:t=>n.gen(function*(){let n=yield*x.Path;yield*F(n.join(t,e.configFiles.config),e.configContent())}),detect:r,files:t,kind:`tooling`,name:e.name,version:e.version})}function et(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 tt(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 nt(e,t,n){let r=!1;return new re({Identifier:e=>{e.start>=n.start&&e.end<=n.end&&e.name===t&&(r=!0)}}).visit(e),r}function rt(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 nt(e,t,r);if(r.name===t)return!0;let i=tt(e,r.name);return i!==null&&nt(e,t,i)}function it(e,t){let n=ie(`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=et(n.program,t.moduleName);return r?rt(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}\`.`}}function at(e){return it(e,{moduleName:`adamantite/analyze`,presetName:`Adamantite analyze`})}function ot(e={}){let t=Object.entries(e).map(([e,t])=>e===`rules`&&R(t)?[` rules: {`,` ...analyze.rules,`,...Object.entries(t).map(([e,t])=>` ${Ne(e)}: ${Pe(t,{continuationIndent:` `,indentation:` `})},`),` },`].join(`
6
- `):` ${Ne(e)}: ${Pe(t)},`);return t.length===0?[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = analyze`,``,`export default config`,``].join(`
1
+ import*as e from"@effect/platform-node/NodeRuntime";import*as t from"@effect/platform-node/NodeServices";import*as n from"effect/Effect";import*as r from"effect/Exit";import*as i from"effect/Layer";import*as a from"effect/Runtime";import*as o from"effect/Stdio";import*as s from"effect/unstable/process/ChildProcessSpawner";import*as c from"effect/Array";import*as l from"effect/unstable/cli/Command";import*as u from"effect/unstable/cli/Flag";import*as d from"effect/Context";import*as f from"effect/unstable/process/ChildProcess";import{stripVTControlCharacters as p}from"node:util";import*as m from"effect/Data";import{pipe as h}from"effect/Function";import*as g from"effect/Option";import*as _ from"effect/Predicate";import*as v from"effect/String";import{parse as ee,printParseErrorCode as y}from"jsonc-parser";import*as b from"effect/FileSystem";import*as x from"effect/Path";import S from"node:process";import*as te from"effect/Record";import*as ne from"effect/Result";import{defu as re}from"defu";import{Visitor as ie,parseSync as ae}from"oxc-parser";import*as C from"effect/unstable/cli/Argument";import*as oe from"effect/Order";import{print as se}from"esrap";import ce from"esrap/languages/ts";import{addDevDependency as le,detectPackageManager as ue,runScriptCommand as de}from"nypm";import*as w from"effect/Schema";import*as T from"@clack/prompts";import*as fe from"effect/Console";import*as pe from"effect/Terminal";function me(e){return _.isError(e)?h(p(e.message),v.split(/\r\n|[\r\n]/),c.map(e=>v.trimEnd(e)),c.filter(e=>v.isNonEmpty(e))):[]}function E(e){return h(me(e),c.head,g.map(e=>{let t=v.trim(e);return/[.!?]$/.test(t)?` Cause: ${t}`:` Cause: ${t}.`}),g.getOrElse(()=>``))}function he(e){let t=me(e);if(!c.isReadonlyArrayNonEmpty(t))return``;let n=c.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=>`- ${y(e.error)} (offset: ${e.offset})`).join(`
3
+ `)}var _e=class extends m.TaggedError(`CliNotFound`){get message(){return`Command \`${this.command}\` not found. Please install it and try again.`}},D=class extends m.TaggedError(`CommandFailed`){get message(){return`Command \`${this.command}\` failed with exit code ${this.exitCode}.`}},ve=class extends m.TaggedError(`FailedToCreateDirectory`){get message(){return`Failed to create directory ${this.path?`\`${this.path}\``:`the target directory`}.${E(this.cause)}`}},ye=class extends m.TaggedError(`FailedToInstallDependency`){get message(){return`Failed to install dependencies${this.packages?.length?`: ${this.packages.join(`, `)}`:``}.${he(this.cause)}`}},be=class extends m.TaggedError(`FailedToInstallExtension`){get message(){let e=this.extension?`\`${this.extension}\``:`the target extension`;return _.isNumber(this.cause)?`Failed to install ${e}. The \`code\` CLI exited with code ${this.cause}.`:`Failed to install ${e}.${E(this.cause)}`}},xe=class extends m.TaggedError(`FailedToMergeConfig`){get message(){return`Failed to merge configuration.${E(this.cause)}`}},Se=class extends m.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 m.TaggedError(`FailedToReadFile`){get message(){return`Failed to read ${this.path?`\`${this.path}\``:`the target file`}.${E(this.cause)}`}},we=class extends m.TaggedError(`FailedToWriteFile`){get message(){return`Failed to write ${this.path?`\`${this.path}\``:`the target file`}.${E(this.cause)}`}},Te=class extends m.TaggedError(`FileNotFound`){get message(){return this.path?`File not found: \`${this.path}\`.`:`File not found.`}},Ee=class extends m.TaggedError(`InvalidConfigFormat`){get message(){return`Invalid config format in ${this.path?`\`${this.path}\``:`the target config file`}. The config must be a JSON object (for example: {}).`}},O=class extends m.TaggedError(`InvalidInitOptions`){get message(){return`Invalid init options. ${this.reason}`}},De=class extends m.TaggedError(`UnsupportedConfigState`){get message(){return`Unsupported config state in ${this.path?`\`${this.path}\``:`the target config file`}.${this.reason?` ${this.reason}`:``}`}},Oe=class extends m.TaggedError(`NoPackageManager`){get message(){return`No package manager detected. Please run this command from a project with a lockfile.${E(this.cause)}`}};m.TaggedError(`MissingPackageVersion`);var ke=class extends m.TaggedError(`OperationCancelled`){get message(){return`Operation cancelled.${this.reason?` Reason: ${this.reason}`:``}`}},Ae=class extends m.TaggedError(`PassthroughNotSupported`){get message(){return`Command \`adamantite ${this.command}\` does not invoke a single underlying CLI and cannot accept passthrough arguments.`}},je=class extends m.TaggedError(`VscodeCliNotFound`){get message(){return`VS Code CLI (\`code\`) not found. Please install it to manage extensions.${E(this.cause)}`}},k=class extends d.Service()(`CommandRunner`){static layer=i.succeed(this)({run:n.fn(`CommandRunner.run`)(function*({args:e,command:t,cwd:r,detached:i,stderr:a=`inherit`,stdin:o=`ignore`,stdout:s=`inherit`}){return yield*n.scoped(n.gen(function*(){return yield*(yield*f.make(t,e,{cwd:r,detached:i,stderr:a,stdin:o,stdout:s})).exitCode})).pipe(n.mapError(e=>e.reason._tag===`NotFound`?new _e({command:t}):e))})})};const A=d.Reference(`adamantite/ForwardedArguments`,{defaultValue:()=>[]});function j(e){return e}const Me=e=>b.FileSystem.pipe(n.flatMap(t=>t.makeDirectory(e,{recursive:!0})),n.mapError(t=>new ve({cause:t,path:e}))),M=e=>b.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.mapError(t=>new Ce({cause:t,path:e}))),N=e=>b.FileSystem.pipe(n.flatMap(t=>t.readFileString(e)),n.map(e=>h(e,g.some)),n.catch(t=>t.reason._tag===`NotFound`?n.succeedNone:n.fail(new Ce({cause:t,path:e})))),P=(e,t)=>b.FileSystem.pipe(n.flatMap(n=>n.writeFileString(e,t)),n.mapError(t=>new we({cause:t,path:e}))),F=(e,t)=>P(e,`${JSON.stringify(t,null,2)}\n`),I=(e,t)=>n.suspend(()=>{let r=[],i=ee(e,r,{allowTrailingComma:!0});return r.length>0?n.fail(new Se({errors:r,path:t})):n.succeed(i)}),L=e=>_.isObject(e),Ne=e=>Array.isArray(e);function Pe(e){return e===`__proto__`?`["__proto__"]`:/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}function Fe(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 Ie=(e,t)=>n.try({catch:e=>new xe({cause:e}),try:()=>re(e,t)}),Le=/^workspace:/,Re=/^[\^~]/;function ze(e){return e.trim().replace(Le,``).replace(Re,``)}const R=(e=S.cwd())=>n.gen(function*(){let t=(yield*x.Path).join(e,`package.json`),n=yield*M(t);return yield*I(n,t)}),Be=(e,t)=>n.gen(function*(){let n=yield*x.Path;yield*F(n.join(e,`package.json`),t)});function Ve(e){return e===`bun`||e===`deno`||e===`npm`||e===`pnpm`||e===`yarn`}const z={analyze:`adamantite analyze`,check:`adamantite check`,"check:monorepo":`adamantite monorepo`,fix:`adamantite fix`,"fix:monorepo":`adamantite monorepo --fix`,format:`adamantite format`};function He(e){let t=e.scripts??{};return h(te.keys(z),c.filter(e=>t[e]===z[e]))}function Ue(e,t){let n=e.scripts??{};return c.filterMap(t,e=>{let t=n[e];return t!==void 0&&t!==``&&t!==z[e]?ne.succeed({command:t,script:e}):ne.failVoid})}function We(e){return e.endsWith(`.jsonc`)?`jsonc`:e.endsWith(`.json`)?`json`:`ts`}function Ge(e,t){return c.findFirst(e.legacyConfigs,e=>We(e)===t)}function Ke(e){let t=Ge(e,`json`),n=Ge(e,`jsonc`);return h(g.zipWith(t,n,e=>`${e}(c)`),g.orElse(()=>n),g.orElse(()=>t),g.getOrElse(()=>``))}function qe(e,t,n,r){return n===null||r.length===0?[]:n.format===`ts`?[`Found both \`${t.config}\` and \`${Ke(t)}\`. Adamantite will use \`${t.config}\`.`]:h(g.zipWith(Ge(t,`json`),Ge(t,`jsonc`),(t,n)=>`Found both \`${t}\` and \`${n}\`. Multiple legacy ${e} configs exist; Adamantite will treat \`${n}\` as the source of truth in its findings.`),g.toArray)}const Je=n.fn(`detectToolingConfig`)(function*(e,t,r){let i=yield*b.FileSystem,a=yield*x.Path,o=[r.config,...r.legacyConfigs].map(t=>({file:t,format:We(t),path:a.join(e,t)})),s=yield*n.forEach(o,e=>i.exists(e.path),{concurrency:`unbounded`}),l=o.filter((e,t)=>s[t]),u=h(c.findFirst(l,e=>e.format===`ts`),g.orElse(()=>c.findFirst(l,e=>e.format===`jsonc`)),g.orElse(()=>c.findFirst(l,e=>e.format===`json`)),g.getOrNull),d=l.filter(e=>e!==u&&e.format!==`ts`);return{active:u,legacy:d,warnings:qe(t,r,u,d)}});function Ye(e,t,n){let r=e.devDependencies?.[t.name]??e.dependencies?.[t.name];return r?ze(r)===t.version?[]:[{currentVersion:r,description:`Update \`${t.name}\` from \`${r}\` to \`${t.version}\`.`,package:t.name,targetVersion:t.version,type:`update_package`}]:[{description:`Install \`${t.name}@${t.version}\` for ${n}.`,package:t.name,targetVersion:t.version,type:`install_package`}]}function Xe(e,t){return e.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 Ze(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??`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 Qe(e,t){let n=He(e);return t.some(e=>n.includes(e))}function $e(e){return j({assess:(t,r)=>n.sync(()=>{if(!Qe(r,e.scripts))return{applicable:!1,warnings:[]};let t=Ye(r,e,e.purpose);return{applicable:!0,findings:Xe(t,e.name),packageActions:t,warnings:[]}}),kind:`tooling`,name:e.name,version:e.version})}function et(e){let t=[{path:e.configFiles.config,type:`config`},...e.configFiles.legacyConfigs.map(e=>({path:e,type:`legacy_config`}))],r=t=>Je(t,e.name,e.configFiles);return j({assess:(t,i)=>n.gen(function*(){if(!Qe(i,e.scripts))return{applicable:!1,warnings:[]};let n=yield*r(t),a=Ye(i,e,e.purpose),o=e.configContent(),s=n.active?.format===`ts`?e.inspectConfig(yield*M(n.active.path)):void 0;return{applicable:!0,findings:[...Xe(a,e.name),...Ze(n,{configContent:o,configFile:e.configFiles.config,inspection:s,toolName:e.name})],packageActions:a,warnings:n.warnings}}),config:e.configFiles.config,create:t=>n.gen(function*(){let n=yield*x.Path;yield*P(n.join(t,e.configFiles.config),e.configContent())}),detect:r,files:t,kind:`tooling`,name:e.name,version:e.version})}function tt(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 nt(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 ie({Identifier:e=>{e.start>=n.start&&e.end<=n.end&&e.name===t&&(r=!0)}}).visit(e),r}function it(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=nt(e,r.name);return i!==null&&rt(e,t,i)}function at(e,t){let n=ae(`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=tt(n.program,t.moduleName);return r?it(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}\`.`}}function ot(e){return at(e,{moduleName:`adamantite/analyze`,presetName:`Adamantite analyze`})}function st(e={}){let t=Object.entries(e).map(([e,t])=>e===`rules`&&L(t)?[` rules: {`,` ...analyze.rules,`,...Object.entries(t).map(([e,t])=>` ${Pe(e)}: ${Fe(t,{continuationIndent:` `,indentation:` `})},`),` },`].join(`
6
+ `):` ${Pe(e)}: ${Fe(t)},`);return t.length===0?[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = analyze`,``,`export default config`,``].join(`
7
7
  `):[`import type { KnipConfig } from "knip"`,`import analyze from "adamantite/analyze"`,``,`const config: KnipConfig = {`,` ...analyze,`,...t,`}`,``,`export default config`,``].join(`
8
- `)}var V=$e({configContent:()=>ot(),configFiles:{config:`knip.config.ts`,legacyConfigs:[`knip.json`,`knip.jsonc`]},inspectConfig:at,name:`knip`,purpose:"the managed `analyze` script",scripts:[`analyze`],version:`6.32.2`});const st=u.Boolean(`fix`).pipe(u.withDefault(!1),u.withDescription(`Automatically fix issues`)),ct=u.Boolean(`strict`).pipe(u.withDefault(!1),u.withDescription(`Enable strict mode`));var lt=l.make(`analyze`,{fix:st,strict:ct}).pipe(l.withDescription(`Find unused dependencies, exports, and files using knip`),l.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run knip from a specific directory`}]),l.withHandler(({fix:e,strict:t})=>n.gen(function*(){let n=yield*j,r=yield*A,i=[];e&&i.push(`--fix`,`--allow-remove-files`),t&&i.push(`--production`,`--strict`),i.push(...n);let a=yield*r.run({args:i,command:V.name});a!==s.ExitCode(0)&&(yield*new O({command:V.name,exitCode:a}))})));const ut=`**/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(`,`),dt=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],ft="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",pt="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",mt="`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 ht(e=[]){return e.includes(`core`)?e:[`core`,...e]}function gt(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}const _t=ae.mapInput(ae.String,e=>e[0]);function vt(e){let t=(c.isArray(e)?e:[]).filter(e=>_.isString(e)).filter(e=>!ut.includes(e));return t.length===0?`core.ignorePatterns`:`[...core.ignorePatterns, ${t.map(e=>JSON.stringify(e)).join(`, `)}]`}function yt(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}`}"`)],s=[...t.map(e=>gt(e)),...n.map(e=>JSON.stringify(e))],l=_.isObject(i)?{...i}:{};l.respectEslintDisableDirectives=!0,l.typeAware=!0,l.typeCheck=!0;let u=JSON.stringify(Object.fromEntries(c.sort(Object.entries(l),_t)),null,2),d=Object.entries(a).map(([e,t])=>[e,JSON.stringify(t,null,2)]),f=[[`extends`,`[${s.join(`, `)}]`],[`ignorePatterns`,vt(r)],[`options`,u],...d],p=c.sort(f,_t).map(([e,t])=>` ${e}: ${t},`).join(`
8
+ `)}var B=et({configContent:()=>st(),configFiles:{config:`knip.config.ts`,legacyConfigs:[`knip.json`,`knip.jsonc`]},inspectConfig:ot,name:`knip`,purpose:"the managed `analyze` script",scripts:[`analyze`],version:`6.32.2`});const ct=u.Boolean(`fix`).pipe(u.withDefault(!1),u.withDescription(`Automatically fix issues`)),lt=u.Boolean(`strict`).pipe(u.withDefault(!1),u.withDescription(`Enable strict mode`));var ut=l.make(`analyze`,{fix:ct,strict:lt}).pipe(l.withDescription(`Find unused dependencies, exports, and files using knip`),l.withExamples([{command:`adamantite analyze -- --directory packages/app`,description:`Run knip from a specific directory`}]),l.withHandler(({fix:e,strict:t})=>n.gen(function*(){let n=yield*A,r=yield*k,i=[];e&&i.push(`--fix`,`--allow-remove-files`),t&&i.push(`--production`,`--strict`),i.push(...n);let a=yield*r.run({args:i,command:B.name});a!==s.ExitCode(0)&&(yield*new D({command:B.name,exitCode:a}))})));const dt=`**/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(`,`),ft=[`respectEslintDisableDirectives`,`typeAware`,`typeCheck`],pt="`oxlint.config.ts` must export an object literal directly, with or without `defineConfig(...)`, for Adamantite to patch `options` safely.",mt="`oxlint.config.ts` has an `options` property, but it is not an object literal that Adamantite can patch safely.",ht="`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 gt(e=[]){return e.includes(`core`)?e:[`core`,...e]}function _t(e){return e.replaceAll(/-([a-z])/g,(e,t)=>t.toUpperCase())}const vt=oe.mapInput(oe.String,e=>e[0]);function yt(e){let t=(c.isArray(e)?e:[]).filter(e=>_.isString(e)).filter(e=>!dt.includes(e));return t.length===0?`core.ignorePatterns`:`[...core.ignorePatterns, ${t.map(e=>JSON.stringify(e)).join(`, `)}]`}function bt(e,t,n=[]){let{ignorePatterns:r,options:i,...a}=e,o=[`import { defineConfig } from "oxlint"`,...t.map(e=>`import ${_t(e)} from "${e===`core`?`adamantite/lint`:`adamantite/lint/${e}`}"`)],s=[...t.map(e=>_t(e)),...n.map(e=>JSON.stringify(e))],l=_.isObject(i)?{...i}:{};l.respectEslintDisableDirectives=!0,l.typeAware=!0,l.typeCheck=!0;let u=JSON.stringify(Object.fromEntries(c.sort(Object.entries(l),vt)),null,2),d=Object.entries(a).map(([e,t])=>[e,JSON.stringify(t,null,2)]),f=[[`extends`,`[${s.join(`, `)}]`],[`ignorePatterns`,yt(r)],[`options`,u],...d],p=c.sort(f,vt).map(([e,t])=>` ${e}: ${t},`).join(`
9
9
  `);return[...o,``,`export default defineConfig({`,p,`})`,``].join(`
10
- `)}const bt=g.liftThrowable(e=>ie(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function xt(e){return bt(e).pipe(g.flatMap(e=>e.errors.length===0?g.fromNullishOr(e.program):g.none()))}function St(e){let{code:t}=oe(e,se({quotes:`double`}));return t.endsWith(`
11
- `)?t:`${t}\n`}function Ct(e){return e.type===`Identifier`?h(e.name,g.some):e.type===`Literal`&&_.isString(e.value)?h(e.value,g.some):g.none()}function wt(e){return e.type===`ObjectExpression`?h(e,g.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?g.none():h(e.arguments.length===1?c.head(e.arguments):g.none(),g.filter(e=>e.type===`ObjectExpression`))}function Tt(e){return h(e.body,c.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?c.head(e):g.none(),g.flatMap(e=>wt(e.declaration)))}function Et(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`manual`};let e=g.contains(Ct(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 Dt(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 Ot(){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:dt.map(e=>Dt(e)),start:0,type:`ObjectExpression`}}}function kt(e,t){let n=[],r=!1;for(let e of dt){let i=Et(t,e);if(i.status===`manual`)return{kind:`manual`,reason:mt};if(i.status===`missing`){n.push(e);continue}let a=i.property.value;if(a.type!==`Literal`||!_.isBoolean(a.value))return{kind:`manual`,reason:mt};a.value||(a.raw=`true`,a.value=!0,r=!0)}return n.length>0&&(t.properties.unshift(...n.map(e=>Dt(e))),r=!0),r?{kind:`patchable`,updatedContent:St(e)}:{kind:`configured`}}function At(e){let t=xt(e);if(g.isNone(t))return{kind:`manual`,reason:ft};let n=Tt(t.value);if(g.isNone(n))return{kind:`manual`,reason:ft};let r=Et(n.value,`options`);return r.status===`manual`?{kind:`manual`,reason:pt}:r.status===`missing`?(n.value.properties.unshift(Ot()),{kind:`patchable`,updatedContent:St(t.value)}):r.property.value.type===`ObjectExpression`?kt(t.value,r.property.value):{kind:`manual`,reason:pt}}const H=`oxlint.config.ts`,jt=`.oxlintrc.json`,Mt=[{path:H,type:`config`},{path:jt,type:`legacy_config`}],Nt={config:H,legacyConfigs:[jt]},Pt=`1.79.0`,Ft=e=>qe(e,`oxlint`,Nt);var U=M({assess:(e,t)=>n.gen(function*(){let n=Ve(t);if(!n.includes(`check`)&&!n.includes(`fix`))return{applicable:!1,warnings:[]};let r=yield*Ft(e),i=Je(t,{name:`oxlint`,version:Pt},`the managed lint scripts`),a=r.active,o;if(a?.format===`ts`){let e=At(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=yt({},ht());return{applicable:!0,findings:[...Ye(i,`oxlint`),...Xe(r,{configContent:s,configFile:H,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:H,create:(e,t=[])=>n.gen(function*(){let n=yield*x.Path,r=yt({},ht(t));yield*F(n.join(e,H),r)}),detect:Ft,files:Mt,kind:`tooling`,name:`oxlint`,update:e=>n.gen(function*(){let t=yield*b.FileSystem,n=(yield*x.Path).join(e,H);if(!(yield*t.exists(n)))return yield*new we({path:H});let r=At(yield*N(n));if(r.kind!==`configured`){if(r.kind===`manual`)return yield*new Ee({path:H,reason:r.reason});yield*F(n,r.updatedContent)}}),version:Pt});const It=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to lint (optional)`),w.variadic());var Lt=l.make(`check`,{files:It}).pipe(l.withDescription(`Find issues and type errors in code using oxlint`),l.withHandler(({files:e})=>n.gen(function*(){let t=yield*j,n=yield*(yield*A).run({args:[...e,...t],command:U.name});n!==s.ExitCode(0)&&(yield*new O({command:U.name,exitCode:n}))})));const Rt=[{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]}],zt=e=>n.gen(function*(){let t=yield*A;return(yield*n.forEach(Rt,r=>t.run({args:[...r.probeArguments??[`--version`]],command:r.command,cwd:e,stderr:`ignore`,stdout:`ignore`}).pipe(n.timeout(`10 seconds`),n.as(r),n.catch(()=>n.succeed(null))),{concurrency:Rt.length})).filter(e=>e!==null)});var Bt=class extends m.TaggedError(`AgentSessionFailed`){};const Vt=()=>{},Ht=e=>n.acquireUseRelease(n.sync(()=>{let e=S.listeners(`SIGINT`);return S.removeAllListeners(`SIGINT`),S.on(`SIGINT`,Vt),e}),()=>e,e=>n.sync(()=>{S.removeAllListeners(`SIGINT`);for(let t of e)S.on(`SIGINT`,t)})),Ut=({agent:e,cwd:t})=>n.gen(function*(){let n=yield*A;yield*Ht(n.run({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:t,detached:!1,stderr:`inherit`,stdin:`inherit`,stdout:`inherit`}))}).pipe(n.asVoid,n.mapError(e=>new Bt({cause:e,reason:e._tag===`CliNotFound`?`not-found`:`spawn-failed`}))),Wt=e=>n.gen(function*(){let t=yield*(yield*A).run({args:[`diff`,`--quiet`,`HEAD`],command:`git`,cwd:e,stderr:`ignore`,stdout:`ignore`});return t===s.ExitCode(0)?`clean`:t===s.ExitCode(1)?`dirty`:`unknown`}).pipe(n.catch(()=>n.succeed(`unknown`))),Gt=[{name:`check`,script:`check`},{args:[`--check`],name:`format`,script:`format`},{name:`monorepo`,script:`check:monorepo`},{name:`analyze`,script:`analyze`}];function Kt(e,t){let n=[];for(let r of Gt)t.includes(r.script)&&n.push({command:ue(e,r.script,{args:r.args}),name:r.name});return n}function qt(e){return Gt.some(t=>e.includes(t.script))}var W=class extends d.Service()(`DependencyInstaller`){static layer=i.succeed(this)({addDevDependencies:n.fn(`DependencyInstaller.addDevDependencies`)((e,t,r)=>n.tryPromise({catch:t=>new ve({cause:t,packages:e}),try:()=>ce(e,{...r,cwd:t})}).pipe(n.asVoid)),detectPackageManager:n.fn(`DependencyInstaller.detectPackageManager`)(e=>n.tryPromise({catch:e=>new De({cause:e}),try:()=>le(e)}).pipe(n.map(e=>e??null)))})};function Jt(e){return{_tag:`File`,path:e}}function Yt(e){return{_tag:`Version`,value:e}}const Xt=[`.node-version`,`.nvmrc`],Zt=T.Struct({volta:T.Struct({node:T.NonEmptyString})}),Qt=T.Struct({engines:T.Struct({node:T.NonEmptyString})}),$t=T.Struct({name:T.NonEmptyString,version:T.NonEmptyString});function en(e){return e.split(`
12
- `).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function tn(e){return T.is($t)(e)&&e.name.toLowerCase()===`node`}function nn(e){if(T.is(Zt)(e))return!0;if(_.isObject(e)&&_.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>tn(e)))return!0}return T.is(Qt)(e)}var rn=class extends d.Service()(`NodeVersionResolver`){static layer=i.effect(this,n.gen(function*(){let e=yield*b.FileSystem,t=yield*x.Path,r=(r,i)=>P(t.join(r,i)).pipe(n.provideService(b.FileSystem,e));return{resolve:n.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of Xt){let n=yield*r(e,t);if(g.exists(n,e=>v.isNonEmpty(e.trim())))return Jt(t)}let n=yield*r(e,`.tool-versions`);if(g.exists(n,e=>en(e)))return Jt(`.tool-versions`);let i=yield*r(e,`package.json`);return g.isSome(i)&&nn(yield*L(i.value,t.join(e,`package.json`)))?Jt(`package.json`):Yt(`lts/*`)})}}))};const an=/^\s*node-version:\s*"?\d/m,on=/^[>|](?:[1-9][+-]?|[+-][1-9]?)?(?:\s+#.*)?$/,sn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+check|deno(?:\s+(?!task\b)\S+)*\s+task\s+check)\b/,cn=/^(\s*)(?:-\s*)?(?:command|run):\s*(.*)$/;function ln(e){let t=e.split(`
13
- `);for(let[e,n]of t.entries()){let r=cn.exec(n);if(!r)continue;let i=r[1]?.length??0,a=(r[2]??``).trim();if(sn.test(a))return!0;if(on.test(a))for(let n of t.slice(e+1)){let e=n.trim();if(e.length!==0){if(n.length-n.trimStart().length<=i)break;if(sn.test(e))return!0}}}return!1}function un(e){return` - name: Setup Node.js
10
+ `)}const xt=g.liftThrowable(e=>ae(`oxlint.config.ts`,e,{astType:`ts`,lang:`ts`,sourceType:`module`}));function St(e){return xt(e).pipe(g.flatMap(e=>e.errors.length===0?g.fromNullishOr(e.program):g.none()))}function Ct(e){let{code:t}=se(e,ce({quotes:`double`}));return t.endsWith(`
11
+ `)?t:`${t}\n`}function wt(e){return e.type===`Identifier`?h(e.name,g.some):e.type===`Literal`&&_.isString(e.value)?h(e.value,g.some):g.none()}function Tt(e){return e.type===`ObjectExpression`?h(e,g.some):e.type!==`CallExpression`||e.callee.type!==`Identifier`||e.callee.name!==`defineConfig`?g.none():h(e.arguments.length===1?c.head(e.arguments):g.none(),g.filter(e=>e.type===`ObjectExpression`))}function Et(e){return h(e.body,c.filter(e=>e.type===`ExportDefaultDeclaration`),e=>e.length===1?c.head(e):g.none(),g.flatMap(e=>Tt(e.declaration)))}function Dt(e,t){let n=null;for(let r of e.properties){if(r.type===`SpreadElement`||r.computed)return{status:`manual`};let e=g.contains(wt(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 Ot(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 kt(){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:ft.map(e=>Ot(e)),start:0,type:`ObjectExpression`}}}function At(e,t){let n=[],r=!1;for(let e of ft){let i=Dt(t,e);if(i.status===`manual`)return{kind:`manual`,reason:ht};if(i.status===`missing`){n.push(e);continue}let a=i.property.value;if(a.type!==`Literal`||!_.isBoolean(a.value))return{kind:`manual`,reason:ht};a.value||(a.raw=`true`,a.value=!0,r=!0)}return n.length>0&&(t.properties.unshift(...n.map(e=>Ot(e))),r=!0),r?{kind:`patchable`,updatedContent:Ct(e)}:{kind:`configured`}}function jt(e){let t=St(e);if(g.isNone(t))return{kind:`manual`,reason:pt};let n=Et(t.value);if(g.isNone(n))return{kind:`manual`,reason:pt};let r=Dt(n.value,`options`);return r.status===`manual`?{kind:`manual`,reason:mt}:r.status===`missing`?(n.value.properties.unshift(kt()),{kind:`patchable`,updatedContent:Ct(t.value)}):r.property.value.type===`ObjectExpression`?At(t.value,r.property.value):{kind:`manual`,reason:mt}}const V=`oxlint.config.ts`,Mt=`.oxlintrc.json`,Nt=[{path:V,type:`config`},{path:Mt,type:`legacy_config`}],Pt={config:V,legacyConfigs:[Mt]},Ft=`1.83.0`,It=e=>Je(e,`oxlint`,Pt);var H=j({assess:(e,t)=>n.gen(function*(){let n=He(t);if(!n.includes(`check`)&&!n.includes(`fix`))return{applicable:!1,warnings:[]};let r=yield*It(e),i=Ye(t,{name:`oxlint`,version:Ft},`the managed lint scripts`),a=r.active,o;if(a?.format===`ts`){let e=jt(yield*M(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=bt({},gt());return{applicable:!0,findings:[...Xe(i,`oxlint`),...Ze(r,{configContent:s,configFile:V,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:V,create:(e,t=[])=>n.gen(function*(){let n=yield*x.Path,r=bt({},gt(t));yield*P(n.join(e,V),r)}),detect:It,files:Nt,kind:`tooling`,name:`oxlint`,update:e=>n.gen(function*(){let t=yield*b.FileSystem,n=(yield*x.Path).join(e,V);if(!(yield*t.exists(n)))return yield*new Te({path:V});let r=jt(yield*M(n));if(r.kind!==`configured`){if(r.kind===`manual`)return yield*new De({path:V,reason:r.reason});yield*P(n,r.updatedContent)}}),version:Ft});const Lt=C.File(`files`,{mustExist:!0}).pipe(C.withDescription(`Specific files to lint (optional)`),C.variadic());var Rt=l.make(`check`,{files:Lt}).pipe(l.withDescription(`Find issues and type errors in code using oxlint`),l.withHandler(({files:e})=>n.gen(function*(){let t=yield*A,n=yield*(yield*k).run({args:[...e,...t],command:H.name});n!==s.ExitCode(0)&&(yield*new D({command:H.name,exitCode:n}))})));const zt=[{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]}],Bt=e=>n.gen(function*(){let t=yield*k;return(yield*n.forEach(zt,r=>t.run({args:[...r.probeArguments??[`--version`]],command:r.command,cwd:e,stderr:`ignore`,stdout:`ignore`}).pipe(n.timeout(`10 seconds`),n.as(r),n.catch(()=>n.succeed(null))),{concurrency:zt.length})).filter(e=>e!==null)});var Vt=class extends m.TaggedError(`AgentSessionFailed`){};const Ht=()=>{},Ut=e=>n.acquireUseRelease(n.sync(()=>{let e=S.listeners(`SIGINT`);return S.removeAllListeners(`SIGINT`),S.on(`SIGINT`,Ht),e}),()=>e,e=>n.sync(()=>{S.removeAllListeners(`SIGINT`);for(let t of e)S.on(`SIGINT`,t)})),Wt=({agent:e,cwd:t})=>n.gen(function*(){let n=yield*k;yield*Ut(n.run({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:t,detached:!1,stderr:`inherit`,stdin:`inherit`,stdout:`inherit`}))}).pipe(n.asVoid,n.mapError(e=>new Vt({cause:e,reason:e._tag===`CliNotFound`?`not-found`:`spawn-failed`}))),Gt=e=>n.gen(function*(){let t=yield*(yield*k).run({args:[`diff`,`--quiet`,`HEAD`],command:`git`,cwd:e,stderr:`ignore`,stdout:`ignore`});return t===s.ExitCode(0)?`clean`:t===s.ExitCode(1)?`dirty`:`unknown`}).pipe(n.catch(()=>n.succeed(`unknown`))),Kt=[{name:`check`,script:`check`},{args:[`--check`],name:`format`,script:`format`},{name:`monorepo`,script:`check:monorepo`},{name:`analyze`,script:`analyze`}];function qt(e,t){let n=[];for(let r of Kt)t.includes(r.script)&&n.push({command:de(e,r.script,{args:r.args}),name:r.name});return n}function Jt(e){return Kt.some(t=>e.includes(t.script))}var U=class extends d.Service()(`DependencyInstaller`){static layer=i.succeed(this)({addDevDependencies:n.fn(`DependencyInstaller.addDevDependencies`)((e,t,r)=>n.tryPromise({catch:t=>new ye({cause:t,packages:e}),try:()=>le(e,{...r,cwd:t})}).pipe(n.asVoid)),detectPackageManager:n.fn(`DependencyInstaller.detectPackageManager`)(e=>n.tryPromise({catch:e=>new Oe({cause:e}),try:()=>ue(e)}).pipe(n.map(e=>e??null)))})};function Yt(e){return{_tag:`File`,path:e}}function Xt(e){return{_tag:`Version`,value:e}}const Zt=[`.node-version`,`.nvmrc`],Qt=w.Struct({volta:w.Struct({node:w.NonEmptyString})}),$t=w.Struct({engines:w.Struct({node:w.NonEmptyString})}),en=w.Struct({name:w.NonEmptyString,version:w.NonEmptyString});function tn(e){return e.split(`
12
+ `).map(e=>e.split(`#`)[0]?.trim()??``).some(e=>/^node(?:js)?\s+\S/.test(e))}function nn(e){return w.is(en)(e)&&e.name.toLowerCase()===`node`}function rn(e){if(w.is(Qt)(e))return!0;if(_.isObject(e)&&_.isObject(e.devEngines)){let t=e.devEngines.runtime;if((Array.isArray(t)?t:[t]).some(e=>nn(e)))return!0}return w.is($t)(e)}var an=class extends d.Service()(`NodeVersionResolver`){static layer=i.effect(this,n.gen(function*(){let e=yield*b.FileSystem,t=yield*x.Path,r=(r,i)=>N(t.join(r,i)).pipe(n.provideService(b.FileSystem,e));return{resolve:n.fn(`NodeVersionResolver.resolve`)(function*(e){for(let t of Zt){let n=yield*r(e,t);if(g.exists(n,e=>v.isNonEmpty(e.trim())))return Yt(t)}let n=yield*r(e,`.tool-versions`);if(g.exists(n,e=>tn(e)))return Yt(`.tool-versions`);let i=yield*r(e,`package.json`);return g.isSome(i)&&rn(yield*I(i.value,t.join(e,`package.json`)))?Yt(`package.json`):Xt(`lts/*`)})}}))};const on=/^\s*node-version:\s*"?\d/m,sn=/^[>|](?:[1-9][+-]?|[+-][1-9]?)?(?:\s+#.*)?$/,cn=/\b(?:(?:bun|npm|pnpm|yarn)(?:\s+(?!run\b)\S+)*\s+run\s+check|deno(?:\s+(?!task\b)\S+)*\s+task\s+check)\b/,ln=/^(\s*)(?:-\s*)?(?:command|run):\s*(.*)$/;function un(e){let t=e.split(`
13
+ `);for(let[e,n]of t.entries()){let r=ln.exec(n);if(!r)continue;let i=r[1]?.length??0,a=(r[2]??``).trim();if(cn.test(a))return!0;if(sn.test(a))for(let n of t.slice(e+1)){let e=n.trim();if(e.length!==0){if(n.length-n.trimStart().length<=i)break;if(cn.test(e))return!0}}}return!1}function dn(e){return` - name: Setup Node.js
14
14
  uses: actions/setup-node@v7
15
15
  with:
16
- ${e._tag===`File`?`node-version-file: "${e.path}"`:`node-version: "${e.value}"`}`}function dn(e){return{bun:`${un(e)}
16
+ ${e._tag===`File`?`node-version-file: "${e.path}"`:`node-version: "${e.value}"`}`}function fn(e){return{bun:`${dn(e)}
17
17
 
18
18
  - name: Setup Bun
19
19
  uses: oven-sh/setup-bun@v2
@@ -33,22 +33,22 @@ import*as e from"@effect/platform-node/NodeRuntime";import*as t from"@effect/pla
33
33
  uses: denoland/setup-deno@v2
34
34
 
35
35
  - name: Install dependencies
36
- run: deno install --frozen`,npm:`${un(e)}
36
+ run: deno install --frozen`,npm:`${dn(e)}
37
37
  cache: "npm"
38
38
 
39
39
  - name: Install dependencies
40
40
  run: npm ci`,pnpm:` - name: Setup pnpm
41
41
  uses: pnpm/action-setup@v4
42
42
 
43
- ${un(e)}
43
+ ${dn(e)}
44
44
  cache: "pnpm"
45
45
 
46
46
  - name: Install dependencies
47
- run: pnpm install --frozen-lockfile`,yarn:`${un(e)}
47
+ run: pnpm install --frozen-lockfile`,yarn:`${dn(e)}
48
48
  cache: "yarn"
49
49
 
50
50
  - name: Install dependencies
51
- run: yarn install --frozen-lockfile`}}function fn({packageManager:e,scripts:t},n){let r=Kt(e,t);return r.length===0?null:`${`name: adamantite
51
+ run: yarn install --frozen-lockfile`}}function pn({packageManager:e,scripts:t},n){let r=qt(e,t);return r.length===0?null:`${`name: adamantite
52
52
 
53
53
  on:
54
54
  push:
@@ -80,32 +80,32 @@ ${r.map(e=>` - name: ${e.name}\n command: ${e.command}`).joi
80
80
  - name: Checkout
81
81
  uses: actions/checkout@v7
82
82
 
83
- ${dn(n)[e]}
83
+ ${fn(n)[e]}
84
84
 
85
85
  - name: Run \${{ matrix.name }}
86
- run: \${{ matrix.command }}`}\n`}const pn=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],mn=(e,t)=>n.gen(function*(){let n=yield*x.Path,r=yield*rn,i=n.join(e,pn[0].path),a=fn(t,yield*r.resolve(e));a&&(yield*F(i,a))});var hn=M({assess:(e,t)=>n.gen(function*(){let n=(yield*x.Path).join(e,pn[0].path),r=yield*P(n);if(r._tag===`None`)return{applicable:!1,warnings:[]};let i=Ve(t),a=an.test(r.value),o=i.includes(`check`)&&!ln(r.value);if(!a&&!o)return{applicable:!0,findings:[],packageActions:[],warnings:[]};if(!qt(i))return{applicable:!0,findings:[],packageActions:[],warnings:[`No CI-compatible managed scripts were found, so the GitHub Actions workflow cannot be regenerated.`]};let s=yield*(yield*W).detectPackageManager(e);return s?Be(s.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 \`${s.name}\`. Preserve unrelated workflow jobs and project-specific settings.`],title:`Outdated Adamantite workflow`}],packageActions:[],warnings:[]}:{applicable:!0,findings:[],packageActions:[],warnings:[`\`${s.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow cannot be regenerated.`]}:{applicable:!0,findings:[],packageActions:[],warnings:[`Could not detect a package manager, so the GitHub Actions workflow cannot be regenerated.`]}}),create:(e,t)=>n.gen(function*(){let n=yield*x.Path;yield*je(n.dirname(n.join(e,pn[0].path))),yield*mn(e,t)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,pn[0].path))}),files:pn,kind:`ci`,name:`github`,update:mn});const G=[{path:`.zed/settings.json`,type:`config`}],gn={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 vn(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 yn(e){return!R(e)||!Me(e.plugins)?e:Object.fromEntries([...Object.entries(e),[`plugins`,c.dedupe(e.plugins)]])}function bn(e){let t=e.languages;if(!R(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>!(e in gn.languages)||!R(t)?[e,t]:[e,Object.fromEntries(Object.entries(t).map(([e,t])=>e===`formatter`&&Me(t)?[e,c.dedupe(t)]:e===`prettier`?[e,yn(t)]:[e,t]))]));return Object.fromEntries([...Object.entries(e),[`languages`,n]])}var K=M({assess:(e,t)=>n.gen(function*(){let t=(yield*x.Path).join(e,G[0].path),n=yield*P(t);if(n._tag===`None`)return{applicable:!1,warnings:[]};let r=yield*L(n.value,t),i=R(r)?vn(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=>n.gen(function*(){let t=yield*x.Path,n=t.join(e,G[0].path);yield*je(t.dirname(n)),yield*I(n,gn)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,G[0].path))}),files:G,kind:`editor`,name:`zed`,update:e=>n.gen(function*(){let t=(yield*x.Path).join(e,G[0].path),n=yield*N(t),r=yield*L(n,t);if(!_.isObject(r))return yield*new Te({path:t});let i=bn(yield*Fe(gn,r));yield*I(t,i)})});const xn=new Set([`sortImports`,`sortPackageJson`,`sortTailwindcss`]);function Sn(e){return it(e,{moduleName:`adamantite/format`,presetName:`Adamantite format`})}function Cn(e){let t=e.split(`
86
+ run: \${{ matrix.command }}`}\n`}const mn=[{path:`.github/workflows/adamantite.yml`,type:`ci`}],hn=(e,t)=>n.gen(function*(){let n=yield*x.Path,r=yield*an,i=n.join(e,mn[0].path),a=pn(t,yield*r.resolve(e));a&&(yield*P(i,a))});var W=j({assess:(e,t)=>n.gen(function*(){let n=(yield*x.Path).join(e,mn[0].path),r=yield*N(n);if(r._tag===`None`)return{applicable:!1,warnings:[]};let i=He(t),a=on.test(r.value),o=i.includes(`check`)&&!un(r.value);if(!a&&!o)return{applicable:!0,findings:[],packageActions:[],warnings:[]};if(!Jt(i))return{applicable:!0,findings:[],packageActions:[],warnings:[`No CI-compatible managed scripts were found, so the GitHub Actions workflow cannot be regenerated.`]};let s=yield*(yield*U).detectPackageManager(e);return s?Ve(s.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 \`${s.name}\`. Preserve unrelated workflow jobs and project-specific settings.`],title:`Outdated Adamantite workflow`}],packageActions:[],warnings:[]}:{applicable:!0,findings:[],packageActions:[],warnings:[`\`${s.name}\` is not a supported package manager for CI workflow generation, so the GitHub Actions workflow cannot be regenerated.`]}:{applicable:!0,findings:[],packageActions:[],warnings:[`Could not detect a package manager, so the GitHub Actions workflow cannot be regenerated.`]}}),create:(e,t)=>n.gen(function*(){let n=yield*x.Path;yield*Me(n.dirname(n.join(e,mn[0].path))),yield*hn(e,t)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,mn[0].path))}),files:mn,kind:`ci`,name:`github`,update:hn});const G=[{path:`.zed/settings.json`,type:`config`}],gn={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 vn(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 yn(e){return!L(e)||!Ne(e.plugins)?e:Object.fromEntries([...Object.entries(e),[`plugins`,c.dedupe(e.plugins)]])}function bn(e){let t=e.languages;if(!L(t))return e;let n=Object.fromEntries(Object.entries(t).map(([e,t])=>!(e in gn.languages)||!L(t)?[e,t]:[e,Object.fromEntries(Object.entries(t).map(([e,t])=>e===`formatter`&&Ne(t)?[e,c.dedupe(t)]:e===`prettier`?[e,yn(t)]:[e,t]))]));return Object.fromEntries([...Object.entries(e),[`languages`,n]])}var K=j({assess:(e,t)=>n.gen(function*(){let t=(yield*x.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)?vn(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=>n.gen(function*(){let t=yield*x.Path,n=t.join(e,G[0].path);yield*Me(t.dirname(n)),yield*F(n,gn)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,G[0].path))}),files:G,kind:`editor`,name:`zed`,update:e=>n.gen(function*(){let t=(yield*x.Path).join(e,G[0].path),n=yield*M(t),r=yield*I(n,t);if(!_.isObject(r))return yield*new Ee({path:t});let i=bn(yield*Ie(gn,r));yield*F(t,i)})});const xn=new Set([`sortImports`,`sortPackageJson`,`sortTailwindcss`]);function Sn(e){return at(e,{moduleName:`adamantite/format`,presetName:`Adamantite format`})}function Cn(e){let t=e.split(`
87
87
  `);return t.length===1?e.slice(1,-1).trim():t.slice(1,-1).map(e=>` ${e.trimStart()}`).join(`
88
- `)}function wn(e,t){let n=Cn(Pe(t));return[` ${e}: {`,` ...format.${e},`,...n===``?[]:[n],` },`].join(`
89
- `)}function Tn(e={}){let t=Object.entries(e).map(([e,t])=>{if(xn.has(e)&&R(t))return wn(e,t);let n=Pe(t,{continuationIndent:` `});return` ${Ne(e)}: ${n},`});return t.length===0?[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig(format)`,``].join(`
88
+ `)}function wn(e,t){let n=Cn(Fe(t));return[` ${e}: {`,` ...format.${e},`,...n===``?[]:[n],` },`].join(`
89
+ `)}function Tn(e={}){let t=Object.entries(e).map(([e,t])=>{if(xn.has(e)&&L(t))return wn(e,t);let n=Fe(t,{continuationIndent:` `});return` ${Pe(e)}: ${n},`});return t.length===0?[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig(format)`,``].join(`
90
90
  `):[`import { defineConfig } from "oxfmt"`,`import format from "adamantite/format"`,``,`export default defineConfig({`,` ...format,`,...t,`})`,``].join(`
91
- `)}var q=$e({configContent:()=>Tn(),configFiles:{config:`oxfmt.config.ts`,legacyConfigs:[`.oxfmtrc.json`,`.oxfmtrc.jsonc`]},inspectConfig:Sn,name:`oxfmt`,purpose:"the managed `format` script",scripts:[`format`],version:`0.65.0`}),J=Qe({name:`sherif`,purpose:`the managed monorepo scripts`,scripts:[`check:monorepo`,`fix:monorepo`],version:`1.13.0`}),En=Qe({name:`oxlint-tsgolint`,purpose:`the managed lint scripts`,scripts:[`check`,`fix`],version:`7.0.2001`});const Dn=/^(?:packages|"packages"|'packages')\s*:/u;function On(e){return e.replace(/(?:^|\s+)#.*$/u,``).trim()}function kn(e){let t=e.replace(/^\uFEFF/u,``).split(/\r?\n/u),n=t.findIndex(e=>Dn.test(e));if(n===-1)return!1;let r=On((t[n]??``).replace(Dn,``));if(r===`[`){for(let e of t.slice(n+1)){let t=On(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 An=(e=S.cwd())=>n.gen(function*(){let t=yield*x.Path,n=yield*P(t.join(e,`pnpm-workspace.yaml`));if(g.isSome(n)&&kn(n.value))return!0;let r=(yield*z(e)).workspaces;return((c.isArray(r)?r:r?.packages)?.length??0)>0}),Y=[{path:`tsconfig.json`,type:`config`}],X=`adamantite/typescript`,jn={extends:X},Mn=["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 Nn(e){return _.isString(e)?e===X?e:[e,X]:c.isArray(e)?e.includes(X)?e:[...e,X]:X}var Z=M({assess:(e,t)=>n.gen(function*(){let n=Ve(t);if(!n.includes(`check`)&&!n.includes(`fix`))return{applicable:!1,warnings:[]};if(yield*An(e))return{applicable:!0,findings:[],packageActions:[],warnings:Mn};let r=(yield*x.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(jn,null,2)}\n`,language:`json`},title:`Missing TypeScript configuration`}],packageActions:[],warnings:[]};let a=yield*L(i.value,r);return{applicable:!0,findings:_.isObject(a)&&(a.extends===X||c.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(jn,null,2)}\n`,language:`json`},title:`TypeScript preset is not configured`}],packageActions:[],warnings:[]}}),config:Y[0].path,create:e=>n.gen(function*(){let t=yield*x.Path;yield*I(t.join(e,Y[0].path),jn)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,Y[0].path))}),files:Y,kind:`workspace`,name:`tsconfig`,update:e=>n.gen(function*(){let t=(yield*x.Path).join(e,Y[0].path),n=yield*N(t),r=yield*L(n,t);if(!_.isObject(r))return yield*new Te({path:t});let i=yield*Fe(jn,r),a=Object.fromEntries([...Object.entries(i),[`extends`,Nn(`extends`in r?r.extends:void 0)]]);yield*I(t,a)})});const Pn=[V,q,U,J,En,Z,hn,K],Fn=n.fn(`collectApplicableAssessments`)(function*(e,t,r){return yield*n.forEach(e,e=>e.assess(t,r).pipe(n.map(t=>t.applicable?g.some({assessment:t,name:e.name}):g.none())),{concurrency:`unbounded`}).pipe(n.map(e=>c.getSomes(e)))});function In(e,t,n){return Fn(e,t,n)}const Ln=n.fn(`assessProject`)(function*(e,t){let n=t??(yield*z(e)),r=yield*In(Pn,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 Rn(e,t){return e.findings.length===0?zn(e.warnings,t):Bn(e.findings,e.warnings,t)}function zn(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(`
91
+ `)}var q=et({configContent:()=>Tn(),configFiles:{config:`oxfmt.config.ts`,legacyConfigs:[`.oxfmtrc.json`,`.oxfmtrc.jsonc`]},inspectConfig:Sn,name:`oxfmt`,purpose:"the managed `format` script",scripts:[`format`],version:`0.65.0`}),J=$e({name:`sherif`,purpose:`the managed monorepo scripts`,scripts:[`check:monorepo`,`fix:monorepo`],version:`1.13.0`}),En=$e({name:`oxlint-tsgolint`,purpose:`the managed lint scripts`,scripts:[`check`,`fix`],version:`7.0.2001`});const Dn=/^(?:packages|"packages"|'packages')\s*:/u;function On(e){return e.replace(/(?:^|\s+)#.*$/u,``).trim()}function kn(e){let t=e.replace(/^\uFEFF/u,``).split(/\r?\n/u),n=t.findIndex(e=>Dn.test(e));if(n===-1)return!1;let r=On((t[n]??``).replace(Dn,``));if(r===`[`){for(let e of t.slice(n+1)){let t=On(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 An=(e=S.cwd())=>n.gen(function*(){let t=yield*x.Path,n=yield*N(t.join(e,`pnpm-workspace.yaml`));if(g.isSome(n)&&kn(n.value))return!0;let r=(yield*R(e)).workspaces;return((c.isArray(r)?r:r?.packages)?.length??0)>0}),Y=[{path:`tsconfig.json`,type:`config`}],X=`adamantite/typescript`,jn={extends:X},Mn=["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 Nn(e){return _.isString(e)?e===X?e:[e,X]:c.isArray(e)?e.includes(X)?e:[...e,X]:X}var Z=j({assess:(e,t)=>n.gen(function*(){let n=He(t);if(!n.includes(`check`)&&!n.includes(`fix`))return{applicable:!1,warnings:[]};if(yield*An(e))return{applicable:!0,findings:[],packageActions:[],warnings:Mn};let r=(yield*x.Path).join(e,Y[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(jn,null,2)}\n`,language:`json`},title:`Missing TypeScript configuration`}],packageActions:[],warnings:[]};let a=yield*I(i.value,r);return{applicable:!0,findings:_.isObject(a)&&(a.extends===X||c.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(jn,null,2)}\n`,language:`json`},title:`TypeScript preset is not configured`}],packageActions:[],warnings:[]}}),config:Y[0].path,create:e=>n.gen(function*(){let t=yield*x.Path;yield*F(t.join(e,Y[0].path),jn)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,Y[0].path))}),files:Y,kind:`workspace`,name:`tsconfig`,update:e=>n.gen(function*(){let t=(yield*x.Path).join(e,Y[0].path),n=yield*M(t),r=yield*I(n,t);if(!_.isObject(r))return yield*new Ee({path:t});let i=yield*Ie(jn,r),a=Object.fromEntries([...Object.entries(i),[`extends`,Nn(`extends`in r?r.extends:void 0)]]);yield*F(t,a)})});const Pn=[B,q,H,J,En,Z,W,K],Fn=n.fn(`collectApplicableAssessments`)(function*(e,t,r){return yield*n.forEach(e,e=>e.assess(t,r).pipe(n.map(t=>t.applicable?g.some({assessment:t,name:e.name}):g.none())),{concurrency:`unbounded`}).pipe(n.map(e=>c.getSomes(e)))});function In(e,t,n){return Fn(e,t,n)}const Ln=n.fn(`assessProject`)(function*(e,t){let n=t??(yield*R(e)),r=yield*In(Pn,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 Rn(e,t){return e.findings.length===0?zn(e.warnings,t):Bn(e.findings,e.warnings,t)}function zn(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
92
  `)}function Bn(e,t,n){let r=e.map((e,t)=>{let n=e.goal.map(e=>` - ${e}`).join(`
93
93
  `),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
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(`
95
95
 
96
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 Vn=class extends d.Service()(`TerminalCapabilities`){static layer=i.succeed(this)({copyToClipboard:e=>n.sync(()=>{let t=Buffer.from(e).toString(`base64`);S.stdout.write(`\u001B]52;c;${t}\u0007`)}),isInteractive:n.sync(()=>S.stdin.isTTY&&S.stdout.isTTY)})},Q=class extends d.Service()(`Prompter`){static layerWithSpinner(e){return i.succeed(this)({cancel:e=>n.sync(()=>{E.cancel(e)}),confirm:e=>n.promise(()=>E.confirm(e)).pipe(n.filterOrFail(e=>!E.isCancel(e),()=>new Oe({}))),intro:e=>n.sync(()=>{E.intro(e)}),log:{error:e=>n.sync(()=>{E.log.error(e)}),info:e=>n.sync(()=>{E.log.info(e)}),success:e=>n.sync(()=>{E.log.success(e)}),warning:e=>n.sync(()=>{E.log.warning(e)})},message:e=>n.sync(()=>{E.log.message(e,{spacing:0,withGuide:!1})}),multiselect:e=>n.promise(()=>E.multiselect(e)).pipe(n.filterOrFail(e=>!E.isCancel(e),()=>new Oe({}))),note:(e,t)=>n.sync(()=>{E.note(e,t)}),outro:e=>n.sync(()=>{E.outro(e)}),select:e=>n.promise(()=>E.select(e)).pipe(n.filterOrFail(e=>!E.isCancel(e),()=>new Oe({}))),withSpinner:(t,i)=>n.acquireUseRelease(n.sync(()=>{let t=e();return t.start(i.start),t}),e=>t({message:t=>n.sync(()=>{e.message(t)})}),(e,t)=>n.sync(()=>{e.stop(r.match(t,{onFailure:()=>i.failure,onSuccess:e=>_.isFunction(i.success)?i.success(e):i.success}))}))})}static layer=this.layerWithSpinner(E.spinner)};function Hn(e){let t=[`Current state\n${e.currentState}`,`Goal\n${e.goal.map(e=>`• ${e}`).join(`
97
+ `)}var Vn=class extends d.Service()(`TerminalCapabilities`){static layer=i.succeed(this)({copyToClipboard:e=>n.sync(()=>{let t=Buffer.from(e).toString(`base64`);S.stdout.write(`\u001B]52;c;${t}\u0007`)}),isInteractive:n.sync(()=>S.stdin.isTTY&&S.stdout.isTTY)})},Q=class extends d.Service()(`Prompter`){static layerWithSpinner(e){return i.succeed(this)({cancel:e=>n.sync(()=>{T.cancel(e)}),confirm:e=>n.promise(()=>T.confirm(e)).pipe(n.filterOrFail(e=>!T.isCancel(e),()=>new ke({}))),intro:e=>n.sync(()=>{T.intro(e)}),log:{error:e=>n.sync(()=>{T.log.error(e)}),info:e=>n.sync(()=>{T.log.info(e)}),success:e=>n.sync(()=>{T.log.success(e)}),warning:e=>n.sync(()=>{T.log.warning(e)})},message:e=>n.sync(()=>{T.log.message(e,{spacing:0,withGuide:!1})}),multiselect:e=>n.promise(()=>T.multiselect(e)).pipe(n.filterOrFail(e=>!T.isCancel(e),()=>new ke({}))),note:(e,t)=>n.sync(()=>{T.note(e,t)}),outro:e=>n.sync(()=>{T.outro(e)}),select:e=>n.promise(()=>T.select(e)).pipe(n.filterOrFail(e=>!T.isCancel(e),()=>new ke({}))),withSpinner:(t,i)=>n.acquireUseRelease(n.sync(()=>{let t=e();return t.start(i.start),t}),e=>t({message:t=>n.sync(()=>{e.message(t)})}),(e,t)=>n.sync(()=>{e.stop(r.match(t,{onFailure:()=>i.failure,onSuccess:e=>_.isFunction(i.success)?i.success(e):i.success}))}))})}static layer=this.layerWithSpinner(T.spinner)};function Hn(e){let t=[`Current state\n${e.currentState}`,`Goal\n${e.goal.map(e=>`• ${e}`).join(`
98
98
  `)}`];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
99
  `)}`),t.join(`
100
100
 
101
- `)}const Un=n.fn(`printFindings`)(function*(e){let t=yield*Q;for(let[n,r]of e.entries())yield*t.note(Hn(r),`${n+1}. ${r.title}`)}),Wn=' .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 ',Gn=()=>n.gen(function*(){let e=yield*(yield*fe.Terminal).columns,t=Wn.split(`
102
- `).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*de.info(Wn))}),Kn=u.Boolean(`fix`).pipe(u.withDefault(!1),u.withDescription(`Removed. Run doctor and follow its findings`)),qn=`0.39.0`;var Jn=l.make(`doctor`,{fix:Kn}).pipe(l.withDescription(`Assess Adamantite-managed integrations in the current project`),l.withHandler(({fix:e})=>n.gen(function*(){let t=S.cwd(),r=yield*Q,i=yield*Vn,a=yield*i.isInteractive;a&&(yield*Gn(),yield*r.intro(`💠 adamantite doctor`));let o=n.gen(function*(){return yield*r.outro(`⚠️ Doctor found issues.`),yield*new O({command:`doctor`,exitCode:s.ExitCode(1)})});if(e){let e="`doctor --fix` has been removed. Run `adamantite doctor` and follow the reported goal criteria.";return a?(yield*r.log.error(e),yield*r.outro(`❌ Doctor did not run`)):yield*r.message(e),yield*new O({command:`doctor`,exitCode:s.ExitCode(1)})}let c=yield*z(t);if(!c.devDependencies?.adamantite&&!c.dependencies?.adamantite){let e="`adamantite` is not installed in this project. Install it before running `adamantite doctor`.";return a?(yield*r.log.warning(e),yield*r.outro(`⚠️ Doctor found issues.`)):yield*r.message(e),yield*new O({command:`doctor`,exitCode:s.ExitCode(1)})}let l=yield*Ln(t);if(a)for(let e of l.warnings)yield*r.log.warning(e);if(l.applicableIntegrations.length===0){a&&(yield*r.log.success(`No applicable integrations found.`),yield*r.outro(`✅ Doctor completed successfully!`));return}if(l.findings.length===0){a?(yield*r.log.success(`No issues found.`),yield*r.outro(`✅ Doctor completed successfully!`)):l.warnings.length>0&&(yield*r.message(Rn(l,qn)));return}if(!a)return yield*r.message(Rn(l,qn)),yield*new O({command:`doctor`,exitCode:s.ExitCode(1)});let u=e=>n.gen(function*(){(yield*r.confirm({initialValue:!0,message:`Copy the Markdown prompt for a coding agent?`}))&&(yield*r.message(e),yield*i.copyToClipboard(e),yield*r.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`))});yield*Un(l.findings);let d=yield*r.withSpinner(()=>zt(t),{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*r.log.info(`Doctor can hand findings off when one of these CLIs is installed: ${Rt.map(e=>`\`${e.command}\``).join(`, `)}.`));let f=Rn(l,qn),p=yield*r.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(p===`done`)return yield*o;if(p===`copy`)return yield*r.message(f),yield*i.copyToClipboard(f),yield*r.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`),yield*o;let m=p,h=yield*Wt(t);if(h!==`clean`&&(yield*r.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*r.confirm({initialValue:!1,message:`Hand off to ${m.name} anyway?`})))||(yield*r.log.info(`Handing the terminal to ${m.name}. Exit the agent to return to Doctor.`),!(yield*Ut({agent:m,cwd:t}).pipe(n.as(!0),n.catchTag(`AgentSessionFailed`,e=>r.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(n.as(!1)))))))return yield*u(f),yield*o;let g=yield*Ln(t);if(g.findings.length===0){yield*r.log.success(`All findings were resolved by ${m.name}.`),yield*r.outro(`✅ Doctor completed successfully!`);return}return yield*r.log.warning(`${g.findings.length} of ${l.findings.length} findings remain after the ${m.name} session.`),yield*Un(g.findings),yield*u(Rn(g,qn)),yield*o}).pipe(n.catchTag(`OperationCancelled`,()=>n.gen(function*(){return yield*(yield*Q).cancel(`Doctor was cancelled. The findings remain.`),yield*new O({command:`doctor`,exitCode:s.ExitCode(1)})})))));const Yn=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to fix (optional)`),w.variadic()),Xn=u.Boolean(`suggested`).pipe(u.withDefault(!1),u.withDescription(`Apply suggested fixes`)),Zn=u.Boolean(`dangerous`).pipe(u.withDefault(!1),u.withDescription(`Apply dangerous fixes`)),Qn=u.Boolean(`all`).pipe(u.withDefault(!1),u.withDescription(`Apply all fixes, including suggested and dangerous fixes`));var $n=l.make(`fix`,{all:Qn,dangerous:Zn,files:Yn,suggested:Xn}).pipe(l.withDescription(`Fix issues in code using oxlint`),l.withHandler(({all:e,dangerous:t,files:r,suggested:i})=>n.gen(function*(){let n=yield*j,a=yield*A,o=c.dedupe([`--fix`,...i||e?[`--fix-suggestions`]:[],...t||e?[`--fix-dangerously`]:[],...r]),l=yield*a.run({args:[...o,...n],command:U.name});l!==s.ExitCode(0)&&(yield*new O({command:U.name,exitCode:l}))})));const er=w.File(`files`,{mustExist:!0}).pipe(w.withDescription(`Specific files to format (optional)`),w.variadic()),tr=u.Boolean(`check`).pipe(u.withDefault(!1),u.withDescription(`Check if files are formatted without writing`));var nr=l.make(`format`,{check:tr,files:er}).pipe(l.withDescription(`Format files using oxfmt`),l.withHandler(({check:e,files:t})=>n.gen(function*(){let n=yield*j,r=yield*A,i=[];e&&i.push(`--check`),i.push(...t,...n);let a=yield*r.run({args:i,command:q.name});a!==s.ExitCode(0)&&(yield*new O({command:q.name,exitCode:a}))})));const rr=[{path:`.vscode/settings.json`,type:`config`}],ir={"[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:rr[0].path,create:e=>n.gen(function*(){let t=yield*x.Path,n=t.join(e,rr[0].path);yield*je(t.dirname(n)),yield*I(n,ir)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,rr[0].path))}),extension:(e=[])=>n.gen(function*(){let t=[];(e.includes(`check`)||e.includes(`fix`)||e.includes(`format`))&&t.push(`oxc.oxc-vscode`),e.includes(`analyze`)&&t.push(`webpro.vscode-knip`);for(let e of t){let t=yield*(yield*A).run({args:[`--install-extension`,e],command:`code`}).pipe(n.mapError(t=>t._tag===`CliNotFound`&&t.command===`code`?new Ae({cause:t}):new ye({cause:t,extension:e})));if(t!==s.ExitCode(0))return yield*new ye({cause:t,extension:e})}}),files:rr,kind:`editor`,name:`vscode`,update:e=>n.gen(function*(){let t=(yield*x.Path).join(e,rr[0].path),n=yield*N(t),r=yield*L(n,t);if(!_.isObject(r))return yield*new Te({path:t});let i=yield*Fe(ir,r);yield*I(t,i)})});const ar=`<!-- ADAMANTITE:START -->`,or=`<!-- ADAMANTITE:END -->`;function sr(e,t){let n=ue(e,t),r=B[t];switch(t){case`analyze`:return`- Run \`${n}\` after changing dependencies, imports, or exports. Direct command: \`${r}\`.`;case`check`:return`- Run \`${n}\` to catch lint and type issues. Direct command: \`${r}\`.`;case`check:monorepo`:return`- Run \`${n}\` to check monorepo package consistency. Direct command: \`${r}\`.`;case`fix`:return`- Run \`${n}\` to apply safe lint fixes. Direct command: \`${r}\`.`;case`fix:monorepo`:return`- Run \`${n}\` to fix monorepo package consistency. Direct command: \`${r}\`.`;case`format`:return`- Run \`${n}\` after editing files. Direct command: \`${r}\`.`}}function cr({packageManager:e,scripts:t}){let n=[`format`,`check`,`fix`,`analyze`,`check:monorepo`,`fix:monorepo`].filter(e=>t.includes(e)).map(t=>sr(e,t)),r=[`## Adamantite`,``,`This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.`,``,...n.length>0?[`- Prefer the package scripts Adamantite added for this workspace.`,...n]:[],"- Run `adamantite doctor` and follow its findings to repair managed setup."].join(`
103
- `);return[ar,``,r,``,or,``].join(`
104
- `)}const lr=(e,t)=>n.gen(function*(){let n=(yield*x.Path).join(e,`AGENTS.md`),r=h(yield*P(n),g.getOrElse(()=>``)),i=h(r,v.indexOf(ar)),a=h(r,v.indexOf(or)),o=h(g.all({end:a,start:i}),g.filter(({end:e,start:t})=>t<e)),s=cr(t);if(g.isSome(o)){let{end:e,start:t}=o.value,i=e+23,a=`${r.slice(0,t)}${s.trimEnd()}${r.slice(i)}`;return yield*F(n,a.endsWith(`
101
+ `)}const Un=n.fn(`printFindings`)(function*(e){let t=yield*Q;for(let[n,r]of e.entries())yield*t.note(Hn(r),`${n+1}. ${r.title}`)}),Wn=' .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 ',Gn=()=>n.gen(function*(){let e=yield*(yield*pe.Terminal).columns,t=Wn.split(`
102
+ `).reduce((e,t)=>Math.max(e,t.trim().length),0);!e||e<t||(yield*fe.info(Wn))}),Kn=`0.40.0`;var qn=l.make(`doctor`).pipe(l.withDescription(`Assess Adamantite-managed integrations in the current project`),l.withHandler(()=>n.gen(function*(){let e=S.cwd(),t=yield*Q,r=yield*Vn,i=yield*r.isInteractive;i&&(yield*Gn(),yield*t.intro(`💠 adamantite doctor`));let a=n.gen(function*(){return yield*t.outro(`⚠️ Doctor found issues.`),yield*new D({command:`doctor`,exitCode:s.ExitCode(1)})}),o=yield*R(e);if(!o.devDependencies?.adamantite&&!o.dependencies?.adamantite){let e="`adamantite` is not installed in this project. Install it before running `adamantite doctor`.";return i?(yield*t.log.warning(e),yield*t.outro(`⚠️ Doctor found issues.`)):yield*t.message(e),yield*new D({command:`doctor`,exitCode:s.ExitCode(1)})}let c=yield*Ln(e);if(i)for(let e of c.warnings)yield*t.log.warning(e);if(c.applicableIntegrations.length===0){i&&(yield*t.log.success(`No applicable integrations found.`),yield*t.outro(`✅ Doctor completed successfully!`));return}if(c.findings.length===0){i?(yield*t.log.success(`No issues found.`),yield*t.outro(`✅ Doctor completed successfully!`)):c.warnings.length>0&&(yield*t.message(Rn(c,Kn)));return}if(!i)return yield*t.message(Rn(c,Kn)),yield*new D({command:`doctor`,exitCode:s.ExitCode(1)});let l=e=>n.gen(function*(){(yield*t.confirm({initialValue:!0,message:`Copy the Markdown prompt for a coding agent?`}))&&(yield*t.message(e),yield*r.copyToClipboard(e),yield*t.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`))});yield*Un(c.findings);let u=yield*t.withSpinner(()=>Bt(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*t.log.info(`Doctor can hand findings off when one of these CLIs is installed: ${zt.map(e=>`\`${e.command}\``).join(`, `)}.`));let d=Rn(c,Kn),f=yield*t.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(f===`done`)return yield*a;if(f===`copy`)return yield*t.message(d),yield*r.copyToClipboard(d),yield*t.log.success(`The Markdown prompt was printed and sent to the terminal clipboard.`),yield*a;let p=f,m=yield*Gt(e);if(m!==`clean`&&(yield*t.log.warning(m===`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*t.confirm({initialValue:!1,message:`Hand off to ${p.name} anyway?`})))||(yield*t.log.info(`Handing the terminal to ${p.name}. Exit the agent to return to Doctor.`),!(yield*Wt({agent:p,cwd:e}).pipe(n.as(!0),n.catchTag(`AgentSessionFailed`,e=>t.log.error(e.reason===`not-found`?`\`${p.command}\` was not found on PATH. Install ${p.name} or copy the prompt instead.`:`Failed to start ${p.name}: ${e.cause.message}`).pipe(n.as(!1)))))))return yield*l(d),yield*a;let h=yield*Ln(e);if(h.findings.length===0){yield*t.log.success(`All findings were resolved by ${p.name}.`),yield*t.outro(`✅ Doctor completed successfully!`);return}return yield*t.log.warning(`${h.findings.length} of ${c.findings.length} findings remain after the ${p.name} session.`),yield*Un(h.findings),yield*l(Rn(h,Kn)),yield*a}).pipe(n.catchTag(`OperationCancelled`,()=>n.gen(function*(){return yield*(yield*Q).cancel(`Doctor was cancelled. The findings remain.`),yield*new D({command:`doctor`,exitCode:s.ExitCode(1)})})))));const Jn=C.File(`files`,{mustExist:!0}).pipe(C.withDescription(`Specific files to fix (optional)`),C.variadic()),Yn=u.Boolean(`suggested`).pipe(u.withDefault(!1),u.withDescription(`Apply suggested fixes`)),Xn=u.Boolean(`dangerous`).pipe(u.withDefault(!1),u.withDescription(`Apply dangerous fixes`)),Zn=u.Boolean(`all`).pipe(u.withDefault(!1),u.withDescription(`Apply all fixes, including suggested and dangerous fixes`));var Qn=l.make(`fix`,{all:Zn,dangerous:Xn,files:Jn,suggested:Yn}).pipe(l.withDescription(`Fix issues in code using oxlint`),l.withHandler(({all:e,dangerous:t,files:r,suggested:i})=>n.gen(function*(){let n=yield*A,a=yield*k,o=c.dedupe([`--fix`,...i||e?[`--fix-suggestions`]:[],...t||e?[`--fix-dangerously`]:[],...r]),l=yield*a.run({args:[...o,...n],command:H.name});l!==s.ExitCode(0)&&(yield*new D({command:H.name,exitCode:l}))})));const $n=C.File(`files`,{mustExist:!0}).pipe(C.withDescription(`Specific files to format (optional)`),C.variadic()),er=u.Boolean(`check`).pipe(u.withDefault(!1),u.withDescription(`Check if files are formatted without writing`));var tr=l.make(`format`,{check:er,files:$n}).pipe(l.withDescription(`Format files using oxfmt`),l.withHandler(({check:e,files:t})=>n.gen(function*(){let n=yield*A,r=yield*k,i=[];e&&i.push(`--check`),i.push(...t,...n);let a=yield*r.run({args:i,command:q.name});a!==s.ExitCode(0)&&(yield*new D({command:q.name,exitCode:a}))})));const nr=[`check`,`fix`,`format`,`check:monorepo`,`fix:monorepo`,`analyze`],rr=[`react`,`nextjs`,`vue`,`jest`,`vitest`,`node`,`antislop`],ir=[`vscode`,`zed`],ar=n.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:c.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:c.dedupe(e.presets),scripts:c.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new O({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes(`check`)||n.scripts.includes(`fix`);return(n.scripts.includes(`check:monorepo`)||n.scripts.includes(`fix:monorepo`))&&!t.isMonorepo?yield*new O({reason:`Monorepo scripts can only be selected in a detected monorepo.`}):n.presets.length>0&&!r?yield*new O({reason:"`--preset` requires the `check` or `fix` script."}):n.typescript&&!r?yield*new O({reason:"`--typescript` requires the `check` or `fix` script."}):n.installExtensions&&n.editors.length===0?yield*new O({reason:"`--install-extensions` requires at least one `--editor`."}):n.githubActions&&!Jt(n.scripts)?yield*new O({reason:"`--github-actions` requires a CI-compatible script."}):n.githubActions&&t.nonInteractive&&!Ve(t.packageManager)?yield*new O({reason:`\`--github-actions\` does not support the detected package manager \`${t.packageManager}\`. Use bun, deno, npm, pnpm, or yarn.`}):n}),or=u.Boolean(`non-interactive`).pipe(u.withDefault(!1),u.withDescription(`Configure without prompts; requires at least one --script`)),sr=u.Literals(`script`,nr).pipe(u.atMost(nr.length),u.withDescription(`Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo`)),cr=u.Literals(`preset`,rr).pipe(u.atMost(rr.length),u.withDescription(`Oxlint preset to configure; repeatable and requires --script check or fix`)),lr=u.Literals(`editor`,ir).pipe(u.atMost(ir.length),u.withDescription(`Editor to configure; may be specified multiple times`)),ur=u.Boolean(`typescript`).pipe(u.withDefault(!1),u.withDescription(`Configure the TypeScript preset; requires --script check or fix`)),dr=u.Boolean(`install-extensions`).pipe(u.withDefault(!1),u.withDescription(`Install recommended extensions; requires at least one --editor`)),fr=u.Boolean(`github-actions`).pipe(u.withDefault(!1),u.withDescription(`Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn`)),pr={agents:u.Boolean(`agents`).pipe(u.withDefault(!1),u.withDescription(`Add Adamantite guidance to AGENTS.md`)),editors:lr,githubActions:fr,installExtensions:dr,nonInteractive:or,overwriteScripts:u.Boolean(`overwrite-scripts`).pipe(u.withDefault(!1),u.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),presets:cr,scripts:sr,typescript:ur},mr=e=>`\`${e.script}\` is currently \`${e.command}\`; Adamantite would replace it with \`${z[e.script]}\`.`,hr=n.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 - find issues and type errors using oxlint`,value:`check`},{hint:`recommended`,label:`fix - fix code issues using oxlint`,value:`fix`},{hint:`recommended`,label:`format - code formatting using oxfmt`,value:`format`},{disabled:!t,hint:t?void 0:`available for monorepo projects`,label:`check:monorepo - check for monorepo-specific issues using Sherif`,value:`check:monorepo`},{disabled:!t,hint:t?void 0:`available for monorepo projects`,label:`fix:monorepo - fix monorepo-specific issues using Sherif`,value:`fix:monorepo`},{label:`analyze - find unused dependencies, exports, and files using knip`,value:`analyze`}]}),i=Ue(yield*R(e),r),a=!1;if(i.length>0){for(let e of i)yield*n.log.warning(mr(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=Jt(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}}),gr=[{path:`.vscode/settings.json`,type:`config`}],_r={"[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:gr[0].path,create:e=>n.gen(function*(){let t=yield*x.Path,n=t.join(e,gr[0].path);yield*Me(t.dirname(n)),yield*F(n,_r)}),detect:e=>n.gen(function*(){let t=yield*b.FileSystem,n=yield*x.Path;return yield*t.exists(n.join(e,gr[0].path))}),extension:(e=[])=>n.gen(function*(){let t=[];(e.includes(`check`)||e.includes(`fix`)||e.includes(`format`))&&t.push(`oxc.oxc-vscode`),e.includes(`analyze`)&&t.push(`webpro.vscode-knip`);for(let e of t){let t=yield*(yield*k).run({args:[`--install-extension`,e],command:`code`}).pipe(n.mapError(t=>t._tag===`CliNotFound`&&t.command===`code`?new je({cause:t}):new be({cause:t,extension:e})));if(t!==s.ExitCode(0))return yield*new be({cause:t,extension:e})}}),files:gr,kind:`editor`,name:`vscode`,update:e=>n.gen(function*(){let t=(yield*x.Path).join(e,gr[0].path),n=yield*M(t),r=yield*I(n,t);if(!_.isObject(r))return yield*new Ee({path:t});let i=yield*Ie(_r,r);yield*F(t,i)})});const vr=`<!-- ADAMANTITE:START -->`,yr=`<!-- ADAMANTITE:END -->`;function br(e,t){let n=de(e,t),r=z[t];switch(t){case`analyze`:return`- Run \`${n}\` after changing dependencies, imports, or exports. Direct command: \`${r}\`.`;case`check`:return`- Run \`${n}\` to catch lint and type issues. Direct command: \`${r}\`.`;case`check:monorepo`:return`- Run \`${n}\` to check monorepo package consistency. Direct command: \`${r}\`.`;case`fix`:return`- Run \`${n}\` to apply safe lint fixes. Direct command: \`${r}\`.`;case`fix:monorepo`:return`- Run \`${n}\` to fix monorepo package consistency. Direct command: \`${r}\`.`;case`format`:return`- Run \`${n}\` after editing files. Direct command: \`${r}\`.`}}function xr({packageManager:e,scripts:t}){let n=[`format`,`check`,`fix`,`analyze`,`check:monorepo`,`fix:monorepo`].filter(e=>t.includes(e)).map(t=>br(e,t)),r=[`## Adamantite`,``,`This project uses Adamantite for its managed formatting, linting, type checking, and dependency-analysis setup.`,``,...n.length>0?[`- Prefer the package scripts Adamantite added for this workspace.`,...n]:[],"- Run `adamantite doctor` and follow its findings to repair managed setup."].join(`
103
+ `);return[vr,``,r,``,yr,``].join(`
104
+ `)}const Sr=(e,t)=>n.gen(function*(){let n=(yield*x.Path).join(e,`AGENTS.md`),r=h(yield*N(n),g.getOrElse(()=>``)),i=h(r,v.indexOf(vr)),a=h(r,v.indexOf(yr)),o=h(g.all({end:a,start:i}),g.filter(({end:e,start:t})=>t<e)),s=xr(t);if(g.isSome(o)){let{end:e,start:t}=o.value,i=e+23,a=`${r.slice(0,t)}${s.trimEnd()}${r.slice(i)}`;return yield*P(n,a.endsWith(`
105
105
  `)?a:`${a}\n`),`updated`}if(g.isSome(i)||g.isSome(a))return`malformed`;let c=r.length===0||r.endsWith(`
106
106
 
107
107
  `)?``:r.endsWith(`
108
108
  `)?`
109
109
  `:`
110
110
 
111
- `;return yield*F(n,`${r}${c}${s}`),`updated`}),ur=(e,t)=>n.gen(function*(){let r=yield*W;yield*(yield*Q).withSpinner(()=>n.gen(function*(){let n=yield*An(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:n})}),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function dr(e,t,r){return n.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(a=>n.gen(function*(){let n=yield*t.detect(e);for(let e of n.warnings)yield*i.log.warning(e);return n.active===null?(yield*a.message(`\`${t.config}\` not found, creating...`),yield*r,{created:!0,legacyConfig:null}):n.active.format===`ts`?(yield*a.message(`Found \`${t.config}\`, keeping existing config.`),{created:!1,legacyConfig:null}):(yield*a.message(`Found \`${n.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:n.active.file})}),{failure:`Failed to set up ${t.name} config.`,start:`Setting up ${t.name} config...`,success:e=>e.created?`${t.name} config created successfully.`:`${t.name} config is ready.`});a.legacyConfig&&(yield*i.log.info(`Legacy \`${a.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor\` and follow its findings to migrate it to the latest ${t.name} config.`))})}const fr=e=>`\`${e.script}\` is currently \`${e.command}\`; Adamantite would replace it with \`${B[e.script]}\`.`,pr=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=yield*z(e),o=r.overwriteScripts?[]:He(a,t),s=new Set(o.map(e=>e.script)),c=t.filter(e=>!s.has(e));yield*i.withSpinner(()=>n.gen(function*(){if(c.length!==0){a.scripts??={};for(let e of c)a.scripts[e]=B[e];yield*ze(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 monorepo -- --ignore-dependency tailwindcss`.")),c}),mr=(e,t)=>n.gen(function*(){let r=yield*Q;if(t){yield*h(Mn,n.forEach(e=>r.log.info(e)));return}yield*r.withSpinner(t=>n.gen(function*(){return(yield*Z.detect(e))?(yield*t.message(`\`${Z.config}\` found, updating...`),yield*Z.update(e),!1):(yield*t.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`})}),hr=(e,t)=>n.gen(function*(){let r=yield*Q;t.includes(`vscode`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*$.detect(e);return yield*t.message(`\`${$.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?$.update(e):$.create(e),!n}),{failure:`Failed to set up VS Code config.`,start:`Checking for \`${$.config}\`...`,success:e=>`\`${$.config}\` ${e?`created`:`updated`} with Adamantite preset.`})),t.includes(`zed`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*K.detect(e);return yield*t.message(`\`${K.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?K.update(e):K.create(e),!n}),{failure:`Failed to set up Zed config.`,start:`Checking for \`${K.config}\`...`,success:e=>`\`${K.config}\` ${e?`created`:`updated`} with Adamantite preset.`}))}),gr=(e,t)=>n.gen(function*(){let r=yield*Q,i=e.includes(`zed`),a=e.includes(`vscode`);yield*r.withSpinner(e=>n.gen(function*(){return a&&(yield*e.message(`Installing VS Code extension...`),yield*$.extension(t)),!0}),{start:`Installing editor extensions...`,success:i&&!a?`Zed extensions require manual install.`:`Editor extensions installed successfully.`}).pipe(n.catchTag(`FailedToInstallExtension`,e=>n.gen(function*(){return yield*r.log.warning(`⚠️ ${e.message}`),yield*r.log.warning(`Please install it manually after setup completes.`),!1})),n.catchTag(`VscodeCliNotFound`,()=>n.gen(function*(){return yield*r.log.error(`VSCode CLI ('code' command) not found.`),yield*r.log.info(`To install it:`),yield*r.log.info(` 1. Open VS Code`),yield*r.log.info(` 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)`),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),i&&(yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc"))}),_r=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=hn.files[0].path;yield*i.withSpinner(i=>n.gen(function*(){let n=yield*hn.detect(e);return yield*i.message(n?`\`${a}\` found, updating...`:`Creating \`${a}\`...`),yield*n?hn.update(e,{packageManager:t,scripts:r}):hn.create(e,{packageManager:t,scripts:r}),!n}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e?`created`:`updated`} successfully.`})}).pipe(n.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>n.gen(function*(){let t=yield*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.")}))),vr=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(()=>lr(e,{packageManager:t,scripts:r}),{failure:`Failed to update AGENTS.md.`,start:`Updating AGENTS.md...`,success:`AGENTS.md check complete.`}).pipe(n.catchTag([`FailedToReadFile`,`FailedToWriteFile`],e=>n.gen(function*(){return yield*i.log.warning(`Could not update AGENTS.md. ${e.message} Adamantite will continue initialization.`),`failed`})));a!==`failed`&&a===`malformed`&&(yield*i.log.warning(`Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.`))}),yr=[`check`,`fix`,`format`,`check:monorepo`,`fix:monorepo`,`analyze`],br=[`react`,`nextjs`,`vue`,`jest`,`vitest`,`node`,`antislop`],xr=[`vscode`,`zed`],Sr=n.fn(`validateInitOptions`)(function*(e,t){let n={agents:e.agents,editors:c.dedupe(e.editors),githubActions:e.githubActions,installExtensions:e.installExtensions,overwriteScripts:e.overwriteScripts,presets:c.dedupe(e.presets),scripts:c.dedupe(e.scripts),typescript:e.typescript};if(n.scripts.length===0)return yield*new k({reason:"Select at least one script with `--script <name>`."});let r=n.scripts.includes(`check`)||n.scripts.includes(`fix`);return(n.scripts.includes(`check:monorepo`)||n.scripts.includes(`fix:monorepo`))&&!t.isMonorepo?yield*new k({reason:`Monorepo scripts can only be selected in a detected monorepo.`}):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&&!qt(n.scripts)?yield*new k({reason:"`--github-actions` requires a CI-compatible script."}):n.githubActions&&t.nonInteractive&&!Be(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}),Cr=u.Boolean(`non-interactive`).pipe(u.withDefault(!1),u.withDescription(`Configure without prompts; requires at least one --script`)),wr=u.Literals(`script`,yr).pipe(u.atMost(yr.length),u.withDescription(`Package script to configure; repeatable and required in non-interactive mode. Monorepo scripts require a detected monorepo`)),Tr=u.Literals(`preset`,br).pipe(u.atMost(br.length),u.withDescription(`Oxlint preset to configure; repeatable and requires --script check or fix`)),Er=u.Literals(`editor`,xr).pipe(u.atMost(xr.length),u.withDescription(`Editor to configure; may be specified multiple times`)),Dr=u.Boolean(`typescript`).pipe(u.withDefault(!1),u.withDescription(`Configure the TypeScript preset; requires --script check or fix`)),Or=u.Boolean(`install-extensions`).pipe(u.withDefault(!1),u.withDescription(`Install recommended extensions; requires at least one --editor`)),kr=u.Boolean(`github-actions`).pipe(u.withDefault(!1),u.withDescription(`Configure CI; requires a compatible script and bun, deno, npm, pnpm, or yarn`)),Ar=u.Boolean(`agents`).pipe(u.withDefault(!1),u.withDescription(`Add Adamantite guidance to AGENTS.md`)),jr=u.Boolean(`overwrite-scripts`).pipe(u.withDefault(!1),u.withDescription(`Replace existing package scripts that conflict with Adamantite's managed commands`)),Mr=n.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 - find issues and type errors using oxlint`,value:`check`},{hint:`recommended`,label:`fix - fix code issues using oxlint`,value:`fix`},{hint:`recommended`,label:`format - code formatting using oxfmt`,value:`format`},{disabled:!t,hint:t?void 0:`available for monorepo projects`,label:`check:monorepo - check for monorepo-specific issues using Sherif`,value:`check:monorepo`},{disabled:!t,hint:t?void 0:`available for monorepo projects`,label:`fix:monorepo - fix monorepo-specific issues using Sherif`,value:`fix:monorepo`},{label:`analyze - find unused dependencies, exports, and files using knip`,value:`analyze`}]}),i=He(yield*z(e),r),a=!1;if(i.length>0){for(let e of i)yield*n.log.warning(fr(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=qt(r)?yield*n.confirm({message:`Do you want to add a GitHub Actions workflow to run checks in CI?`}):!1;return{agents:yield*n.confirm({initialValue:!0,message:`Add Adamantite guidance to AGENTS.md so coding agents know how to run project checks?`}),editors:l,githubActions:d,installExtensions:u,overwriteScripts:a,presets:s,scripts:r,typescript:c}});var Nr=l.make(`init`,{agents:Ar,editors:Er,githubActions:kr,installExtensions:Or,nonInteractive:Cr,overwriteScripts:jr,presets:Tr,scripts:wr,typescript:Dr}).pipe(l.withDescription(`Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled`),l.withExamples([{command:`adamantite init --non-interactive --script check`,description:`Configure linting without prompts`},{command:`adamantite init --non-interactive --script check --script format --preset react --editor vscode --typescript --install-extensions --github-actions --agents`,description:`Configure a React project with VS Code, TypeScript, CI, and agent guidance`},{command:`adamantite init --non-interactive --script check:monorepo`,description:`Configure monorepo checks in a detected monorepo`}]),l.withHandler(e=>n.gen(function*(){let t=S.cwd(),n=yield*Q;yield*Gn(),yield*n.intro(`💠 adamantite init`);let r=yield*(yield*W).detectPackageManager(t);if(!r)return yield*new De({});if(r.warnings?.length)for(let e of r.warnings)yield*n.log.warning(e);yield*n.log.info(`Detected package manager: ${r.name}`);let i=yield*An(t);if(i&&(yield*n.log.info(`We've detected a monorepo setup in your project.`)),!e.nonInteractive&&c.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],_.isTruthy))return yield*new k({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*Mr(t,i),o=yield*Sr(a,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:r.name}),s=o.scripts,l=o.presets,u=o.editors,d=o.typescript,f=o.installExtensions,p=o.githubActions,m=o.agents,h=s.includes(`check`)||s.includes(`fix`),g=s.includes(`format`),v=s.includes(`check:monorepo`)||s.includes(`fix:monorepo`),ee=s.includes(`analyze`),y=[`adamantite`];h&&y.push(`${U.name}@${U.version}`,`${En.name}@${En.version}`),g&&y.push(`${q.name}@${q.version}`),v&&y.push(`${J.name}@${J.version}`),ee&&y.push(`${V.name}@${V.version}`),yield*ur(t,y),g&&(yield*dr(t,q,q.create(t))),h&&(yield*dr(t,U,U.create(t,l))),ee&&(yield*dr(t,V,V.create(t)));let b=yield*pr(t,s,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(m&&(yield*vr(t,r.name,b)),d&&(yield*mr(t,i)),yield*hr(t,u),f&&(yield*gr(u,s)),p){let e=r.name;Be(e)?yield*_r(t,e,s):yield*n.log.warning(`Skipping GitHub Actions setup: \`${e}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success(`Your project is now configured`),yield*n.outro(`💠 Adamantite initialized successfully!`)}).pipe(n.catchTags({OperationCancelled:()=>n.gen(function*(){yield*(yield*Q).cancel(`You've cancelled the initialization process.`)})}))));const Pr=u.Boolean(`fix`).pipe(u.withDefault(!1),u.withDescription(`Automatically fix issues`));var Fr=l.make(`monorepo`,{fix:Pr}).pipe(l.withDescription(`Find and fix monorepo-specific issues using Sherif`),l.withHandler(({fix:e})=>n.gen(function*(){let t=yield*j,n=yield*A,r=e?[`--fix`,...t]:[...t],i=yield*n.run({args:r,command:J.name,stdin:`inherit`});i!==s.ExitCode(0)&&(yield*new O({command:J.name,exitCode:i}))})));const Ir=[U,En,q,J,V];function Lr(e,t){return c.filterMap(Ir,n=>{if(t.has(n.name))return C.failVoid;let r=e.devDependencies?.[n.name]??e.dependencies?.[n.name];return r&&Re(r)!==n.version?C.succeed({currentVersion:r,name:n.name,targetVersion:n.version}):C.failVoid})}var Rr=l.make(`update`).pipe(l.withDescription(`Update Adamantite-managed dependencies and report setup findings`),l.withHandler(()=>n.gen(function*(){let e=S.cwd(),t=yield*Q,n=yield*W;yield*Gn(),yield*t.intro(`💠 adamantite update`);let r=yield*z(e),i=yield*Ln(e,r),a=i.packageActions,o=new Set(a.map(e=>e.package)),s=[...a.map(e=>({currentVersion:e.type===`install_package`?`not installed`:e.currentVersion,name:e.package,targetVersion:e.targetVersion})),...Lr(r,o)];if(s.length>0){yield*t.log.info(`The following dependencies will be updated:`);for(let e of s)yield*t.log.info(` ${e.name}: ${e.currentVersion} → ${e.targetVersion}`);yield*t.withSpinner(()=>n.addDevDependencies(s.map(e=>`${e.name}@${e.targetVersion}`),e,{silent:!0}),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated successfully`}),yield*t.log.success(`Dependencies updated successfully.`)}let c=s.length===0?i:yield*Ln(e);for(let e of c.warnings)yield*t.log.warning(e);let l=c.findings;return l.length>0&&(yield*Un(l),yield*t.log.info("Run `adamantite doctor` to get the combined Markdown repair prompt.")),s.length===0&&l.length===0?(yield*t.log.success(`No changes needed.`),`no-changes`):`success`}).pipe(n.tapError(()=>n.gen(function*(){yield*(yield*Q).outro(`❌ Update failed`)})),n.tap(e=>n.gen(function*(){yield*(yield*Q).outro(e===`no-changes`?`✅ Adamantite is already up to date.`:`✅ Update completed successfully!`)})))));const zr=[lt,Lt,$n,nr,Fr],Br=[lt,Lt,Jn,$n,nr,Nr,Fr,Rr],Vr=new Set(Br.map(e=>e.name)),Hr=new Set(zr.map(e=>e.name)),Ur=l.make(`adamantite`).pipe(l.withDescription(`Opinionated preset package for modern TypeScript applications`),l.withSubcommands(Br)),Wr=n.fn(`runCli`)(function*(e,t){let[r,i]=c.splitWhere(e,e=>e===`--`),a=c.drop(i,1),o=r.find(e=>Vr.has(e));if(a.length>0&&o!==void 0&&!Hr.has(o))return yield*new ke({command:o});yield*l.runWith(Ur,{version:t})(r).pipe(n.provideService(j,a))}),Gr=n.gen(function*(){let e=yield*(yield*o.Stdio).args;yield*Wr(e,`0.39.0`)}).pipe(n.as(0),n.catchTag(`CommandFailed`,e=>n.succeed(e.exitCode)),n.catch(e=>n.service(Q).pipe(n.flatMap(t=>t.log.error(e.message)),n.as(s.ExitCode(1)))),n.provide(i.mergeAll(t.layer,rn.layer.pipe(i.provide(t.layer)),Q.layer,A.layer,W.layer,Vn.layer)));e.runMain(Gr,{teardown:(e,t)=>{if(r.isSuccess(e)){t(Number(e.value));return}a.defaultTeardown(e,t)}});export{};
111
+ `;return yield*P(n,`${r}${c}${s}`),`updated`}),Cr=(e,t)=>n.gen(function*(){let r=yield*U;yield*(yield*Q).withSpinner(()=>n.gen(function*(){let n=yield*An(e);yield*r.addDevDependencies(t,e,{silent:!0,workspace:n})}),{failure:`Failed to install dependencies.`,start:`Installing dependencies...`,success:`Dependencies installed.`})});function wr(e,t,r){return n.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(a=>n.gen(function*(){let n=yield*t.detect(e);for(let e of n.warnings)yield*i.log.warning(e);return n.active===null?(yield*a.message(`\`${t.config}\` not found, creating...`),yield*r,{created:!0,legacyConfig:null}):n.active.format===`ts`?(yield*a.message(`Found \`${t.config}\`, keeping existing config.`),{created:!1,legacyConfig:null}):(yield*a.message(`Found \`${n.active.file}\`, keeping existing config.`),{created:!1,legacyConfig:n.active.file})}),{failure:`Failed to set up ${t.name} config.`,start:`Setting up ${t.name} config...`,success:e=>e.created?`${t.name} config created successfully.`:`${t.name} config is ready.`});a.legacyConfig&&(yield*i.log.info(`Legacy \`${a.legacyConfig}\` was preserved during \`adamantite init\`. Run \`adamantite doctor\` and follow its findings to migrate it to the latest ${t.name} config.`))})}const Tr=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=yield*R(e),o=r.overwriteScripts?[]:Ue(a,t),s=new Set(o.map(e=>e.script)),c=t.filter(e=>!s.has(e));yield*i.withSpinner(()=>n.gen(function*(){if(c.length!==0){a.scripts??={};for(let e of c)a.scripts[e]=z[e];yield*Be(e,a)}}),{failure:"Failed to add scripts to `package.json`.",start:"Adding scripts to your `package.json`...",success:o.length===0?"Scripts added to your `package.json`":c.length===0?"Kept your existing `package.json` scripts.":"Scripts added to your `package.json`; conflicting scripts were kept."});let l=r.nonInteractive?"Use `--overwrite-scripts` to replace it.":"Re-run `adamantite init` and confirm overwriting to replace it.";for(let e of o)yield*i.log.warning(`Kept existing \`${e.script}\` script (\`${e.command}\`) instead of \`${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 monorepo -- --ignore-dependency tailwindcss`.")),c}),Er=(e,t)=>n.gen(function*(){let r=yield*Q;if(t){yield*h(Mn,n.forEach(e=>r.log.info(e)));return}yield*r.withSpinner(t=>n.gen(function*(){return(yield*Z.detect(e))?(yield*t.message(`\`${Z.config}\` found, updating...`),yield*Z.update(e),!1):(yield*t.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`})}),Dr=(e,t)=>n.gen(function*(){let r=yield*Q;t.includes(`vscode`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*$.detect(e);return yield*t.message(`\`${$.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?$.update(e):$.create(e),!n}),{failure:`Failed to set up VS Code config.`,start:`Checking for \`${$.config}\`...`,success:e=>`\`${$.config}\` ${e?`created`:`updated`} with Adamantite preset.`})),t.includes(`zed`)&&(yield*r.withSpinner(t=>n.gen(function*(){let n=yield*K.detect(e);return yield*t.message(`\`${K.config}\` ${n?`found, updating`:`not found, creating`}...`),yield*n?K.update(e):K.create(e),!n}),{failure:`Failed to set up Zed config.`,start:`Checking for \`${K.config}\`...`,success:e=>`\`${K.config}\` ${e?`created`:`updated`} with Adamantite preset.`}))}),Or=(e,t)=>n.gen(function*(){let r=yield*Q,i=e.includes(`zed`),a=e.includes(`vscode`);yield*r.withSpinner(e=>n.gen(function*(){return a&&(yield*e.message(`Installing VS Code extension...`),yield*$.extension(t)),!0}),{start:`Installing editor extensions...`,success:i&&!a?`Zed extensions require manual install.`:`Editor extensions installed successfully.`}).pipe(n.catchTag(`FailedToInstallExtension`,e=>n.gen(function*(){return yield*r.log.warning(`⚠️ ${e.message}`),yield*r.log.warning(`Please install it manually after setup completes.`),!1})),n.catchTag(`VscodeCliNotFound`,()=>n.gen(function*(){return yield*r.log.error(`VSCode CLI ('code' command) not found.`),yield*r.log.info(`To install it:`),yield*r.log.info(` 1. Open VS Code`),yield*r.log.info(` 2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)`),yield*r.log.info(` 3. Run 'Shell Command: Install "code" command in PATH'`),!1}))),i&&(yield*r.log.info("Install the Zed `oxc` extension: zed://extension/oxc"))}),kr=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=W.files[0].path;yield*i.withSpinner(i=>n.gen(function*(){let n=yield*W.detect(e);return yield*i.message(n?`\`${a}\` found, updating...`:`Creating \`${a}\`...`),yield*n?W.update(e,{packageManager:t,scripts:r}):W.create(e,{packageManager:t,scripts:r}),!n}),{failure:`Failed to set up GitHub Actions workflow.`,start:`Setting up GitHub Actions workflow...`,success:e=>`GitHub Actions workflow ${e?`created`:`updated`} successfully.`})}).pipe(n.catchTag([`FailedToCreateDirectory`,`FailedToParseFile`,`FailedToReadFile`,`FailedToWriteFile`,`PlatformError`],e=>n.gen(function*(){let t=yield*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.")}))),Ar=(e,t,r)=>n.gen(function*(){let i=yield*Q,a=yield*i.withSpinner(()=>Sr(e,{packageManager:t,scripts:r}),{failure:`Failed to update AGENTS.md.`,start:`Updating AGENTS.md...`,success:`AGENTS.md check complete.`}).pipe(n.catchTag([`FailedToReadFile`,`FailedToWriteFile`],e=>n.gen(function*(){return yield*i.log.warning(`Could not update AGENTS.md. ${e.message} Adamantite will continue initialization.`),`failed`})));a!==`failed`&&a===`malformed`&&(yield*i.log.warning(`Could not update AGENTS.md because Adamantite markers are incomplete. Remove the stale ADAMANTITE marker and run adamantite init again.`))});var jr=l.make(`init`,pr).pipe(l.withDescription(`Initialize Adamantite in the current directory. Setup flags require --non-interactive; omitted boolean setup flags are disabled`),l.withExamples([{command:`adamantite init --non-interactive --script check`,description:`Configure linting without prompts`},{command:`adamantite init --non-interactive --script check --script format --preset react --editor vscode --typescript --install-extensions --github-actions --agents`,description:`Configure a React project with VS Code, TypeScript, CI, and agent guidance`},{command:`adamantite init --non-interactive --script check:monorepo`,description:`Configure monorepo checks in a detected monorepo`}]),l.withHandler(e=>n.gen(function*(){let t=S.cwd(),n=yield*Q;yield*Gn(),yield*n.intro(`💠 adamantite init`);let r=yield*(yield*U).detectPackageManager(t);if(!r)return yield*new Oe({});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*An(t);if(i&&(yield*n.log.info(`We've detected a monorepo setup in your project.`)),!e.nonInteractive&&c.some([e.scripts.length>0,e.presets.length>0,e.editors.length>0,e.typescript,e.installExtensions,e.githubActions,e.agents,e.overwriteScripts],_.isTruthy))return yield*new O({reason:"Setup flags require `--non-interactive`."});let a=e.nonInteractive?e:yield*hr(t,i),o=yield*ar(a,{isMonorepo:i,nonInteractive:e.nonInteractive,packageManager:r.name}),s=o.scripts,l=o.presets,u=o.editors,d=o.typescript,f=o.installExtensions,p=o.githubActions,m=o.agents,h=s.includes(`check`)||s.includes(`fix`),g=s.includes(`format`),v=s.includes(`check:monorepo`)||s.includes(`fix:monorepo`),ee=s.includes(`analyze`),y=[`adamantite`];h&&y.push(`${H.name}@${H.version}`,`${En.name}@${En.version}`),g&&y.push(`${q.name}@${q.version}`),v&&y.push(`${J.name}@${J.version}`),ee&&y.push(`${B.name}@${B.version}`),yield*Cr(t,y),g&&(yield*wr(t,q,q.create(t))),h&&(yield*wr(t,H,H.create(t,l))),ee&&(yield*wr(t,B,B.create(t)));let b=yield*Tr(t,s,{nonInteractive:e.nonInteractive,overwriteScripts:o.overwriteScripts});if(m&&(yield*Ar(t,r.name,b)),d&&(yield*Er(t,i)),yield*Dr(t,u),f&&(yield*Or(u,s)),p){let e=r.name;Ve(e)?yield*kr(t,e,s):yield*n.log.warning(`Skipping GitHub Actions setup: \`${e}\` is not a supported package manager for CI workflow generation.`)}yield*n.log.success(`Your project is now configured`),yield*n.outro(`💠 Adamantite initialized successfully!`)}).pipe(n.catchTags({OperationCancelled:()=>n.gen(function*(){yield*(yield*Q).cancel(`You've cancelled the initialization process.`)})}))));const Mr=u.Boolean(`fix`).pipe(u.withDefault(!1),u.withDescription(`Automatically fix issues`));var Nr=l.make(`monorepo`,{fix:Mr}).pipe(l.withDescription(`Find and fix monorepo-specific issues using Sherif`),l.withHandler(({fix:e})=>n.gen(function*(){let t=yield*A,n=yield*k,r=e?[`--fix`,...t]:[...t],i=yield*n.run({args:r,command:J.name,stdin:`inherit`});i!==s.ExitCode(0)&&(yield*new D({command:J.name,exitCode:i}))})));const Pr=[H,En,q,J,B];function Fr(e,t){return c.filterMap(Pr,n=>{if(t.has(n.name))return ne.failVoid;let r=e.devDependencies?.[n.name]??e.dependencies?.[n.name];return r&&ze(r)!==n.version?ne.succeed({currentVersion:r,name:n.name,targetVersion:n.version}):ne.failVoid})}var Ir=l.make(`update`).pipe(l.withDescription(`Update Adamantite-managed dependencies and report setup findings`),l.withHandler(()=>n.gen(function*(){let e=S.cwd(),t=yield*Q,n=yield*U;yield*Gn(),yield*t.intro(`💠 adamantite update`);let r=yield*R(e),i=yield*Ln(e,r),a=i.packageActions,o=new Set(a.map(e=>e.package)),s=[...a.map(e=>({currentVersion:e.type===`install_package`?`not installed`:e.currentVersion,name:e.package,targetVersion:e.targetVersion})),...Fr(r,o)];if(s.length>0){yield*t.log.info(`The following dependencies will be updated:`);for(let e of s)yield*t.log.info(` ${e.name}: ${e.currentVersion} → ${e.targetVersion}`);yield*t.withSpinner(()=>n.addDevDependencies(s.map(e=>`${e.name}@${e.targetVersion}`),e,{silent:!0}),{failure:`Failed to update dependencies`,start:`Updating dependencies...`,success:`Dependencies updated successfully`}),yield*t.log.success(`Dependencies updated successfully.`)}let c=s.length===0?i:yield*Ln(e);for(let e of c.warnings)yield*t.log.warning(e);let l=c.findings;return l.length>0&&(yield*Un(l),yield*t.log.info("Run `adamantite doctor` to get the combined Markdown repair prompt.")),s.length===0&&l.length===0?(yield*t.log.success(`No changes needed.`),`no-changes`):`success`}).pipe(n.tapError(()=>n.gen(function*(){yield*(yield*Q).outro(`❌ Update failed`)})),n.tap(e=>n.gen(function*(){yield*(yield*Q).outro(e===`no-changes`?`✅ Adamantite is already up to date.`:`✅ Update completed successfully!`)})))));const Lr=[ut,Rt,Qn,tr,Nr],Rr=[ut,Rt,qn,Qn,tr,jr,Nr,Ir],zr=new Set(Rr.map(e=>e.name)),Br=new Set(Lr.map(e=>e.name)),Vr=l.make(`adamantite`).pipe(l.withDescription(`Opinionated preset package for modern TypeScript applications`),l.withSubcommands(Rr)),Hr=n.fn(`runCli`)(function*(e,t){let[r,i]=c.splitWhere(e,e=>e===`--`),a=c.drop(i,1),o=r.find(e=>zr.has(e));if(a.length>0&&o!==void 0&&!Br.has(o))return yield*new Ae({command:o});yield*l.runWith(Vr,{version:t})(r).pipe(n.provideService(A,a))}),Ur=n.gen(function*(){let e=yield*(yield*o.Stdio).args;yield*Hr(e,`0.40.0`)}).pipe(n.as(0),n.catchTag(`CommandFailed`,e=>n.succeed(e.exitCode)),n.catch(e=>n.service(Q).pipe(n.flatMap(t=>t.log.error(e.message)),n.as(s.ExitCode(1)))),n.provide(i.mergeAll(t.layer,an.layer.pipe(i.provide(t.layer)),Q.layer,k.layer,U.layer,Vn.layer)));e.runMain(Ur,{teardown:(e,t)=>{if(r.isSuccess(e)){t(Number(e.value));return}a.defaultTeardown(e,t)}});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adamantite",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "An strict and opinionated set of presets for modern TypeScript applications",
5
5
  "keywords": [
6
6
  "adamantite",
@@ -78,7 +78,7 @@
78
78
  "figlet": "1.11.4",
79
79
  "knip": "6.32.2",
80
80
  "oxfmt": "0.65.0",
81
- "oxlint": "1.79.0",
81
+ "oxlint": "1.83.0",
82
82
  "oxlint-tsgolint": "7.0.2001",
83
83
  "sherif": "1.13.0",
84
84
  "tsdown": "0.22.14",