@serviceme/devtools-core 2.0.2 → 2.0.4

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 (56) hide show
  1. package/dist/{device-CDDcwDY6.mjs → device-BVcUUQ9t.mjs} +54 -19
  2. package/dist/device-BVcUUQ9t.mjs.map +1 -0
  3. package/dist/device-DCo0rgUt.mjs +793 -0
  4. package/dist/device-DCo0rgUt.mjs.map +1 -0
  5. package/dist/{device-DuAYH8bk.js → device-ihxrFR-w.js} +52 -17
  6. package/dist/device-ihxrFR-w.js.map +1 -0
  7. package/dist/device-uFAQxlNt.js +874 -0
  8. package/dist/device-uFAQxlNt.js.map +1 -0
  9. package/dist/device-yWpY_Zds.js +874 -0
  10. package/dist/device-yWpY_Zds.js.map +1 -0
  11. package/dist/device.d.mts +1 -1
  12. package/dist/device.d.ts +1 -1
  13. package/dist/device.js +1 -1
  14. package/dist/device.mjs +1 -1
  15. package/dist/{index-BI11AfMH.d.ts → index-DGXYp8J5.d.mts} +30 -15
  16. package/dist/{index-BI11AfMH.d.mts → index-DGXYp8J5.d.ts} +30 -15
  17. package/dist/index.d.mts +13 -82
  18. package/dist/index.d.ts +13 -82
  19. package/dist/index.js +72 -138
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +74 -135
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/skill-linker.js +1 -1
  24. package/dist/skill-linker.mjs +1 -1
  25. package/dist/{submit-Cg7wSa3x.mjs → submit-6zQPPrOJ.mjs} +2 -2
  26. package/dist/{submit-Cg7wSa3x.mjs.map → submit-6zQPPrOJ.mjs.map} +1 -1
  27. package/dist/submit-BTdbGEAd.mjs +84 -0
  28. package/dist/submit-BTdbGEAd.mjs.map +1 -0
  29. package/dist/submit-CW9schoc.js +98 -0
  30. package/dist/submit-CW9schoc.js.map +1 -0
  31. package/dist/submit-Dy0KTHzm.js +98 -0
  32. package/dist/submit-Dy0KTHzm.js.map +1 -0
  33. package/dist/submit.js +1 -1
  34. package/dist/submit.mjs +1 -1
  35. package/dist/toolbox-BV7vLGXZ.js +614 -0
  36. package/dist/toolbox-BV7vLGXZ.js.map +1 -0
  37. package/dist/{toolbox-CbfxpNg-.mjs → toolbox-BxgnUyDU.mjs} +2 -2
  38. package/dist/{toolbox-CbfxpNg-.mjs.map → toolbox-BxgnUyDU.mjs.map} +1 -1
  39. package/dist/toolbox-GSWMRdts.js +614 -0
  40. package/dist/toolbox-GSWMRdts.js.map +1 -0
  41. package/dist/toolbox-UG4dA2TI.mjs +540 -0
  42. package/dist/toolbox-UG4dA2TI.mjs.map +1 -0
  43. package/dist/toolbox.js +1 -1
  44. package/dist/toolbox.mjs +1 -1
  45. package/dist/userHome-B97jBm5O.mjs +196 -0
  46. package/dist/userHome-B97jBm5O.mjs.map +1 -0
  47. package/dist/userHome-Baz205B7.js +498 -0
  48. package/dist/userHome-Baz205B7.js.map +1 -0
  49. package/dist/userHome-CLlsXCvW.js +518 -0
  50. package/dist/userHome-CLlsXCvW.js.map +1 -0
  51. package/dist/{userHome-CcnAQPG1.mjs → userHome-DOMLiHy7.mjs} +2 -4
  52. package/dist/userHome-DOMLiHy7.mjs.map +1 -0
  53. package/package.json +2 -2
  54. package/dist/device-CDDcwDY6.mjs.map +0 -1
  55. package/dist/device-DuAYH8bk.js.map +0 -1
  56. package/dist/userHome-CcnAQPG1.mjs.map +0 -1
