@compilr-dev/cli 0.4.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 (152) hide show
  1. package/README.md +110 -0
  2. package/dist/agent.d.ts +62 -0
  3. package/dist/agent.js +317 -0
  4. package/dist/agents/registry.d.ts +66 -0
  5. package/dist/agents/registry.js +238 -0
  6. package/dist/agents/types.d.ts +40 -0
  7. package/dist/agents/types.js +94 -0
  8. package/dist/commands/custom-registry.d.ts +69 -0
  9. package/dist/commands/custom-registry.js +246 -0
  10. package/dist/commands/index.d.ts +7 -0
  11. package/dist/commands/index.js +7 -0
  12. package/dist/commands/types.d.ts +31 -0
  13. package/dist/commands/types.js +26 -0
  14. package/dist/commands.d.ts +63 -0
  15. package/dist/commands.js +324 -0
  16. package/dist/db/index.d.ts +42 -0
  17. package/dist/db/index.js +146 -0
  18. package/dist/db/repositories/document-repository.d.ts +63 -0
  19. package/dist/db/repositories/document-repository.js +184 -0
  20. package/dist/db/repositories/index.d.ts +9 -0
  21. package/dist/db/repositories/index.js +6 -0
  22. package/dist/db/repositories/project-repository.d.ts +132 -0
  23. package/dist/db/repositories/project-repository.js +337 -0
  24. package/dist/db/repositories/work-item-repository.d.ts +115 -0
  25. package/dist/db/repositories/work-item-repository.js +389 -0
  26. package/dist/db/schema.d.ts +83 -0
  27. package/dist/db/schema.js +143 -0
  28. package/dist/debug.d.ts +8 -0
  29. package/dist/debug.js +48 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.js +348 -0
  32. package/dist/index.old.d.ts +7 -0
  33. package/dist/index.old.js +1014 -0
  34. package/dist/repl.d.ts +121 -0
  35. package/dist/repl.js +1878 -0
  36. package/dist/settings/index.d.ts +80 -0
  37. package/dist/settings/index.js +195 -0
  38. package/dist/shared-handlers.d.ts +63 -0
  39. package/dist/shared-handlers.js +57 -0
  40. package/dist/slash-autocomplete.d.ts +41 -0
  41. package/dist/slash-autocomplete.js +638 -0
  42. package/dist/state.d.ts +75 -0
  43. package/dist/state.js +130 -0
  44. package/dist/tabbed-menu.d.ts +11 -0
  45. package/dist/tabbed-menu.js +328 -0
  46. package/dist/templates/backlog-md.d.ts +7 -0
  47. package/dist/templates/backlog-md.js +94 -0
  48. package/dist/templates/claude-md.d.ts +7 -0
  49. package/dist/templates/claude-md.js +189 -0
  50. package/dist/templates/coding-standards.d.ts +7 -0
  51. package/dist/templates/coding-standards.js +299 -0
  52. package/dist/templates/compilr-md.d.ts +7 -0
  53. package/dist/templates/compilr-md.js +189 -0
  54. package/dist/templates/config-json.d.ts +38 -0
  55. package/dist/templates/config-json.js +39 -0
  56. package/dist/templates/gitignore.d.ts +7 -0
  57. package/dist/templates/gitignore.js +85 -0
  58. package/dist/templates/index.d.ts +19 -0
  59. package/dist/templates/index.js +302 -0
  60. package/dist/templates/package-json.d.ts +7 -0
  61. package/dist/templates/package-json.js +111 -0
  62. package/dist/templates/readme-md.d.ts +7 -0
  63. package/dist/templates/readme-md.js +161 -0
  64. package/dist/templates/tsconfig.d.ts +7 -0
  65. package/dist/templates/tsconfig.js +61 -0
  66. package/dist/templates/types.d.ts +33 -0
  67. package/dist/templates/types.js +24 -0
  68. package/dist/test-autocomplete.d.ts +7 -0
  69. package/dist/test-autocomplete.js +85 -0
  70. package/dist/test-tabbed-menu.d.ts +7 -0
  71. package/dist/test-tabbed-menu.js +25 -0
  72. package/dist/themes/colors.d.ts +49 -0
  73. package/dist/themes/colors.js +135 -0
  74. package/dist/themes/index.d.ts +23 -0
  75. package/dist/themes/index.js +24 -0
  76. package/dist/themes/registry.d.ts +60 -0
  77. package/dist/themes/registry.js +195 -0
  78. package/dist/themes/types.d.ts +82 -0
  79. package/dist/themes/types.js +7 -0
  80. package/dist/tool-selector.d.ts +71 -0
  81. package/dist/tool-selector.js +184 -0
  82. package/dist/tools/ask-user-simple.d.ts +19 -0
  83. package/dist/tools/ask-user-simple.js +86 -0
  84. package/dist/tools/ask-user.d.ts +32 -0
  85. package/dist/tools/ask-user.js +113 -0
  86. package/dist/tools/backlog.d.ts +53 -0
  87. package/dist/tools/backlog.js +709 -0
  88. package/dist/tools.d.ts +15 -0
  89. package/dist/tools.js +121 -0
  90. package/dist/ui/agents-overlay.d.ts +12 -0
  91. package/dist/ui/agents-overlay.js +501 -0
  92. package/dist/ui/arch-type-overlay.d.ts +20 -0
  93. package/dist/ui/arch-type-overlay.js +229 -0
  94. package/dist/ui/ask-user-overlay.d.ts +26 -0
  95. package/dist/ui/ask-user-overlay.js +647 -0
  96. package/dist/ui/ask-user-simple-overlay.d.ts +25 -0
  97. package/dist/ui/ask-user-simple-overlay.js +242 -0
  98. package/dist/ui/backlog-overlay.d.ts +17 -0
  99. package/dist/ui/backlog-overlay.js +786 -0
  100. package/dist/ui/commands-overlay.d.ts +11 -0
  101. package/dist/ui/commands-overlay.js +410 -0
  102. package/dist/ui/config-overlay.d.ts +34 -0
  103. package/dist/ui/config-overlay.js +977 -0
  104. package/dist/ui/conversation.d.ts +82 -0
  105. package/dist/ui/conversation.js +508 -0
  106. package/dist/ui/diff.d.ts +38 -0
  107. package/dist/ui/diff.js +182 -0
  108. package/dist/ui/ephemeral.d.ts +111 -0
  109. package/dist/ui/ephemeral.js +413 -0
  110. package/dist/ui/file-autocomplete.d.ts +45 -0
  111. package/dist/ui/file-autocomplete.js +237 -0
  112. package/dist/ui/footer.d.ts +153 -0
  113. package/dist/ui/footer.js +422 -0
  114. package/dist/ui/index.d.ts +12 -0
  115. package/dist/ui/index.js +15 -0
  116. package/dist/ui/init-overlay.d.ts +24 -0
  117. package/dist/ui/init-overlay.js +525 -0
  118. package/dist/ui/input-prompt-v2.d.ts +179 -0
  119. package/dist/ui/input-prompt-v2.js +991 -0
  120. package/dist/ui/input-prompt.d.ts +97 -0
  121. package/dist/ui/input-prompt.js +800 -0
  122. package/dist/ui/iteration-limit-overlay.d.ts +21 -0
  123. package/dist/ui/iteration-limit-overlay.js +150 -0
  124. package/dist/ui/keys-overlay.d.ts +14 -0
  125. package/dist/ui/keys-overlay.js +181 -0
  126. package/dist/ui/model-warning-overlay.d.ts +30 -0
  127. package/dist/ui/model-warning-overlay.js +171 -0
  128. package/dist/ui/overlay-controller.d.ts +25 -0
  129. package/dist/ui/overlay-controller.js +35 -0
  130. package/dist/ui/overlays.d.ts +47 -0
  131. package/dist/ui/overlays.js +627 -0
  132. package/dist/ui/permission-overlay.d.ts +16 -0
  133. package/dist/ui/permission-overlay.js +494 -0
  134. package/dist/ui/terminal.d.ts +117 -0
  135. package/dist/ui/terminal.js +237 -0
  136. package/dist/ui/todo-zone.d.ts +112 -0
  137. package/dist/ui/todo-zone.js +353 -0
  138. package/dist/ui/tools-overlay.d.ts +26 -0
  139. package/dist/ui/tools-overlay.js +278 -0
  140. package/dist/ui/tutorial-overlay.d.ts +10 -0
  141. package/dist/ui/tutorial-overlay.js +936 -0
  142. package/dist/ui/types.d.ts +103 -0
  143. package/dist/ui/types.js +33 -0
  144. package/dist/utils/credentials.d.ts +55 -0
  145. package/dist/utils/credentials.js +268 -0
  146. package/dist/utils/model-tiers.d.ts +37 -0
  147. package/dist/utils/model-tiers.js +118 -0
  148. package/dist/utils/project-memory.d.ts +47 -0
  149. package/dist/utils/project-memory.js +117 -0
  150. package/dist/utils/project-status.d.ts +56 -0
  151. package/dist/utils/project-status.js +237 -0
  152. package/package.json +66 -0
