@muggleai/works 5.16.0 → 5.17.0-staging.113

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 (35) hide show
  1. package/README.md +3 -0
  2. package/dist/{chunk-FK7XVMVA.js → chunk-6ILUPFM5.js} +188 -4
  3. package/dist/{chunk-VQZLKLAY.js → chunk-EKSYEVM2.js} +279 -2
  4. package/dist/cli.js +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/plugin/config/onboarding-limits.json +3 -0
  7. package/dist/plugin/config/preference-defaults.json +25 -0
  8. package/dist/plugin/scripts/ensure-electron-app.sh +36 -21
  9. package/dist/plugin/skills/muggle/SKILL.md +1 -1
  10. package/dist/plugin/skills/muggle-preferences/SKILL.md +3 -2
  11. package/dist/plugin/skills/muggle-preferences/ops/configure.md +4 -3
  12. package/dist/plugin/skills/muggle-preferences/ops/list.md +2 -1
  13. package/dist/plugin/skills/muggle-preferences/ops/onboard.md +54 -0
  14. package/dist/plugin/skills/muggle-preferences/preference-gates/README.md +7 -5
  15. package/dist/plugin/skills/muggle-preferences/preference-gates/autoResolveConflicts.md +1 -1
  16. package/dist/plugin/skills/muggle-test-prepare/steps/check-running.md +1 -1
  17. package/dist/plugin/skills/muggle-test-prepare/steps/reuse-plan.md +1 -1
  18. package/dist/release-manifest.json +3 -3
  19. package/dist/src-52J7RTUV.js +1 -0
  20. package/package.json +3 -2
  21. package/plugin/config/onboarding-limits.json +3 -0
  22. package/plugin/config/preference-defaults.json +25 -0
  23. package/plugin/scripts/ensure-electron-app.sh +36 -21
  24. package/plugin/skills/muggle/SKILL.md +1 -1
  25. package/plugin/skills/muggle-preferences/SKILL.md +3 -2
  26. package/plugin/skills/muggle-preferences/ops/configure.md +4 -3
  27. package/plugin/skills/muggle-preferences/ops/list.md +2 -1
  28. package/plugin/skills/muggle-preferences/ops/onboard.md +54 -0
  29. package/plugin/skills/muggle-preferences/preference-gates/README.md +7 -5
  30. package/plugin/skills/muggle-preferences/preference-gates/autoResolveConflicts.md +1 -1
  31. package/plugin/skills/muggle-test-prepare/steps/check-running.md +1 -1
  32. package/plugin/skills/muggle-test-prepare/steps/reuse-plan.md +1 -1
  33. package/scripts/onboarding-backfill.mjs +49 -0
  34. package/scripts/postinstall.mjs +12 -0
  35. package/dist/src-EHF3T2T2.js +0 -1
@@ -0,0 +1,49 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "fs";
2
+ import { join } from "path";
3
+
4
+ /**
5
+ * Outcome of a backfill attempt.
6
+ * @typedef {object} BackfillResult
7
+ * @property {boolean} stamped - Whether a completion stamp was written.
8
+ * @property {string} reason - Why the attempt ended the way it did.
9
+ */
10
+
11
+ /**
12
+ * Mark an existing installation as having already seen the first-run walkthrough.
13
+ *
14
+ * Postinstall runs before any `muggle setup`, so the preferences file exists at this
15
+ * moment only for someone who has already used Muggle. Stamping them here reserves the
16
+ * walkthrough for genuinely new installs, which have no file yet.
17
+ *
18
+ * @param {string} dataDir - The ~/.muggle-ai directory.
19
+ * @param {Date} [now] - Stamp timestamp; defaults to the current time.
20
+ * @returns {BackfillResult} What happened, for the caller to log.
21
+ */
22
+ export function backfillOnboardingStamp(dataDir, now = new Date()) {
23
+ const preferencesPath = join(dataDir, "preferences.json");
24
+
25
+ if (!existsSync(preferencesPath)) {
26
+ return { stamped: false, reason: "new installation" };
27
+ }
28
+
29
+ let preferencesFile;
30
+ try {
31
+ preferencesFile = JSON.parse(readFileSync(preferencesPath, "utf-8"));
32
+ } catch (error) {
33
+ return { stamped: false, reason: `unreadable preferences file: ${error.message}` };
34
+ }
35
+
36
+ if (typeof preferencesFile.onboardingCompletedAt === "string" && preferencesFile.onboardingCompletedAt.length > 0) {
37
+ return { stamped: false, reason: "already stamped" };
38
+ }
39
+
40
+ preferencesFile.onboardingCompletedAt = now.toISOString();
41
+
42
+ try {
43
+ writeFileSync(preferencesPath, `${JSON.stringify(preferencesFile, null, 2)}\n`, "utf-8");
44
+ } catch (error) {
45
+ return { stamped: false, reason: `could not write preferences file: ${error.message}` };
46
+ }
47
+
48
+ return { stamped: true, reason: "existing installation" };
49
+ }
@@ -25,6 +25,7 @@ import { dirname, join } from "path";
25
25
  import { pipeline } from "stream/promises";