@@ -0,0 +1,498 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.js");
2
+ let node_path = require("node:path");
3
+ node_path = require_rolldown_runtime.__toESM(node_path);
4
+ let node_os = require("node:os");
5
+ node_os = require_rolldown_runtime.__toESM(node_os);
6
+ //#region src/paths/userHome.ts
7
+ /**
8
+ * SERVICEME user home directory helpers.
9
+ *
10
+ * All paths resolve under {@link getServicemeHome}, which is either the
11
+ * `SERVICEME_HOME` environment variable (when set and non-empty) or
12
+ * `$HOME/.serviceme` on POSIX / `%USERPROFILE%\.serviceme` on Windows.
13
+ *
14
+ * Tests inject `homeDir` and `servicemeHomeEnv` overrides via
15
+ * {@link setUserHomeOverrides} / {@link resetUserHomeOverrides} so they can
16
+ * exercise the path logic without touching the real user environment.
17
+ */
18
+ /** Layout constants — kept in one place so other modules can reuse them. */
19
+ const SERVICEME_DIR_NAME = ".serviceme";
20
+ const REPOS_SUBDIR = "repos";
21
+ const CACHE_SUBDIR = "cache";
22
+ const DRAFTS_SUBDIR = "drafts";
23
+ const SKILL_DRAFTS_SUBDIR = "skills";
24
+ const AGENT_DRAFTS_SUBDIR = "agents";
25
+ const REPOS_CONFIG_FILENAME = "repos.json";
26
+ const WORKSPACES_SUBDIR = "workspaces";
27
+ const WORKSPACE_CONTENT_STATE_FILENAME = "copilot-content-state.json";
28
+ /**
29
+ * Repo id regex — used to validate any `repoId` argument before it is joined
30
+ * into a filesystem path. Keeps path traversal attempts out and gives us a
31
+ * predictable on-disk shape.
32
+ */
33
+ const SAFE_REPO_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
34
+ /** Environment variable that overrides the user-home root directory. */
35
+ const SERVICEME_HOME_ENV = "SERVICEME_HOME";
36
+ let activeOverrides = {};
37
+ function setUserHomeOverrides(overrides) {
38
+ activeOverrides = { ...overrides };
39
+ }
40
+ function resetUserHomeOverrides() {
41
+ activeOverrides = {};
42
+ }
43
+ function resolveHomeDir() {
44
+ const injected = activeOverrides.homeDir;
45
+ if (injected !== void 0) return injected;
46
+ return node_os.homedir();
47
+ }
48
+ function resolveServicemeHomeEnv() {
49
+ const injected = activeOverrides.servicemeHomeEnv;
50
+ if (injected !== void 0) return injected.length > 0 ? injected : void 0;
51
+ const envValue = process.env[SERVICEME_HOME_ENV];
52
+ return envValue && envValue.length > 0 ? envValue : void 0;
53
+ }
54
+ function resolvePlatform() {
55
+ return activeOverrides.platform ?? process.platform;
56
+ }
57
+ function assertSafeRepoId(repoId) {
58
+ if (typeof repoId !== "string" || repoId.length === 0 || !SAFE_REPO_ID_PATTERN.test(repoId)) throw new Error(`Invalid repo id: ${JSON.stringify(repoId)}. Must match ${SAFE_REPO_ID_PATTERN} (alphanumeric start, then alphanumerics / underscores / hyphens, ≤ 64 chars).`);
59
+ return repoId;
60
+ }
61
+ /**
62
+ * The raw OS home directory (`os.homedir()`), honoring test overrides
63
+ * ({@link setUserHomeOverrides}). Exported for callers that need a
64
+ * home-relative path *outside* of `~/.serviceme` — e.g. the
65
+ * `~/.agents/{skills,agents}` convention used by `SkillLinker` for
66
+ * user-scope links.
67
+ */
68
+ function getHomeDir() {
69
+ return resolveHomeDir();
70
+ }
71
+ /**
72
+ * Root directory for all SERVICEME user-level state. Resolves to
73
+ * `${SERVICEME_HOME}` when that env var is set, otherwise `${HOME}/.serviceme`
74
+ * (POSIX) or `%USERPROFILE%\.serviceme` (Windows via `os.homedir`).
75
+ */
76
+ function getServicemeHome() {
77
+ const override = resolveServicemeHomeEnv();
78
+ if (override !== void 0) return node_path.resolve(override);
79
+ return node_path.join(resolveHomeDir(), SERVICEME_DIR_NAME);
80
+ }
81
+ /** `$HOME/.serviceme/repos` (or `${SERVICEME_HOME}/repos`). */
82
+ function getReposDir() {
83
+ return node_path.join(getServicemeHome(), REPOS_SUBDIR);
84
+ }
85
+ /** `$HOME/.serviceme/repos/<repoId>` — validates `repoId` first. */
86
+ function getRepoDir(repoId) {
87
+ return node_path.join(getReposDir(), assertSafeRepoId(repoId));
88
+ }
89
+ /** `$HOME/.serviceme/cache` — generic per-user cache. */
90
+ function getCacheDir() {
91
+ return node_path.join(getServicemeHome(), CACHE_SUBDIR);
92
+ }
93
+ /** `$HOME/.serviceme/cache/<repoId>` — per-repo sync state lives here. */
94
+ function getRepoCacheDir(repoId) {
95
+ return node_path.join(getCacheDir(), assertSafeRepoId(repoId));
96
+ }
97
+ /** `$HOME/.serviceme/drafts` — local edits not yet pushed upstream. */
98
+ function getDraftsDir() {
99
+ return node_path.join(getServicemeHome(), DRAFTS_SUBDIR);
100
+ }
101
+ /** `$HOME/.serviceme/drafts/skills` — local skill drafts. */
102
+ function getSkillDraftsDir() {
103
+ return node_path.join(getDraftsDir(), SKILL_DRAFTS_SUBDIR);
104
+ }
105
+ /** `$HOME/.serviceme/drafts/agents` — local agent drafts. */
106
+ function getAgentDraftsDir() {
107
+ return node_path.join(getDraftsDir(), AGENT_DRAFTS_SUBDIR);
108
+ }
109
+ /**
110
+ * `$HOME/.serviceme/repos.json` — the single config entry point for repo
111
+ * metadata. Always under the resolved home root (i.e. follows
112
+ * `SERVICEME_HOME` overrides too).
113
+ */
114
+ function getReposConfigPath() {
115
+ return node_path.join(getServicemeHome(), REPOS_CONFIG_FILENAME);
116
+ }
117
+ /** `~/.serviceme/workspaces` — machine-local per-workspace state root. */
118
+ function getWorkspacesDir() {
119
+ return node_path.join(getServicemeHome(), WORKSPACES_SUBDIR);
120
+ }
121
+ /**
122
+ * Convenience helper for callers that need to switch behaviour on platform
123
+ * (e.g. `SkillLinker` chooses symlink vs junction). Exported mostly so tests
124
+ * can pin the value without touching `process.platform` directly.
125
+ */
126
+ function getHomePlatform() {
127
+ return resolvePlatform();
128
+ }
129
+ /** Layout constants for scheduled-tasks files. Kept here so other modules
130
+ * can reuse them and the names stay in sync with the design doc. */
131
+ const SCHEDULED_TASKS_CONFIG_FILENAME = "scheduled-tasks.json";
132
+ const SCHEDULED_TASKS_LOG_FILENAME = "scheduled-tasks-log.json";
133
+ const SCHEDULER_PID_FILENAME = "scheduler.pid";
134
+ const SCHEDULER_LOCK_FILENAME = "scheduler.lock";
135
+ const SCHEDULER_LOG_FILENAME = "scheduler.log";
136
+ const MIGRATION_FAILURES_FILENAME = "migration-failures.json";
137
+ const KNOWN_WORKSPACES_FILENAME = "known-workspaces.json";
138
+ /** `~/.serviceme/scheduled-tasks.json` — the global v2 task list. */
139
+ function getScheduledTasksConfigPath() {
140
+ return node_path.join(getServicemeHome(), SCHEDULED_TASKS_CONFIG_FILENAME);
141
+ }
142
+ /** `~/.serviceme/scheduled-tasks-log.json` — the global execution log (200 LRU). */
143
+ function getScheduledTasksLogPath() {
144
+ return node_path.join(getServicemeHome(), SCHEDULED_TASKS_LOG_FILENAME);
145
+ }
146
+ /** `~/.serviceme/scheduler.pid` — global daemon PID file. */
147
+ function getSchedulerPidPath() {
148
+ return node_path.join(getServicemeHome(), SCHEDULER_PID_FILENAME);
149
+ }
150
+ /** `~/.serviceme/scheduler.lock` — global daemon startup flock. */
151
+ function getSchedulerLockPath() {
152
+ return node_path.join(getServicemeHome(), SCHEDULER_LOCK_FILENAME);
153
+ }
154
+ /** `~/.serviceme/scheduler.log` — global daemon log (daemon lifecycle, not task execution). */
155
+ function getSchedulerLogPath() {
156
+ return node_path.join(getServicemeHome(), SCHEDULER_LOG_FILENAME);
157
+ }
158
+ /** `~/.serviceme/migration-failures.json` — diagnostics for failed v1→v2 imports. */
159
+ function getMigrationFailuresPath() {
160
+ return node_path.join(getServicemeHome(), MIGRATION_FAILURES_FILENAME);
161
+ }
162
+ /** `~/.serviceme/known-workspaces.json` — workspace list the extension has seen. */
163
+ function getKnownWorkspacesPath() {
164
+ return node_path.join(getServicemeHome(), KNOWN_WORKSPACES_FILENAME);
165
+ }
166
+ /** Layout constants for the Phase 5 client-side state files. The server
167
+ * already has the corresponding routes (`/api/v1/auth/...`,
168
+ * `/api/v1/device/...`, etc.) — the client just needs the on-disk
169
+ * file paths + a first-run bootstrap so the auth/device/toolbox
170
+ * services can open + read them without a per-call existence check. */
171
+ const CREDENTIALS_CONFIG_FILENAME = "credentials.json";
172
+ const DEVICE_JSON_FILENAME = "device.json";
173
+ const TOOLBOX_JSON_FILENAME = "toolbox.json";
174
+ const MACHINE_ID_FILENAME = "machine-id";
175
+ const PROFILES_JSON_FILENAME = "profiles.json";
176
+ /** `~/.serviceme/credentials.json` — better-auth session tokens + refresh state (client-side cache). */
177
+ function getCredentialsConfigPath() {
178
+ return node_path.join(getServicemeHome(), CREDENTIALS_CONFIG_FILENAME);
179
+ }
180
+ /** `~/.serviceme/device.json` — device enrollment payload (id, public key fingerprint, claimed-by). */
181
+ function getDeviceJsonPath() {
182
+ return node_path.join(getServicemeHome(), DEVICE_JSON_FILENAME);
183
+ }
184
+ /** `~/.serviceme/toolbox.json` — local toolbox state (installed tool refs, per-user prefs). */
185
+ function getToolboxJsonPath() {
186
+ return node_path.join(getServicemeHome(), TOOLBOX_JSON_FILENAME);
187
+ }
188
+ /** `~/.serviceme/machine-id` — opaque stable per-install id (uuid v4 string, no JSON wrapper). */
189
+ function getMachineIdPath() {
190
+ return node_path.join(getServicemeHome(), MACHINE_ID_FILENAME);
191
+ }
192
+ /** `~/.serviceme/profiles.json` — cached projection of server-side profile rows; refresh on demand. */
193
+ function getProfilesJsonPath() {
194
+ return node_path.join(getServicemeHome(), PROFILES_JSON_FILENAME);
195
+ }
196
+ //#endregion
197
+ Object.defineProperty(exports, "AGENT_DRAFTS_SUBDIR", {
198
+ enumerable: true,
199
+ get: function() {
200
+ return AGENT_DRAFTS_SUBDIR;
201
+ }
202
+ });
203
+ Object.defineProperty(exports, "CACHE_SUBDIR", {
204
+ enumerable: true,
205
+ get: function() {
206
+ return CACHE_SUBDIR;
207
+ }
208
+ });
209
+ Object.defineProperty(exports, "CREDENTIALS_CONFIG_FILENAME", {
210
+ enumerable: true,
211
+ get: function() {
212
+ return CREDENTIALS_CONFIG_FILENAME;
213
+ }
214
+ });
215
+ Object.defineProperty(exports, "DEVICE_JSON_FILENAME", {
216
+ enumerable: true,
217
+ get: function() {
218
+ return DEVICE_JSON_FILENAME;
219
+ }
220
+ });
221
+ Object.defineProperty(exports, "DRAFTS_SUBDIR", {
222
+ enumerable: true,
223
+ get: function() {
224
+ return DRAFTS_SUBDIR;
225
+ }
226
+ });
227
+ Object.defineProperty(exports, "KNOWN_WORKSPACES_FILENAME", {
228
+ enumerable: true,
229
+ get: function() {
230
+ return KNOWN_WORKSPACES_FILENAME;
231
+ }
232
+ });
233
+ Object.defineProperty(exports, "MACHINE_ID_FILENAME", {
234
+ enumerable: true,
235
+ get: function() {
236
+ return MACHINE_ID_FILENAME;
237
+ }
238
+ });
239
+ Object.defineProperty(exports, "MIGRATION_FAILURES_FILENAME", {
240
+ enumerable: true,
241
+ get: function() {
242
+ return MIGRATION_FAILURES_FILENAME;
243
+ }
244
+ });
245
+ Object.defineProperty(exports, "PROFILES_JSON_FILENAME", {
246
+ enumerable: true,
247
+ get: function() {
248
+ return PROFILES_JSON_FILENAME;
249
+ }
250
+ });
251
+ Object.defineProperty(exports, "REPOS_CONFIG_FILENAME", {
252
+ enumerable: true,
253
+ get: function() {
254
+ return REPOS_CONFIG_FILENAME;
255
+ }
256
+ });
257
+ Object.defineProperty(exports, "REPOS_SUBDIR", {
258
+ enumerable: true,
259
+ get: function() {
260
+ return REPOS_SUBDIR;
261
+ }
262
+ });
263
+ Object.defineProperty(exports, "SAFE_REPO_ID_PATTERN", {
264
+ enumerable: true,
265
+ get: function() {
266
+ return SAFE_REPO_ID_PATTERN;
267
+ }
268
+ });
269
+ Object.defineProperty(exports, "SCHEDULED_TASKS_CONFIG_FILENAME", {
270
+ enumerable: true,
271
+ get: function() {
272
+ return SCHEDULED_TASKS_CONFIG_FILENAME;
273
+ }
274
+ });
275
+ Object.defineProperty(exports, "SCHEDULED_TASKS_LOG_FILENAME", {
276
+ enumerable: true,
277
+ get: function() {
278
+ return SCHEDULED_TASKS_LOG_FILENAME;
279
+ }
280
+ });
281
+ Object.defineProperty(exports, "SCHEDULER_LOCK_FILENAME", {
282
+ enumerable: true,
283
+ get: function() {
284
+ return SCHEDULER_LOCK_FILENAME;
285
+ }
286
+ });
287
+ Object.defineProperty(exports, "SCHEDULER_LOG_FILENAME", {
288
+ enumerable: true,
289
+ get: function() {
290
+ return SCHEDULER_LOG_FILENAME;
291
+ }
292
+ });
293
+ Object.defineProperty(exports, "SCHEDULER_PID_FILENAME", {
294
+ enumerable: true,
295
+ get: function() {
296
+ return SCHEDULER_PID_FILENAME;
297
+ }
298
+ });
299
+ Object.defineProperty(exports, "SERVICEME_DIR_NAME", {
300
+ enumerable: true,
301
+ get: function() {
302
+ return SERVICEME_DIR_NAME;
303
+ }
304
+ });
305
+ Object.defineProperty(exports, "SERVICEME_HOME_ENV", {
306
+ enumerable: true,
307
+ get: function() {
308
+ return SERVICEME_HOME_ENV;
309
+ }
310
+ });
311
+ Object.defineProperty(exports, "SKILL_DRAFTS_SUBDIR", {
312
+ enumerable: true,
313
+ get: function() {
314
+ return SKILL_DRAFTS_SUBDIR;
315
+ }
316
+ });
317
+ Object.defineProperty(exports, "TOOLBOX_JSON_FILENAME", {
318
+ enumerable: true,
319
+ get: function() {
320
+ return TOOLBOX_JSON_FILENAME;
321
+ }
322
+ });
323
+ Object.defineProperty(exports, "WORKSPACES_SUBDIR", {
324
+ enumerable: true,
325
+ get: function() {
326
+ return WORKSPACES_SUBDIR;
327
+ }
328
+ });
329
+ Object.defineProperty(exports, "WORKSPACE_CONTENT_STATE_FILENAME", {
330
+ enumerable: true,
331
+ get: function() {
332
+ return WORKSPACE_CONTENT_STATE_FILENAME;
333
+ }
334
+ });
335
+ Object.defineProperty(exports, "assertSafeRepoId", {
336
+ enumerable: true,
337
+ get: function() {
338
+ return assertSafeRepoId;
339
+ }
340
+ });
341
+ Object.defineProperty(exports, "getAgentDraftsDir", {
342
+ enumerable: true,
343
+ get: function() {
344
+ return getAgentDraftsDir;
345
+ }
346
+ });
347
+ Object.defineProperty(exports, "getCacheDir", {
348
+ enumerable: true,
349
+ get: function() {
350
+ return getCacheDir;
351
+ }
352
+ });
353
+ Object.defineProperty(exports, "getCredentialsConfigPath", {
354
+ enumerable: true,
355
+ get: function() {
356
+ return getCredentialsConfigPath;
357
+ }
358
+ });
359
+ Object.defineProperty(exports, "getDeviceJsonPath", {
360
+ enumerable: true,
361
+ get: function() {
362
+ return getDeviceJsonPath;
363
+ }
364
+ });
365
+ Object.defineProperty(exports, "getDraftsDir", {
366
+ enumerable: true,
367
+ get: function() {
368
+ return getDraftsDir;
369
+ }
370
+ });
371
+ Object.defineProperty(exports, "getHomeDir", {
372
+ enumerable: true,
373
+ get: function() {
374
+ return getHomeDir;
375
+ }
376
+ });
377
+ Object.defineProperty(exports, "getHomePlatform", {
378
+ enumerable: true,
379
+ get: function() {
380
+ return getHomePlatform;
381
+ }
382
+ });
383
+ Object.defineProperty(exports, "getKnownWorkspacesPath", {
384
+ enumerable: true,
385
+ get: function() {
386
+ return getKnownWorkspacesPath;
387
+ }
388
+ });
389
+ Object.defineProperty(exports, "getMachineIdPath", {
390
+ enumerable: true,
391
+ get: function() {
392
+ return getMachineIdPath;
393
+ }
394
+ });
395
+ Object.defineProperty(exports, "getMigrationFailuresPath", {
396
+ enumerable: true,
397
+ get: function() {
398
+ return getMigrationFailuresPath;
399
+ }
400
+ });
401
+ Object.defineProperty(exports, "getProfilesJsonPath", {
402
+ enumerable: true,
403
+ get: function() {
404
+ return getProfilesJsonPath;
405
+ }
406
+ });
407
+ Object.defineProperty(exports, "getRepoCacheDir", {
408
+ enumerable: true,
409
+ get: function() {
410
+ return getRepoCacheDir;
411
+ }
412
+ });
413
+ Object.defineProperty(exports, "getRepoDir", {
414
+ enumerable: true,
415
+ get: function() {
416
+ return getRepoDir;
417
+ }
418
+ });
419
+ Object.defineProperty(exports, "getReposConfigPath", {
420
+ enumerable: true,
421
+ get: function() {
422
+ return getReposConfigPath;
423
+ }
424
+ });
425
+ Object.defineProperty(exports, "getReposDir", {
426
+ enumerable: true,
427
+ get: function() {
428
+ return getReposDir;
429
+ }
430
+ });
431
+ Object.defineProperty(exports, "getScheduledTasksConfigPath", {
432
+ enumerable: true,
433
+ get: function() {
434
+ return getScheduledTasksConfigPath;
435
+ }
436
+ });
437
+ Object.defineProperty(exports, "getScheduledTasksLogPath", {
438
+ enumerable: true,
439
+ get: function() {
440
+ return getScheduledTasksLogPath;
441
+ }
442
+ });
443
+ Object.defineProperty(exports, "getSchedulerLockPath", {
444
+ enumerable: true,
445
+ get: function() {
446
+ return getSchedulerLockPath;
447
+ }
448
+ });
449
+ Object.defineProperty(exports, "getSchedulerLogPath", {
450
+ enumerable: true,
451
+ get: function() {
452
+ return getSchedulerLogPath;
453
+ }
454
+ });
455
+ Object.defineProperty(exports, "getSchedulerPidPath", {
456
+ enumerable: true,
457
+ get: function() {
458
+ return getSchedulerPidPath;
459
+ }
460
+ });
461
+ Object.defineProperty(exports, "getServicemeHome", {
462
+ enumerable: true,
463
+ get: function() {
464
+ return getServicemeHome;
465
+ }
466
+ });
467
+ Object.defineProperty(exports, "getSkillDraftsDir", {
468
+ enumerable: true,
469
+ get: function() {
470
+ return getSkillDraftsDir;
471
+ }
472
+ });
473
+ Object.defineProperty(exports, "getToolboxJsonPath", {
474
+ enumerable: true,
475
+ get: function() {
476
+ return getToolboxJsonPath;
477
+ }
478
+ });
479
+ Object.defineProperty(exports, "getWorkspacesDir", {
480
+ enumerable: true,
481
+ get: function() {
482
+ return getWorkspacesDir;
483
+ }
484
+ });
485
+ Object.defineProperty(exports, "resetUserHomeOverrides", {
486
+ enumerable: true,
487
+ get: function() {
488
+ return resetUserHomeOverrides;
489
+ }
490
+ });
491
+ Object.defineProperty(exports, "setUserHomeOverrides", {
492
+ enumerable: true,
493
+ get: function() {
494
+ return setUserHomeOverrides;
495
+ }
496
+ });
497
+
498
+ //# sourceMappingURL=userHome-Baz205B7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userHome-Baz205B7.js","names":["os","path"],"sources":["../src/paths/userHome.ts"],"sourcesContent":["import * as os from \"node:os\";\nimport * as path from \"node:path\";\n\n/**\n * SERVICEME user home directory helpers.\n *\n * All paths resolve under {@link getServicemeHome}, which is either the\n * `SERVICEME_HOME` environment variable (when set and non-empty) or\n * `$HOME/.serviceme` on POSIX / `%USERPROFILE%\\.serviceme` on Windows.\n *\n * Tests inject `homeDir` and `servicemeHomeEnv` overrides via\n * {@link setUserHomeOverrides} / {@link resetUserHomeOverrides} so they can\n * exercise the path logic without touching the real user environment.\n */\n\n/** Layout constants — kept in one place so other modules can reuse them. */\nexport const SERVICEME_DIR_NAME = \".serviceme\";\nexport const REPOS_SUBDIR = \"repos\";\nexport const CACHE_SUBDIR = \"cache\";\nexport const DRAFTS_SUBDIR = \"drafts\";\nexport const SKILL_DRAFTS_SUBDIR = \"skills\";\nexport const AGENT_DRAFTS_SUBDIR = \"agents\";\nexport const REPOS_CONFIG_FILENAME = \"repos.json\";\nexport const WORKSPACES_SUBDIR = \"workspaces\";\nexport const WORKSPACE_CONTENT_STATE_FILENAME = \"copilot-content-state.json\";\n\n/**\n * Repo id regex — used to validate any `repoId` argument before it is joined\n * into a filesystem path. Keeps path traversal attempts out and gives us a\n * predictable on-disk shape.\n */\nexport const SAFE_REPO_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;\n\n/** Environment variable that overrides the user-home root directory. */\nexport const SERVICEME_HOME_ENV = \"SERVICEME_HOME\";\n\n/**\n * Test seam: lets unit tests inject deterministic values for `os.homedir()`\n * and the `SERVICEME_HOME` env override without actually mutating\n * `process.env` (which would leak into other tests).\n */\ninterface UserHomeOverrides {\n\thomeDir?: string | undefined;\n\tservicemeHomeEnv?: string | undefined;\n\tplatform?: NodeJS.Platform | undefined;\n}\n\nlet activeOverrides: UserHomeOverrides = {};\n\nexport function setUserHomeOverrides(overrides: UserHomeOverrides): void {\n\tactiveOverrides = { ...overrides };\n}\n\nexport function resetUserHomeOverrides(): void {\n\tactiveOverrides = {};\n}\n\nfunction resolveHomeDir(): string {\n\tconst injected = activeOverrides.homeDir;\n\tif (injected !== undefined) {\n\t\treturn injected;\n\t}\n\treturn os.homedir();\n}\n\nfunction resolveServicemeHomeEnv(): string | undefined {\n\tconst injected = activeOverrides.servicemeHomeEnv;\n\tif (injected !== undefined) {\n\t\t// Treat empty string as \"not set\" — `process.env` always returns a string\n\t\t// but tests may deliberately pass \"\" to opt out.\n\t\treturn injected.length > 0 ? injected : undefined;\n\t}\n\tconst envValue = process.env[SERVICEME_HOME_ENV];\n\treturn envValue && envValue.length > 0 ? envValue : undefined;\n}\n\nfunction resolvePlatform(): NodeJS.Platform {\n\treturn activeOverrides.platform ?? process.platform;\n}\n\nexport function assertSafeRepoId(repoId: string): string {\n\tif (typeof repoId !== \"string\" || repoId.length === 0 || !SAFE_REPO_ID_PATTERN.test(repoId)) {\n\t\tthrow new Error(\n\t\t\t`Invalid repo id: ${JSON.stringify(repoId)}. ` +\n\t\t\t\t`Must match ${SAFE_REPO_ID_PATTERN} (alphanumeric start, then ` +\n\t\t\t\t`alphanumerics / underscores / hyphens, ≤ 64 chars).`\n\t\t);\n\t}\n\treturn repoId;\n}\n\n/**\n * The raw OS home directory (`os.homedir()`), honoring test overrides\n * ({@link setUserHomeOverrides}). Exported for callers that need a\n * home-relative path *outside* of `~/.serviceme` — e.g. the\n * `~/.agents/{skills,agents}` convention used by `SkillLinker` for\n * user-scope links.\n */\nexport function getHomeDir(): string {\n\treturn resolveHomeDir();\n}\n\n/**\n * Root directory for all SERVICEME user-level state. Resolves to\n * `${SERVICEME_HOME}` when that env var is set, otherwise `${HOME}/.serviceme`\n * (POSIX) or `%USERPROFILE%\\.serviceme` (Windows via `os.homedir`).\n */\nexport function getServicemeHome(): string {\n\tconst override = resolveServicemeHomeEnv();\n\tif (override !== undefined) {\n\t\treturn path.resolve(override);\n\t}\n\treturn path.join(resolveHomeDir(), SERVICEME_DIR_NAME);\n}\n\n/** `$HOME/.serviceme/repos` (or `${SERVICEME_HOME}/repos`). */\nexport function getReposDir(): string {\n\treturn path.join(getServicemeHome(), REPOS_SUBDIR);\n}\n\n/** `$HOME/.serviceme/repos/<repoId>` — validates `repoId` first. */\nexport function getRepoDir(repoId: string): string {\n\treturn path.join(getReposDir(), assertSafeRepoId(repoId));\n}\n\n/** `$HOME/.serviceme/cache` — generic per-user cache. */\nexport function getCacheDir(): string {\n\treturn path.join(getServicemeHome(), CACHE_SUBDIR);\n}\n\n/** `$HOME/.serviceme/cache/<repoId>` — per-repo sync state lives here. */\nexport function getRepoCacheDir(repoId: string): string {\n\treturn path.join(getCacheDir(), assertSafeRepoId(repoId));\n}\n\n/** `$HOME/.serviceme/drafts` — local edits not yet pushed upstream. */\nexport function getDraftsDir(): string {\n\treturn path.join(getServicemeHome(), DRAFTS_SUBDIR);\n}\n\n/** `$HOME/.serviceme/drafts/skills` — local skill drafts. */\nexport function getSkillDraftsDir(): string {\n\treturn path.join(getDraftsDir(), SKILL_DRAFTS_SUBDIR);\n}\n\n/** `$HOME/.serviceme/drafts/agents` — local agent drafts. */\nexport function getAgentDraftsDir(): string {\n\treturn path.join(getDraftsDir(), AGENT_DRAFTS_SUBDIR);\n}\n\n/**\n * `$HOME/.serviceme/repos.json` — the single config entry point for repo\n * metadata. Always under the resolved home root (i.e. follows\n * `SERVICEME_HOME` overrides too).\n */\nexport function getReposConfigPath(): string {\n\treturn path.join(getServicemeHome(), REPOS_CONFIG_FILENAME);\n}\n\n/** `~/.serviceme/workspaces` — machine-local per-workspace state root. */\nexport function getWorkspacesDir(): string {\n\treturn path.join(getServicemeHome(), WORKSPACES_SUBDIR);\n}\n\n/**\n * Convenience helper for callers that need to switch behaviour on platform\n * (e.g. `SkillLinker` chooses symlink vs junction). Exported mostly so tests\n * can pin the value without touching `process.platform` directly.\n */\nexport function getHomePlatform(): NodeJS.Platform {\n\treturn resolvePlatform();\n}\n\n// ─── Scheduled Tasks paths (added by M1.5.3) ───────────────────────────────\n\n/** Layout constants for scheduled-tasks files. Kept here so other modules\n * can reuse them and the names stay in sync with the design doc. */\nexport const SCHEDULED_TASKS_CONFIG_FILENAME = \"scheduled-tasks.json\";\nexport const SCHEDULED_TASKS_LOG_FILENAME = \"scheduled-tasks-log.json\";\nexport const SCHEDULER_PID_FILENAME = \"scheduler.pid\";\nexport const SCHEDULER_LOCK_FILENAME = \"scheduler.lock\";\nexport const SCHEDULER_LOG_FILENAME = \"scheduler.log\";\nexport const MIGRATION_FAILURES_FILENAME = \"migration-failures.json\";\nexport const KNOWN_WORKSPACES_FILENAME = \"known-workspaces.json\";\n\n/** `~/.serviceme/scheduled-tasks.json` — the global v2 task list. */\nexport function getScheduledTasksConfigPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULED_TASKS_CONFIG_FILENAME);\n}\n\n/** `~/.serviceme/scheduled-tasks-log.json` — the global execution log (200 LRU). */\nexport function getScheduledTasksLogPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULED_TASKS_LOG_FILENAME);\n}\n\n/** `~/.serviceme/scheduler.pid` — global daemon PID file. */\nexport function getSchedulerPidPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULER_PID_FILENAME);\n}\n\n/** `~/.serviceme/scheduler.lock` — global daemon startup flock. */\nexport function getSchedulerLockPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULER_LOCK_FILENAME);\n}\n\n/** `~/.serviceme/scheduler.log` — global daemon log (daemon lifecycle, not task execution). */\nexport function getSchedulerLogPath(): string {\n\treturn path.join(getServicemeHome(), SCHEDULER_LOG_FILENAME);\n}\n\n/** `~/.serviceme/migration-failures.json` — diagnostics for failed v1→v2 imports. */\nexport function getMigrationFailuresPath(): string {\n\treturn path.join(getServicemeHome(), MIGRATION_FAILURES_FILENAME);\n}\n\n/** `~/.serviceme/known-workspaces.json` — workspace list the extension has seen. */\nexport function getKnownWorkspacesPath(): string {\n\treturn path.join(getServicemeHome(), KNOWN_WORKSPACES_FILENAME);\n}\n\n// ─── r7 BYOM Server Proxy (rev.20) ─────────────────────────────────────────\n\n// ─── Phase 5 (auth + device + toolbox) placeholders (Spec §11.12) ────────\n\n/** Layout constants for the Phase 5 client-side state files. The server\n * already has the corresponding routes (`/api/v1/auth/...`,\n * `/api/v1/device/...`, etc.) — the client just needs the on-disk\n * file paths + a first-run bootstrap so the auth/device/toolbox\n * services can open + read them without a per-call existence check. */\nexport const CREDENTIALS_CONFIG_FILENAME = \"credentials.json\";\nexport const DEVICE_JSON_FILENAME = \"device.json\";\nexport const TOOLBOX_JSON_FILENAME = \"toolbox.json\";\nexport const MACHINE_ID_FILENAME = \"machine-id\";\nexport const PROFILES_JSON_FILENAME = \"profiles.json\";\n\n/** `~/.serviceme/credentials.json` — better-auth session tokens + refresh state (client-side cache). */\nexport function getCredentialsConfigPath(): string {\n\treturn path.join(getServicemeHome(), CREDENTIALS_CONFIG_FILENAME);\n}\n\n/** `~/.serviceme/device.json` — device enrollment payload (id, public key fingerprint, claimed-by). */\nexport function getDeviceJsonPath(): string {\n\treturn path.join(getServicemeHome(), DEVICE_JSON_FILENAME);\n}\n\n/** `~/.serviceme/toolbox.json` — local toolbox state (installed tool refs, per-user prefs). */\nexport function getToolboxJsonPath(): string {\n\treturn path.join(getServicemeHome(), TOOLBOX_JSON_FILENAME);\n}\n\n/** `~/.serviceme/machine-id` — opaque stable per-install id (uuid v4 string, no JSON wrapper). */\nexport function getMachineIdPath(): string {\n\treturn path.join(getServicemeHome(), MACHINE_ID_FILENAME);\n}\n\n/** `~/.serviceme/profiles.json` — cached projection of server-side profile rows; refresh on demand. */\nexport function getProfilesJsonPath(): string {\n\treturn path.join(getServicemeHome(), PROFILES_JSON_FILENAME);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,MAAa,qBAAqB;AAClC,MAAa,eAAe;AAC5B,MAAa,eAAe;AAC5B,MAAa,gBAAgB;AAC7B,MAAa,sBAAsB;AACnC,MAAa,sBAAsB;AACnC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;AACjC,MAAa,mCAAmC;;;;;;AAOhD,MAAa,uBAAuB;;AAGpC,MAAa,qBAAqB;AAalC,IAAI,kBAAqC,CAAC;AAE1C,SAAgB,qBAAqB,WAAoC;CACxE,kBAAkB,EAAE,GAAG,UAAU;AAClC;AAEA,SAAgB,yBAA+B;CAC9C,kBAAkB,CAAC;AACpB;AAEA,SAAS,iBAAyB;CACjC,MAAM,WAAW,gBAAgB;CACjC,IAAI,aAAa,KAAA,GAChB,OAAO;CAER,OAAOA,QAAG,QAAQ;AACnB;AAEA,SAAS,0BAA8C;CACtD,MAAM,WAAW,gBAAgB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