prjct-cli 0.33.5 → 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 (39) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/package.json +1 -1
  3. package/scripts/postinstall.js +26 -2
  4. package/templates/agentic/orchestrator.md +303 -0
  5. package/templates/commands/bug.md +2 -0
  6. package/templates/commands/github.md +63 -7
  7. package/templates/commands/jira.md +44 -4
  8. package/templates/commands/linear.md +40 -8
  9. package/templates/commands/monday.md +42 -6
  10. package/templates/commands/p.md +57 -10
  11. package/templates/commands/sync.md +133 -97
  12. package/templates/commands/task.md +12 -0
  13. package/templates/config/skill-mappings.json +95 -63
  14. package/dist/bin/prjct.mjs +0 -13581
  15. package/dist/core/infrastructure/command-installer.js +0 -473
  16. package/dist/core/infrastructure/editors-config.js +0 -157
  17. package/dist/core/infrastructure/setup.js +0 -893
  18. package/dist/core/utils/version.js +0 -142
  19. package/packages/shared/.turbo/turbo-build.log +0 -14
  20. package/packages/shared/dist/index.d.ts +0 -10
  21. package/packages/shared/dist/index.d.ts.map +0 -1
  22. package/packages/shared/dist/index.js +0 -4196
  23. package/packages/shared/dist/schemas.d.ts +0 -408
  24. package/packages/shared/dist/schemas.d.ts.map +0 -1
  25. package/packages/shared/dist/types.d.ts +0 -144
  26. package/packages/shared/dist/types.d.ts.map +0 -1
  27. package/packages/shared/dist/unified.d.ts +0 -139
  28. package/packages/shared/dist/unified.d.ts.map +0 -1
  29. package/packages/shared/dist/utils.d.ts +0 -60
  30. package/packages/shared/dist/utils.d.ts.map +0 -1
  31. package/templates/commands/ask.md +0 -128
  32. package/templates/commands/dashboard.md +0 -686
  33. package/templates/commands/feature.md +0 -46
  34. package/templates/commands/now.md +0 -53
  35. package/templates/commands/suggest.md +0 -116
  36. package/templates/global/docs/agents.md +0 -88
  37. package/templates/global/docs/architecture.md +0 -103
  38. package/templates/global/docs/commands.md +0 -96
  39. package/templates/global/docs/validation.md +0 -95
