facult 2.13.3 → 2.13.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/self-update.ts +49 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "facult",
3
- "version": "2.13.3",
3
+ "version": "2.13.5",
4
4
  "description": "Manage canonical AI capabilities, sync surfaces, and evolution state.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -187,13 +187,17 @@ export function looksLikeMiseShim(
187
187
  }
188
188
 
189
189
  async function activeFcltUsesMiseNpmFacult(): Promise<boolean> {
190
- if (!Bun.which("mise")) {
190
+ const misePath = Bun.which("mise") ?? (await resolveCommandPath("mise"));
191
+ if (!misePath) {
191
192
  return false;
192
193
  }
193
- const fcltPath = Bun.which("fclt");
194
+ const fcltPath = Bun.which("fclt") ?? (await resolveCommandPath("fclt"));
194
195
  if (looksLikeMiseNpmFacultExecutable(fcltPath ?? "")) {
195
196
  return true;
196
197
  }
198
+ if (await miseHasCurrentFacultTool()) {
199
+ return true;
200
+ }
197
201
  if (!looksLikeMiseShim(fcltPath)) {
198
202
  return false;
199
203
  }
@@ -214,6 +218,35 @@ async function activeFcltUsesMiseNpmFacult(): Promise<boolean> {
214
218
  return looksLikeMiseNpmFacultExecutable(stdout.trim());
215
219
  }
216
220
 
221
+ async function miseHasCurrentFacultTool(): Promise<boolean> {
222
+ const proc = Bun.spawn({
223
+ cmd: ["mise", "current", `npm:${PACKAGE_NAME}`],
224
+ stdin: "ignore",
225
+ stdout: "ignore",
226
+ stderr: "ignore",
227
+ env: process.env,
228
+ });
229
+ return (await proc.exited) === 0;
230
+ }
231
+
232
+ async function resolveCommandPath(command: string): Promise<string | null> {
233
+ const proc = Bun.spawn({
234
+ cmd: ["sh", "-lc", `command -v ${command}`],
235
+ stdin: "ignore",
236
+ stdout: "pipe",
237
+ stderr: "ignore",
238
+ env: process.env,
239
+ });
240
+ const [stdout, code] = await Promise.all([
241
+ new Response(proc.stdout).text(),
242
+ proc.exited,
243
+ ]);
244
+ if (code !== 0) {
245
+ return null;
246
+ }
247
+ return stdout.trim() || null;
248
+ }
249
+
217
250
  function resolvePlatformTarget(): {
218
251
  platform: string;
219
252
  arch: string;
@@ -278,6 +311,7 @@ async function writeInstallState(args: {
278
311
  method: InstallMethod;
279
312
  packageVersion?: string;
280
313
  binaryPath?: string;
314
+ packageManager?: string;
281
315
  }) {
282
316
  const dir = dirname(facultInstallStatePath(args.home));
283
317
  await mkdir(dir, { recursive: true });
@@ -286,7 +320,11 @@ async function writeInstallState(args: {
286
320
  method: args.method,
287
321
  packageVersion: args.packageVersion,
288
322
  binaryPath: args.binaryPath,
289
- source: args.method === "npm-binary-cache" ? "npm" : "direct",
323
+ packageManager: args.packageManager,
324
+ source:
325
+ args.method === "npm-binary-cache" || args.method === "mise-npm"
326
+ ? "npm"
327
+ : "direct",
290
328
  installedAt: new Date().toISOString(),
291
329
  };
292
330
  await Bun.write(
@@ -412,6 +450,7 @@ async function resolvePackageTargetVersion(requestedVersion?: string): Promise<{
412
450
  }
413
451
 
414
452
  async function selfUpdateViaPackageManager(args: {
453
+ home: string;
415
454
  requestedVersion?: string;
416
455
  dryRun: boolean;
417
456
  preferredPackageManager?: string;
@@ -450,6 +489,12 @@ async function selfUpdateViaPackageManager(args: {
450
489
  await runBestEffort(["mise", "reshim", `npm:${PACKAGE_NAME}`]);
451
490
  }
452
491
  await assertActiveFcltVersion(target.version, pm);
492
+ await writeInstallState({
493
+ home: args.home,
494
+ method: pm === "mise" ? "mise-npm" : "npm-binary-cache",
495
+ packageVersion: target.version,
496
+ packageManager: pm,
497
+ });
453
498
  console.log(`Updated fclt via ${pm}: ${PACKAGE_NAME}@${target.version}`);
454
499
  if (target.resolvedFromLatest) {
455
500
  console.log(`Resolved latest release to ${target.version}`);
@@ -603,6 +648,7 @@ export async function selfUpdateCommand(argv: string[]) {
603
648
  if (method === "npm-binary-cache" || method === "mise-npm") {
604
649
  await selfUpdateViaPackageManager({
605
650
  ...parsed,
651
+ home,
606
652
  method,
607
653
  preferredPackageManager:
608
654
  process.env.FACULT_INSTALL_PM?.trim() || state?.packageManager,