prjct-cli 0.31.0 → 0.34.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 (121) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/CLAUDE.md +41 -0
  3. package/core/__tests__/agentic/memory-system.test.ts +2 -2
  4. package/core/__tests__/types/fs.test.ts +125 -0
  5. package/core/agentic/agent-router.ts +16 -4
  6. package/core/agentic/chain-of-thought.ts +4 -12
  7. package/core/agentic/command-executor.ts +10 -11
  8. package/core/agentic/context-builder.ts +24 -10
  9. package/core/agentic/ground-truth.ts +139 -55
  10. package/core/agentic/prompt-builder.ts +20 -7
  11. package/core/agentic/smart-context.ts +1 -1
  12. package/core/agentic/template-loader.ts +1 -1
  13. package/core/agentic/tool-registry.ts +4 -2
  14. package/core/bus/bus.ts +1 -1
  15. package/core/commands/cleanup.ts +24 -8
  16. package/core/commands/planning.ts +4 -2
  17. package/core/commands/setup.ts +4 -4
  18. package/core/commands/shipping.ts +34 -8
  19. package/core/commands/snapshots.ts +27 -13
  20. package/core/context/generator.ts +9 -5
  21. package/core/domain/agent-generator.ts +1 -1
  22. package/core/domain/agent-loader.ts +1 -1
  23. package/core/domain/analyzer.ts +76 -31
  24. package/core/domain/context-estimator.ts +1 -1
  25. package/core/domain/snapshot-manager.ts +55 -21
  26. package/core/domain/task-stack.ts +16 -7
  27. package/core/infrastructure/author-detector.ts +1 -1
  28. package/core/infrastructure/claude-agent.ts +12 -8
  29. package/core/infrastructure/command-installer.ts +42 -21
  30. package/core/infrastructure/editors-config.ts +1 -1
  31. package/core/infrastructure/path-manager.ts +27 -2
  32. package/core/infrastructure/permission-manager.ts +1 -1
  33. package/core/infrastructure/setup.ts +31 -13
  34. package/core/infrastructure/update-checker.ts +5 -5
  35. package/core/integrations/jira/client.ts +91 -30
  36. package/core/integrations/jira/index.ts +29 -5
  37. package/core/integrations/jira/mcp-adapter.ts +451 -0
  38. package/core/integrations/linear/client.ts +23 -3
  39. package/core/plugin/loader.ts +16 -6
  40. package/core/plugin/registry.ts +16 -6
  41. package/core/server/routes-extended.ts +13 -6
  42. package/core/server/routes.ts +15 -5
  43. package/core/server/sse.ts +4 -3
  44. package/core/services/agent-service.ts +4 -2
  45. package/core/services/memory-service.ts +16 -5
  46. package/core/services/project-service.ts +11 -2
  47. package/core/services/skill-service.ts +4 -3
  48. package/core/session/compaction.ts +4 -5
  49. package/core/session/metrics.ts +11 -4
  50. package/core/session/task-session-manager.ts +27 -9
  51. package/core/storage/storage-manager.ts +12 -5
  52. package/core/storage/storage.ts +26 -10
  53. package/core/sync/auth-config.ts +2 -2
  54. package/core/sync/oauth-handler.ts +1 -1
  55. package/core/sync/sync-client.ts +4 -2
  56. package/core/sync/sync-manager.ts +1 -1
  57. package/core/types/agentic.ts +8 -18
  58. package/core/types/config.ts +1 -1
  59. package/core/types/index.ts +3 -2
  60. package/core/types/integrations.ts +4 -48
  61. package/core/types/storage.ts +0 -8
  62. package/core/types/task.ts +0 -4
  63. package/core/utils/file-helper.ts +10 -4
  64. package/core/utils/jsonl-helper.ts +4 -4
  65. package/core/utils/keychain.ts +130 -0
  66. package/core/utils/logger.ts +27 -25
  67. package/core/utils/runtime.ts +1 -1
  68. package/core/utils/session-helper.ts +4 -4
  69. package/core/utils/version.ts +1 -1
  70. package/package.json +1 -1
  71. package/packages/shared/src/utils.ts +1 -1
  72. package/scripts/postinstall.js +26 -2
  73. package/templates/agentic/orchestrator.md +303 -0
  74. package/templates/commands/bug.md +2 -0
  75. package/templates/commands/enrich.md +601 -195
  76. package/templates/commands/github.md +287 -0
  77. package/templates/commands/init.md +45 -26
  78. package/templates/commands/jira.md +198 -258
  79. package/templates/commands/linear.md +186 -172
  80. package/templates/commands/monday.md +232 -0
  81. package/templates/commands/p.md +57 -10
  82. package/templates/commands/setup.md +4 -1
  83. package/templates/commands/sync.md +133 -97
  84. package/templates/commands/task.md +12 -0
  85. package/templates/config/skill-mappings.json +95 -63
  86. package/templates/mcp-config.json +42 -39
  87. package/core/integrations/notion/client.ts +0 -413
  88. package/core/integrations/notion/index.ts +0 -46
  89. package/core/integrations/notion/setup.ts +0 -235
  90. package/core/integrations/notion/sync.ts +0 -818
  91. package/core/integrations/notion/templates.ts +0 -246
  92. package/core/plugin/builtin/notion.ts +0 -178
  93. package/dist/bin/prjct.mjs +0 -13581
  94. package/dist/core/infrastructure/command-installer.js +0 -473
  95. package/dist/core/infrastructure/editors-config.js +0 -157
  96. package/dist/core/infrastructure/setup.js +0 -893
  97. package/dist/core/utils/version.js +0 -142
  98. package/packages/shared/.turbo/turbo-build.log +0 -14
  99. package/packages/shared/dist/index.d.ts +0 -10
  100. package/packages/shared/dist/index.d.ts.map +0 -1
  101. package/packages/shared/dist/index.js +0 -4196
  102. package/packages/shared/dist/schemas.d.ts +0 -408
  103. package/packages/shared/dist/schemas.d.ts.map +0 -1
  104. package/packages/shared/dist/types.d.ts +0 -144
  105. package/packages/shared/dist/types.d.ts.map +0 -1
  106. package/packages/shared/dist/unified.d.ts +0 -139
  107. package/packages/shared/dist/unified.d.ts.map +0 -1
  108. package/packages/shared/dist/utils.d.ts +0 -60
  109. package/packages/shared/dist/utils.d.ts.map +0 -1
  110. package/templates/commands/ask.md +0 -128
  111. package/templates/commands/dashboard.md +0 -686
  112. package/templates/commands/feature.md +0 -46
  113. package/templates/commands/now.md +0 -53
  114. package/templates/commands/suggest.md +0 -116
  115. package/templates/global/docs/agents.md +0 -88
  116. package/templates/global/docs/architecture.md +0 -103
  117. package/templates/global/docs/commands.md +0 -96
  118. package/templates/global/docs/validation.md +0 -95
  119. package/templates/skills/notion-push.md +0 -116
  120. package/templates/skills/notion-setup.md +0 -199
  121. package/templates/skills/notion-sync.md +0 -290