@@ -1,893 +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/setup.ts
32
- var setup_exports = {};
33
- __export(setup_exports, {
34
- default: () => setup_default,
35
- run: () => run
36
- });
37
- module.exports = __toCommonJS(setup_exports);
38
- var import_child_process = require("child_process");
39
- var import_fs2 = __toESM(require("fs"));
40
- var import_path4 = __toESM(require("path"));
41
- var import_os3 = __toESM(require("os"));
42
-
43
- // core/infrastructure/command-installer.ts
44
- var import_promises = __toESM(require("fs/promises"));
45
- var import_path2 = __toESM(require("path"));
46
- var import_os = __toESM(require("os"));
47
-
48
- // core/utils/version.ts
49
- var import_fs = __toESM(require("fs"));
50
- var import_path = __toESM(require("path"));
51
- var cachedVersion = null;
52
- var cachedPackageJson = null;
53
- var cachedPackageRoot = null;
54
- function getPackageRoot() {
55
- if (cachedPackageRoot) {
56
- return cachedPackageRoot;
57
- }
58
- let currentDir = __dirname;
59
- for (let i = 0; i < 5; i++) {
60
- const packageJsonPath = import_path.default.join(currentDir, "package.json");
61
- if (import_fs.default.existsSync(packageJsonPath)) {
62
- try {
63
- const pkg = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf-8"));
64
- if (pkg.name === "prjct-cli") {
65
- cachedPackageRoot = currentDir;
66
- return currentDir;
67
- }
68
- } catch {
69
- }
70
- }
71
- currentDir = import_path.default.dirname(currentDir);
72
- }
73
- cachedPackageRoot = import_path.default.join(__dirname, "..", "..", "..");
74
- return cachedPackageRoot;
75
- }
76
- __name(getPackageRoot, "getPackageRoot");
77
- function getVersion() {
78
- if (cachedVersion) {
79
- return cachedVersion;
80
- }
81
- try {
82
- const packageJsonPath = import_path.default.join(getPackageRoot(), "package.json");
83
- const packageJson = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf-8"));
84
- cachedVersion = packageJson.version;
85
- cachedPackageJson = packageJson;
86
- return cachedVersion;
87
- } catch (error) {
88
- console.error("Failed to read version from package.json:", error.message);
89
- return "0.0.0";
90
- }
91
- }
92
- __name(getVersion, "getVersion");
93
- var VERSION = getVersion();
94
- var PACKAGE_ROOT = getPackageRoot();
95
-
96
- // core/infrastructure/command-installer.ts
97
- async function installDocs() {
98
- try {
99
- const docsDir = import_path2.default.join(import_os.default.homedir(), ".prjct-cli", "docs");
100
- const templateDocsDir = import_path2.default.join(getPackageRoot(), "templates/global/docs");
101
- await import_promises.default.mkdir(docsDir, { recursive: true });
102
- const docFiles = await import_promises.default.readdir(templateDocsDir);
103
- for (const file of docFiles) {
104
- if (file.endsWith(".md")) {
105
- const srcPath = import_path2.default.join(templateDocsDir, file);
106
- const destPath = import_path2.default.join(docsDir, file);
107
- const content = await import_promises.default.readFile(srcPath, "utf-8");
108
- await import_promises.default.writeFile(destPath, content, "utf-8");
109
- }
110
- }
111
- return { success: true };
112
- } catch (error) {
113
- return { success: false, error: error.message };
114
- }
115
- }
116
- __name(installDocs, "installDocs");
117
- async function installGlobalConfig(claudeConfigPath, detectClaude) {
118
- const claudeDetected = await detectClaude();
119
- if (!claudeDetected) {
120
- return {
121
- success: false,
122
- error: "Claude not detected",
123
- action: "skipped"
124
- };
125
- }
126
- try {
127
- const claudeDir = import_path2.default.join(import_os.default.homedir(), ".claude");
128
- await import_promises.default.mkdir(claudeDir, { recursive: true });
129
- const globalConfigPath = import_path2.default.join(claudeDir, "CLAUDE.md");
130
- const templatePath = import_path2.default.join(getPackageRoot(), "templates/global/CLAUDE.md");
131
- const templateContent = await import_promises.default.readFile(templatePath, "utf-8");
132
- let existingContent = "";
133
- let fileExists = false;
134
- try {
135
- existingContent = await import_promises.default.readFile(globalConfigPath, "utf-8");
136
- fileExists = true;
137
- } catch {
138
- fileExists = false;
139
- }
140
- if (!fileExists) {
141
- await import_promises.default.writeFile(globalConfigPath, templateContent, "utf-8");
142
- return {
143
- success: true,
144
- action: "created",
145
- path: globalConfigPath
146
- };
147
- } else {
148
- const startMarker = "<!-- prjct:start - DO NOT REMOVE THIS MARKER -->";
149
- const endMarker = "<!-- prjct:end - DO NOT REMOVE THIS MARKER -->";
150
- const hasMarkers = existingContent.includes(startMarker) && existingContent.includes(endMarker);
151
- if (!hasMarkers) {
152
- const updatedContent = existingContent + "\n\n" + templateContent;
153
- await import_promises.default.writeFile(globalConfigPath, updatedContent, "utf-8");
154
- return {
155
- success: true,
156
- action: "appended",
157
- path: globalConfigPath
158
- };
159
- } else {
160
- const beforeMarker = existingContent.substring(0, existingContent.indexOf(startMarker));
161
- const afterMarker = existingContent.substring(
162
- existingContent.indexOf(endMarker) + endMarker.length
163
- );
164
- const prjctSection = templateContent.substring(
165
- templateContent.indexOf(startMarker),
166
- templateContent.indexOf(endMarker) + endMarker.length
167
- );
168
- const updatedContent = beforeMarker + prjctSection + afterMarker;
169
- await import_promises.default.writeFile(globalConfigPath, updatedContent, "utf-8");
170
- return {
171
- success: true,
172
- action: "updated",
173
- path: globalConfigPath
174
- };
175
- }
176
- }
177
- } catch (error) {
178
- return {
179
- success: false,
180
- error: error.message,
181
- action: "failed"
182
- };
183
- }
184
- }
185
- __name(installGlobalConfig, "installGlobalConfig");
186
- var CommandInstaller = class {
187
- static {
188
- __name(this, "CommandInstaller");
189
- }
190
- homeDir;
191
- claudeCommandsPath;
192
- claudeConfigPath;
193
- templatesDir;
194
- constructor() {
195
- this.homeDir = import_os.default.homedir();
196
- this.claudeCommandsPath = import_path2.default.join(this.homeDir, ".claude", "commands", "p");
197
- this.claudeConfigPath = import_path2.default.join(this.homeDir, ".claude");
198
- this.templatesDir = import_path2.default.join(getPackageRoot(), "templates", "commands");
199
- }
200
- /**
201
- * Detect if Claude is installed
202
- */
203
- async detectClaude() {
204
- try {
205
- await import_promises.default.access(this.claudeConfigPath);
206
- return true;
207
- } catch {
208
- return false;
209
- }
210
- }
211
- /**
212
- * Get list of command files to install
213
- */
214
- async getCommandFiles() {
215
- try {
216
- const files = await import_promises.default.readdir(this.templatesDir);
217
- return files.filter((f) => f.endsWith(".md"));
218
- } catch {
219
- return [
220
- "init.md",
221
- "now.md",
222
- "done.md",
223
- "ship.md",
224
- "next.md",
225
- "idea.md",
226
- "recap.md",
227
- "progress.md",
228
- "stuck.md",
229
- "context.md",
230
- "analyze.md",
231
- "sync.md",
232
- "roadmap.md",
233
- "task.md",
234
- "git.md",
235
- "fix.md",
236
- "test.md",
237
- "cleanup.md",
238
- "design.md"
239
- ];
240
- }
241
- }
242
- /**
243
- * Install commands to Claude
244
- */
245
- async installCommands() {
246
- const claudeDetected = await this.detectClaude();
247
- if (!claudeDetected) {
248
- return {
249
- success: false,
250
- error: "Claude not detected. Please install Claude Code or Claude Desktop first."
251
- };
252
- }
253
- try {
254
- await this.installRouter();
255
- await import_promises.default.mkdir(this.claudeCommandsPath, { recursive: true });
256
- const commandFiles = await this.getCommandFiles();
257
- const installed = [];
258
- const errors = [];
259
- for (const file of commandFiles) {
260
- try {
261
- const sourcePath = import_path2.default.join(this.templatesDir, file);
262
- const destPath = import_path2.default.join(this.claudeCommandsPath, file);
263
- const content = await import_promises.default.readFile(sourcePath, "utf-8");
264
- await import_promises.default.writeFile(destPath, content, "utf-8");
265
- installed.push(file.replace(".md", ""));
266
- } catch (error) {
267
- errors.push({ file, error: error.message });
268
- }
269
- }
270
- return {
271
- success: true,
272
- installed,
273
- errors,
274
- path: this.claudeCommandsPath
275
- };
276
- } catch (error) {
277
- return {
278
- success: false,
279
- error: error.message
280
- };
281
- }
282
- }
283
- /**
284
- * Uninstall commands from Claude
285
- */
286
- async uninstallCommands() {
287
- try {
288
- const commandFiles = await this.getCommandFiles();
289
- const uninstalled = [];
290
- const errors = [];
291
- for (const file of commandFiles) {
292
- try {
293
- const filePath = import_path2.default.join(this.claudeCommandsPath, file);
294
- await import_promises.default.unlink(filePath);
295
- uninstalled.push(file.replace(".md", ""));
296
- } catch (error) {
297
- if (error.code !== "ENOENT") {
298
- errors.push({ file, error: error.message });
299
- }
300
- }
301
- }
302
- try {
303
- await import_promises.default.rmdir(this.claudeCommandsPath);
304
- } catch {
305
- }
306
- return {
307
- success: true,
308
- uninstalled,
309
- errors
310
- };
311
- } catch (error) {
312
- return {
313
- success: false,
314
- error: error.message
315
- };
316
- }
317
- }
318
- /**
319
- * Check if commands are already installed
320
- */
321
- async checkInstallation() {
322
- const claudeDetected = await this.detectClaude();
323
- if (!claudeDetected) {
324
- return {
325
- installed: false,
326
- claudeDetected: false
327
- };
328
- }
329
- try {
330
- await import_promises.default.access(this.claudeCommandsPath);
331
- const files = await import_promises.default.readdir(this.claudeCommandsPath);
332
- const installedCommands = files.filter((f) => f.endsWith(".md")).map((f) => f.replace(".md", ""));
333
- return {
334
- installed: installedCommands.length > 0,
335
- claudeDetected: true,
336
- commands: installedCommands,
337
- path: this.claudeCommandsPath
338
- };
339
- } catch {
340
- return {
341
- installed: false,
342
- claudeDetected: true,
343
- commands: []
344
- };
345
- }
346
- }
347
- /**
348
- * Update commands (reinstall with latest templates)
349
- */
350
- async updateCommands() {
351
- console.log("Updating commands with latest templates...");
352
- const result = await this.installCommands();
353
- if (result.success && result.installed) {
354
- console.log(`Updated ${result.installed.length} commands`);
355
- }
356
- return result;
357
- }
358
- /**
359
- * Install to all detected editors (alias for installCommands)
360
- */
361
- async installToAll() {
362
- return await this.installCommands();
363
- }
364
- /**
365
- * Get installation path for Claude commands
366
- */
367
- getInstallPath() {
368
- return this.claudeCommandsPath;
369
- }
370
- /**
371
- * Verify command template exists
372
- */
373
- async verifyTemplate(commandName) {
374
- try {
375
- const templatePath = import_path2.default.join(this.templatesDir, `${commandName}.md`);
376
- await import_promises.default.access(templatePath);
377
- return true;
378
- } catch {
379
- return false;
380
- }
381
- }
382
- /**
383
- * Install the p.md router to ~/.claude/commands/
384
- * This enables the "p. task" natural language trigger
385
- * Claude Code bug #2422 prevents subdirectory slash command discovery
386
- */
387
- async installRouter() {
388
- try {
389
- const routerSource = import_path2.default.join(this.templatesDir, "p.md");
390
- const routerDest = import_path2.default.join(this.homeDir, ".claude", "commands", "p.md");
391
- const content = await import_promises.default.readFile(routerSource, "utf-8");
392
- await import_promises.default.writeFile(routerDest, content, "utf-8");
393
- return true;
394
- } catch {
395
- return false;
396
- }
397
- }
398
- /**
399
- * Sync commands - intelligent update that detects and removes orphans
400
- */
401
- async syncCommands() {
402
- const claudeDetected = await this.detectClaude();
403
- if (!claudeDetected) {
404
- return {
405
- success: false,
406
- error: "Claude not detected",
407
- added: 0,
408
- updated: 0,
409
- removed: 0
410
- };
411
- }
412
- try {
413
- await this.installRouter();
414
- await import_promises.default.mkdir(this.claudeCommandsPath, { recursive: true });
415
- const templateFiles = await this.getCommandFiles();
416
- let installedFiles = [];
417
- try {
418
- installedFiles = await import_promises.default.readdir(this.claudeCommandsPath);
419
- installedFiles = installedFiles.filter((f) => f.endsWith(".md"));
420
- } catch {
421
- installedFiles = [];
422
- }
423
- const results = {
424
- success: true,
425
- added: 0,
426
- updated: 0,
427
- removed: 0,
428
- errors: []
429
- };
430
- for (const file of templateFiles) {
431
- try {
432
- const sourcePath = import_path2.default.join(this.templatesDir, file);
433
- const destPath = import_path2.default.join(this.claudeCommandsPath, file);
434
- const exists = installedFiles.includes(file);
435
- const content = await import_promises.default.readFile(sourcePath, "utf-8");
436
- await import_promises.default.writeFile(destPath, content, "utf-8");
437
- if (!exists) {
438
- results.added++;
439
- } else {
440
- results.updated++;
441
- }
442
- } catch (error) {
443
- results.errors.push({ file, error: error.message });
444
- }
445
- }
446
- return results;
447
- } catch (error) {
448
- return {
449
- success: false,
450
- error: error.message,
451
- added: 0,
452
- updated: 0,
453
- removed: 0
454
- };
455
- }
456
- }
457
- /**
458
- * Install or update global CLAUDE.md configuration
459
- */
460
- async installGlobalConfig() {
461
- return installGlobalConfig(this.claudeConfigPath, () => this.detectClaude());
462
- }
463
- /**
464
- * Install documentation files to ~/.prjct-cli/docs/
465
- */
466
- async installDocs() {
467
- return installDocs();
468
- }
469
- };
470
- var commandInstaller = new CommandInstaller();
471
- var command_installer_default = commandInstaller;
472
-
473
- // core/infrastructure/editors-config.ts
474
- var import_promises2 = __toESM(require("fs/promises"));
475
- var import_path3 = __toESM(require("path"));
476
- var import_os2 = __toESM(require("os"));
477
- var EditorsConfig = class {
478
- static {
479
- __name(this, "EditorsConfig");
480
- }
481
- homeDir;
482
- configDir;
483
- configFile;
484
- constructor() {
485
- this.homeDir = import_os2.default.homedir();
486
- this.configDir = import_path3.default.join(this.homeDir, ".prjct-cli", "config");
487
- this.configFile = import_path3.default.join(this.configDir, "installed-editors.json");
488
- }
489
- /**
490
- * Ensure config directory exists
491
- */
492
- async ensureConfigDir() {
493
- try {
494
- await import_promises2.default.mkdir(this.configDir, { recursive: true });
495
- } catch (error) {
496
- console.error("[editors-config] Error creating config directory:", error.message);
497
- }
498
- }
499
- /**
500
- * Load installation configuration
501
- */
502
- async loadConfig() {
503
- try {
504
- const content = await import_promises2.default.readFile(this.configFile, "utf-8");
505
- return JSON.parse(content);
506
- } catch (error) {
507
- if (error.code === "ENOENT") {
508
- return null;
509
- }
510
- console.error("[editors-config] Error loading config:", error.message);
511
- return null;
512
- }
513
- }
514
- /**
515
- * Save installation configuration
516
- */
517
- async saveConfig(version, claudePath) {
518
- try {
519
- await this.ensureConfigDir();
520
- const config = {
521
- version,
522
- editor: "claude",
523
- lastInstall: (/* @__PURE__ */ new Date()).toISOString(),
524
- path: claudePath
525
- };
526
- await import_promises2.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
527
- return true;
528
- } catch (error) {
529
- console.error("[editors-config] Error saving config:", error.message);
530
- return false;
531
- }
532
- }
533
- /**
534
- * Get last installed version
535
- */
536
- async getLastVersion() {
537
- const config = await this.loadConfig();
538
- return config ? config.version : null;
539
- }
540
- /**
541
- * Check if version has changed since last install
542
- */
543
- async hasVersionChanged(currentVersion) {
544
- const lastVersion = await this.getLastVersion();
545
- return lastVersion !== null && lastVersion !== currentVersion;
546
- }
547
- /**
548
- * Update version in configuration
549
- */
550
- async updateVersion(version) {
551
- try {
552
- const config = await this.loadConfig();
553
- if (!config) {
554
- return false;
555
- }
556
- config.version = version;
557
- config.lastInstall = (/* @__PURE__ */ new Date()).toISOString();
558
- await import_promises2.default.writeFile(this.configFile, JSON.stringify(config, null, 2), "utf-8");
559
- return true;
560
- } catch (error) {
561
- console.error("[editors-config] Error updating version:", error.message);
562
- return false;
563
- }
564
- }
565
- /**
566
- * Check if config file exists
567
- */
568
- async configExists() {
569
- try {
570
- await import_promises2.default.access(this.configFile);
571
- return true;
572
- } catch {
573
- return false;
574
- }
575
- }
576
- /**
577
- * Delete configuration file
578
- * Used during uninstallation to clean up tracking data
579
- */
580
- async deleteConfig() {
581
- try {
582
- const exists = await this.configExists();
583
- if (exists) {
584
- await import_promises2.default.unlink(this.configFile);
585
- }
586
- return true;
587
- } catch (error) {
588
- console.error("[editors-config] Error deleting config:", error.message);
589
- return false;
590
- }
591
- }
592
- };
593
- var editorsConfig = new EditorsConfig();
594
- var editors_config_default = editorsConfig;
595
-
596
- // core/infrastructure/setup.ts
597
- var GREEN = "\x1B[32m";
598
- var YELLOW = "\x1B[33m";
599
- var DIM = "\x1B[2m";
600
- var NC = "\x1B[0m";
601
- async function hasClaudeCodeCLI() {
602
- try {
603
- (0, import_child_process.execSync)("which claude", { stdio: "ignore" });
604
- return true;
605
- } catch {
606
- return false;
607
- }
608
- }
609
- __name(hasClaudeCodeCLI, "hasClaudeCodeCLI");
610
- async function installClaudeCode() {
611
- try {
612
- console.log(`${YELLOW}\u{1F4E6} Claude Code not found. Installing...${NC}`);
613
- console.log("");
614
- (0, import_child_process.execSync)("npm install -g @anthropic-ai/claude-code", { stdio: "inherit" });
615
- console.log("");
616
- console.log(`${GREEN}\u2713${NC} Claude Code installed successfully`);
617
- console.log("");
618
- return true;
619
- } catch (error) {
620
- console.log(`${YELLOW}\u26A0\uFE0F Failed to install Claude Code: ${error.message}${NC}`);
621
- console.log(`${DIM}Please install manually: npm install -g @anthropic-ai/claude-code${NC}`);
622
- console.log("");
623
- return false;
624
- }
625
- }
626
- __name(installClaudeCode, "installClaudeCode");
627
- async function run() {
628
- const results = {
629
- claudeInstalled: false,
630
- commandsAdded: 0,
631
- commandsUpdated: 0,
632
- configAction: null
633
- };
634
- const hasClaude = await hasClaudeCodeCLI();
635
- if (!hasClaude) {
636
- const installed = await installClaudeCode();
637
- if (installed) {
638
- results.claudeInstalled = true;
639
- } else {
640
- throw new Error("Claude Code installation failed");
641
- }
642
- }
643
- const claudeDetected = await command_installer_default.detectClaude();
644
- if (claudeDetected) {
645
- const syncResult = await command_installer_default.syncCommands();
646
- if (syncResult.success) {
647
- results.commandsAdded = syncResult.added;
648
- results.commandsUpdated = syncResult.updated;
649
- }
650
- const configResult = await command_installer_default.installGlobalConfig();
651
- if (configResult.success) {
652
- results.configAction = configResult.action;
653
- }
654
- await command_installer_default.installDocs();
655
- await installStatusLine();
656
- }
657
- await editors_config_default.saveConfig(VERSION, command_installer_default.getInstallPath());
658
- await migrateProjectsCliVersion();
659
- showResults(results);
660
- return results;
661
- }
662
- __name(run, "run");
663
- var setup_default = { run };
664
- async function migrateProjectsCliVersion() {
665
- try {
666
- const projectsDir = import_path4.default.join(import_os3.default.homedir(), ".prjct-cli", "projects");
667
- if (!import_fs2.default.existsSync(projectsDir)) {
668
- return;
669
- }
670
- const projectDirs = import_fs2.default.readdirSync(projectsDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
671
- let migrated = 0;
672
- for (const projectId of projectDirs) {
673
- const projectJsonPath = import_path4.default.join(projectsDir, projectId, "project.json");
674
- if (!import_fs2.default.existsSync(projectJsonPath)) {
675
- continue;
676
- }
677
- try {
678
- const content = import_fs2.default.readFileSync(projectJsonPath, "utf8");
679
- const project = JSON.parse(content);
680
- if (project.cliVersion !== VERSION) {
681
- project.cliVersion = VERSION;
682
- import_fs2.default.writeFileSync(projectJsonPath, JSON.stringify(project, null, 2));
683
- migrated++;
684
- }
685
- } catch {
686
- }
687
- }
688
- if (migrated > 0) {
689
- console.log(` ${GREEN}\u2713${NC} Updated ${migrated} project(s) to v${VERSION}`);
690
- }
691
- } catch {
692
- }
693
- }
694
- __name(migrateProjectsCliVersion, "migrateProjectsCliVersion");
695
- function ensureStatusLineSettings(settingsPath, statusLinePath) {
696
- let settings = {};
697
- if (import_fs2.default.existsSync(settingsPath)) {
698
- try {
699
- settings = JSON.parse(import_fs2.default.readFileSync(settingsPath, "utf8"));
700
- } catch {
701
- }
702
- }
703
- settings.statusLine = { type: "command", command: statusLinePath };
704
- import_fs2.default.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
705
- }
706
- __name(ensureStatusLineSettings, "ensureStatusLineSettings");
707
- async function installStatusLine() {
708
- try {
709
- const claudeDir = import_path4.default.join(import_os3.default.homedir(), ".claude");
710
- const settingsPath = import_path4.default.join(claudeDir, "settings.json");
711
- const claudeStatusLinePath = import_path4.default.join(claudeDir, "prjct-statusline.sh");
712
- const prjctStatusLineDir = import_path4.default.join(import_os3.default.homedir(), ".prjct-cli", "statusline");
713
- const prjctStatusLinePath = import_path4.default.join(prjctStatusLineDir, "statusline.sh");
714
- const prjctThemesDir = import_path4.default.join(prjctStatusLineDir, "themes");
715
- const prjctLibDir = import_path4.default.join(prjctStatusLineDir, "lib");
716
- const prjctComponentsDir = import_path4.default.join(prjctStatusLineDir, "components");
717
- const prjctConfigPath = import_path4.default.join(prjctStatusLineDir, "config.json");
718
- const assetsDir = import_path4.default.join(getPackageRoot(), "assets", "statusline");
719
- const sourceScript = import_path4.default.join(assetsDir, "statusline.sh");
720
- const sourceThemeDir = import_path4.default.join(assetsDir, "themes");
721
- const sourceLibDir = import_path4.default.join(assetsDir, "lib");
722
- const sourceComponentsDir = import_path4.default.join(assetsDir, "components");
723
- const sourceConfigPath = import_path4.default.join(assetsDir, "default-config.json");
724
- if (!import_fs2.default.existsSync(claudeDir)) {
725
- import_fs2.default.mkdirSync(claudeDir, { recursive: true });
726
- }
727
- if (!import_fs2.default.existsSync(prjctStatusLineDir)) {
728
- import_fs2.default.mkdirSync(prjctStatusLineDir, { recursive: true });
729
- }
730
- if (!import_fs2.default.existsSync(prjctThemesDir)) {
731
- import_fs2.default.mkdirSync(prjctThemesDir, { recursive: true });
732
- }
733
- if (!import_fs2.default.existsSync(prjctLibDir)) {
734
- import_fs2.default.mkdirSync(prjctLibDir, { recursive: true });
735
- }
736
- if (!import_fs2.default.existsSync(prjctComponentsDir)) {
737
- import_fs2.default.mkdirSync(prjctComponentsDir, { recursive: true });
738
- }
739
- if (import_fs2.default.existsSync(prjctStatusLinePath)) {
740
- const existingContent = import_fs2.default.readFileSync(prjctStatusLinePath, "utf8");
741
- if (existingContent.includes("CLI_VERSION=")) {
742
- const versionMatch = existingContent.match(/CLI_VERSION="([^"]*)"/);
743
- if (versionMatch && versionMatch[1] !== VERSION) {
744
- const updatedContent = existingContent.replace(
745
- /CLI_VERSION="[^"]*"/,
746
- `CLI_VERSION="${VERSION}"`
747
- );
748
- import_fs2.default.writeFileSync(prjctStatusLinePath, updatedContent, { mode: 493 });
749
- }
750
- installStatusLineModules(sourceLibDir, prjctLibDir);
751
- installStatusLineModules(sourceComponentsDir, prjctComponentsDir);
752
- ensureStatusLineSymlink(claudeStatusLinePath, prjctStatusLinePath);
753
- ensureStatusLineSettings(settingsPath, claudeStatusLinePath);
754
- return;
755
- }
756
- }
757
- if (import_fs2.default.existsSync(sourceScript)) {
758
- let scriptContent = import_fs2.default.readFileSync(sourceScript, "utf8");
759
- scriptContent = scriptContent.replace(
760
- /CLI_VERSION="[^"]*"/,
761
- `CLI_VERSION="${VERSION}"`
762
- );
763
- import_fs2.default.writeFileSync(prjctStatusLinePath, scriptContent, { mode: 493 });
764
- installStatusLineModules(sourceLibDir, prjctLibDir);
765
- installStatusLineModules(sourceComponentsDir, prjctComponentsDir);
766
- if (import_fs2.default.existsSync(sourceThemeDir)) {
767
- const themes = import_fs2.default.readdirSync(sourceThemeDir);
768
- for (const theme of themes) {
769
- const src = import_path4.default.join(sourceThemeDir, theme);
770
- const dest = import_path4.default.join(prjctThemesDir, theme);
771
- import_fs2.default.copyFileSync(src, dest);
772
- }
773
- }
774
- if (!import_fs2.default.existsSync(prjctConfigPath) && import_fs2.default.existsSync(sourceConfigPath)) {
775
- import_fs2.default.copyFileSync(sourceConfigPath, prjctConfigPath);
776
- }
777
- } else {
778
- const scriptContent = `#!/bin/bash
779
- # prjct Status Line for Claude Code
780
- CLI_VERSION="${VERSION}"
781
- input=$(cat)
782
- CWD=$(echo "$input" | jq -r '.workspace.current_dir // "~"' 2>/dev/null)
783
- CONFIG="$CWD/.prjct/prjct.config.json"
784
- if [ -f "$CONFIG" ]; then
785
- PROJECT_ID=$(jq -r '.projectId // ""' "$CONFIG" 2>/dev/null)
786
- if [ -n "$PROJECT_ID" ]; then
787
- PROJECT_JSON="$HOME/.prjct-cli/projects/$PROJECT_ID/project.json"
788
- if [ -f "$PROJECT_JSON" ]; then
789
- PROJECT_VERSION=$(jq -r '.cliVersion // ""' "$PROJECT_JSON" 2>/dev/null)
790
- if [ -z "$PROJECT_VERSION" ] || [ "$PROJECT_VERSION" != "$CLI_VERSION" ]; then
791
- echo "prjct v$CLI_VERSION - run p. sync"
792
- exit 0
793
- fi
794
- else
795
- echo "prjct v$CLI_VERSION - run p. sync"
796
- exit 0
797
- fi
798
- STATE="$HOME/.prjct-cli/projects/$PROJECT_ID/storage/state.json"
799
- if [ -f "$STATE" ]; then
800
- TASK=$(jq -r '.currentTask.description // ""' "$STATE" 2>/dev/null)
801
- if [ -n "$TASK" ]; then
802
- echo "$TASK"
803
- exit 0
804
- fi
805
- fi
806
- fi
807
- fi
808
- echo "prjct"
809
- `;
810
- import_fs2.default.writeFileSync(prjctStatusLinePath, scriptContent, { mode: 493 });
811
- }
812
- ensureStatusLineSymlink(claudeStatusLinePath, prjctStatusLinePath);
813
- ensureStatusLineSettings(settingsPath, claudeStatusLinePath);
814
- } catch {
815
- }
816
- }
817
- __name(installStatusLine, "installStatusLine");
818
- function installStatusLineModules(sourceDir, destDir) {
819
- if (!import_fs2.default.existsSync(sourceDir)) {
820
- return;
821
- }
822
- const files = import_fs2.default.readdirSync(sourceDir);
823
- for (const file of files) {
824
- if (file.endsWith(".sh")) {
825
- const src = import_path4.default.join(sourceDir, file);
826
- const dest = import_path4.default.join(destDir, file);
827
- import_fs2.default.copyFileSync(src, dest);
828
- import_fs2.default.chmodSync(dest, 493);
829
- }
830
- }
831
- }
832
- __name(installStatusLineModules, "installStatusLineModules");
833
- function ensureStatusLineSymlink(linkPath, targetPath) {
834
- try {
835
- if (import_fs2.default.existsSync(linkPath)) {
836
- const stats = import_fs2.default.lstatSync(linkPath);
837
- if (stats.isSymbolicLink()) {
838
- const existingTarget = import_fs2.default.readlinkSync(linkPath);
839
- if (existingTarget === targetPath) {
840
- return;
841
- }
842
- }
843
- import_fs2.default.unlinkSync(linkPath);
844
- }
845
- import_fs2.default.symlinkSync(targetPath, linkPath);
846
- } catch {
847
- try {
848
- if (import_fs2.default.existsSync(targetPath)) {
849
- import_fs2.default.copyFileSync(targetPath, linkPath);
850
- import_fs2.default.chmodSync(linkPath, 493);
851
- }
852
- } catch {
853
- }
854
- }
855
- }
856
- __name(ensureStatusLineSymlink, "ensureStatusLineSymlink");
857
- function showResults(results) {
858
- console.log("");
859
- if (results.claudeInstalled) {
860
- console.log(` ${GREEN}\u2713${NC} Claude Code CLI installed`);
861
- } else {
862
- console.log(` ${GREEN}\u2713${NC} Claude Code CLI found`);
863
- }
864
- const totalCommands = results.commandsAdded + results.commandsUpdated;
865
- if (totalCommands > 0) {
866
- const parts = [];
867
- if (results.commandsAdded > 0) parts.push(`${results.commandsAdded} new`);
868
- if (results.commandsUpdated > 0) parts.push(`${results.commandsUpdated} updated`);
869
- console.log(` ${GREEN}\u2713${NC} Commands synced (${parts.join(", ")})`);
870
- } else {
871
- console.log(` ${GREEN}\u2713${NC} Commands up to date`);
872
- }
873
- if (results.configAction === "created") {
874
- console.log(` ${GREEN}\u2713${NC} Global config created`);
875
- } else if (results.configAction === "updated") {
876
- console.log(` ${GREEN}\u2713${NC} Global config updated`);
877
- } else if (results.configAction === "appended") {
878
- console.log(` ${GREEN}\u2713${NC} Global config merged`);
879
- }
880
- console.log("");
881
- }
882
- __name(showResults, "showResults");
883
- var isDirectRun = process.argv[1]?.includes("setup.ts") || process.argv[1]?.includes("setup.js");
884
- if (isDirectRun) {
885
- run().catch((error) => {
886
- console.error("Setup error:", error.message);
887
- process.exit(1);
888
- });
889
- }
890
- // Annotate the CommonJS export names for ESM import in node:
891
- 0 && (module.exports = {
892
- run
893
- });