@involvex/prompt-enhancer 0.0.2
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.
- package/.github/FUNDING.yml +9 -0
- package/LICENSE +21 -0
- package/dist/app.d.ts +5 -0
- package/dist/app.js +39 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +53 -0
- package/dist/commands/about.d.ts +1 -0
- package/dist/commands/about.js +6 -0
- package/dist/commands/direct-enhance.d.ts +5 -0
- package/dist/commands/direct-enhance.js +52 -0
- package/dist/commands/enhanceprompt.d.ts +1 -0
- package/dist/commands/enhanceprompt.js +6 -0
- package/dist/commands/help.d.ts +1 -0
- package/dist/commands/help.js +6 -0
- package/dist/commands/settings.d.ts +1 -0
- package/dist/commands/settings.js +1 -0
- package/dist/commands/version.d.ts +1 -0
- package/dist/commands/version.js +6 -0
- package/dist/components/enhance-prompt.d.ts +5 -0
- package/dist/components/enhance-prompt.js +82 -0
- package/dist/components/history-viewer.d.ts +5 -0
- package/dist/components/history-viewer.js +64 -0
- package/dist/components/menu.d.ts +11 -0
- package/dist/components/menu.js +6 -0
- package/dist/components/select-input.d.ts +19 -0
- package/dist/components/select-input.js +51 -0
- package/dist/components/settings.d.ts +5 -0
- package/dist/components/settings.js +246 -0
- package/dist/lib/config/manager.d.ts +49 -0
- package/dist/lib/config/manager.js +152 -0
- package/dist/lib/config/schema.d.ts +69 -0
- package/dist/lib/config/schema.js +37 -0
- package/dist/lib/config/types.d.ts +34 -0
- package/dist/lib/config/types.js +4 -0
- package/dist/lib/enhancement/engine.d.ts +41 -0
- package/dist/lib/enhancement/engine.js +163 -0
- package/dist/lib/history/manager.d.ts +45 -0
- package/dist/lib/history/manager.js +120 -0
- package/dist/lib/providers/base.d.ts +47 -0
- package/dist/lib/providers/base.js +30 -0
- package/dist/lib/providers/copilot.d.ts +18 -0
- package/dist/lib/providers/copilot.js +112 -0
- package/dist/lib/providers/gemini.d.ts +13 -0
- package/dist/lib/providers/gemini.js +86 -0
- package/dist/lib/providers/index.d.ts +26 -0
- package/dist/lib/providers/index.js +86 -0
- package/dist/lib/providers/kilo.d.ts +22 -0
- package/dist/lib/providers/kilo.js +174 -0
- package/dist/lib/providers/opencode.d.ts +22 -0
- package/dist/lib/providers/opencode.js +174 -0
- package/dist/lib/types/index.d.ts +26 -0
- package/dist/lib/types/index.js +4 -0
- package/dist/lib/utils/copilot-auth.d.ts +14 -0
- package/dist/lib/utils/copilot-auth.js +84 -0
- package/dist/lib/utils/models-cache.d.ts +12 -0
- package/dist/lib/utils/models-cache.js +139 -0
- package/dist/lib/utils/paths.d.ts +10 -0
- package/dist/lib/utils/paths.js +18 -0
- package/package.json +101 -0
- package/readme.md +271 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches and caches the models list from https://models.dev/api.json
|
|
3
|
+
* Cache TTL is 24 hours, stored at ~/.prompt-enhancer/models-cache.json
|
|
4
|
+
*/
|
|
5
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
6
|
+
import { existsSync } from 'fs';
|
|
7
|
+
import { MODELS_CACHE_FILE } from './paths.js';
|
|
8
|
+
import { KILO_MODELS } from '../providers/kilo.js';
|
|
9
|
+
import { OPENCODE_MODELS_ENDPOINT, OPENCODE_DEFAULT_MODEL, } from '../providers/opencode.js';
|
|
10
|
+
const MODELS_API_URL = 'https://models.dev/api.json';
|
|
11
|
+
const CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
12
|
+
async function loadCache() {
|
|
13
|
+
if (!existsSync(MODELS_CACHE_FILE))
|
|
14
|
+
return null;
|
|
15
|
+
try {
|
|
16
|
+
const raw = await readFile(MODELS_CACHE_FILE, 'utf-8');
|
|
17
|
+
return JSON.parse(raw);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function fetchAndCache() {
|
|
24
|
+
const response = await fetch(MODELS_API_URL);
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`models.dev fetch failed: ${response.status}`);
|
|
27
|
+
}
|
|
28
|
+
const data = (await response.json());
|
|
29
|
+
const cache = { fetchedAt: Date.now(), data };
|
|
30
|
+
try {
|
|
31
|
+
await writeFile(MODELS_CACHE_FILE, JSON.stringify(cache, null, 2), 'utf-8');
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Non-fatal: cache write failure just means we refetch next time
|
|
35
|
+
}
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
async function getModelsData() {
|
|
39
|
+
const cache = await loadCache();
|
|
40
|
+
if (cache && Date.now() - cache.fetchedAt < CACHE_TTL_MS) {
|
|
41
|
+
return cache.data;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return await fetchAndCache();
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Network failure: return cached data even if stale, or empty
|
|
48
|
+
return cache?.data ?? {};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function extractModels(data, providerKeys) {
|
|
52
|
+
for (const key of providerKeys) {
|
|
53
|
+
const provider = data[key];
|
|
54
|
+
if (provider?.models) {
|
|
55
|
+
return Object.values(provider.models).map(m => ({
|
|
56
|
+
id: m.id ?? m.name,
|
|
57
|
+
name: m.name,
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Fetches available models directly from the OpenCode API.
|
|
65
|
+
* Falls back to a hardcoded list if the request fails.
|
|
66
|
+
*/
|
|
67
|
+
async function getOpenCodeModels(apiKey) {
|
|
68
|
+
const OPENCODE_FALLBACK = [
|
|
69
|
+
{ id: OPENCODE_DEFAULT_MODEL, name: 'Claude Sonnet 4.5' },
|
|
70
|
+
{ id: 'anthropic/claude-opus-4-5', name: 'Claude Opus 4.5' },
|
|
71
|
+
{ id: 'anthropic/claude-haiku-4-5', name: 'Claude Haiku 4.5' },
|
|
72
|
+
{ id: 'openai/gpt-4o', name: 'GPT-4o' },
|
|
73
|
+
{ id: 'openai/gpt-4o-mini', name: 'GPT-4o mini' },
|
|
74
|
+
{ id: 'google/gemini-2.5-flash', name: 'Gemini 2.5 Flash' },
|
|
75
|
+
];
|
|
76
|
+
try {
|
|
77
|
+
const headers = {};
|
|
78
|
+
if (apiKey)
|
|
79
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
80
|
+
const response = await fetch(OPENCODE_MODELS_ENDPOINT, { headers });
|
|
81
|
+
if (!response.ok)
|
|
82
|
+
return OPENCODE_FALLBACK;
|
|
83
|
+
const data = (await response.json());
|
|
84
|
+
if (!Array.isArray(data.data) || data.data.length === 0) {
|
|
85
|
+
return OPENCODE_FALLBACK;
|
|
86
|
+
}
|
|
87
|
+
return data.data
|
|
88
|
+
.map(m => ({
|
|
89
|
+
id: m.id,
|
|
90
|
+
name: m.id,
|
|
91
|
+
}))
|
|
92
|
+
.filter(m => m.id);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return OPENCODE_FALLBACK;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Falls back to a hardcoded list if network is unavailable.
|
|
100
|
+
*/
|
|
101
|
+
export async function getModelsForProvider(provider, apiKey) {
|
|
102
|
+
if (provider === 'opencode') {
|
|
103
|
+
return getOpenCodeModels(apiKey);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const data = await getModelsData();
|
|
107
|
+
switch (provider) {
|
|
108
|
+
case 'gemini':
|
|
109
|
+
return extractModels(data, ['google']);
|
|
110
|
+
case 'copilot':
|
|
111
|
+
return extractModels(data, ['github', 'openai']);
|
|
112
|
+
case 'kilo':
|
|
113
|
+
// models.dev may not have a kilo key — fall through to hardcoded list
|
|
114
|
+
return KILO_MODELS;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Fall through to defaults
|
|
119
|
+
}
|
|
120
|
+
// Hardcoded fallbacks
|
|
121
|
+
if (provider === 'kilo')
|
|
122
|
+
return KILO_MODELS;
|
|
123
|
+
if (provider === 'gemini') {
|
|
124
|
+
return [
|
|
125
|
+
{ id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash' },
|
|
126
|
+
{ id: 'gemini-2.5-pro', name: 'Gemini 2.5 Pro' },
|
|
127
|
+
{ id: 'gemini-2.0-flash', name: 'Gemini 2.0 Flash' },
|
|
128
|
+
{ id: 'gemini-1.5-pro', name: 'Gemini 1.5 Pro' },
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
// copilot
|
|
132
|
+
return [
|
|
133
|
+
{ id: 'gpt-4o', name: 'GPT-4o' },
|
|
134
|
+
{ id: 'gpt-4o-mini', name: 'GPT-4o mini' },
|
|
135
|
+
{ id: 'gpt-4.1', name: 'GPT-4.1' },
|
|
136
|
+
{ id: 'claude-sonnet-4', name: 'Claude Sonnet 4' },
|
|
137
|
+
{ id: 'o3', name: 'o3' },
|
|
138
|
+
];
|
|
139
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for managing paths and file system operations
|
|
3
|
+
*/
|
|
4
|
+
export declare const CONFIG_DIR: string;
|
|
5
|
+
export declare const CONFIG_FILE: string;
|
|
6
|
+
export declare const HISTORY_FILE: string;
|
|
7
|
+
export declare const MODELS_CACHE_FILE: string;
|
|
8
|
+
export declare function getConfigPath(): string;
|
|
9
|
+
export declare function getConfigFilePath(): string;
|
|
10
|
+
export declare function getHistoryFilePath(): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for managing paths and file system operations
|
|
3
|
+
*/
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
export const CONFIG_DIR = join(homedir(), '.prompt-enhancer');
|
|
7
|
+
export const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
8
|
+
export const HISTORY_FILE = join(CONFIG_DIR, 'history.json');
|
|
9
|
+
export const MODELS_CACHE_FILE = join(CONFIG_DIR, 'models-cache.json');
|
|
10
|
+
export function getConfigPath() {
|
|
11
|
+
return CONFIG_DIR;
|
|
12
|
+
}
|
|
13
|
+
export function getConfigFilePath() {
|
|
14
|
+
return CONFIG_FILE;
|
|
15
|
+
}
|
|
16
|
+
export function getHistoryFilePath() {
|
|
17
|
+
return HISTORY_FILE;
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@involvex/prompt-enhancer",
|
|
3
|
+
"description": "A Cli to enhance your prompts",
|
|
4
|
+
"author": "involvex",
|
|
5
|
+
"version": "0.0.2",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"prompt-enhancer": "dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"funding": {
|
|
12
|
+
"type": "github",
|
|
13
|
+
"url": "https://github.com/sponsors/involvex"
|
|
14
|
+
},
|
|
15
|
+
"sponsor": {
|
|
16
|
+
"url": "https://github.com/sponsors/involvex"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"url": "git+https://github.com/involvex/prompt-enhancer-cli.git",
|
|
20
|
+
"type": "git"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=16"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"dev": "bun run src/cli.tsx",
|
|
28
|
+
"format": "prettier --write .",
|
|
29
|
+
"lint": "eslint src",
|
|
30
|
+
"lint:fix": "eslint src --fix",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"prebuild": "bun run format && bun run lint:fix && bun run typecheck",
|
|
33
|
+
"test": "prettier --check . && xo && ava",
|
|
34
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
35
|
+
"compile": "bun run prebuild && bun build src/cli.tsx --compile --outfile dist/prompt-enhancer.exe",
|
|
36
|
+
"clean": "del-cli dist",
|
|
37
|
+
"release": "bun run clean && powershell -File scripts/release.ps1"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"readme.md",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
".github/FUNDING.yml"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@google/generative-ai": "^0.24.1",
|
|
47
|
+
"@types/ink": "^0.5.2",
|
|
48
|
+
"@types/meow": "^6.0.0",
|
|
49
|
+
"del-cli": "^7.0.0",
|
|
50
|
+
"has-flag": "^5.0.1",
|
|
51
|
+
"ink": "^5.0.0",
|
|
52
|
+
"ink-select-input": "^6.2.0",
|
|
53
|
+
"ink-text-input": "^6.0.0",
|
|
54
|
+
"meow": "^14.1.0",
|
|
55
|
+
"openai": "^6.27.0",
|
|
56
|
+
"react": "^18.3.1",
|
|
57
|
+
"react-devtools-core": "^7.0.1",
|
|
58
|
+
"react-dom": "^18.3.1",
|
|
59
|
+
"zod": "^4.3.6"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@eslint/js": "latest",
|
|
63
|
+
"@sindresorhus/tsconfig": "^8.1.0",
|
|
64
|
+
"@types/react": "^18.0.32",
|
|
65
|
+
"@vdemedes/prettier-config": "^2.0.1",
|
|
66
|
+
"ava": "^5.2.0",
|
|
67
|
+
"chalk": "^5.2.0",
|
|
68
|
+
"conventional-changelog-cli": "^5.0.0",
|
|
69
|
+
"eslint": "latest",
|
|
70
|
+
"eslint-config-xo-react": "^0.29.0",
|
|
71
|
+
"eslint-plugin-react": "^7.32.2",
|
|
72
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
73
|
+
"ink-testing-library": "^4.0.0",
|
|
74
|
+
"jiti": "latest",
|
|
75
|
+
"prettier": "latest",
|
|
76
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
77
|
+
"prettier-plugin-packagejson": "^3.0.0",
|
|
78
|
+
"prettier-plugin-sort-imports": "^1.8.10",
|
|
79
|
+
"ts-node": "^10.9.1",
|
|
80
|
+
"typescript": "^5.0.3",
|
|
81
|
+
"typescript-eslint": "latest",
|
|
82
|
+
"xo": "^0.53.1"
|
|
83
|
+
},
|
|
84
|
+
"ava": {
|
|
85
|
+
"extensions": {
|
|
86
|
+
"ts": "module",
|
|
87
|
+
"tsx": "module"
|
|
88
|
+
},
|
|
89
|
+
"nodeArguments": [
|
|
90
|
+
"--loader=ts-node/esm"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"xo": {
|
|
94
|
+
"extends": "xo-react",
|
|
95
|
+
"prettier": true,
|
|
96
|
+
"rules": {
|
|
97
|
+
"react/prop-types": "off"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"prettier": "@vdemedes/prettier-config"
|
|
101
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# prompt-enhancer
|
|
2
|
+
|
|
3
|
+
> CLI/TUI tool to enhance prompts using various LLM providers (Gemini, Copilot, Kilo-gateway, Opencode Zen)
|
|
4
|
+
|
|
5
|
+
**Status**: ✅ MVP Complete - Phase 4 Interactive TUI Ready for Use
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🎯 **Interactive TUI Mode** - Menu-driven interface for prompt enhancement
|
|
10
|
+
- ⚡ **CLI Mode** - Direct enhancement via command-line flags
|
|
11
|
+
- 🔧 **Multi-Provider Support** - Gemini, Copilot, Kilo-gateway
|
|
12
|
+
- 💾 **Config Management** - Persistent settings at `~/.prompt-enhancer/`
|
|
13
|
+
- 📜 **History Tracking** - Browse past enhancements
|
|
14
|
+
- 🔄 **Streaming Output** - Real-time enhanced prompt display
|
|
15
|
+
- 🎨 **Interactive Settings** - Configure providers via TUI
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install --global prompt-enhancer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or use directly:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx prompt-enhancer
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### Interactive TUI Mode (Default)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
prompt-enhancer
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This launches the interactive menu where you can:
|
|
38
|
+
|
|
39
|
+
- Enhance a prompt
|
|
40
|
+
- Configure provider settings
|
|
41
|
+
- View enhancement history
|
|
42
|
+
- Get help
|
|
43
|
+
|
|
44
|
+
### CLI Mode - Direct Enhancement
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
$ prompt-enhancer --prompt "Your prompt here"
|
|
48
|
+
# or shorter
|
|
49
|
+
$ prompt-enhancer -p "Your prompt here"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
### Setting Up Providers
|
|
55
|
+
|
|
56
|
+
1. **Via TUI Settings Menu** (Interactive):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
$ prompt-enhancer
|
|
60
|
+
# Select "Settings" → Choose provider → Enter API Key → Select Model
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. **Manual Config File**:
|
|
64
|
+
Edit `~/.prompt-enhancer/config.json`:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"version": "0.1.0",
|
|
69
|
+
"providers": {
|
|
70
|
+
"gemini": {
|
|
71
|
+
"name": "gemini",
|
|
72
|
+
"apiKey": "your-api-key",
|
|
73
|
+
"model": "gemini-2.5-flash",
|
|
74
|
+
"enabled": true
|
|
75
|
+
},
|
|
76
|
+
"copilot": {
|
|
77
|
+
"name": "copilot",
|
|
78
|
+
"apiKey": "your-api-key",
|
|
79
|
+
"model": "gpt-4o",
|
|
80
|
+
"enabled": true
|
|
81
|
+
},
|
|
82
|
+
"kilo": {
|
|
83
|
+
"name": "kilo",
|
|
84
|
+
"apiKey": "your-api-key",
|
|
85
|
+
"model": "auto",
|
|
86
|
+
"enabled": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"defaultProvider": "gemini",
|
|
90
|
+
"maxTokens": 500,
|
|
91
|
+
"temperature": 1.0,
|
|
92
|
+
"saveHistory": true,
|
|
93
|
+
"streaming": true,
|
|
94
|
+
"theme": "dark"
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Usage Examples
|
|
99
|
+
|
|
100
|
+
### Interactive Enhancement
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
$ prompt-enhancer
|
|
104
|
+
# Select "Enhance Prompt" → Type your prompt → Choose provider → View result
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Quick CLI Enhancement
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
prompt-enhancer -p "write a hello world program"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### View Enhancement History
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
$ prompt-enhancer
|
|
117
|
+
# Select "View History" to browse past enhancements
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Get Help
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
$ prompt-enhancer --help
|
|
124
|
+
$ prompt-enhancer
|
|
125
|
+
# Select "Help" in menu for interactive guide
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Supported Models
|
|
129
|
+
|
|
130
|
+
### Gemini
|
|
131
|
+
|
|
132
|
+
- `gemini-2.5-flash` (default)
|
|
133
|
+
- `gemini-2.0-pro`
|
|
134
|
+
- `gemini-1.5-flash`
|
|
135
|
+
- `gemini-1.5-pro`
|
|
136
|
+
|
|
137
|
+
### Copilot / OpenAI
|
|
138
|
+
|
|
139
|
+
- `gpt-4o` (default)
|
|
140
|
+
- `gpt-4.1`
|
|
141
|
+
- `gpt-4-turbo`
|
|
142
|
+
- `gpt-3.5-turbo`
|
|
143
|
+
|
|
144
|
+
### Kilo Gateway
|
|
145
|
+
|
|
146
|
+
- `auto` (default) - Automatically routes to best available free model
|
|
147
|
+
- Any model supported by Kilo's router
|
|
148
|
+
|
|
149
|
+
## Configuration Files
|
|
150
|
+
|
|
151
|
+
- **Config**: `~/.prompt-enhancer/config.json` - Provider settings, API keys, preferences
|
|
152
|
+
- **History**: `~/.prompt-enhancer/history.json` - Enhancement history with timestamps
|
|
153
|
+
|
|
154
|
+
## API Keys Setup
|
|
155
|
+
|
|
156
|
+
### Gemini
|
|
157
|
+
|
|
158
|
+
Get your API key at: <https://makersuite.google.com/app/apikey>
|
|
159
|
+
|
|
160
|
+
### OpenAI / Copilot
|
|
161
|
+
|
|
162
|
+
Get your API key at: <https://platform.openai.com/api-keys>
|
|
163
|
+
|
|
164
|
+
### Kilo Gateway
|
|
165
|
+
|
|
166
|
+
Get your key at: <https://kilo.dev> (or use free models with no key)
|
|
167
|
+
|
|
168
|
+
## Commands
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
$ prompt-enhancer --help
|
|
172
|
+
|
|
173
|
+
Usage
|
|
174
|
+
$ prompt-enhancer
|
|
175
|
+
|
|
176
|
+
Options
|
|
177
|
+
--prompt, -p Your prompt to enhance (optional)
|
|
178
|
+
--help, -h Show help
|
|
179
|
+
--version, -v Show version
|
|
180
|
+
|
|
181
|
+
Examples
|
|
182
|
+
$ prompt-enhancer
|
|
183
|
+
$ prompt-enhancer -p "build a cli to enhance prompts"
|
|
184
|
+
$ prompt-enhancer --help
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Architecture
|
|
188
|
+
|
|
189
|
+
### Project Structure
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
src/
|
|
193
|
+
├── cli.tsx # CLI entry point and routing
|
|
194
|
+
├── app.tsx # Interactive TUI main app
|
|
195
|
+
├── commands/ # Command implementations
|
|
196
|
+
│ ├── direct-enhance.tsx # CLI enhancement
|
|
197
|
+
│ ├── about.tsx
|
|
198
|
+
│ ├── help.tsx
|
|
199
|
+
│ └── version.tsx
|
|
200
|
+
├── components/ # React/Ink TUI components
|
|
201
|
+
│ ├── enhance-prompt.tsx # Interactive enhancement UI
|
|
202
|
+
│ ├── settings.tsx # Provider configuration UI
|
|
203
|
+
│ ├── history-viewer.tsx # History browsing UI
|
|
204
|
+
│ └── menu.tsx # Menu component
|
|
205
|
+
└── lib/ # Core libraries
|
|
206
|
+
├── providers/ # Provider implementations
|
|
207
|
+
│ ├── gemini.ts
|
|
208
|
+
│ ├── copilot.ts
|
|
209
|
+
│ ├── kilo.ts
|
|
210
|
+
│ ├── base.ts # Abstract base provider
|
|
211
|
+
│ └── index.ts # Provider registry
|
|
212
|
+
├── config/ # Configuration management
|
|
213
|
+
│ ├── manager.ts # Config read/write
|
|
214
|
+
│ ├── schema.ts # Zod validation
|
|
215
|
+
│ └── types.ts # TypeScript types
|
|
216
|
+
├── enhancement/ # Enhancement engine
|
|
217
|
+
│ └── engine.ts # Streaming enhancement logic
|
|
218
|
+
├── history/ # History management
|
|
219
|
+
│ └── manager.ts # History persistence
|
|
220
|
+
└── utils/ # Utilities
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Development
|
|
224
|
+
|
|
225
|
+
### Build
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
bun run build
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Lint & Format
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
bun run lint
|
|
235
|
+
bun run format
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Type Check
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
bun run typecheck
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Full Build Pipeline
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
bun run build # Runs format, lint, typecheck, then compile
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Technology Stack
|
|
251
|
+
|
|
252
|
+
- **React 18** - Component framework
|
|
253
|
+
- **Ink 5.2.1** - Terminal UI rendering
|
|
254
|
+
- **TypeScript** - Type safety
|
|
255
|
+
- **Zod** - Schema validation
|
|
256
|
+
- **Meow** - CLI argument parsing
|
|
257
|
+
- **Provider SDKs**:
|
|
258
|
+
- `@google/generative-ai` - Gemini API
|
|
259
|
+
- `openai` - OpenAI/Copilot API
|
|
260
|
+
- Custom HTTP client for Kilo
|
|
261
|
+
|
|
262
|
+
## Notes
|
|
263
|
+
|
|
264
|
+
- Configuration is stored locally in `~/.prompt-enhancer/`
|
|
265
|
+
- API keys are stored unencrypted in config.json (consider using environment variables for production)
|
|
266
|
+
- History is automatically saved unless disabled in config
|
|
267
|
+
- Streaming output requires provider and model support
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
MIT
|