26
26
  import { createRequire } from "module";
27
27
  import { fileURLToPath } from "url";
28
+ import { backfillOnboardingStamp } from "./onboarding-backfill.mjs";
28
29
  import {
29
30
  SIGNATURE_BUNDLE_SUFFIX,
30
31
  resolveIntegrityPolicy,
@@ -1010,10 +1011,21 @@ function syncClaudePluginCache() {
1010
1011
  }
1011
1012
  }
1012
1013
 
1014
+ /**
1015
+ * Run the onboarding backfill and log only when it actually stamps.
1016
+ */
1017
+ function logOnboardingBackfill() {
1018
+ const result = backfillOnboardingStamp(join(homedir(), ".muggle-ai"));
1019
+ if (result.stamped) {
1020
+ log("Existing installation: first-run walkthrough marked as already seen.");
1021
+ }
1022
+ }
1023
+
1013
1024
  // Run postinstall. The explicit `process.exit` guarantees the script doesn't
1014
1025
  // linger when something below (a hung socket, an EPERM rmSync retry on
1015
1026
  // Windows) keeps the event loop alive — see issue #167.
1016
1027
  initLogFile();
1028
+ logOnboardingBackfill();
1017
1029
  removeVersionOverrideFile();
1018
1030
  syncCursorSkills();
1019
1031
  syncClaudePluginCache();
@@ -1 +0,0 @@
1
- export { DEFAULT_PREFERENCES, ElectronAppReleaseStream, PREFERENCES_FILE_NAME, PREFERENCES_PROJECT_DIR_NAME, PREFERENCES_SCHEMA, PREFERENCES_VERSION, PREFERENCE_ALLOWED_VALUES, PreferenceKey, PreferenceValue, ProjectPreferencesReconcileOutcome, RuntimeTarget, WATCHER_LIFETIME_SECONDS, WATCHER_LIFETIME_UNBOUNDED_SECONDS, assertDeviceCodeClientProvisioned, buildElectronAppChecksumsUrl, buildElectronAppReleaseAssetUrl, buildElectronAppReleaseTag, calculateFileChecksum, createApiKeyWithToken, createChildLogger, deleteApiKeyData, deleteCredentials, e2e_exports as e2e, formatPreferencesOneLiner, getActiveElectronAppReleaseStream, getActiveRuntimeTarget, getApiKey, getApiKeyFilePath, getAuthService, getBundledElectronAppVersion, getCallerCredentials, getCallerCredentialsAsync, getChecksumForPlatform, getConfig, getCredentialsFilePath, getDataDir, getDownloadBaseUrl, getElectronAppChecksums, getElectronAppDir, getElectronAppReleaseTagPrefix, getElectronAppSignedFromVersion, getElectronAppVersion, getElectronAppVersionSource, getLocalQaTools, getLogger, getPlatformKey, getQaTools, getReleaseSignerIdentityUri, getValidApiKeyData, getValidCredentials, hasApiKey, isElectronAppInstalled, isFirstRun, loadApiKeyData, loadCredentials, local_exports as localQa, mcp_exports as mcp, openBrowserUrl, performLogin, performLogout, pollDeviceCode, e2e_exports as qa, reconcileProjectPreferences, resetConfig, resetLogger, resetPreference, resolveActiveProfile, resolveActiveReleaseStream, resolveActiveReleaseTagPrefix, resolveElectronAppPathOrNull, resolvePreferences, resolveRuntimeTarget, saveApiKey, saveApiKeyData, saveCredentials, startDeviceCodeFlow, toolRequiresAuth, validatePreference, verifyFileChecksum, writePreferences } from './chunk-VQZLKLAY.js';