iaip-mcp-pde 2.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/README.md +187 -0
- package/dist/cli.d.ts +18 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +385 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.d.ts +59 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +293 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/parser.d.ts +19 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +89 -0
- package/dist/parser.js.map +1 -0
- package/dist/pde-engine.d.ts +54 -0
- package/dist/pde-engine.d.ts.map +1 -0
- package/dist/pde-engine.js +85 -0
- package/dist/pde-engine.js.map +1 -0
- package/dist/prompts.d.ts +10 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +93 -0
- package/dist/prompts.js.map +1 -0
- package/dist/storage.d.ts +44 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +369 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +24 -0
- package/dist/types.js.map +1 -0
- package/package.json +63 -0
- package/rispecs/pde-data-models.rispec.md +182 -0
- package/rispecs/pde-overview.rispec.md +157 -0
- package/rispecs/pde-parent-child-schema.rispec.md +525 -0
- package/rispecs/pde-prompts.rispec.md +144 -0
- package/rispecs/pde-resources.rispec.md +101 -0
- package/rispecs/pde-tools.rispec.md +179 -0
- package/rispecs/relation-to-mcp-structural-thinking.kin.md +66 -0
- package/scenarios/01-simple-decomposition.md +88 -0
- package/scenarios/02-multi-intent-workflow.md +112 -0
- package/scenarios/03-ceremonial-alignment.md +155 -0
- package/scenarios/04-dependency-resolution.md +163 -0
- package/scenarios/05-checkpoint-recovery.md +171 -0
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# PDE-MCP: Prompt Decomposition Engine
|
|
2
|
+
|
|
3
|
+
> A Model Context Protocol (MCP) server that transforms complex prompts into ceremonially-aligned execution plans.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
PDE-MCP enables LLM terminal agents to decompose complex user requests into structured, executable workflows following the Medicine Wheel ceremonial framework. It honors both Western technical precision and Indigenous epistemological frameworks.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **5-Layer Decomposition Pipeline**: Intent extraction → Dependency analysis → Wheel assignment → Workflow generation → Execution planning
|
|
12
|
+
- **Medicine Wheel Alignment**: Tasks organized by the Four Directions (EAST/SOUTH/WEST/NORTH)
|
|
13
|
+
- **Dependency Resolution**: Automatic ordering and parallelization detection
|
|
14
|
+
- **Checkpoint Recovery**: Resume workflows from failure points
|
|
15
|
+
- **MCP Integration**: Works with any MCP-compatible agent
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
npm run build
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### As MCP Server
|
|
27
|
+
|
|
28
|
+
Add to your MCP configuration:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"mcpServers": {
|
|
33
|
+
"pde": {
|
|
34
|
+
"command": "node",
|
|
35
|
+
"args": ["/path/to/mcp-pde/dist/index.js"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Guidance for LLM Agents: Preserving User Intent
|
|
42
|
+
|
|
43
|
+
The primary purpose of the `pde_decompose` tool is to **preserve user intent**. Complex user prompts often contain subtle, nested, or implicit requirements that standard LLM processing can misinterpret or ignore. This tool is designed to be the first step in any complex interaction to mitigate this risk.
|
|
44
|
+
|
|
45
|
+
### Two Modes of Operation
|
|
46
|
+
|
|
47
|
+
1. **Simple Mode (Recommended Default)**: Activated with `options: { simple: true }`. This mode is the key to preserving intent. It uses the powerful intent extraction layer and then directly translates the findings into a simple, actionable to-do list. **This should be your default way of using the tool.**
|
|
48
|
+
|
|
49
|
+
2. **Ceremonial Mode (Default, for Structured Problems)**: If the `simple` option is omitted, the engine runs its full 5-layer pipeline, producing a complex, ceremonially-aligned workflow. This mode is powerful but should only be used for well-defined, top-down problems that explicitly require a formal, multi-stage plan.
|
|
50
|
+
|
|
51
|
+
### Recommended Workflow
|
|
52
|
+
|
|
53
|
+
To ensure user intent is never lost, follow this interaction pattern:
|
|
54
|
+
|
|
55
|
+
1. **Receive Complex Prompt**: When a user provides a complex, multi-part prompt (e.g., bug reports, feature ideas, architectural plans).
|
|
56
|
+
|
|
57
|
+
2. **Decompose in Simple Mode**: Your immediate first action should be to call `pde_decompose` with the `simple: true` option.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Example agent call
|
|
61
|
+
pde_decompose({
|
|
62
|
+
prompt: "The user's complex prompt...",
|
|
63
|
+
options: { simple: true }
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
3. **Confirm Understanding**: Present the resulting to-do list back to the user. This list is a clear, point-by-point reflection of your understanding of their request.
|
|
68
|
+
|
|
69
|
+
4. **Execute with Confidence**: Once the user confirms the to-do list is accurate, you can proceed to execute each task, confident that you are perfectly aligned with their original intent.
|
|
70
|
+
|
|
71
|
+
This workflow transforms the tool from a simple planner into a powerful "understanding and confirmation" engine, building trust and ensuring accuracy from the very beginning of an interaction.
|
|
72
|
+
|
|
73
|
+
### Available Tools
|
|
74
|
+
|
|
75
|
+
| Tool | Description |
|
|
76
|
+
|------|-------------|
|
|
77
|
+
| `pde_decompose` | Decompose a complex prompt into execution plan |
|
|
78
|
+
| `pde_get_plan` | Retrieve a stored execution plan |
|
|
79
|
+
| `pde_validate_plan` | Validate plan coherence and completeness |
|
|
80
|
+
| `pde_get_checkpoint` | Get checkpoint for workflow recovery |
|
|
81
|
+
| `pde_list_workflows` | List all workflows |
|
|
82
|
+
|
|
83
|
+
### Available Resources
|
|
84
|
+
|
|
85
|
+
| URI | Description |
|
|
86
|
+
|-----|-------------|
|
|
87
|
+
| `pde://ceremonies/medicine-wheel` | Four Directions definitions |
|
|
88
|
+
| `pde://schemas/intent-types` | Intent classification schema |
|
|
89
|
+
| `pde://templates/workflow-stages` | Workflow stage templates |
|
|
90
|
+
|
|
91
|
+
### Available Prompts
|
|
92
|
+
|
|
93
|
+
| Prompt | Purpose |
|
|
94
|
+
|--------|---------|
|
|
95
|
+
| `pde-intent-extraction` | Guide Layer 1 intent extraction |
|
|
96
|
+
| `pde-dependency-analysis` | Guide Layer 2 dependency mapping |
|
|
97
|
+
| `pde-wheel-assignment` | Guide Layer 3 direction assignment |
|
|
98
|
+
| `pde-workflow-generation` | Guide Layer 4 workflow creation |
|
|
99
|
+
| `pde-execution-plan` | Guide Layer 5 plan finalization |
|
|
100
|
+
|
|
101
|
+
## Example
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Input: "Create a REST API with JWT authentication, connect to PostgreSQL, write tests, deploy to staging"
|
|
105
|
+
|
|
106
|
+
Output:
|
|
107
|
+
📋 Decomposed Workflow:
|
|
108
|
+
|
|
109
|
+
Stage: SOUTH - Planning & Growth
|
|
110
|
+
[Parallel execution possible]
|
|
111
|
+
- [ ] Create REST API structure
|
|
112
|
+
- [ ] Implement JWT authentication
|
|
113
|
+
|
|
114
|
+
Stage: WEST - Living & Action
|
|
115
|
+
- [ ] Connect to PostgreSQL database
|
|
116
|
+
- [ ] Write comprehensive tests
|
|
117
|
+
|
|
118
|
+
Stage: NORTH - Assurance & Reflection
|
|
119
|
+
- [ ] Deploy to staging environment
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Medicine Wheel Framework
|
|
123
|
+
|
|
124
|
+
| Direction | Name | Theme | Intent Types |
|
|
125
|
+
|-----------|------|-------|--------------|
|
|
126
|
+
| EAST | Nitsáhákees | Thinking & Beginnings | ANALYSIS |
|
|
127
|
+
| SOUTH | Nahat'á | Planning & Growth | CREATION, MODIFICATION |
|
|
128
|
+
| WEST | Iina | Living & Action | VALIDATION, INTEGRATION |
|
|
129
|
+
| NORTH | Siihasin | Assurance & Reflection | COMMUNICATION |
|
|
130
|
+
|
|
131
|
+
## Testing
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Run unit tests
|
|
135
|
+
npm run test
|
|
136
|
+
|
|
137
|
+
# Run scenario tests
|
|
138
|
+
./run-scenarios.sh
|
|
139
|
+
|
|
140
|
+
# Run specific scenario
|
|
141
|
+
./run-scenarios.sh 01
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Project Structure
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
mcp-pde/
|
|
148
|
+
├── src/
|
|
149
|
+
│ ├── index.ts # Entry point
|
|
150
|
+
│ ├── mcp-server.ts # MCP server implementation
|
|
151
|
+
│ ├── pde-engine.ts # 5-layer decomposition engine
|
|
152
|
+
│ └── types.ts # TypeScript interfaces
|
|
153
|
+
├── tests/
|
|
154
|
+
│ ├── pde-engine.test.ts
|
|
155
|
+
│ └── mcp-tools.test.ts
|
|
156
|
+
├── scenarios/
|
|
157
|
+
│ ├── 01-simple-decomposition.md
|
|
158
|
+
│ ├── 02-multi-intent-workflow.md
|
|
159
|
+
│ ├── 03-ceremonial-alignment.md
|
|
160
|
+
│ ├── 04-dependency-resolution.md
|
|
161
|
+
│ └── 05-checkpoint-recovery.md
|
|
162
|
+
├── rispecs/ # RISE specifications
|
|
163
|
+
│ ├── pde-overview.rispec.md
|
|
164
|
+
│ ├── pde-tools.rispec.md
|
|
165
|
+
│ ├── pde-resources.rispec.md
|
|
166
|
+
│ ├── pde-prompts.rispec.md
|
|
167
|
+
│ └── pde-data-models.rispec.md
|
|
168
|
+
├── mcp-config.json # Example MCP configuration
|
|
169
|
+
├── run-scenarios.sh # Scenario test runner
|
|
170
|
+
└── package.json
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## RISE Framework
|
|
174
|
+
|
|
175
|
+
This project was developed using the RISE Framework:
|
|
176
|
+
- **R**everse-engineer: Analyze PDE concepts from CONTENT.md
|
|
177
|
+
- **I**ntent-extract: Clarify desired outcomes and user needs
|
|
178
|
+
- **S**pecify: Create rispecs before implementation
|
|
179
|
+
- **E**xport: Build production-ready MCP server
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
|
184
|
+
|
|
185
|
+
## Attribution
|
|
186
|
+
|
|
187
|
+
Part of the Indigenous-AI Collaborative Platform (IAIP), honoring Two-Eyed Seeing (Etuaptmumk) and sacred technology practice.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* mcp-pde CLI — Full PDE pipeline from terminal
|
|
4
|
+
*
|
|
5
|
+
* Commands:
|
|
6
|
+
* decompose <text> Decompose a prompt via LLM (Anthropic Claude)
|
|
7
|
+
* parse <file> Parse a raw LLM response file into PDE
|
|
8
|
+
* build-prompt <text> Output system+user prompt (for piping to other LLMs)
|
|
9
|
+
* list List stored decompositions
|
|
10
|
+
* get <id> Show a stored decomposition
|
|
11
|
+
* export <id> Export decomposition as markdown
|
|
12
|
+
* serve Start MCP server (original behavior)
|
|
13
|
+
*
|
|
14
|
+
* The decompose command calls Claude directly, parses the response,
|
|
15
|
+
* saves to .pde/, and outputs the result — full end-to-end.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* mcp-pde CLI — Full PDE pipeline from terminal
|
|
5
|
+
*
|
|
6
|
+
* Commands:
|
|
7
|
+
* decompose <text> Decompose a prompt via LLM (Anthropic Claude)
|
|
8
|
+
* parse <file> Parse a raw LLM response file into PDE
|
|
9
|
+
* build-prompt <text> Output system+user prompt (for piping to other LLMs)
|
|
10
|
+
* list List stored decompositions
|
|
11
|
+
* get <id> Show a stored decomposition
|
|
12
|
+
* export <id> Export decomposition as markdown
|
|
13
|
+
* serve Start MCP server (original behavior)
|
|
14
|
+
*
|
|
15
|
+
* The decompose command calls Claude directly, parses the response,
|
|
16
|
+
* saves to .pde/, and outputs the result — full end-to-end.
|
|
17
|
+
*/
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const minimist_1 = __importDefault(require("minimist"));
|
|
23
|
+
const fs_1 = require("fs");
|
|
24
|
+
const path_1 = require("path");
|
|
25
|
+
const pde_engine_js_1 = require("./pde-engine.js");
|
|
26
|
+
const types_js_1 = require("./types.js");
|
|
27
|
+
const mcp_server_js_1 = require("./mcp-server.js");
|
|
28
|
+
const HELP = `
|
|
29
|
+
🧠 mcp-pde — Prompt Decomposition Engine CLI
|
|
30
|
+
|
|
31
|
+
USAGE:
|
|
32
|
+
mcp-pde [command] [options]
|
|
33
|
+
|
|
34
|
+
COMMANDS:
|
|
35
|
+
(none) Start MCP server (stdio transport)
|
|
36
|
+
decompose <text|-> Decompose prompt via Claude API (full end-to-end)
|
|
37
|
+
parse <file> Parse raw LLM response JSON into PDE & store
|
|
38
|
+
build-prompt <text> Output system+user prompt pair (for piping)
|
|
39
|
+
list List stored decompositions in .pde/
|
|
40
|
+
get <id> Show a stored decomposition by ID
|
|
41
|
+
export <id> Export decomposition as markdown
|
|
42
|
+
serve Start MCP server (stdio transport)
|
|
43
|
+
|
|
44
|
+
OPTIONS:
|
|
45
|
+
--workdir, -w <path> Working directory for .pde/ storage (default: cwd)
|
|
46
|
+
--model, -m <model> Claude model (default: claude-sonnet-4-20250514)
|
|
47
|
+
--parent, -p <uuid> Parent PDE UUID for parent-child nesting
|
|
48
|
+
--no-implicit Don't extract implicit intents
|
|
49
|
+
--no-deps Don't map dependencies
|
|
50
|
+
--json Output raw JSON instead of formatted
|
|
51
|
+
--limit, -l <n> Limit for list command (default: 10)
|
|
52
|
+
--file, -f <path> Read prompt from file instead of argument
|
|
53
|
+
--help, -h Show this help
|
|
54
|
+
|
|
55
|
+
ENVIRONMENT:
|
|
56
|
+
ANTHROPIC_API_KEY Required for 'decompose' command
|
|
57
|
+
PDE_MODEL Default model override
|
|
58
|
+
PDE_WORKDIR Default working directory
|
|
59
|
+
|
|
60
|
+
EXAMPLES:
|
|
61
|
+
# Full decompose — calls Claude, parses, stores, outputs
|
|
62
|
+
mcp-pde decompose "Build a CLI for mcp-pde that calls Claude directly"
|
|
63
|
+
|
|
64
|
+
# Decompose from file
|
|
65
|
+
mcp-pde decompose -f ./my-prompt.txt
|
|
66
|
+
|
|
67
|
+
# Decompose from stdin
|
|
68
|
+
echo "complex prompt here" | mcp-pde decompose -
|
|
69
|
+
|
|
70
|
+
# Just build the prompt (pipe to your own LLM)
|
|
71
|
+
mcp-pde build-prompt "my prompt" --json | jq .systemPrompt
|
|
72
|
+
|
|
73
|
+
# Parse a saved LLM response
|
|
74
|
+
mcp-pde parse ./llm-response.txt --prompt "original prompt"
|
|
75
|
+
|
|
76
|
+
# List & explore
|
|
77
|
+
mcp-pde list
|
|
78
|
+
mcp-pde get <uuid>
|
|
79
|
+
mcp-pde export <uuid>
|
|
80
|
+
|
|
81
|
+
PIPELINE:
|
|
82
|
+
mcp-pde decompose → coaia-pde import <id> → cnarrative ls -M <chart.jsonl>
|
|
83
|
+
`;
|
|
84
|
+
// ── Anthropic LLM call ──────────────────────────────────────────────────────
|
|
85
|
+
async function callClaude(systemPrompt, userMessage, model) {
|
|
86
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
87
|
+
if (!apiKey) {
|
|
88
|
+
console.error('❌ ANTHROPIC_API_KEY not set. Required for decompose command.');
|
|
89
|
+
console.error(' Set it: export ANTHROPIC_API_KEY=sk-ant-...');
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
const { default: Anthropic } = await import('@anthropic-ai/sdk');
|
|
93
|
+
const client = new Anthropic({ apiKey });
|
|
94
|
+
const response = await client.messages.create({
|
|
95
|
+
model,
|
|
96
|
+
max_tokens: 4096,
|
|
97
|
+
system: systemPrompt,
|
|
98
|
+
messages: [{ role: 'user', content: userMessage }],
|
|
99
|
+
});
|
|
100
|
+
const textBlock = response.content.find(b => b.type === 'text');
|
|
101
|
+
if (!textBlock || textBlock.type !== 'text') {
|
|
102
|
+
throw new Error('No text response from Claude');
|
|
103
|
+
}
|
|
104
|
+
return textBlock.text;
|
|
105
|
+
}
|
|
106
|
+
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
107
|
+
function readPromptInput(argv) {
|
|
108
|
+
// From --file / -f
|
|
109
|
+
if (argv.file || argv.f) {
|
|
110
|
+
const filePath = (0, path_1.resolve)(argv.file || argv.f);
|
|
111
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
112
|
+
console.error(`❌ File not found: ${filePath}`);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
return (0, fs_1.readFileSync)(filePath, 'utf-8').trim();
|
|
116
|
+
}
|
|
117
|
+
// From positional arg (or stdin via "-")
|
|
118
|
+
const text = argv._.slice(1).join(' ');
|
|
119
|
+
if (text === '-' || text === '') {
|
|
120
|
+
// Read from stdin
|
|
121
|
+
return (0, fs_1.readFileSync)(0, 'utf-8').trim();
|
|
122
|
+
}
|
|
123
|
+
return text;
|
|
124
|
+
}
|
|
125
|
+
function getOptions(argv) {
|
|
126
|
+
const opts = {};
|
|
127
|
+
if (argv['no-implicit'])
|
|
128
|
+
opts.extractImplicit = false;
|
|
129
|
+
if (argv['no-deps'])
|
|
130
|
+
opts.mapDependencies = false;
|
|
131
|
+
return opts;
|
|
132
|
+
}
|
|
133
|
+
function formatDecomposition(stored, json) {
|
|
134
|
+
if (json)
|
|
135
|
+
return JSON.stringify(stored, null, 2);
|
|
136
|
+
const r = stored.result;
|
|
137
|
+
const lines = [];
|
|
138
|
+
lines.push(`\n🧠 PDE Decomposition: ${stored.id}`);
|
|
139
|
+
lines.push(`📅 ${stored.timestamp}\n`);
|
|
140
|
+
// Primary
|
|
141
|
+
lines.push(`🎯 PRIMARY: ${r.primary.action} → ${r.primary.target}`);
|
|
142
|
+
lines.push(` Urgency: ${r.primary.urgency} | Confidence: ${Math.round(r.primary.confidence * 100)}%\n`);
|
|
143
|
+
// Secondary
|
|
144
|
+
if (r.secondary.length > 0) {
|
|
145
|
+
lines.push(`📋 SECONDARY INTENTS (${r.secondary.length}):`);
|
|
146
|
+
for (const s of r.secondary) {
|
|
147
|
+
const tag = s.implicit ? ' (implicit)' : '';
|
|
148
|
+
lines.push(` • ${s.action} → ${s.target}${tag}`);
|
|
149
|
+
}
|
|
150
|
+
lines.push('');
|
|
151
|
+
}
|
|
152
|
+
// Four Directions
|
|
153
|
+
const dirEmoji = { east: '🌅', south: '🔥', west: '🌊', north: '❄️' };
|
|
154
|
+
const dirName = { east: 'VISION', south: 'ANALYSIS', west: 'VALIDATION', north: 'ACTION' };
|
|
155
|
+
for (const dir of ['east', 'south', 'west', 'north']) {
|
|
156
|
+
const items = r.directions[dir];
|
|
157
|
+
if (items && items.length > 0) {
|
|
158
|
+
lines.push(`${dirEmoji[dir]} ${dir.toUpperCase()} — ${dirName[dir]}:`);
|
|
159
|
+
for (const item of items) {
|
|
160
|
+
lines.push(` • ${item.text} [${Math.round(item.confidence * 100)}%]`);
|
|
161
|
+
}
|
|
162
|
+
lines.push('');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Action Stack
|
|
166
|
+
if (r.actionStack.length > 0) {
|
|
167
|
+
lines.push(`⚡ ACTION STACK (${r.actionStack.length}):`);
|
|
168
|
+
for (const a of r.actionStack) {
|
|
169
|
+
const check = a.completed ? '✅' : '⬜';
|
|
170
|
+
const dep = a.dependency ? ` (→ ${a.dependency})` : '';
|
|
171
|
+
lines.push(` ${check} [${dirEmoji[a.direction] || '?'}] ${a.text}${dep}`);
|
|
172
|
+
}
|
|
173
|
+
lines.push('');
|
|
174
|
+
}
|
|
175
|
+
// Ambiguities
|
|
176
|
+
if (r.ambiguities.length > 0) {
|
|
177
|
+
lines.push(`⚠️ AMBIGUITIES (${r.ambiguities.length}):`);
|
|
178
|
+
for (const a of r.ambiguities) {
|
|
179
|
+
lines.push(` ❓ "${a.text}"`);
|
|
180
|
+
lines.push(` → ${a.suggestion}`);
|
|
181
|
+
}
|
|
182
|
+
lines.push('');
|
|
183
|
+
}
|
|
184
|
+
// Context
|
|
185
|
+
const ctx = r.context;
|
|
186
|
+
if (ctx.files_needed.length || ctx.tools_required.length || ctx.assumptions.length) {
|
|
187
|
+
lines.push('📦 CONTEXT:');
|
|
188
|
+
if (ctx.files_needed.length)
|
|
189
|
+
lines.push(` Files: ${ctx.files_needed.join(', ')}`);
|
|
190
|
+
if (ctx.tools_required.length)
|
|
191
|
+
lines.push(` Tools: ${ctx.tools_required.join(', ')}`);
|
|
192
|
+
if (ctx.assumptions.length) {
|
|
193
|
+
lines.push(' Assumptions:');
|
|
194
|
+
for (const a of ctx.assumptions)
|
|
195
|
+
lines.push(` • ${a}`);
|
|
196
|
+
}
|
|
197
|
+
lines.push('');
|
|
198
|
+
}
|
|
199
|
+
// Outputs
|
|
200
|
+
const out = r.outputs;
|
|
201
|
+
if (out.artifacts.length || out.updates.length || out.communications.length) {
|
|
202
|
+
lines.push('📤 EXPECTED OUTPUTS:');
|
|
203
|
+
if (out.artifacts.length)
|
|
204
|
+
lines.push(` Artifacts: ${out.artifacts.join(', ')}`);
|
|
205
|
+
if (out.updates.length)
|
|
206
|
+
lines.push(` Updates: ${out.updates.join(', ')}`);
|
|
207
|
+
if (out.communications.length)
|
|
208
|
+
lines.push(` Comms: ${out.communications.join(', ')}`);
|
|
209
|
+
lines.push('');
|
|
210
|
+
}
|
|
211
|
+
return lines.join('\n');
|
|
212
|
+
}
|
|
213
|
+
// ── Main ────────────────────────────────────────────────────────────────────
|
|
214
|
+
async function main() {
|
|
215
|
+
const argv = (0, minimist_1.default)(process.argv.slice(2), {
|
|
216
|
+
alias: { h: 'help', w: 'workdir', m: 'model', l: 'limit', f: 'file', p: 'parent' },
|
|
217
|
+
boolean: ['help', 'json', 'no-implicit', 'no-deps'],
|
|
218
|
+
string: ['workdir', 'model', 'file', 'prompt', 'parent'],
|
|
219
|
+
});
|
|
220
|
+
if (argv.help) {
|
|
221
|
+
console.log(HELP);
|
|
222
|
+
process.exit(0);
|
|
223
|
+
}
|
|
224
|
+
if (argv._.length === 0) {
|
|
225
|
+
await (0, mcp_server_js_1.startServer)();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const command = argv._[0];
|
|
229
|
+
const workdir = argv.workdir || process.env.PDE_WORKDIR || process.cwd();
|
|
230
|
+
const model = argv.model || process.env.PDE_MODEL || 'claude-sonnet-4-20250514';
|
|
231
|
+
const engine = new pde_engine_js_1.PdeEngine(workdir);
|
|
232
|
+
const opts = getOptions(argv);
|
|
233
|
+
try {
|
|
234
|
+
switch (command) {
|
|
235
|
+
// ── decompose: full end-to-end ──────────────────────────────────────
|
|
236
|
+
case 'decompose':
|
|
237
|
+
case 'd': {
|
|
238
|
+
const prompt = readPromptInput(argv);
|
|
239
|
+
if (!prompt) {
|
|
240
|
+
console.error('❌ No prompt provided. Pass text, use -f <file>, or pipe via stdin.');
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
const fullOpts = { ...types_js_1.DEFAULT_OPTIONS, ...opts };
|
|
244
|
+
const { systemPrompt, userMessage } = engine.buildPrompt(prompt, opts);
|
|
245
|
+
const parentPdeId = argv.parent || undefined;
|
|
246
|
+
console.error(`🧠 Decomposing with ${model}...`);
|
|
247
|
+
console.error(`📁 Storing in ${(0, path_1.resolve)(workdir, '.pde/')}`);
|
|
248
|
+
if (parentPdeId)
|
|
249
|
+
console.error(`🔗 Parent PDE: ${parentPdeId}`);
|
|
250
|
+
const llmResponse = await callClaude(systemPrompt, userMessage, model);
|
|
251
|
+
const stored = engine.parseAndStore(llmResponse, prompt, opts, workdir, parentPdeId);
|
|
252
|
+
console.error(`✅ Stored: ${stored.id}`);
|
|
253
|
+
if (stored.folder_name) {
|
|
254
|
+
console.error(`📂 Folder: ${stored.folder_name}`);
|
|
255
|
+
}
|
|
256
|
+
console.log(formatDecomposition(stored, !!argv.json));
|
|
257
|
+
// Print pipeline hint
|
|
258
|
+
console.error(`\n🧭 Next: coaia-pde import ${stored.id} -w ${workdir}`);
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
// ── parse: parse raw LLM response file ─────────────────────────────
|
|
262
|
+
case 'parse':
|
|
263
|
+
case 'p': {
|
|
264
|
+
const filePath = argv._[1];
|
|
265
|
+
if (!filePath) {
|
|
266
|
+
console.error('❌ Usage: mcp-pde parse <response-file> --prompt "original prompt"');
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
const responseText = (0, fs_1.readFileSync)((0, path_1.resolve)(filePath), 'utf-8');
|
|
270
|
+
const originalPrompt = argv.prompt || '(prompt not provided)';
|
|
271
|
+
const parentPdeId = argv.parent || undefined;
|
|
272
|
+
const stored = engine.parseAndStore(responseText, originalPrompt, opts, workdir, parentPdeId);
|
|
273
|
+
console.error(`✅ Parsed & stored: ${stored.id}`);
|
|
274
|
+
console.log(formatDecomposition(stored, !!argv.json));
|
|
275
|
+
console.error(`\n🧭 Next: coaia-pde import ${stored.id} -w ${workdir}`);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
// ── build-prompt: output prompt pair ────────────────────────────────
|
|
279
|
+
case 'build-prompt':
|
|
280
|
+
case 'bp': {
|
|
281
|
+
const prompt = readPromptInput(argv);
|
|
282
|
+
if (!prompt) {
|
|
283
|
+
console.error('❌ No prompt provided.');
|
|
284
|
+
process.exit(1);
|
|
285
|
+
}
|
|
286
|
+
const { systemPrompt, userMessage } = engine.buildPrompt(prompt, opts);
|
|
287
|
+
if (argv.json) {
|
|
288
|
+
console.log(JSON.stringify({ systemPrompt, userMessage, originalPrompt: prompt }, null, 2));
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
console.log('=== SYSTEM PROMPT ===');
|
|
292
|
+
console.log(systemPrompt);
|
|
293
|
+
console.log('\n=== USER MESSAGE ===');
|
|
294
|
+
console.log(userMessage);
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
// ── list ────────────────────────────────────────────────────────────
|
|
299
|
+
case 'list':
|
|
300
|
+
case 'ls': {
|
|
301
|
+
const limit = argv.limit || 10;
|
|
302
|
+
const parentId = argv.parent || undefined;
|
|
303
|
+
const items = parentId
|
|
304
|
+
? engine.listChildren(parentId, workdir)
|
|
305
|
+
: engine.list(workdir, limit);
|
|
306
|
+
if (items.length === 0) {
|
|
307
|
+
console.log(parentId
|
|
308
|
+
? `No children found for parent ${parentId} in ${(0, path_1.resolve)(workdir, '.pde/')}`
|
|
309
|
+
: `No decompositions found in ${(0, path_1.resolve)(workdir, '.pde/')}`);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
if (argv.json) {
|
|
313
|
+
const summary = items.map(d => ({
|
|
314
|
+
id: d.id,
|
|
315
|
+
timestamp: d.timestamp,
|
|
316
|
+
primary: `${d.result.primary.action} → ${d.result.primary.target}`,
|
|
317
|
+
secondary: d.result.secondary.length,
|
|
318
|
+
ambiguities: d.result.ambiguities.length,
|
|
319
|
+
actions: d.result.actionStack.length,
|
|
320
|
+
}));
|
|
321
|
+
console.log(JSON.stringify(summary, null, 2));
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
console.log(`\n📂 Decompositions in ${(0, path_1.resolve)(workdir, '.pde/')} (${items.length}):\n`);
|
|
325
|
+
for (const d of items) {
|
|
326
|
+
const date = new Date(d.timestamp).toLocaleString();
|
|
327
|
+
console.log(` 🔹 ${d.id}`);
|
|
328
|
+
console.log(` ${date} | 🎯 ${d.result.primary.action} → ${d.result.primary.target}`);
|
|
329
|
+
console.log(` ${d.result.secondary.length} secondary | ${d.result.actionStack.length} actions | ${d.result.ambiguities.length} ambiguities`);
|
|
330
|
+
console.log('');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
// ── get ─────────────────────────────────────────────────────────────
|
|
336
|
+
case 'get':
|
|
337
|
+
case 'g': {
|
|
338
|
+
const id = argv._[1];
|
|
339
|
+
if (!id) {
|
|
340
|
+
console.error('❌ Usage: mcp-pde get <id>');
|
|
341
|
+
process.exit(1);
|
|
342
|
+
}
|
|
343
|
+
const stored = engine.get(id, workdir);
|
|
344
|
+
if (!stored) {
|
|
345
|
+
console.error(`❌ Decomposition ${id} not found in ${(0, path_1.resolve)(workdir, '.pde/')}`);
|
|
346
|
+
process.exit(1);
|
|
347
|
+
}
|
|
348
|
+
console.log(formatDecomposition(stored, !!argv.json));
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
// ── export ──────────────────────────────────────────────────────────
|
|
352
|
+
case 'export':
|
|
353
|
+
case 'exp': {
|
|
354
|
+
const id = argv._[1];
|
|
355
|
+
if (!id) {
|
|
356
|
+
console.error('❌ Usage: mcp-pde export <id>');
|
|
357
|
+
process.exit(1);
|
|
358
|
+
}
|
|
359
|
+
const md = engine.exportMarkdown(id, workdir);
|
|
360
|
+
if (!md) {
|
|
361
|
+
console.error(`❌ Decomposition ${id} not found`);
|
|
362
|
+
process.exit(1);
|
|
363
|
+
}
|
|
364
|
+
console.log(md);
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
// ── serve (original MCP behavior) ───────────────────────────────────
|
|
368
|
+
case 'serve':
|
|
369
|
+
case 'mcp': {
|
|
370
|
+
await (0, mcp_server_js_1.startServer)();
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
default:
|
|
374
|
+
console.error(`❌ Unknown command: ${command}`);
|
|
375
|
+
console.log(HELP);
|
|
376
|
+
process.exit(1);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
console.error(`❌ ${error instanceof Error ? error.message : String(error)}`);
|
|
381
|
+
process.exit(1);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
main();
|
|
385
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;GAcG;;;;;AAEH,wDAAgC;AAChC,2BAA8C;AAC9C,+BAA+B;AAC/B,mDAA4C;AAE5C,yCAAwE;AACxE,mDAA8C;AAE9C,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDZ,CAAC;AAEF,+EAA+E;AAE/E,KAAK,UAAU,UAAU,CACvB,YAAoB,EACpB,WAAmB,EACnB,KAAa;IAEb,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAC9E,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,SA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K,CAAC,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* PDE-MCP v2 Entry Point
|
|
4
|
+
* Starts the Model Context Protocol server for Prompt Decomposition Engine.
|
|
5
|
+
*
|
|
6
|
+
* Also re-exports core engine, parser, prompts, storage for programmatic use.
|
|
7
|
+
* CLI: ./cli.ts (bin: mcp-pde)
|
|
8
|
+
*/
|
|
9
|
+
export { PdeEngine, PDEParseError } from './pde-engine.js';
|
|
10
|
+
export { parseDecompositionResponse, actionStackToMarkdown } from './parser.js';
|
|
11
|
+
export { buildSystemPrompt, formatUserMessage } from './prompts.js';
|
|
12
|
+
export { saveDecomposition, loadDecomposition, listDecompositions, decompositionToMarkdown } from './storage.js';
|
|
13
|
+
export { startServer } from './mcp-server.js';
|
|
14
|
+
export type { DecompositionResult, DecompositionOptions, PrimaryIntent, SecondaryIntent, ContextRequirements, ExpectedOutputs, Direction, DirectionItem, DirectionMap, ActionItem, AmbiguityFlag, StoredDecomposition, } from './types.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAUH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACjH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,aAAa,EACb,YAAY,EACZ,UAAU,EACV,aAAa,EACb,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|