promptbridge-mcp 0.2.0__tar.gz
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.
- promptbridge_mcp-0.2.0/.gitignore +8 -0
- promptbridge_mcp-0.2.0/CHANGELOG.md +29 -0
- promptbridge_mcp-0.2.0/LICENSE +21 -0
- promptbridge_mcp-0.2.0/PKG-INFO +160 -0
- promptbridge_mcp-0.2.0/README.md +127 -0
- promptbridge_mcp-0.2.0/README.th.md +111 -0
- promptbridge_mcp-0.2.0/pyproject.toml +55 -0
- promptbridge_mcp-0.2.0/skills/spec/SKILL.md +98 -0
- promptbridge_mcp-0.2.0/src/promptbridge/__init__.py +3 -0
- promptbridge_mcp-0.2.0/src/promptbridge/catalog.py +106 -0
- promptbridge_mcp-0.2.0/src/promptbridge/clarify.py +121 -0
- promptbridge_mcp-0.2.0/src/promptbridge/glossary.py +133 -0
- promptbridge_mcp-0.2.0/src/promptbridge/locales/en.yaml +44 -0
- promptbridge_mcp-0.2.0/src/promptbridge/locales/th.yaml +49 -0
- promptbridge_mcp-0.2.0/src/promptbridge/models.py +82 -0
- promptbridge_mcp-0.2.0/src/promptbridge/render.py +156 -0
- promptbridge_mcp-0.2.0/src/promptbridge/scanner.py +95 -0
- promptbridge_mcp-0.2.0/src/promptbridge/server.py +347 -0
- promptbridge_mcp-0.2.0/src/promptbridge/store.py +170 -0
- promptbridge_mcp-0.2.0/src/promptbridge/templates/_common.yaml +27 -0
- promptbridge_mcp-0.2.0/src/promptbridge/templates/bug_fix.yaml +52 -0
- promptbridge_mcp-0.2.0/src/promptbridge/templates/explain.yaml +31 -0
- promptbridge_mcp-0.2.0/src/promptbridge/templates/feature.yaml +42 -0
- promptbridge_mcp-0.2.0/src/promptbridge/templates/refactor.yaml +38 -0
- promptbridge_mcp-0.2.0/src/promptbridge/templates/test.yaml +36 -0
- promptbridge_mcp-0.2.0/tests/conftest.py +23 -0
- promptbridge_mcp-0.2.0/tests/test_core.py +161 -0
- promptbridge_mcp-0.2.0/tests/test_server_e2e.py +148 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.2.0] — first public release
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Published on PyPI as **`promptbridge-mcp`** (the name `promptbridge` is taken). Install with `uvx promptbridge-mcp`. The import package and the `promptbridge` command are unchanged; a `promptbridge-mcp` command alias is added.
|
|
11
|
+
- README is now in English; the Thai README moved to `README.th.md`.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- CI on Python 3.10–3.13 (Linux, macOS) and tag-triggered PyPI release via trusted publishing.
|
|
15
|
+
- CONTRIBUTING, Code of Conduct, Security policy, issue and pull request templates.
|
|
16
|
+
|
|
17
|
+
## [0.1.1]
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- **Breaking:** tool argument `session_id` renamed to `spec_id` in `pb_clarify`, `pb_compile` and `pb_save`, and `pb_capture` now returns `spec_id`. Some MCP bridges strip arguments named `session_id`, which made these tools fail when proxied.
|
|
21
|
+
|
|
22
|
+
## [0.1.0]
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- MCP server with six tools: `pb_capture`, `pb_clarify`, `pb_compile`, `pb_save`, `pb_glossary`, `pb_library`.
|
|
26
|
+
- Task types `bug_fix`, `feature`, `refactor`, `test`, `explain`.
|
|
27
|
+
- Thai and English question phrasing; other languages fall back to English phrasing translated by the host model.
|
|
28
|
+
- Personal (SQLite) and repo (YAML) glossary; spec library.
|
|
29
|
+
- `/spec` skill for Claude Code.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Endy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: promptbridge-mcp
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Type coding requests in your own language; get a clear English task spec for AI coding agents (MCP server).
|
|
5
|
+
Project-URL: Homepage, https://github.com/Endistic/promptbridge
|
|
6
|
+
Project-URL: Issues, https://github.com/Endistic/promptbridge/issues
|
|
7
|
+
Project-URL: Changelog, https://github.com/Endistic/promptbridge/blob/main/CHANGELOG.md
|
|
8
|
+
Author: Endy
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: claude,coding-agent,i18n,mcp,model-context-protocol,prompt,spec,thai
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Natural Language :: English
|
|
16
|
+
Classifier: Natural Language :: Thai
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Software Development
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: jinja2>=3
|
|
26
|
+
Requires-Dist: mcp>=1.2
|
|
27
|
+
Requires-Dist: pydantic>=2
|
|
28
|
+
Requires-Dist: pyyaml>=6
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# promptbridge
|
|
35
|
+
|
|
36
|
+
**Type coding requests in your own language. Get a clear English task spec your AI coding agent can execute without guessing.**
|
|
37
|
+
|
|
38
|
+
[ภาษาไทย](README.th.md) · [Changelog](CHANGELOG.md) · [Contributing](CONTRIBUTING.md)
|
|
39
|
+
|
|
40
|
+
Many developers read English fine but don't *think* in it fast enough to write precise prompts. promptbridge sits between you and your coding agent (Claude Code, Claude Desktop, Cursor, any MCP client):
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
/spec หน้า login อยากให้ถ้าใส่รหัสผิดหลายครั้งมันล็อคไว้ก่อน
|
|
44
|
+
(login page: lock it after too many wrong passwords)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
1. It asks **only what is ambiguous** — at most 3 tap-to-answer questions, in your language: *how many attempts? lock for how long? per account or per IP?*
|
|
48
|
+
2. It shows a **2–3 line summary in your language** plus the English spec: Goal · Context · Requirements · Constraints · Acceptance criteria · Assumptions.
|
|
49
|
+
3. You approve, and the agent does the work — **reporting back in your language**, with code, paths and errors left untouched.
|
|
50
|
+
|
|
51
|
+
It also learns your vocabulary: tell it once that «ตะกร้า» means `CartStore`, and every future spec uses the real name.
|
|
52
|
+
|
|
53
|
+
## How it works
|
|
54
|
+
|
|
55
|
+
| Part | Does |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| **Host model** (the Claude/LLM you already use) | Reads your language, fills spec slots in English, asks the questions, summarizes results |
|
|
58
|
+
| **promptbridge MCP server** (Python) | Task templates, decides which questions matter, renders the spec deterministically, remembers your glossary and specs that worked |
|
|
59
|
+
|
|
60
|
+
The server never calls an LLM itself — no extra API cost, no data leaves your machine. Everything is stored locally in `~/.promptbridge/`.
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
You need [uv](https://docs.astral.sh/uv/).
|
|
65
|
+
|
|
66
|
+
### Claude Code
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# 1) Register the MCP server for all projects
|
|
70
|
+
claude mcp add promptbridge -s user -- uvx promptbridge-mcp
|
|
71
|
+
|
|
72
|
+
# 2) Install the /spec skill
|
|
73
|
+
mkdir -p ~/.claude/skills/spec
|
|
74
|
+
curl -fsSL https://raw.githubusercontent.com/Endistic/promptbridge/main/skills/spec/SKILL.md \
|
|
75
|
+
-o ~/.claude/skills/spec/SKILL.md
|
|
76
|
+
|
|
77
|
+
# 3) In any project
|
|
78
|
+
/spec ปุ่มบันทึกในหน้าโปรไฟล์กดแล้วขึ้น error 500
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Claude Desktop
|
|
82
|
+
|
|
83
|
+
Claude menu (macOS menu bar) → **Settings… → Developer → Edit Config**, add the server, then quit (⌘Q) and reopen:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"promptbridge": { "command": "/opt/homebrew/bin/uvx", "args": ["promptbridge-mcp"] }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Use the full path from `which uvx` — Claude Desktop does not see your shell's `PATH`. Then ask: *"Use promptbridge to make a spec for: …"*
|
|
94
|
+
|
|
95
|
+
### Cursor and other MCP clients
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{ "mcpServers": { "promptbridge": { "command": "uvx", "args": ["promptbridge-mcp"] } } }
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Clients without the skill follow the workflow described in the tools themselves.
|
|
102
|
+
|
|
103
|
+
### From source
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone https://github.com/Endistic/promptbridge
|
|
107
|
+
claude mcp add promptbridge -s user -- uvx --from ./promptbridge promptbridge
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Or load it as a Claude Code plugin (server + skill): `claude --plugin-dir ./promptbridge`, then `/promptbridge:spec`.
|
|
111
|
+
|
|
112
|
+
## Usage
|
|
113
|
+
|
|
114
|
+
| Type | Result |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `/spec <request>` | Full flow: ask → summarize → do |
|
|
117
|
+
| `/spec --quick <request>` | Skip questions; unknowns become visible Assumptions in the spec |
|
|
118
|
+
| "remember: ตะกร้า = CartStore" | Add a glossary term |
|
|
119
|
+
| "show my glossary" | List glossary terms |
|
|
120
|
+
| "have I asked for something like this before?" | Search specs that worked |
|
|
121
|
+
|
|
122
|
+
### Task types
|
|
123
|
+
|
|
124
|
+
`bug_fix` · `feature` · `refactor` · `test` · `explain` — each has its own required facts ([`src/promptbridge/templates/`](src/promptbridge/templates/)). Adding a type is one YAML file.
|
|
125
|
+
|
|
126
|
+
### Glossary
|
|
127
|
+
|
|
128
|
+
- **personal** — `~/.promptbridge/pb.db`, follows you across projects
|
|
129
|
+
- **repo** — `<repo>/.promptbridge/glossary.yaml`, commit it so the whole team shares one vocabulary
|
|
130
|
+
|
|
131
|
+
When you edit a spec and add a real name (e.g. `LoginAttemptService`), promptbridge offers to remember the pairing.
|
|
132
|
+
|
|
133
|
+
## Languages
|
|
134
|
+
|
|
135
|
+
Built around a `locale` from day one. Thai and English have hand-written question phrasing; any other language (Japanese, Vietnamese, Indonesian, Korean, Spanish, …) works today — the host model translates the questions. Adding native phrasing for a language is one file: [`src/promptbridge/locales/`](src/promptbridge/locales/). See [CONTRIBUTING.md](CONTRIBUTING.md#add-a-language).
|
|
136
|
+
|
|
137
|
+
## MCP tools
|
|
138
|
+
|
|
139
|
+
| Tool | Purpose |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| `pb_capture` | Start from the user's raw request: guess task type, match glossary, scan the repo |
|
|
142
|
+
| `pb_clarify` | Decide which questions to ask (max 3 per round, max 2 rounds) |
|
|
143
|
+
| `pb_compile` | Render the English spec; unconfirmed guesses become Assumptions |
|
|
144
|
+
| `pb_save` | Record accepted / edited / rejected; suggest glossary terms from edits |
|
|
145
|
+
| `pb_glossary` | List / add / remove terms (personal or repo scope) |
|
|
146
|
+
| `pb_library` | Search specs that worked before |
|
|
147
|
+
|
|
148
|
+
Resource `promptbridge://stats` reports accepted / edited / rejected counts.
|
|
149
|
+
|
|
150
|
+
## Configuration
|
|
151
|
+
|
|
152
|
+
| Variable | Default | Meaning |
|
|
153
|
+
| --- | --- | --- |
|
|
154
|
+
| `PROMPTBRIDGE_HOME` | `~/.promptbridge` | Where the local database lives |
|
|
155
|
+
|
|
156
|
+
Works with MCP Python SDK 1.x and 2.x.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# promptbridge
|
|
2
|
+
|
|
3
|
+
**Type coding requests in your own language. Get a clear English task spec your AI coding agent can execute without guessing.**
|
|
4
|
+
|
|
5
|
+
[ภาษาไทย](README.th.md) · [Changelog](CHANGELOG.md) · [Contributing](CONTRIBUTING.md)
|
|
6
|
+
|
|
7
|
+
Many developers read English fine but don't *think* in it fast enough to write precise prompts. promptbridge sits between you and your coding agent (Claude Code, Claude Desktop, Cursor, any MCP client):
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
/spec หน้า login อยากให้ถ้าใส่รหัสผิดหลายครั้งมันล็อคไว้ก่อน
|
|
11
|
+
(login page: lock it after too many wrong passwords)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
1. It asks **only what is ambiguous** — at most 3 tap-to-answer questions, in your language: *how many attempts? lock for how long? per account or per IP?*
|
|
15
|
+
2. It shows a **2–3 line summary in your language** plus the English spec: Goal · Context · Requirements · Constraints · Acceptance criteria · Assumptions.
|
|
16
|
+
3. You approve, and the agent does the work — **reporting back in your language**, with code, paths and errors left untouched.
|
|
17
|
+
|
|
18
|
+
It also learns your vocabulary: tell it once that «ตะกร้า» means `CartStore`, and every future spec uses the real name.
|
|
19
|
+
|
|
20
|
+
## How it works
|
|
21
|
+
|
|
22
|
+
| Part | Does |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| **Host model** (the Claude/LLM you already use) | Reads your language, fills spec slots in English, asks the questions, summarizes results |
|
|
25
|
+
| **promptbridge MCP server** (Python) | Task templates, decides which questions matter, renders the spec deterministically, remembers your glossary and specs that worked |
|
|
26
|
+
|
|
27
|
+
The server never calls an LLM itself — no extra API cost, no data leaves your machine. Everything is stored locally in `~/.promptbridge/`.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
You need [uv](https://docs.astral.sh/uv/).
|
|
32
|
+
|
|
33
|
+
### Claude Code
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# 1) Register the MCP server for all projects
|
|
37
|
+
claude mcp add promptbridge -s user -- uvx promptbridge-mcp
|
|
38
|
+
|
|
39
|
+
# 2) Install the /spec skill
|
|
40
|
+
mkdir -p ~/.claude/skills/spec
|
|
41
|
+
curl -fsSL https://raw.githubusercontent.com/Endistic/promptbridge/main/skills/spec/SKILL.md \
|
|
42
|
+
-o ~/.claude/skills/spec/SKILL.md
|
|
43
|
+
|
|
44
|
+
# 3) In any project
|
|
45
|
+
/spec ปุ่มบันทึกในหน้าโปรไฟล์กดแล้วขึ้น error 500
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Claude Desktop
|
|
49
|
+
|
|
50
|
+
Claude menu (macOS menu bar) → **Settings… → Developer → Edit Config**, add the server, then quit (⌘Q) and reopen:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"promptbridge": { "command": "/opt/homebrew/bin/uvx", "args": ["promptbridge-mcp"] }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Use the full path from `which uvx` — Claude Desktop does not see your shell's `PATH`. Then ask: *"Use promptbridge to make a spec for: …"*
|
|
61
|
+
|
|
62
|
+
### Cursor and other MCP clients
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{ "mcpServers": { "promptbridge": { "command": "uvx", "args": ["promptbridge-mcp"] } } }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Clients without the skill follow the workflow described in the tools themselves.
|
|
69
|
+
|
|
70
|
+
### From source
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/Endistic/promptbridge
|
|
74
|
+
claude mcp add promptbridge -s user -- uvx --from ./promptbridge promptbridge
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or load it as a Claude Code plugin (server + skill): `claude --plugin-dir ./promptbridge`, then `/promptbridge:spec`.
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
| Type | Result |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `/spec <request>` | Full flow: ask → summarize → do |
|
|
84
|
+
| `/spec --quick <request>` | Skip questions; unknowns become visible Assumptions in the spec |
|
|
85
|
+
| "remember: ตะกร้า = CartStore" | Add a glossary term |
|
|
86
|
+
| "show my glossary" | List glossary terms |
|
|
87
|
+
| "have I asked for something like this before?" | Search specs that worked |
|
|
88
|
+
|
|
89
|
+
### Task types
|
|
90
|
+
|
|
91
|
+
`bug_fix` · `feature` · `refactor` · `test` · `explain` — each has its own required facts ([`src/promptbridge/templates/`](src/promptbridge/templates/)). Adding a type is one YAML file.
|
|
92
|
+
|
|
93
|
+
### Glossary
|
|
94
|
+
|
|
95
|
+
- **personal** — `~/.promptbridge/pb.db`, follows you across projects
|
|
96
|
+
- **repo** — `<repo>/.promptbridge/glossary.yaml`, commit it so the whole team shares one vocabulary
|
|
97
|
+
|
|
98
|
+
When you edit a spec and add a real name (e.g. `LoginAttemptService`), promptbridge offers to remember the pairing.
|
|
99
|
+
|
|
100
|
+
## Languages
|
|
101
|
+
|
|
102
|
+
Built around a `locale` from day one. Thai and English have hand-written question phrasing; any other language (Japanese, Vietnamese, Indonesian, Korean, Spanish, …) works today — the host model translates the questions. Adding native phrasing for a language is one file: [`src/promptbridge/locales/`](src/promptbridge/locales/). See [CONTRIBUTING.md](CONTRIBUTING.md#add-a-language).
|
|
103
|
+
|
|
104
|
+
## MCP tools
|
|
105
|
+
|
|
106
|
+
| Tool | Purpose |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `pb_capture` | Start from the user's raw request: guess task type, match glossary, scan the repo |
|
|
109
|
+
| `pb_clarify` | Decide which questions to ask (max 3 per round, max 2 rounds) |
|
|
110
|
+
| `pb_compile` | Render the English spec; unconfirmed guesses become Assumptions |
|
|
111
|
+
| `pb_save` | Record accepted / edited / rejected; suggest glossary terms from edits |
|
|
112
|
+
| `pb_glossary` | List / add / remove terms (personal or repo scope) |
|
|
113
|
+
| `pb_library` | Search specs that worked before |
|
|
114
|
+
|
|
115
|
+
Resource `promptbridge://stats` reports accepted / edited / rejected counts.
|
|
116
|
+
|
|
117
|
+
## Configuration
|
|
118
|
+
|
|
119
|
+
| Variable | Default | Meaning |
|
|
120
|
+
| --- | --- | --- |
|
|
121
|
+
| `PROMPTBRIDGE_HOME` | `~/.promptbridge` | Where the local database lives |
|
|
122
|
+
|
|
123
|
+
Works with MCP Python SDK 1.x and 2.x.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# promptbridge
|
|
2
|
+
|
|
3
|
+
**พิมพ์สั่งงาน AI coding เป็นภาษาไทย แล้วได้ task spec ภาษาอังกฤษที่ชัดเจน ให้ agent ทำงานได้โดยไม่ต้องเดา**
|
|
4
|
+
|
|
5
|
+
[English](README.md) · [Changelog](CHANGELOG.md) · [ร่วมพัฒนา](CONTRIBUTING.md)
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
/spec หน้า login อยากให้ถ้าใส่รหัสผิดหลายครั้งมันล็อคไว้ก่อน
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
1. ถามกลับเฉพาะจุดที่กำกวม ไม่เกิน 3 ข้อแบบกดเลือก เป็นภาษาไทย (ผิดกี่ครั้ง? ล็อคนานแค่ไหน? นับต่อ account หรือ IP?)
|
|
12
|
+
2. สรุปไทย 2–3 บรรทัดให้ตรวจ พร้อม spec อังกฤษ (Goal / Context / Requirements / Constraints / Acceptance criteria / Assumptions)
|
|
13
|
+
3. กด "ลงมือเลย" แล้ว agent ทำตาม spec และรายงานกลับเป็นไทย ส่วนโค้ด ชื่อไฟล์ และ error คงเป็นต้นฉบับ
|
|
14
|
+
|
|
15
|
+
สอนคำศัพท์ครั้งเดียว เช่น «ตะกร้า» = `CartStore` แล้ว spec ครั้งต่อ ๆ ไปจะใช้ชื่อจริงในโค้ดเอง
|
|
16
|
+
|
|
17
|
+
## ทำงานอย่างไร
|
|
18
|
+
|
|
19
|
+
| ส่วน | หน้าที่ |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| **Host model** (Claude หรือ LLM ที่คุณใช้อยู่) | อ่านภาษาไทย, เติม slot เป็นอังกฤษ, ถามคำถามเป็นไทย, สรุปผลเป็นไทย |
|
|
22
|
+
| **MCP server** (`promptbridge`, Python) | template ตาม task type, เลือกว่าจะถามอะไร, render spec แบบ deterministic, จำ glossary และ spec ที่เคยใช้ได้ผล |
|
|
23
|
+
|
|
24
|
+
Server ไม่เรียก LLM เอง จึงไม่มีค่า API เพิ่ม และข้อมูลทั้งหมดเก็บในเครื่องที่ `~/.promptbridge/`
|
|
25
|
+
|
|
26
|
+
## ติดตั้ง
|
|
27
|
+
|
|
28
|
+
ต้องมี [uv](https://docs.astral.sh/uv/) (`brew install uv`)
|
|
29
|
+
|
|
30
|
+
### Claude Code
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# 1) ลงทะเบียน MCP server (ครั้งเดียว ใช้ได้ทุกโปรเจกต์)
|
|
34
|
+
claude mcp add promptbridge -s user -- uvx promptbridge-mcp
|
|
35
|
+
|
|
36
|
+
# 2) ติดตั้ง skill /spec
|
|
37
|
+
mkdir -p ~/.claude/skills/spec
|
|
38
|
+
curl -fsSL https://raw.githubusercontent.com/Endistic/promptbridge/main/skills/spec/SKILL.md \
|
|
39
|
+
-o ~/.claude/skills/spec/SKILL.md
|
|
40
|
+
|
|
41
|
+
# 3) เปิด Claude Code ในโปรเจกต์ไหนก็ได้ แล้วพิมพ์
|
|
42
|
+
/spec ปุ่มบันทึกในหน้าโปรไฟล์กดแล้วขึ้น error 500
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Claude Desktop
|
|
46
|
+
|
|
47
|
+
เมนู **Claude** ที่แถบเมนูบนของ Mac → **Settings… → Developer → Edit Config** ใส่ config นี้ แล้วปิดแอปด้วย ⌘Q และเปิดใหม่
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"promptbridge": { "command": "/opt/homebrew/bin/uvx", "args": ["promptbridge-mcp"] }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
ใส่ path เต็มจากคำสั่ง `which uvx` เพราะ Claude Desktop ไม่เห็น `PATH` ของ terminal จากนั้นพิมพ์ว่า "ใช้ promptbridge ทำ spec จากคำขอนี้: …"
|
|
58
|
+
|
|
59
|
+
### Cursor / client อื่นที่รองรับ MCP
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{ "mcpServers": { "promptbridge": { "command": "uvx", "args": ["promptbridge-mcp"] } } }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Client ที่ไม่มี skill จะทำตามขั้นตอนที่อธิบายไว้ใน tool แทน
|
|
66
|
+
|
|
67
|
+
### ติดตั้งจาก source
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git clone https://github.com/Endistic/promptbridge
|
|
71
|
+
claude mcp add promptbridge -s user -- uvx --from ./promptbridge promptbridge
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
หรือโหลดเป็น Claude Code plugin (รวม server + skill): `claude --plugin-dir ./promptbridge` แล้วใช้ `/promptbridge:spec`
|
|
75
|
+
|
|
76
|
+
## คำสั่งที่ใช้บ่อย
|
|
77
|
+
|
|
78
|
+
| พิมพ์ | ผล |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `/spec <ข้อความ>` | flow เต็ม: ถาม → สรุป → ลงมือ |
|
|
81
|
+
| `/spec --quick <ข้อความ>` | ข้ามคำถาม ช่องที่ไม่รู้จะถูกเขียนเป็น Assumptions ให้เห็น |
|
|
82
|
+
| "จำคำนี้ไว้: ตะกร้า = CartStore" | เพิ่ม glossary |
|
|
83
|
+
| "ดูคำที่จำไว้" | แสดง glossary ทั้งหมด |
|
|
84
|
+
| "เคยสั่งงานคล้าย ๆ นี้ไหม" | ค้น spec เก่าที่เคยใช้ได้ผล |
|
|
85
|
+
|
|
86
|
+
## Task types
|
|
87
|
+
|
|
88
|
+
`bug_fix` · `feature` · `refactor` · `test` · `explain` — แต่ละแบบมีข้อมูลที่ต้องมีต่างกัน (ดู `src/promptbridge/templates/*.yaml`) เพิ่ม type ใหม่ได้ด้วยไฟล์ YAML หนึ่งไฟล์
|
|
89
|
+
|
|
90
|
+
## Glossary
|
|
91
|
+
|
|
92
|
+
- **personal** — เก็บใน `~/.promptbridge/pb.db` ตามคุณไปทุกโปรเจกต์
|
|
93
|
+
- **repo** — เก็บใน `<repo>/.promptbridge/glossary.yaml` commit เข้า repo เพื่อให้ทั้งทีมใช้ศัพท์ชุดเดียวกัน
|
|
94
|
+
|
|
95
|
+
เมื่อคุณแก้ spec แล้วใส่ชื่อจริง (เช่น `LoginAttemptService`) ระบบจะเสนอให้จำคู่คำนั้นไว้ใช้ครั้งหน้า
|
|
96
|
+
|
|
97
|
+
## ภาษาอื่น
|
|
98
|
+
|
|
99
|
+
ออกแบบเป็น `locale` ตั้งแต่ต้น ตอนนี้มีคำถามสำเร็จรูปภาษาไทยและอังกฤษ ภาษาอื่น (ja, vi, id, ko, …) ใช้ได้เลยโดย host model แปลคำถามให้ เพิ่มภาษาใหม่ได้ด้วยไฟล์ `src/promptbridge/locales/<code>.yaml` หนึ่งไฟล์ ดู [CONTRIBUTING.md](CONTRIBUTING.md#add-a-language)
|
|
100
|
+
|
|
101
|
+
## ตั้งค่า
|
|
102
|
+
|
|
103
|
+
| ตัวแปร | ค่าเริ่มต้น | ความหมาย |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| `PROMPTBRIDGE_HOME` | `~/.promptbridge` | ที่เก็บฐานข้อมูล |
|
|
106
|
+
|
|
107
|
+
ดูสถิติ accepted / edited / rejected ได้จาก MCP resource `promptbridge://stats` รองรับ MCP Python SDK ทั้ง 1.x และ 2.x
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "promptbridge-mcp"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Type coding requests in your own language; get a clear English task spec for AI coding agents (MCP server)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
authors = [{ name = "Endy" }]
|
|
9
|
+
keywords = ["mcp", "model-context-protocol", "claude", "prompt", "spec", "i18n", "thai", "coding-agent"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Natural Language :: English",
|
|
15
|
+
"Natural Language :: Thai",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Topic :: Software Development",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"mcp>=1.2",
|
|
26
|
+
"pydantic>=2",
|
|
27
|
+
"jinja2>=3",
|
|
28
|
+
"pyyaml>=6",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/Endistic/promptbridge"
|
|
33
|
+
Issues = "https://github.com/Endistic/promptbridge/issues"
|
|
34
|
+
Changelog = "https://github.com/Endistic/promptbridge/blob/main/CHANGELOG.md"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.23"]
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
promptbridge = "promptbridge.server:main"
|
|
41
|
+
promptbridge-mcp = "promptbridge.server:main"
|
|
42
|
+
|
|
43
|
+
[build-system]
|
|
44
|
+
requires = ["hatchling"]
|
|
45
|
+
build-backend = "hatchling.build"
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.wheel]
|
|
48
|
+
packages = ["src/promptbridge"]
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build.targets.sdist]
|
|
51
|
+
include = ["src/", "tests/", "skills/", "README.md", "README.th.md", "LICENSE", "CHANGELOG.md", "pyproject.toml"]
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
testpaths = ["tests"]
|
|
55
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec
|
|
3
|
+
description: Turn a request the user wrote in their own language (Thai by default) into a clear English task spec, ask only the questions that matter, then carry it out. Use when the user types /spec, or writes a coding request in Thai or another non-English language and wants it done properly.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /spec — native-language request → English task spec → done
|
|
7
|
+
|
|
8
|
+
The user thinks in their own language. Your job is to turn what they wrote into a spec a coding
|
|
9
|
+
agent can execute without guessing, check it with them in their language, then do the work.
|
|
10
|
+
The `promptbridge` MCP server owns the structure (templates, which questions, rendering, memory).
|
|
11
|
+
You own the language work.
|
|
12
|
+
|
|
13
|
+
## Language rules (whole session)
|
|
14
|
+
|
|
15
|
+
- Talk to the user in their language (the `locale`; default Thai). Short sentences, plain words.
|
|
16
|
+
- Everything you send to the pb_* tools as `value_en` is **English**. Translate; never paste Thai into slots.
|
|
17
|
+
- Keep code, file paths, identifiers, commands, error messages and numbers exactly as they are.
|
|
18
|
+
- Technical terms with no common Thai word (API, endpoint, cache, deploy) stay in English inside Thai sentences.
|
|
19
|
+
|
|
20
|
+
## Steps
|
|
21
|
+
|
|
22
|
+
### 1. Capture
|
|
23
|
+
Call `pb_capture` with:
|
|
24
|
+
- `raw_text`: the user's request exactly as typed (everything after `/spec`)
|
|
25
|
+
- `locale`: `th` unless the user writes in another language (`ja`, `vi`, `id`, …)
|
|
26
|
+
- `cwd`: the current working directory
|
|
27
|
+
|
|
28
|
+
If the user wrote `/spec --quick …`, remember `quick=true` for step 3 and strip the flag from `raw_text`.
|
|
29
|
+
|
|
30
|
+
### 2. Fill slots (silently)
|
|
31
|
+
From `raw_text`, the returned `glossary_hits`, `repo_context` and — if it helps — a quick look at the
|
|
32
|
+
repo (Glob/Grep for the obvious files), fill the `slot_schema`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{"goal": {"value_en": "Lock a user account after repeated failed logins.", "status": "stated"},
|
|
36
|
+
"behavior": {"value_en": ["Lock after 5 failures"], "status": "inferred"}}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- `stated` = the user actually said it. `inferred` = you guessed it (from context or code). Be honest; the
|
|
40
|
+
server uses this to decide what to confirm.
|
|
41
|
+
- Omit slots you know nothing about. Do not invent requirements to look complete.
|
|
42
|
+
- Use glossary `term_en` names and real file paths you found.
|
|
43
|
+
- If `task_type` is clearly wrong (e.g. the user describes a bug but it guessed `feature`), pass the right
|
|
44
|
+
one to `pb_clarify`.
|
|
45
|
+
|
|
46
|
+
### 3. Clarify (max 2 rounds)
|
|
47
|
+
Call `pb_clarify(spec_id, slots, task_type?, quick?)`.
|
|
48
|
+
|
|
49
|
+
If `ready` is false, ask the returned `questions` with **AskUserQuestion** in one call:
|
|
50
|
+
- One question per item, in the user's language. Start from `prompt`, adapt it to this task.
|
|
51
|
+
- Give 2–4 concrete options that make sense for *this* code (e.g. "5 ครั้ง", "10 ครั้ง"), put the most
|
|
52
|
+
likely first. The user can always type their own answer.
|
|
53
|
+
- `kind: "confirm"` → show your inferred value as the first option ("ใช่ ตามนี้") and alternatives after it.
|
|
54
|
+
- Keep headers ≤ 12 characters.
|
|
55
|
+
|
|
56
|
+
Translate the answers to English, update those slots with `status: "stated"`, and call `pb_clarify` again
|
|
57
|
+
with the full slot set. Stop when `ready` is true. If the user says "ไปเลย", "ข้ามได้", or similar,
|
|
58
|
+
call again with `quick: true`.
|
|
59
|
+
|
|
60
|
+
If AskUserQuestion is not available, ask in plain text as a numbered list with the options.
|
|
61
|
+
|
|
62
|
+
### 4. Compile and confirm
|
|
63
|
+
Call `pb_compile(spec_id)`. Then show the user:
|
|
64
|
+
|
|
65
|
+
1. A 2–3 line summary in their language, following `summary_instruction`.
|
|
66
|
+
2. The assumptions, if any, as a short list in their language — these are the things they should check.
|
|
67
|
+
3. The English spec in a ```markdown code block, so they can glance at it.
|
|
68
|
+
|
|
69
|
+
Then ask with AskUserQuestion: **ลงมือเลย / แก้ไข spec / ยกเลิก** (in their language).
|
|
70
|
+
|
|
71
|
+
If `validation.warnings` mentions untranslated text, fix the slot and compile again before showing it.
|
|
72
|
+
|
|
73
|
+
### 5. Do the work
|
|
74
|
+
- **Approve** → treat `spec_markdown` as your task and carry it out. Follow its "How to work" section.
|
|
75
|
+
Follow `reflect_instruction` for everything you say along the way: plans, questions and the final
|
|
76
|
+
report are in the user's language; code stays as-is.
|
|
77
|
+
- **Edit** → apply the user's change to the spec (they may describe it in their language; you update the
|
|
78
|
+
English), show the updated summary, confirm again. Record it as `edited` in step 6.
|
|
79
|
+
- **Cancel** → call `pb_save(outcome="rejected")` and stop.
|
|
80
|
+
|
|
81
|
+
### 6. Save and learn
|
|
82
|
+
After the work (or after cancel), call `pb_save(spec_id, outcome, final_spec?)`:
|
|
83
|
+
- `accepted` if the spec was used as compiled, `edited` + `final_spec` if it changed, `rejected` if cancelled.
|
|
84
|
+
- If it returns `glossary_candidates`, match each to the word the user used in `raw_text`, then ask once:
|
|
85
|
+
"จำคำเหล่านี้ไว้ไหม? «ตะกร้า» = `CartStore`". On yes, call `pb_glossary(action="add", …)`.
|
|
86
|
+
Use `scope="repo"` (with `cwd`) for names specific to this codebase the team would share; otherwise `personal`.
|
|
87
|
+
|
|
88
|
+
## Other commands the user may ask for
|
|
89
|
+
|
|
90
|
+
- "จำคำนี้ไว้: X = Y" → `pb_glossary(action="add", term_native="X", term_en="Y", kind=...)`
|
|
91
|
+
- "ดูคำที่จำไว้" → `pb_glossary(action="list", cwd=...)` and show a small table.
|
|
92
|
+
- "เคยสั่งงานคล้าย ๆ นี้ไหม" → `pb_library(query=...)`; offer to reuse a result as the starting slots.
|
|
93
|
+
|
|
94
|
+
## Don't
|
|
95
|
+
|
|
96
|
+
- Don't ask more than the server returned, and never more than 2 rounds.
|
|
97
|
+
- Don't start coding before the user approves the spec (except task_type `explain`, which needs no approval).
|
|
98
|
+
- Don't show the English spec without the summary in their language.
|