prompt2task 0.1.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.
package/LICENSE ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,170 @@
1
+ # prompt2task
2
+
3
+ Local-first CLI that turns natural-language prompts into structured tasks, sends them to AI providers (OpenAI, Claude), and stores history locally in SQLite.
4
+
5
+ ## What it does
6
+
7
+ 1. Reads your configuration (`~/.prompt2task/config.json`)
8
+ 2. Detects current project context (React, Laravel, WordPress, etc.)
9
+ 3. Converts raw prompt into a structured coding task
10
+ 4. Saves task to local SQLite (`~/.prompt2task/history.db`)
11
+ 5. Sends task to selected AI provider
12
+ 6. Displays response and saves result + metadata
13
+
14
+ **Local-first:** No remote backend, telemetry, or account system. Secrets prefer OS env vars / secure file with `0600`.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install
20
+ npm run build
21
+ npm link # makes `prompt2task` available globally
22
+ ```
23
+
24
+ Or run directly:
25
+
26
+ ```bash
27
+ npm run dev -- "Build a login page"
28
+ npx prompt2task --help
29
+ ```
30
+
31
+ ## First-time setup
32
+
33
+ ```bash
34
+ prompt2task init
35
+ ```
36
+
37
+ Interactive flow:
38
+ - Select provider (OpenAI / Claude)
39
+ - Enter API key (stored in `~/.prompt2task/credentials.json` with `0600`, or use env vars)
40
+ - Select default model
41
+ - Select primary project type
42
+
43
+ Re-run `prompt2task init` to reconfigure (will prompt before overwriting).
44
+
45
+ ## Usage
46
+
47
+ ### Run a task
48
+
49
+ ```bash
50
+ prompt2task "Build a responsive login page with Google OAuth"
51
+ prompt2task "Build a React dashboard"
52
+ ```
53
+
54
+ With JSON output for automation:
55
+
56
+ ```bash
57
+ prompt2task --json "Create a REST API for users"
58
+ ```
59
+
60
+ ### History
61
+
62
+ ```bash
63
+ prompt2task list
64
+ prompt2task list --limit 20
65
+ prompt2task list --status completed
66
+ prompt2task list --json
67
+
68
+ prompt2task show tsk_8f29a
69
+ prompt2task show tsk_8f29a --json
70
+
71
+ prompt2task search "authentication"
72
+ prompt2task search "authentication" --json
73
+ ```
74
+
75
+ ### Configuration
76
+
77
+ ```bash
78
+ prompt2task config
79
+ prompt2task config set model gpt-5
80
+ prompt2task config set project-type react
81
+ prompt2task config set provider openai
82
+ ```
83
+
84
+ ### Provider & Credentials
85
+
86
+ ```bash
87
+ prompt2task provider
88
+ prompt2task credentials remove openai
89
+ prompt2task credentials remove claude
90
+ prompt2task credentials remove all
91
+ ```
92
+
93
+ Environment variables (used as fallback, not persisted):
94
+
95
+ ```bash
96
+ export OPENAI_API_KEY=sk-...
97
+ export ANTHROPIC_API_KEY=sk-ant-...
98
+ ```
99
+
100
+ ## Global files
101
+
102
+ ```
103
+ ~/.prompt2task/
104
+ ├── config.json
105
+ ├── credentials.json # 0600, not in DB
106
+ ├── history.db
107
+ └── logs/
108
+ ```
109
+
110
+ Example `config.json`:
111
+
112
+ ```json
113
+ {
114
+ "version": 1,
115
+ "provider": "openai",
116
+ "model": "gpt-5",
117
+ "projectType": "web-applications"
118
+ }
119
+ ```
120
+
121
+ ## Security notes
122
+
123
+ - API keys never enter task history, logs, or error messages
124
+ - Never committed to git (see `.gitignore`)
125
+ - `config.json` and `credentials.json` are `0600`, app dir `0700`
126
+ - Prefer env vars in CI; file store is fallback with restrictive perms
127
+ - HTTPS only for provider calls
128
+
129
+ ## Development
130
+
131
+ ```bash
132
+ npm run build # tsup build to dist/
133
+ npm run typecheck # tsc --noEmit
134
+ npm test # vitest run
135
+ npm run dev # watch mode
136
+ ```
137
+
138
+ ## Architecture
139
+
140
+ ```
141
+ src/
142
+ ├── cli/ # commander + inquirer + chalk + ora + cli-table3
143
+ ├── providers/ # provider abstraction (openai, claude)
144
+ ├── tasks/ # task model, manager, prompt-builder
145
+ ├── storage/ # drizzle-orm + better-sqlite3, migrations, repositories
146
+ ├── config/ # config-manager (zod) + credentials
147
+ └── project/ # detector (package.json, composer.json, artisan, wp-config)
148
+ ```
149
+
150
+ ## Testing
151
+
152
+ Provider calls are mocked; no real API keys needed.
153
+
154
+ ```bash
155
+ npm test
156
+ ```
157
+
158
+ ## Example workflows
159
+
160
+ ```bash
161
+ npm install && npm run build && npm link
162
+
163
+ prompt2task init
164
+
165
+ prompt2task "Build a responsive React dashboard"
166
+ prompt2task list
167
+ prompt2task show <task-id>
168
+ prompt2task search "dashboard"
169
+ prompt2task --json "Fix WordPress menu" | jq .
170
+ ```
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/tasks/prompt-builder.ts
4
+ function buildStructuredPrompt(options) {
5
+ const { prompt, projectType, projectContext } = options;
6
+ const lines = [];
7
+ lines.push("You are an expert software development agent.");
8
+ lines.push("");
9
+ if (projectType) {
10
+ lines.push(`Project type:`);
11
+ lines.push(projectType);
12
+ lines.push("");
13
+ }
14
+ lines.push(`User request:`);
15
+ lines.push(`"${prompt}"`);
16
+ lines.push("");
17
+ if (projectContext) {
18
+ lines.push("Project context:");
19
+ if (projectContext.path) lines.push(`- Path: ${projectContext.path}`);
20
+ if (projectContext.type) lines.push(`- Detected type: ${projectContext.type}`);
21
+ if (projectContext.framework) lines.push(`- Framework: ${projectContext.framework}`);
22
+ if (projectContext.language) lines.push(`- Language: ${projectContext.language}`);
23
+ if (!projectContext.type && !projectContext.framework) {
24
+ lines.push("- No specific framework detected (generic project).");
25
+ }
26
+ lines.push("");
27
+ } else {
28
+ lines.push("Project context: Not detected (running outside a project or detection unavailable).");
29
+ lines.push("");
30
+ }
31
+ lines.push("Your task:");
32
+ lines.push("1. Inspect the existing project before making changes.");
33
+ lines.push("2. Understand the current implementation.");
34
+ lines.push("3. Implement the requested improvement.");
35
+ lines.push("4. Preserve existing functionality.");
36
+ lines.push("5. Follow the project's existing coding conventions.");
37
+ lines.push("6. Avoid unrelated changes.");
38
+ lines.push("7. Validate the implementation.");
39
+ lines.push("8. Explain what was changed.");
40
+ lines.push("");
41
+ lines.push("Return:");
42
+ lines.push("- Summary");
43
+ lines.push("- Files changed");
44
+ lines.push("- Implementation details");
45
+ lines.push("- Testing performed");
46
+ lines.push("- Remaining issues");
47
+ return lines.join("\n");
48
+ }
49
+
50
+ export {
51
+ buildStructuredPrompt
52
+ };
@@ -0,0 +1,2 @@
1
+
2
+ export { }