@@ -0,0 +1,161 @@
1
+ /**
2
+ * README.md Template Generator
3
+ *
4
+ * Generates the project README with next steps.
5
+ */
6
+ import { TECH_STACK_LABELS } from './types.js';
7
+ export function generateReadmeMd(config) {
8
+ const techStackSetup = getTechStackSetup(config.techStack);
9
+ return `# ${config.name}
10
+
11
+ ${config.description}
12
+
13
+ ---
14
+
15
+ ## Getting Started
16
+
17
+ ### Prerequisites
18
+
19
+ ${getPrerequisites(config.techStack)}
20
+
21
+ ### Installation
22
+
23
+ \`\`\`bash
24
+ cd ${config.name}
25
+ ${techStackSetup.install}
26
+ \`\`\`
27
+
28
+ ### Development
29
+
30
+ \`\`\`bash
31
+ ${techStackSetup.dev}
32
+ \`\`\`
33
+
34
+ ---
35
+
36
+ ## Project Structure
37
+
38
+ \`\`\`
39
+ ${config.name}/
40
+ ├── src/ # Source code
41
+ ${config.repoPattern === 'single' ? `├── .compilr/ # Workflow files (backlog, sessions, etc.)
42
+ ├── COMPILR.md # AI assistant context` : ''}
43
+ ├── package.json
44
+ └── README.md
45
+ \`\`\`
46
+ ${config.repoPattern === 'two-repo' ? `
47
+ **Documentation repo:** \`${config.name}-docs/\`
48
+ ` : ''}
49
+
50
+ ---
51
+
52
+ ## Next Steps
53
+
54
+ 1. ${techStackSetup.nextSteps[0]}
55
+ 2. ${techStackSetup.nextSteps[1]}
56
+ 3. ${techStackSetup.nextSteps[2]}
57
+ 4. Start coding with \`compilr start\`
58
+
59
+ ---
60
+
61
+ ## Workflow Commands
62
+
63
+ \`\`\`bash
64
+ compilr start # Begin coding session with context loaded
65
+ compilr save # Save session progress and generate notes
66
+ compilr backlog # View and manage tasks
67
+ compilr resume # Restore context after interruption
68
+ \`\`\`
69
+
70
+ ---
71
+
72
+ ## Tech Stack
73
+
74
+ **${TECH_STACK_LABELS[config.techStack]}**
75
+
76
+ ${techStackSetup.description}
77
+
78
+ ---
79
+
80
+ ## License
81
+
82
+ *Add your license here*
83
+
84
+ ---
85
+
86
+ *Created with [compilr-dev-cli](https://github.com/scozzola/compilr-dev-cli)*
87
+ `;
88
+ }
89
+ function getPrerequisites(techStack) {
90
+ const common = '- Node.js 20+\n- npm or yarn';
91
+ if (techStack === 'react-python-pg') {
92
+ return `${common}\n- Python 3.11+\n- PostgreSQL 15+`;
93
+ }
94
+ return `${common}\n- PostgreSQL 15+ (for database)`;
95
+ }
96
+ function getTechStackSetup(techStack) {
97
+ const setups = {
98
+ 'react-node-pg': {
99
+ install: 'npm install',
100
+ dev: 'npm run dev',
101
+ description: `
102
+ | Layer | Technology |
103
+ |-------|------------|
104
+ | Frontend | React 18, Vite, TypeScript |
105
+ | Backend | Node.js, Express, TypeScript |
106
+ | Database | PostgreSQL |
107
+ | ORM | Prisma |
108
+ `,
109
+ nextSteps: [
110
+ 'Install dependencies: `npm install`',
111
+ 'Set up PostgreSQL and configure `.env`',
112
+ 'Run database migrations: `npx prisma migrate dev`',
113
+ ],
114
+ },
115
+ 'react-python-pg': {
116
+ install: 'npm install # Frontend\npip install -r requirements.txt # Backend',
117
+ dev: 'npm run dev # Frontend\nuvicorn main:app --reload # Backend',
118
+ description: `
119
+ | Layer | Technology |
120
+ |-------|------------|
121
+ | Frontend | React 18, Vite, TypeScript |
122
+ | Backend | Python, FastAPI |
123
+ | Database | PostgreSQL |
124
+ | ORM | SQLAlchemy |
125
+ `,
126
+ nextSteps: [
127
+ 'Install frontend deps: `npm install`',
128
+ 'Install backend deps: `pip install -r requirements.txt`',
129
+ 'Set up PostgreSQL and configure environment',
130
+ ],
131
+ },
132
+ 'vue-node-pg': {
133
+ install: 'npm install',
134
+ dev: 'npm run dev',
135
+ description: `
136
+ | Layer | Technology |
137
+ |-------|------------|
138
+ | Frontend | Vue 3, Vite, TypeScript |
139
+ | Backend | Node.js, Express, TypeScript |
140
+ | Database | PostgreSQL |
141
+ | ORM | Prisma |
142
+ `,
143
+ nextSteps: [
144
+ 'Install dependencies: `npm install`',
145
+ 'Set up PostgreSQL and configure `.env`',
146
+ 'Run database migrations: `npx prisma migrate dev`',
147
+ ],
148
+ },
149
+ custom: {
150
+ install: '# Add your installation command',
151
+ dev: '# Add your development command',
152
+ description: '*Configure your tech stack*',
153
+ nextSteps: [
154
+ 'Choose and set up your tech stack',
155
+ 'Configure development environment',
156
+ 'Update this README with your stack details',
157
+ ],
158
+ },
159
+ };
160
+ return setups[techStack] ?? setups.custom;
161
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * TSConfig Template Generator
3
+ *
4
+ * Generates a tsconfig.json file based on coding standards.
5
+ */
6
+ import type { ProjectConfig } from './types.js';
7
+ export declare function generateTsconfig(config: ProjectConfig): string;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * TSConfig Template Generator
3
+ *
4
+ * Generates a tsconfig.json file based on coding standards.
5
+ */
6
+ export function generateTsconfig(config) {
7
+ const tsconfig = getTsconfigTemplate(config);
8
+ return JSON.stringify(tsconfig, null, 2) + '\n';
9
+ }
10
+ function getTsconfigTemplate(config) {
11
+ // Base config for all presets
12
+ const base = {
13
+ compilerOptions: {
14
+ target: 'ES2022',
15
+ useDefineForClassFields: true,
16
+ module: 'ESNext',
17
+ lib: ['ES2022', 'DOM', 'DOM.Iterable'],
18
+ skipLibCheck: true,
19
+ // Bundler mode
20
+ moduleResolution: 'bundler',
21
+ allowImportingTsExtensions: true,
22
+ resolveJsonModule: true,
23
+ isolatedModules: true,
24
+ noEmit: true,
25
+ // JSX for React/Vue
26
+ jsx: config.techStack === 'vue-node-pg' ? 'preserve' : 'react-jsx',
27
+ // Common strict settings
28
+ esModuleInterop: true,
29
+ forceConsistentCasingInFileNames: true,
30
+ },
31
+ include: ['src'],
32
+ exclude: ['node_modules'],
33
+ };
34
+ // Apply coding standards
35
+ if (config.codingStandards === 'strict') {
36
+ return {
37
+ ...base,
38
+ compilerOptions: {
39
+ ...base.compilerOptions,
40
+ strict: true,
41
+ noUncheckedIndexedAccess: true,
42
+ noImplicitReturns: true,
43
+ noFallthroughCasesInSwitch: true,
44
+ noUnusedLocals: true,
45
+ noUnusedParameters: true,
46
+ exactOptionalPropertyTypes: true,
47
+ },
48
+ };
49
+ }
50
+ if (config.codingStandards === 'relaxed') {
51
+ return {
52
+ ...base,
53
+ compilerOptions: {
54
+ ...base.compilerOptions,
55
+ strict: true,
56
+ },
57
+ };
58
+ }
59
+ // Custom - minimal config
60
+ return base;
61
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Project Configuration Types
3
+ *
4
+ * Shared types for project initialization templates.
5
+ */
6
+ export type TechStack = 'react-node-pg' | 'react-python-pg' | 'vue-node-pg' | 'custom';
7
+ export declare const TECH_STACK_LABELS: Record<TechStack, string>;
8
+ export type CodingStandards = 'strict' | 'relaxed' | 'custom';
9
+ export declare const CODING_STANDARDS_LABELS: Record<CodingStandards, string>;
10
+ export type RepoPattern = 'single' | 'two-repo';
11
+ export declare const REPO_PATTERN_LABELS: Record<RepoPattern, string>;
12
+ export interface ProjectConfig {
13
+ /** Project name (lowercase, alphanumeric + hyphens) */
14
+ name: string;
15
+ /** Project description (1-2 sentences) */
16
+ description: string;
17
+ /** Repository pattern */
18
+ repoPattern: RepoPattern;
19
+ /** Selected tech stack */
20
+ techStack: TechStack;
21
+ /** Coding standards preset */
22
+ codingStandards: CodingStandards;
23
+ /** Whether to initialize git */
24
+ initGit: boolean;
25
+ }
26
+ export interface GenerationResult {
27
+ success: boolean;
28
+ projectPath: string;
29
+ docsPath?: string;
30
+ filesCreated: string[];
31
+ error?: string;
32
+ }
33
+ export declare const WORKFLOW_VERSION = "1.0.0";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Project Configuration Types
3
+ *
4
+ * Shared types for project initialization templates.
5
+ */
6
+ export const TECH_STACK_LABELS = {
7
+ 'react-node-pg': 'React + Node.js + PostgreSQL',
8
+ 'react-python-pg': 'React + Python + PostgreSQL',
9
+ 'vue-node-pg': 'Vue + Node.js + PostgreSQL',
10
+ custom: 'Custom (configure later)',
11
+ };
12
+ export const CODING_STANDARDS_LABELS = {
13
+ strict: 'TypeScript Strict (recommended)',
14
+ relaxed: 'TypeScript Relaxed',
15
+ custom: 'Custom (configure later)',
16
+ };
17
+ export const REPO_PATTERN_LABELS = {
18
+ single: 'Single repo (.compilr/ folder + COMPILR.md in project root)',
19
+ 'two-repo': 'Two repos (project/ + project-docs/ separate repositories)',
20
+ };
21
+ // =============================================================================
22
+ // Workflow Version
23
+ // =============================================================================
24
+ export const WORKFLOW_VERSION = '1.0.0';
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Test script for slash command autocomplete
4
+ *
5
+ * Run with: npx tsx src/test-autocomplete.ts
6
+ */
7
+ export {};
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Test script for slash command autocomplete
4
+ *
5
+ * Run with: npx tsx src/test-autocomplete.ts
6
+ */
7
+ import pc from 'picocolors';
8
+ import { createInteractiveInput, SLASH_COMMANDS } from './slash-autocomplete.js';
9
+ console.log(pc.bold(pc.cyan('Slash Command Autocomplete Test')));
10
+ console.log(pc.dim('─'.repeat(40)));
11
+ console.log('');
12
+ console.log(pc.dim('Available commands:'));
13
+ for (const cmd of SLASH_COMMANDS) {
14
+ console.log(pc.dim(` ${cmd.name.padEnd(12)} ${cmd.description}`));
15
+ }
16
+ console.log('');
17
+ console.log(pc.dim('Instructions:'));
18
+ console.log(pc.dim(' • Type "/" to see autocomplete dropdown'));
19
+ console.log(pc.dim(' • Use ↑↓ arrows to navigate'));
20
+ console.log(pc.dim(' • Press Tab to autocomplete selected'));
21
+ console.log(pc.dim(' • Press Enter to execute'));
22
+ console.log(pc.dim(' • Press Esc to close dropdown'));
23
+ console.log(pc.dim(' • Type "quit" to exit'));
24
+ console.log('');
25
+ const prompt = pc.bold(pc.blue('Test> '));
26
+ const handleSubmit = (input) => {
27
+ if (input.trim().toLowerCase() === 'quit') {
28
+ console.log(pc.dim('Goodbye!'));
29
+ inputHandler.stop();
30
+ process.exit(0);
31
+ }
32
+ if (input.trim()) {
33
+ console.log(pc.green('Received: ') + pc.cyan(input));
34
+ // Handle the command
35
+ if (input.startsWith('/')) {
36
+ const cmd = input.slice(1).toLowerCase();
37
+ switch (cmd) {
38
+ case 'exit':
39
+ case 'quit':
40
+ case 'q':
41
+ console.log(pc.dim('Goodbye!'));
42
+ inputHandler.stop();
43
+ process.exit(0);
44
+ break;
45
+ case 'help':
46
+ case '?':
47
+ console.log(pc.bold('\nAvailable commands:'));
48
+ for (const c of SLASH_COMMANDS) {
49
+ console.log(` ${pc.cyan(c.name.padEnd(12))} ${c.description}`);
50
+ }
51
+ break;
52
+ case 'clear':
53
+ console.log(pc.green('✓') + ' History cleared');
54
+ break;
55
+ case 'tools':
56
+ console.log(pc.green('✓') + ' Would list tools here');
57
+ break;
58
+ case 'tokens':
59
+ console.log(pc.green('✓') + ' Would show token usage here');
60
+ break;
61
+ case 'context':
62
+ console.log(pc.green('✓') + ' Would show context info here');
63
+ break;
64
+ case 'compact':
65
+ console.log(pc.green('✓') + ' Would compact context here');
66
+ break;
67
+ default:
68
+ console.log(pc.yellow(`Unknown command: ${input}`));
69
+ }
70
+ }
71
+ }
72
+ console.log('');
73
+ // Show prompt for next input (handler stays running)
74
+ process.stdout.write(prompt);
75
+ };
76
+ // Don't show separator for test - simpler continuous REPL
77
+ const inputHandler = createInteractiveInput(prompt, handleSubmit, false);
78
+ // Handle Ctrl+C
79
+ process.on('SIGINT', () => {
80
+ console.log('\n' + pc.dim('Interrupted.'));
81
+ inputHandler.stop();
82
+ process.exit(0);
83
+ });
84
+ // Start
85
+ inputHandler.start();
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Test script for tabbed help menu (Claude Code-style)
4
+ *
5
+ * Run with: npx tsx src/test-tabbed-menu.ts
6
+ */
7
+ export {};
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Test script for tabbed help menu (Claude Code-style)
4
+ *
5
+ * Run with: npx tsx src/test-tabbed-menu.ts
6
+ */
7
+ import { showHelpMenu } from './tabbed-menu.js';
8
+ import pc from 'picocolors';
9
+ console.log(pc.bold(pc.cyan('Tabbed Help Menu Test')));
10
+ console.log(pc.dim('─'.repeat(40)));
11
+ console.log('');
12
+ console.log(pc.dim('This is some terminal history that should remain visible.'));
13
+ console.log(pc.dim('The help menu will appear below without clearing this.'));
14
+ console.log('');
15
+ console.log(pc.dim('Instructions:'));
16
+ console.log(pc.dim(' • Press Tab to cycle through tabs'));
17
+ console.log(pc.dim(' • Press ↑/↓ to navigate commands list'));
18
+ console.log(pc.dim(' • Press Esc to close the menu'));
19
+ console.log('');
20
+ // Show the help menu
21
+ showHelpMenu().then(() => {
22
+ console.log(pc.green('✓') + ' Help menu closed');
23
+ console.log(pc.dim('Notice how the history above is preserved!'));
24
+ process.exit(0);
25
+ });
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Theme Colors
3
+ *
4
+ * Creates style functions from a theme's color palette.
5
+ * Uses chalk for hex color support.
6
+ *
7
+ * Usage:
8
+ * import { getStyles } from './themes/colors.js';
9
+ * const s = getStyles();
10
+ * console.log(s.primary('Hello')); // Colored with theme's primary
11
+ * console.log(s.muted('dim text')); // Colored with theme's muted
12
+ */
13
+ import type { Theme, ThemeStyleFunctions } from './types.js';
14
+ /**
15
+ * Create style functions from a theme
16
+ */
17
+ export declare function createThemeStyles(theme: Theme): ThemeStyleFunctions;
18
+ /**
19
+ * Get style functions for the current theme
20
+ *
21
+ * This is the main entry point for using theme colors throughout the app.
22
+ * Styles are cached and automatically updated when the theme changes.
23
+ *
24
+ * Usage:
25
+ * import { getStyles } from './themes/colors.js';
26
+ * const s = getStyles();
27
+ * console.log(s.primary('Hello'));
28
+ */
29
+ export declare function getStyles(): ThemeStyleFunctions;
30
+ /**
31
+ * Clear style cache (call after theme change)
32
+ */
33
+ export declare function clearStyleCache(): void;
34
+ /**
35
+ * Get the current theme's raw colors
36
+ */
37
+ export declare function getThemeColors(): Theme['colors'];
38
+ /**
39
+ * Check if current theme is dark
40
+ */
41
+ export declare function isDarkTheme(): boolean;
42
+ /**
43
+ * Check if current theme is light
44
+ */
45
+ export declare function isLightTheme(): boolean;
46
+ /**
47
+ * Plain style functions (no colors, for testing or non-TTY)
48
+ */
49
+ export declare const plainStyles: ThemeStyleFunctions;
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Theme Colors
3
+ *
4
+ * Creates style functions from a theme's color palette.
5
+ * Uses chalk for hex color support.
6
+ *
7
+ * Usage:
8
+ * import { getStyles } from './themes/colors.js';
9
+ * const s = getStyles();
10
+ * console.log(s.primary('Hello')); // Colored with theme's primary
11
+ * console.log(s.muted('dim text')); // Colored with theme's muted
12
+ */
13
+ import chalk from 'chalk';
14
+ import { getCurrentTheme } from './registry.js';
15
+ // =============================================================================
16
+ // Style Creation
17
+ // =============================================================================
18
+ /**
19
+ * Create style functions from a theme
20
+ */
21
+ export function createThemeStyles(theme) {
22
+ const colors = theme.colors;
23
+ return {
24
+ // ==========================================================================
25
+ // Theme colors (from palette)
26
+ // ==========================================================================
27
+ primary: (text) => chalk.hex(colors.primary)(text),
28
+ secondary: (text) => chalk.hex(colors.secondary || colors.primary)(text),
29
+ foreground: (text) => chalk.hex(colors.foreground)(text),
30
+ muted: (text) => chalk.hex(colors.muted)(text),
31
+ border: (text) => chalk.hex(colors.border)(text),
32
+ background: (text) => chalk.bgHex(colors.background)(text),
33
+ card: (text) => chalk.bgHex(colors.card || colors.background)(text),
34
+ selection: (text) => chalk.hex(colors.selection)(text),
35
+ cursor: (text) => chalk.hex(colors.cursor)(text),
36
+ // ==========================================================================
37
+ // Semantic colors (fixed for consistency across themes)
38
+ // ==========================================================================
39
+ success: (text) => chalk.hex('#50fa7b')(text), // Green
40
+ warning: (text) => chalk.hex('#f1fa8c')(text), // Yellow
41
+ error: (text) => chalk.hex('#ff5555')(text), // Red
42
+ info: (text) => chalk.hex('#8be9fd')(text), // Cyan
43
+ // ==========================================================================
44
+ // Compound styles
45
+ // ==========================================================================
46
+ primaryBold: (text) => chalk.hex(colors.primary).bold(text),
47
+ inverse: (text) => chalk.inverse(text),
48
+ selected: (text) => chalk.bgHex(colors.secondary || colors.primary).hex(colors.background)(text),
49
+ onCard: (text) => chalk.bgHex(colors.card || colors.background).hex(colors.foreground)(text),
50
+ };
51
+ }
52
+ // =============================================================================
53
+ // Global Style Access
54
+ // =============================================================================
55
+ // Cached styles for current theme
56
+ let cachedStyles = null;
57
+ let cachedThemeId = null;
58
+ /**
59
+ * Get style functions for the current theme
60
+ *
61
+ * This is the main entry point for using theme colors throughout the app.
62
+ * Styles are cached and automatically updated when the theme changes.
63
+ *
64
+ * Usage:
65
+ * import { getStyles } from './themes/colors.js';
66
+ * const s = getStyles();
67
+ * console.log(s.primary('Hello'));
68
+ */
69
+ export function getStyles() {
70
+ const theme = getCurrentTheme();
71
+ // Return cached if theme hasn't changed
72
+ if (cachedStyles && cachedThemeId === theme.id) {
73
+ return cachedStyles;
74
+ }
75
+ // Create new styles for current theme
76
+ cachedStyles = createThemeStyles(theme);
77
+ cachedThemeId = theme.id;
78
+ return cachedStyles;
79
+ }
80
+ /**
81
+ * Clear style cache (call after theme change)
82
+ */
83
+ export function clearStyleCache() {
84
+ cachedStyles = null;
85
+ cachedThemeId = null;
86
+ }
87
+ // =============================================================================
88
+ // Convenience Exports
89
+ // =============================================================================
90
+ /**
91
+ * Get the current theme's raw colors
92
+ */
93
+ export function getThemeColors() {
94
+ return getCurrentTheme().colors;
95
+ }
96
+ /**
97
+ * Check if current theme is dark
98
+ */
99
+ export function isDarkTheme() {
100
+ return getCurrentTheme().type === 'dark';
101
+ }
102
+ /**
103
+ * Check if current theme is light
104
+ */
105
+ export function isLightTheme() {
106
+ return getCurrentTheme().type === 'light';
107
+ }
108
+ // =============================================================================
109
+ // Fallback/Plain Styles (no colors)
110
+ // =============================================================================
111
+ /**
112
+ * Plain style functions (no colors, for testing or non-TTY)
113
+ */
114
+ export const plainStyles = {
115
+ // Theme colors
116
+ primary: (text) => text,
117
+ secondary: (text) => text,
118
+ foreground: (text) => text,
119
+ muted: (text) => text,
120
+ border: (text) => text,
121
+ background: (text) => text,
122
+ card: (text) => text,
123
+ selection: (text) => text,
124
+ cursor: (text) => text,
125
+ // Semantic colors
126
+ success: (text) => text,
127
+ warning: (text) => text,
128
+ error: (text) => text,
129
+ info: (text) => text,
130
+ // Compound styles
131
+ primaryBold: (text) => text,
132
+ inverse: (text) => text,
133
+ selected: (text) => text,
134
+ onCard: (text) => text,
135
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Theme System
3
+ *
4
+ * 418 terminal themes with style functions for the CLI.
5
+ *
6
+ * Usage:
7
+ * import { getStyles, getCurrentTheme, setCurrentTheme } from './themes/index.js';
8
+ *
9
+ * // Get style functions for current theme
10
+ * const s = getStyles();
11
+ * console.log(s.primary('Hello'));
12
+ * console.log(s.muted('dim text'));
13
+ *
14
+ * // Change theme
15
+ * setCurrentTheme('dracula');
16
+ *
17
+ * // Get current theme info
18
+ * const theme = getCurrentTheme();
19
+ * console.log(theme.name, theme.type);
20
+ */
21
+ export type { Theme, ThemeColors, ThemeConfig, ThemeStyleFunctions } from './types.js';
22
+ export { getAllThemes, getCuratedThemes, getThemeById, searchThemes, filterThemesByType, searchAndFilterThemes, getThemeCount, loadThemeConfig, saveThemeConfig, getCurrentTheme, setCurrentTheme, clearThemeCache, } from './registry.js';
23
+ export { createThemeStyles, getStyles, clearStyleCache, getThemeColors, isDarkTheme, isLightTheme, plainStyles, } from './colors.js';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Theme System
3
+ *
4
+ * 418 terminal themes with style functions for the CLI.
5
+ *
6
+ * Usage:
7
+ * import { getStyles, getCurrentTheme, setCurrentTheme } from './themes/index.js';
8
+ *
9
+ * // Get style functions for current theme
10
+ * const s = getStyles();
11
+ * console.log(s.primary('Hello'));
12
+ * console.log(s.muted('dim text'));
13
+ *
14
+ * // Change theme
15
+ * setCurrentTheme('dracula');
16
+ *
17
+ * // Get current theme info
18
+ * const theme = getCurrentTheme();
19
+ * console.log(theme.name, theme.type);
20
+ */
21
+ // Registry functions
22
+ export { getAllThemes, getCuratedThemes, getThemeById, searchThemes, filterThemesByType, searchAndFilterThemes, getThemeCount, loadThemeConfig, saveThemeConfig, getCurrentTheme, setCurrentTheme, clearThemeCache, } from './registry.js';
23
+ // Style functions
24
+ export { createThemeStyles, getStyles, clearStyleCache, getThemeColors, isDarkTheme, isLightTheme, plainStyles, } from './colors.js';