@@ -1,473 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // core/infrastructure/command-installer.ts
32
- var command_installer_exports = {};
33
- __export(command_installer_exports, {
34
- CommandInstaller: () => CommandInstaller,
35
- default: () => command_installer_default,
36
- installDocs: () => installDocs,
37
- installGlobalConfig: () => installGlobalConfig
38
- });
39
- module.exports = __toCommonJS(command_installer_exports);
40
- var import_promises = __toESM(require("fs/promises"));
41
- var import_path2 = __toESM(require("path"));
42
- var import_os = __toESM(require("os"));
43
-
44
- // core/utils/version.ts
45
- var import_fs = __toESM(require("fs"));
46
- var import_path = __toESM(require("path"));
47
- var cachedVersion = null;
48
- var cachedPackageJson = null;
49
- var cachedPackageRoot = null;
50
- function getPackageRoot() {
51
- if (cachedPackageRoot) {
52
- return cachedPackageRoot;
53
- }
54
- let currentDir = __dirname;
55
- for (let i = 0; i < 5; i++) {
56
- const packageJsonPath = import_path.default.join(currentDir, "package.json");
57
- if (import_fs.default.existsSync(packageJsonPath)) {
58
- try {
59
- const pkg = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf-8"));
60
- if (pkg.name === "prjct-cli") {
61
- cachedPackageRoot = currentDir;
62
- return currentDir;
63
- }
64
- } catch {
65
- }
66
- }
67
- currentDir = import_path.default.dirname(currentDir);
68
- }
69
- cachedPackageRoot = import_path.default.join(__dirname, "..", "..", "..");
70
- return cachedPackageRoot;
71
- }
72
- __name(getPackageRoot, "getPackageRoot");
73
- function getVersion() {
74
- if (cachedVersion) {
75
- return cachedVersion;
76
- }
77
- try {
78
- const packageJsonPath = import_path.default.join(getPackageRoot(), "package.json");
79
- const packageJson = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf-8"));
80
- cachedVersion = packageJson.version;
81
- cachedPackageJson = packageJson;
82
- return cachedVersion;
83
- } catch (error) {
84
- console.error("Failed to read version from package.json:", error.message);
85
- return "0.0.0";
86
- }
87
- }
88
- __name(getVersion, "getVersion");
89
- var VERSION = getVersion();
90
- var PACKAGE_ROOT = getPackageRoot();
91
-
92
- // core/infrastructure/command-installer.ts
93
- async function installDocs() {
94
- try {
95
- const docsDir = import_path2.default.join(import_os.default.homedir(), ".prjct-cli", "docs");
96
- const templateDocsDir = import_path2.default.join(getPackageRoot(), "templates/global/docs");
97
- await import_promises.default.mkdir(docsDir, { recursive: true });
98
- const docFiles = await import_promises.default.readdir(templateDocsDir);
99
- for (const file of docFiles) {
100
- if (file.endsWith(".md")) {
101
- const srcPath = import_path2.default.join(templateDocsDir, file);
102
- const destPath = import_path2.default.join(docsDir, file);
103
- const content = await import_promises.default.readFile(srcPath, "utf-8");
104
- await import_promises.default.writeFile(destPath, content, "utf-8");
105
- }
106
- }
107
- return { success: true };
108
- } catch (error) {
109
- return { success: false, error: error.message };
110
- }
111
- }
112
- __name(installDocs, "installDocs");
113
- async function installGlobalConfig(claudeConfigPath, detectClaude) {
114
- const claudeDetected = await detectClaude();
115
- if (!claudeDetected) {
116
- return {
117
- success: false,
118
- error: "Claude not detected",
119
- action: "skipped"
120
- };
121
- }
122
- try {
123
- const claudeDir = import_path2.default.join(import_os.default.homedir(), ".claude");
124
- await import_promises.default.mkdir(claudeDir, { recursive: true });
125
- const globalConfigPath = import_path2.default.join(claudeDir, "CLAUDE.md");
126
- const templatePath = import_path2.default.join(getPackageRoot(), "templates/global/CLAUDE.md");
127
- const templateContent = await import_promises.default.readFile(templatePath, "utf-8");
128
- let existingContent = "";
129
- let fileExists = false;
130
- try {
131
- existingContent = await import_promises.default.readFile(globalConfigPath, "utf-8");
132
- fileExists = true;
133
- } catch {
134
- fileExists = false;
135
- }
136
- if (!fileExists) {
137
- await import_promises.default.writeFile(globalConfigPath, templateContent, "utf-8");
138
- return {
139
- success: true,
140
- action: "created",
141
- path: globalConfigPath
142
- };
143
- } else {
144
- const startMarker = "<!-- prjct:start - DO NOT REMOVE THIS MARKER -->";
145
- const endMarker = "<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";
146
- const hasMarkers = existingContent.includes(startMarker) && existingContent.includes(endMarker);
147
- if (!hasMarkers) {
148
- const updatedContent = existingContent + "\n\n" + templateContent;
149
- await import_promises.default.writeFile(globalConfigPath, updatedContent, "utf-8");
150
- return {
151
- success: true,
152
- action: "appended",
153
- path: globalConfigPath
154
- };
155
- } else {
156
- const beforeMarker = existingContent.substring(0, existingContent.indexOf(startMarker));
157
- const afterMarker = existingContent.substring(
158
- existingContent.indexOf(endMarker) + endMarker.length
159
- );
160
- const prjctSection = templateContent.substring(
161
- templateContent.indexOf(startMarker),
162
- templateContent.indexOf(endMarker) + endMarker.length
163
- );
164
- const updatedContent = beforeMarker + prjctSection + afterMarker;
165
- await import_promises.default.writeFile(globalConfigPath, updatedContent, "utf-8");
166
- return {
167
- success: true,
168
- action: "updated",
169
- path: globalConfigPath
170
- };
171
- }
172
- }
173
- } catch (error) {
174
- return {
175
- success: false,
176
- error: error.message,
177
- action: "failed"
178
- };
179
- }
180
- }
181
- __name(installGlobalConfig, "installGlobalConfig");
182
- var CommandInstaller = class {
183
- static {
184
- __name(this, "CommandInstaller");
185
- }
186
- homeDir;
187
- claudeCommandsPath;
188
- claudeConfigPath;
189
- templatesDir;
190
- constructor() {
191
- this.homeDir = import_os.default.homedir();
192
- this.claudeCommandsPath = import_path2.default.join(this.homeDir, ".claude", "commands", "p");
193
- this.claudeConfigPath = import_path2.default.join(this.homeDir, ".claude");
194
- this.templatesDir = import_path2.default.join(getPackageRoot(), "templates", "commands");
195
- }
196
- /**
197
- * Detect if Claude is installed
198
- */
199
- async detectClaude() {
200
- try {
201
- await import_promises.default.access(this.claudeConfigPath);
202
- return true;
203
- } catch {
204
- return false;
205
- }
206
- }
207
- /**
208
- * Get list of command files to install
209
- */
210
- async getCommandFiles() {
211
- try {
212
- const files = await import_promises.default.readdir(this.templatesDir);
213
- return files.filter((f) => f.endsWith(".md"));
214
- } catch {
215
- return [
216
- "init.md",
217
- "now.md",
218
- "done.md",
219
- "ship.md",
220
- "next.md",
221
- "idea.md",
222
- "recap.md",
223
- "progress.md",
224
- "stuck.md",
225
- "context.md",
226
- "analyze.md",
227
- "sync.md",
228
- "roadmap.md",
229
- "task.md",
230
- "git.md",
231
- "fix.md",
232
- "test.md",
233
- "cleanup.md",
234
- "design.md"
235
- ];
236
- }
237
- }
238
- /**
239
- * Install commands to Claude
240
- */
241
- async installCommands() {
242
- const claudeDetected = await this.detectClaude();
243
- if (!claudeDetected) {
244
- return {
245
- success: false,
246
- error: "Claude not detected. Please install Claude Code or Claude Desktop first."
247
- };
248
- }
249
- try {
250
- await this.installRouter();
251
- await import_promises.default.mkdir(this.claudeCommandsPath, { recursive: true });
252
- const commandFiles = await this.getCommandFiles();
253
- const installed = [];
254
- const errors = [];
255
- for (const file of commandFiles) {
256
- try {
257
- const sourcePath = import_path2.default.join(this.templatesDir, file);
258
- const destPath = import_path2.default.join(this.claudeCommandsPath, file);
259
- const content = await import_promises.default.readFile(sourcePath, "utf-8");
260
- await import_promises.default.writeFile(destPath, content, "utf-8");
261
- installed.push(file.replace(".md", ""));
262
- } catch (error) {
263
- errors.push({ file, error: error.message });
264
- }
265
- }
266
- return {
267
- success: true,
268
- installed,
269
- errors,
270
- path: this.claudeCommandsPath
271
- };
272
- } catch (error) {
273
- return {
274
- success: false,
275
- error: error.message
276
- };
277
- }
278
- }
279
- /**
280
- * Uninstall commands from Claude
281
- */
282
- async uninstallCommands() {
283
- try {
284
- const commandFiles = await this.getCommandFiles();
285
- const uninstalled = [];
286
- const errors = [];
287
- for (const file of commandFiles) {
288
- try {
289
- const filePath = import_path2.default.join(this.claudeCommandsPath, file);
290
- await import_promises.default.unlink(filePath);
291
- uninstalled.push(file.replace(".md", ""));
292
- } catch (error) {
293
- if (error.code !== "ENOENT") {
294
- errors.push({ file, error: error.message });
295
- }
296
- }
297
- }
298
- try {
299
- await import_promises.default.rmdir(this.claudeCommandsPath);
300
- } catch {
301
- }
302
- return {
303
- success: true,
304
- uninstalled,
305
- errors
306
- };
307
- } catch (error) {
308
- return {
309
- success: false,
310
- error: error.message
311
- };
312
- }
313
- }
314
- /**
315
- * Check if commands are already installed
316
- */
317
- async checkInstallation() {
318
- const claudeDetected = await this.detectClaude();
319
- if (!claudeDetected) {
320
- return {
321
- installed: false,
322
- claudeDetected: false
323
- };
324
- }
325
- try {
326
- await import_promises.default.access(this.claudeCommandsPath);
327
- const files = await import_promises.default.readdir(this.claudeCommandsPath);
328
- const installedCommands = files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
329
- return {
330
- installed: installedCommands.length > 0,
331
- claudeDetected: true,
332
- commands: installedCommands,
333
- path: this.claudeCommandsPath
334
- };
335
- } catch {
336
- return {
337
- installed: false,
338
- claudeDetected: true,
339
- commands: []
340
- };
341
- }
342
- }
343
- /**
344
- * Update commands (reinstall with latest templates)
345
- */
346
- async updateCommands() {
347
- console.log("Updating commands with latest templates...");
348
- const result = await this.installCommands();
349
- if (result.success && result.installed) {
350
- console.log(`Updated ${result.installed.length} commands`);
351
- }
352
- return result;
353
- }
354
- /**
355
- * Install to all detected editors (alias for installCommands)
356
- */
357
- async installToAll() {
358
- return await this.installCommands();
359
- }
360
- /**
361
- * Get installation path for Claude commands
362
- */
363
- getInstallPath() {
364
- return this.claudeCommandsPath;
365
- }
366
- /**
367
- * Verify command template exists
368
- */
369
- async verifyTemplate(commandName) {
370
- try {
371
- const templatePath = import_path2.default.join(this.templatesDir, `${commandName}.md`);
372
- await import_promises.default.access(templatePath);
373
- return true;
374
- } catch {
375
- return false;
376
- }
377
- }
378
- /**
379
- * Install the p.md router to ~/.claude/commands/
380
- * This enables the "p. task" natural language trigger
381
- * Claude Code bug #2422 prevents subdirectory slash command discovery
382
- */
383
- async installRouter() {
384
- try {
385
- const routerSource = import_path2.default.join(this.templatesDir, "p.md");
386
- const routerDest = import_path2.default.join(this.homeDir, ".claude", "commands", "p.md");
387
- const content = await import_promises.default.readFile(routerSource, "utf-8");
388
- await import_promises.default.writeFile(routerDest, content, "utf-8");
389
- return true;
390
- } catch {
391
- return false;
392
- }
393
- }
394
- /**
395
- * Sync commands - intelligent update that detects and removes orphans
396
- */
397
- async syncCommands() {
398
- const claudeDetected = await this.detectClaude();
399
- if (!claudeDetected) {
400
- return {
401
- success: false,
402
- error: "Claude not detected",
403
- added: 0,
404
- updated: 0,
405
- removed: 0
406
- };
407
- }
408
- try {
409
- await this.installRouter();
410
- await import_promises.default.mkdir(this.claudeCommandsPath, { recursive: true });
411
- const templateFiles = await this.getCommandFiles();
412
- let installedFiles = [];
413
- try {
414
- installedFiles = await import_promises.default.readdir(this.claudeCommandsPath);
415
- installedFiles = installedFiles.filter((f) => f.endsWith(".md"));
416
- } catch {
417
- installedFiles = [];
418
- }
419
- const results = {
420
- success: true,
421
- added: 0,
422
- updated: 0,
423
- removed: 0,
424
- errors: []
425
- };
426
- for (const file of templateFiles) {
427
- try {
428
- const sourcePath = import_path2.default.join(this.templatesDir, file);
429
- const destPath = import_path2.default.join(this.claudeCommandsPath, file);
430
- const exists = installedFiles.includes(file);
431
- const content = await import_promises.default.readFile(sourcePath, "utf-8");
432
- await import_promises.default.writeFile(destPath, content, "utf-8");
433
- if (!exists) {
434
- results.added++;
435
- } else {
436
- results.updated++;
437
- }
438
- } catch (error) {
439
- results.errors.push({ file, error: error.message });
440
- }
441
- }
442
- return results;
443
- } catch (error) {
444
- return {
445
- success: false,
446
- error: error.message,
447
- added: 0,
448
- updated: 0,
449
- removed: 0
450
- };
451
- }
452
- }
453
- /**
454
- * Install or update global CLAUDE.md configuration
455
- */
456
- async installGlobalConfig() {
457
- return installGlobalConfig(this.claudeConfigPath, () => this.detectClaude());
458
- }
459
- /**
460
- * Install documentation files to ~/.prjct-cli/docs/
461
- */
462
- async installDocs() {
463
- return installDocs();
464
- }
465
- };
466
- var commandInstaller = new CommandInstaller();
467
- var command_installer_default = commandInstaller;
468
- // Annotate the CommonJS export names for ESM import in node:
469
- 0 && (module.exports = {
470
- CommandInstaller,
471
- installDocs,
472
- installGlobalConfig
473
- });
@@ -1,157 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // core/infrastructure/editors-config.ts
32
- var editors_config_exports = {};
33
- __export(editors_config_exports, {
34
- default: () => editors_config_default
35
- });
36
- module.exports = __toCommonJS(editors_config_exports);
37
- var import_promises = __toESM(require("fs/promises"));
38
- var import_path = __toESM(require("path"));
39
- var import_os = __toESM(require("os"));
40
- var EditorsConfig = class {
41
- static {
42
- __name(this, "EditorsConfig");
43
- }
44
- homeDir;
45
- configDir;
46
- configFile;
47
- constructor() {
48
- this.homeDir = import_os.default.homedir();
49
- this.configDir = import_path.default.join(this.homeDir, ".prjct-cli", "config");
50
- this.configFile = import_path.default.join(this.configDir, "installed-editors.json");
51
- }
52
- /**
53
- * Ensure config directory exists
54
- */
55
- async ensureConfigDir() {
56
- try {
57
- await import_promises.default.mkdir(this.configDir, { recursive: true });
58
- } catch (error) {
59
- console.error("[editors-config] Error creating config directory:", error.message);
60
- }
61
- }
62
- /**
63
- * Load installation configuration
64
- */
65
- async loadConfig() {
66
- try {
67
- const content = await import_promises.default.readFile(this.configFile, "utf-8");
68
- return JSON.parse(content);
69
- } catch (error) {
70
- if (error.code === "ENOENT") {
71
- return null;
72
- }
73
- console.error("[editors-config] Error loading config:", error.message);
74
- return null;
75
- }
76
- }
77
- /**
78
- * Save installation configuration
79
- */
80
- async saveConfig(version, claudePath) {
81
- try {
82
- await this.ensureConfigDir();
83
- const config = {
84
- version,
85
- editor: "claude",
86
- lastInstall: (/* @__PURE__ */ new Date()).toISOString(),
87
- path: claudePath
88
- };
89
- await import_promises.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
90
- return true;
91
- } catch (error) {
92
- console.error("[editors-config] Error saving config:", error.message);
93
- return false;
94
- }
95
- }
96
- /**
97
- * Get last installed version
98
- */
99
- async getLastVersion() {
100
- const config = await this.loadConfig();
101
- return config ? config.version : null;
102
- }
103
- /**
104
- * Check if version has changed since last install
105
- */
106
- async hasVersionChanged(currentVersion) {
107
- const lastVersion = await this.getLastVersion();
108
- return lastVersion !== null && lastVersion !== currentVersion;
109
- }
110
- /**
111
- * Update version in configuration
112
- */
113
- async updateVersion(version) {
114
- try {
115
- const config = await this.loadConfig();
116
- if (!config) {
117
- return false;
118
- }
119
- config.version = version;
120
- config.lastInstall = (/* @__PURE__ */ new Date()).toISOString();
121
- await import_promises.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
122
- return true;
123
- } catch (error) {
124
- console.error("[editors-config] Error updating version:", error.message);
125
- return false;
126
- }
127
- }
128
- /**
129
- * Check if config file exists
130
- */
131
- async configExists() {
132
- try {
133
- await import_promises.default.access(this.configFile);
134
- return true;
135
- } catch {
136
- return false;
137
- }
138
- }
139
- /**
140
- * Delete configuration file
141
- * Used during uninstallation to clean up tracking data
142
- */
143
- async deleteConfig() {
144
- try {
145
- const exists = await this.configExists();
146
- if (exists) {
147
- await import_promises.default.unlink(this.configFile);
148
- }
149
- return true;
150
- } catch (error) {
151
- console.error("[editors-config] Error deleting config:", error.message);
152
- return false;
153
- }
154
- }
155
- };
156
- var editorsConfig = new EditorsConfig();
157
- var editors_config_default = editorsConfig;