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/dist/types.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDE-MCP Types v2
|
|
3
|
+
*
|
|
4
|
+
* Canonical types from IAIP/lib/pde/types.ts — the LLM-driven Prompt Decomposition Engine.
|
|
5
|
+
* This replaces the v1 regex-based types with the proven DecompositionResult schema
|
|
6
|
+
* that powers the IAIP web UI and is designed for reuse across MCP, CLI, and UI contexts.
|
|
7
|
+
*
|
|
8
|
+
* Lineage: IAIP/lib/pde/types.ts → mcp-pde/src/types.ts
|
|
9
|
+
*/
|
|
10
|
+
export interface DecompositionOptions {
|
|
11
|
+
extractImplicit: boolean;
|
|
12
|
+
mapDependencies: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_OPTIONS: DecompositionOptions;
|
|
15
|
+
export interface DecompositionResult {
|
|
16
|
+
primary: PrimaryIntent;
|
|
17
|
+
secondary: SecondaryIntent[];
|
|
18
|
+
context: ContextRequirements;
|
|
19
|
+
outputs: ExpectedOutputs;
|
|
20
|
+
directions: DirectionMap;
|
|
21
|
+
actionStack: ActionItem[];
|
|
22
|
+
ambiguities: AmbiguityFlag[];
|
|
23
|
+
}
|
|
24
|
+
export interface PrimaryIntent {
|
|
25
|
+
action: string;
|
|
26
|
+
target: string;
|
|
27
|
+
urgency: Urgency;
|
|
28
|
+
confidence: number;
|
|
29
|
+
}
|
|
30
|
+
export type Urgency = "immediate" | "session" | "persistent";
|
|
31
|
+
export interface SecondaryIntent {
|
|
32
|
+
action: string;
|
|
33
|
+
target: string;
|
|
34
|
+
implicit: boolean;
|
|
35
|
+
dependency: string | null;
|
|
36
|
+
confidence: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ContextRequirements {
|
|
39
|
+
files_needed: string[];
|
|
40
|
+
tools_required: string[];
|
|
41
|
+
assumptions: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface ExpectedOutputs {
|
|
44
|
+
artifacts: string[];
|
|
45
|
+
updates: string[];
|
|
46
|
+
communications: string[];
|
|
47
|
+
}
|
|
48
|
+
export type Direction = "east" | "south" | "west" | "north";
|
|
49
|
+
export interface DirectionItem {
|
|
50
|
+
text: string;
|
|
51
|
+
confidence: number;
|
|
52
|
+
implicit: boolean;
|
|
53
|
+
}
|
|
54
|
+
export type DirectionMap = Record<Direction, DirectionItem[]>;
|
|
55
|
+
export interface ActionItem {
|
|
56
|
+
text: string;
|
|
57
|
+
direction: Direction;
|
|
58
|
+
dependency: string | null;
|
|
59
|
+
completed?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface AmbiguityFlag {
|
|
62
|
+
text: string;
|
|
63
|
+
suggestion: string;
|
|
64
|
+
}
|
|
65
|
+
export interface DirectionMeta {
|
|
66
|
+
name: string;
|
|
67
|
+
desc: string;
|
|
68
|
+
emoji: string;
|
|
69
|
+
color: string;
|
|
70
|
+
}
|
|
71
|
+
export declare const DIRECTION_META: Record<Direction, DirectionMeta>;
|
|
72
|
+
export declare const DIRECTIONS: Direction[];
|
|
73
|
+
export interface StoredDecomposition {
|
|
74
|
+
id: string;
|
|
75
|
+
timestamp: string;
|
|
76
|
+
prompt: string;
|
|
77
|
+
result: DecompositionResult;
|
|
78
|
+
options: DecompositionOptions;
|
|
79
|
+
/** Path to the exported markdown file, if any */
|
|
80
|
+
markdownPath?: string;
|
|
81
|
+
/** UUID of parent PDE (for parent-child relationships) */
|
|
82
|
+
parent_pde_id?: string;
|
|
83
|
+
/** Folder name, e.g. "2604041200--83a2d7f9-..." */
|
|
84
|
+
folder_name?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface DecomposeInput {
|
|
87
|
+
prompt: string;
|
|
88
|
+
options?: Partial<DecompositionOptions>;
|
|
89
|
+
/** Working directory for .pde/ storage. Defaults to cwd. */
|
|
90
|
+
workdir?: string;
|
|
91
|
+
/** UUID of parent PDE for parent-child nesting */
|
|
92
|
+
parent_pde_id?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface GetDecompositionInput {
|
|
95
|
+
id: string;
|
|
96
|
+
workdir?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface ListDecompositionsInput {
|
|
99
|
+
workdir?: string;
|
|
100
|
+
limit?: number;
|
|
101
|
+
/** Filter to children of a specific parent PDE */
|
|
102
|
+
parent_id?: string;
|
|
103
|
+
}
|
|
104
|
+
export interface ExportMarkdownInput {
|
|
105
|
+
id: string;
|
|
106
|
+
workdir?: string;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PDE-MCP Types v2
|
|
4
|
+
*
|
|
5
|
+
* Canonical types from IAIP/lib/pde/types.ts — the LLM-driven Prompt Decomposition Engine.
|
|
6
|
+
* This replaces the v1 regex-based types with the proven DecompositionResult schema
|
|
7
|
+
* that powers the IAIP web UI and is designed for reuse across MCP, CLI, and UI contexts.
|
|
8
|
+
*
|
|
9
|
+
* Lineage: IAIP/lib/pde/types.ts → mcp-pde/src/types.ts
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DIRECTIONS = exports.DIRECTION_META = exports.DEFAULT_OPTIONS = void 0;
|
|
13
|
+
exports.DEFAULT_OPTIONS = {
|
|
14
|
+
extractImplicit: true,
|
|
15
|
+
mapDependencies: true,
|
|
16
|
+
};
|
|
17
|
+
exports.DIRECTION_META = {
|
|
18
|
+
east: { name: "VISION", desc: "What is being asked?", emoji: "🌅", color: "#f59e0b" },
|
|
19
|
+
south: { name: "ANALYSIS", desc: "What needs to be learned?", emoji: "🔥", color: "#ef4444" },
|
|
20
|
+
west: { name: "VALIDATION", desc: "What needs reflection?", emoji: "🌊", color: "#3b82f6" },
|
|
21
|
+
north: { name: "ACTION", desc: "What executes the cycle?", emoji: "❄️", color: "#10b981" },
|
|
22
|
+
};
|
|
23
|
+
exports.DIRECTIONS = ["east", "south", "west", "north"];
|
|
24
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAWU,QAAA,eAAe,GAAyB;IACnD,eAAe,EAAE,IAAI;IACrB,eAAe,EAAE,IAAI;CACtB,CAAC;AA0EW,QAAA,cAAc,GAAqC;IAC9D,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;IACrF,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,2BAA2B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;IAC7F,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;IAC3F,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;CAC3F,CAAC;AAEW,QAAA,UAAU,GAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "iaip-mcp-pde",
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "Prompt Decomposition Engine as MCP Server - LLM-driven decomposition into structured JSON with Four Directions mapping, ambiguity detection, and .pde/ storage",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-pde": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest",
|
|
16
|
+
"lint": "eslint src --ext .ts",
|
|
17
|
+
"clean": "rm -rf dist"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"mcp",
|
|
21
|
+
"prompt-decomposition",
|
|
22
|
+
"llm",
|
|
23
|
+
"ai-agents",
|
|
24
|
+
"indigenous-ai",
|
|
25
|
+
"medicine-wheel",
|
|
26
|
+
"ceremonial-technology"
|
|
27
|
+
],
|
|
28
|
+
"author": "Guillaume Descoteaux-Isabelle <jgi@jgwill.com>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/jgwill/mcp-pde.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/jgwill/mcp-pde/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/jgwill/mcp-pde#readme",
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@anthropic-ai/sdk": "^0.80.0",
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
44
|
+
"minimist": "^1.2.8",
|
|
45
|
+
"uuid": "^9.0.0",
|
|
46
|
+
"zod": "^3.22.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/minimist": "^1.2.5",
|
|
50
|
+
"@types/node": "^20.10.0",
|
|
51
|
+
"@types/uuid": "^9.0.0",
|
|
52
|
+
"typescript": "^5.3.0",
|
|
53
|
+
"vitest": "^1.0.0"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18.0.0"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist",
|
|
60
|
+
"rispecs",
|
|
61
|
+
"scenarios"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# PDE-MCP Data Models Specification
|
|
2
|
+
> TypeScript Interface Definitions for Prompt Decomposition Engine v2
|
|
3
|
+
|
|
4
|
+
**Version**: 2.0.0
|
|
5
|
+
**Document ID**: pde-mcp-data-models-v2
|
|
6
|
+
|
|
7
|
+
## Creative Intent
|
|
8
|
+
|
|
9
|
+
### Desired Outcome
|
|
10
|
+
Developers **create** type-safe implementations using the canonical IAIP/lib/pde types — a zero-dependency, reusable schema shared across MCP server, CLI, and web UI contexts.
|
|
11
|
+
|
|
12
|
+
### Lineage
|
|
13
|
+
All types flow from `IAIP/lib/pde/types.ts`. This file is a direct port.
|
|
14
|
+
|
|
15
|
+
## Core DecompositionResult Schema
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
/**
|
|
19
|
+
* Root output of a PDE decomposition.
|
|
20
|
+
* Produced by the LLM when given the buildSystemPrompt() instructions.
|
|
21
|
+
*/
|
|
22
|
+
export interface DecompositionResult {
|
|
23
|
+
primary: PrimaryIntent;
|
|
24
|
+
secondary: SecondaryIntent[];
|
|
25
|
+
context: ContextRequirements;
|
|
26
|
+
outputs: ExpectedOutputs;
|
|
27
|
+
directions: DirectionMap;
|
|
28
|
+
actionStack: ActionItem[];
|
|
29
|
+
ambiguities: AmbiguityFlag[];
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Primary Intent
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
export interface PrimaryIntent {
|
|
37
|
+
action: string; // The main verb/operation
|
|
38
|
+
target: string; // What is being acted upon
|
|
39
|
+
urgency: Urgency; // "immediate" | "session" | "persistent"
|
|
40
|
+
confidence: number; // 0.0 - 1.0
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type Urgency = "immediate" | "session" | "persistent";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Secondary Intents
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
export interface SecondaryIntent {
|
|
50
|
+
action: string;
|
|
51
|
+
target: string;
|
|
52
|
+
implicit: boolean; // true = inferred from hedging language
|
|
53
|
+
dependency: string | null; // what this intent depends on, or null
|
|
54
|
+
confidence: number; // 0.0 - 1.0
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Context Requirements
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
export interface ContextRequirements {
|
|
62
|
+
files_needed: string[]; // Files the agent should read before acting
|
|
63
|
+
tools_required: string[]; // MCP tools or CLI tools needed
|
|
64
|
+
assumptions: string[]; // Statements in the prompt assumed true but unverified
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Expected Outputs
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
export interface ExpectedOutputs {
|
|
72
|
+
artifacts: string[]; // New files to create
|
|
73
|
+
updates: string[]; // Existing files to update
|
|
74
|
+
communications: string[]; // PRs, issues, docs, notifications
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Direction Map (Four Directions)
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
export type Direction = "east" | "south" | "west" | "north";
|
|
82
|
+
|
|
83
|
+
export interface DirectionItem {
|
|
84
|
+
text: string;
|
|
85
|
+
confidence: number; // 0.0 - 1.0
|
|
86
|
+
implicit: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type DirectionMap = Record<Direction, DirectionItem[]>;
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Direction semantics:
|
|
93
|
+
- **east** 🌅 VISION — What is being asked?
|
|
94
|
+
- **south** 🔥 ANALYSIS — What needs to be learned?
|
|
95
|
+
- **west** 🌊 VALIDATION — What needs reflection?
|
|
96
|
+
- **north** ❄️ ACTION — What executes the cycle?
|
|
97
|
+
|
|
98
|
+
### Action Stack
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
export interface ActionItem {
|
|
102
|
+
text: string;
|
|
103
|
+
direction: Direction; // "east" | "south" | "west" | "north"
|
|
104
|
+
dependency: string | null; // Task this depends on, or null
|
|
105
|
+
completed?: boolean; // Defaults to false
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The actionStack is an ordered list of tasks respecting dependencies, each mapped to a direction.
|
|
110
|
+
|
|
111
|
+
### Ambiguity Flags
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
export interface AmbiguityFlag {
|
|
115
|
+
text: string; // The vague/ambiguous phrase or aspect
|
|
116
|
+
suggestion: string; // How to clarify it
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Direction Metadata
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
export interface DirectionMeta {
|
|
124
|
+
name: string; // "VISION" | "ANALYSIS" | "VALIDATION" | "ACTION"
|
|
125
|
+
desc: string; // Short description of what the direction handles
|
|
126
|
+
emoji: string; // "🌅" | "🔥" | "🌊" | "❄️"
|
|
127
|
+
color: string; // Hex color for visualization
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const DIRECTION_META: Record<Direction, DirectionMeta> = {
|
|
131
|
+
east: { name: "VISION", desc: "What is being asked?", emoji: "🌅", color: "#f59e0b" },
|
|
132
|
+
south: { name: "ANALYSIS", desc: "What needs to be learned?", emoji: "🔥", color: "#ef4444" },
|
|
133
|
+
west: { name: "VALIDATION", desc: "What needs reflection?", emoji: "🌊", color: "#3b82f6" },
|
|
134
|
+
north: { name: "ACTION", desc: "What executes the cycle?", emoji: "❄️", color: "#10b981" },
|
|
135
|
+
};
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Storage Types
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
/**
|
|
142
|
+
* Persisted to .pde/<uuid>.json
|
|
143
|
+
*/
|
|
144
|
+
export interface StoredDecomposition {
|
|
145
|
+
id: string; // UUID
|
|
146
|
+
timestamp: string; // ISO 8601
|
|
147
|
+
prompt: string; // Original prompt text
|
|
148
|
+
result: DecompositionResult;
|
|
149
|
+
options: DecompositionOptions;
|
|
150
|
+
markdownPath?: string; // Path to .pde/<id>.md, set after export
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## MCP Tool Input Types
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
export interface DecompositionOptions {
|
|
158
|
+
extractImplicit: boolean; // Extract implicit intents (default: true)
|
|
159
|
+
mapDependencies: boolean; // Map dependencies between actions (default: true)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface DecomposeInput {
|
|
163
|
+
prompt: string;
|
|
164
|
+
options?: Partial<DecompositionOptions>;
|
|
165
|
+
workdir?: string; // Working directory for .pde/ storage
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface GetDecompositionInput {
|
|
169
|
+
id: string;
|
|
170
|
+
workdir?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface ListDecompositionsInput {
|
|
174
|
+
workdir?: string;
|
|
175
|
+
limit?: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface ExportMarkdownInput {
|
|
179
|
+
id: string;
|
|
180
|
+
workdir?: string;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# PDE-MCP Overview Specification
|
|
2
|
+
> Prompt Decomposition Engine as Model Context Protocol Server
|
|
3
|
+
|
|
4
|
+
**Version**: 2.0.0
|
|
5
|
+
**Document ID**: pde-mcp-overview-v2
|
|
6
|
+
**Last Updated**: 2026-02-22
|
|
7
|
+
**Attribution**: Indigenous-AI Collaborative Platform
|
|
8
|
+
|
|
9
|
+
## Creative Intent
|
|
10
|
+
|
|
11
|
+
### Desired Outcome
|
|
12
|
+
LLM terminal agents (claude-code, gemini-cli, copilot-cli) **create** well-decomposed, ceremonially-aligned decompositions from complex user prompts — stored as git-diffable markdown in `.pde/` — enabling transparent, human-in-the-loop review of multi-intent workflows.
|
|
13
|
+
|
|
14
|
+
### Current Reality
|
|
15
|
+
Terminal agents receive complex prompts with:
|
|
16
|
+
- Multiple implicit intentions
|
|
17
|
+
- Nested requirements and action sequences
|
|
18
|
+
- Context requiring cross-referencing
|
|
19
|
+
- Ambiguities that need surfacing before execution
|
|
20
|
+
|
|
21
|
+
Without decomposition, agents miss secondary intentions, lose context, and fail to track multi-step progress.
|
|
22
|
+
|
|
23
|
+
### Structural Tension
|
|
24
|
+
The natural resolution moves agents from "blind execution" to "conscious ceremony" where each task is:
|
|
25
|
+
1. **Understood** (East 🌅 — Vision: what is being asked?)
|
|
26
|
+
2. **Analyzed** (South 🔥 — Analysis: what needs to be learned?)
|
|
27
|
+
3. **Validated** (West 🌊 — Validation: what needs reflection?)
|
|
28
|
+
4. **Executed** (North ❄️ — Action: what executes the cycle?)
|
|
29
|
+
|
|
30
|
+
## System Architecture
|
|
31
|
+
|
|
32
|
+
### LLM-Driven Two-Step Pipeline (v2)
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Step 1: Build Prompt
|
|
36
|
+
pde_decompose(prompt) → { systemPrompt, userMessage }
|
|
37
|
+
↓ agent sends to their own LLM
|
|
38
|
+
LLM → DecompositionResult JSON
|
|
39
|
+
|
|
40
|
+
Step 2: Parse & Store
|
|
41
|
+
pde_parse_response(llm_response, original_prompt)
|
|
42
|
+
→ StoredDecomposition saved to .pde/<uuid>.json
|
|
43
|
+
→ Markdown export to .pde/<uuid>.md (git-diffable)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The engine does **not** embed an LLM. The calling agent (Copilot CLI, Gemini CLI, mia-code) feeds the system prompt to their own LLM provider.
|
|
47
|
+
|
|
48
|
+
### MCP Integration Points
|
|
49
|
+
|
|
50
|
+
The PDE exposes capabilities through three MCP primitives:
|
|
51
|
+
|
|
52
|
+
1. **Tools** — Active operations: `pde_decompose`, `pde_parse_response`, `pde_get`, `pde_list`, `pde_export_markdown`
|
|
53
|
+
2. **Resources** — Static content: `pde://schema/decomposition-result`, `pde://directions`
|
|
54
|
+
3. **Prompts** — Single reusable prompt: `pde-decompose`
|
|
55
|
+
|
|
56
|
+
### Storage Layout
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
.pde/
|
|
60
|
+
<uuid>.json — StoredDecomposition (full structured JSON)
|
|
61
|
+
<uuid>.md — Markdown export (human-editable, git-diffable)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Core Concepts
|
|
65
|
+
|
|
66
|
+
### DecompositionResult Schema
|
|
67
|
+
Canonical output structure (from IAIP/lib/pde lineage):
|
|
68
|
+
- **primary**: Single most important action (action, target, urgency, confidence)
|
|
69
|
+
- **secondary**: All other intents, explicit and implicit
|
|
70
|
+
- **context**: Files needed, tools required, assumptions
|
|
71
|
+
- **outputs**: Artifacts, updates, communications expected
|
|
72
|
+
- **directions**: Items mapped to east/south/west/north
|
|
73
|
+
- **actionStack**: Ordered task list with direction and dependency
|
|
74
|
+
- **ambiguities**: Vague aspects with clarification suggestions
|
|
75
|
+
|
|
76
|
+
### Direction Mapping (Four Directions)
|
|
77
|
+
- **east** 🌅 VISION: Understanding what is being asked, clarifying requirements
|
|
78
|
+
- **south** 🔥 ANALYSIS: Research, learning, investigation, growth tasks
|
|
79
|
+
- **west** 🌊 VALIDATION: Testing, reflection, review, accountability tasks
|
|
80
|
+
- **north** ❄️ ACTION: Implementation, execution, delivery, wisdom tasks
|
|
81
|
+
|
|
82
|
+
### Lineage
|
|
83
|
+
- Canonical types: `IAIP/lib/pde/types.ts`
|
|
84
|
+
- System prompts: `IAIP/lib/pde/prompts.ts`
|
|
85
|
+
- Parser: `IAIP/lib/pde/parser.ts`
|
|
86
|
+
- Web UI reference: `IAIP/app/prompt-decomposer/page.tsx`
|
|
87
|
+
|
|
88
|
+
## Advancing Patterns
|
|
89
|
+
|
|
90
|
+
### What Users Create
|
|
91
|
+
1. **Structured decompositions** — Complex prompts fully understood before execution
|
|
92
|
+
2. **Git-diffable plans** — Markdown exports enable human review and editing
|
|
93
|
+
3. **Surfaced ambiguities** — Vague intent flagged for clarification
|
|
94
|
+
4. **Ceremonially-aligned tasks** — Four Directions organizing principle
|
|
95
|
+
|
|
96
|
+
### Natural Progression
|
|
97
|
+
1. Agent calls `pde_decompose` with user prompt → receives system prompt + user message
|
|
98
|
+
2. Agent sends messages to their LLM → receives DecompositionResult JSON
|
|
99
|
+
3. Agent calls `pde_parse_response` → stored in `.pde/<uuid>.json` + `.pde/<uuid>.md`
|
|
100
|
+
4. User reviews markdown, edits if needed; `git diff` shows changes
|
|
101
|
+
5. Ambiguities become discussion threads for future clarification
|
|
102
|
+
|
|
103
|
+
## Integration with Terminal Agents
|
|
104
|
+
|
|
105
|
+
### Workflow Pattern
|
|
106
|
+
```
|
|
107
|
+
# Step 1: Get decomposition prompt
|
|
108
|
+
pde_decompose({ prompt: "Create user auth with JWT, PostgreSQL, tests" })
|
|
109
|
+
→ { systemPrompt, userMessage }
|
|
110
|
+
|
|
111
|
+
# Step 2: Agent sends to LLM, gets JSON back
|
|
112
|
+
# Step 3: Store result
|
|
113
|
+
pde_parse_response({ llm_response: "<json>", original_prompt: "..." })
|
|
114
|
+
→ StoredDecomposition { id, timestamp, result, markdownPath }
|
|
115
|
+
|
|
116
|
+
# Step 4: Retrieve or export
|
|
117
|
+
pde_get({ id: "<uuid>" })
|
|
118
|
+
pde_export_markdown({ id: "<uuid>" })
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Expected Markdown Output (`.pde/<uuid>.md`)
|
|
122
|
+
```markdown
|
|
123
|
+
# Prompt Decomposition
|
|
124
|
+
|
|
125
|
+
## Directions
|
|
126
|
+
- 🌅 **EAST** — VISION: What is being asked?
|
|
127
|
+
- 🔥 **SOUTH** — ANALYSIS: What needs to be learned?
|
|
128
|
+
- 🌊 **WEST** — VALIDATION: What needs reflection?
|
|
129
|
+
- ❄️ **NORTH** — ACTION: What executes the cycle?
|
|
130
|
+
|
|
131
|
+
## Primary Intent
|
|
132
|
+
**Action:** create **Target:** user auth system **Urgency:** immediate
|
|
133
|
+
|
|
134
|
+
## Action Stack
|
|
135
|
+
- [ ] 🌅 Clarify JWT token lifespan (no deps)
|
|
136
|
+
- [ ] 🔥 Design PostgreSQL schema
|
|
137
|
+
- [ ] 🔥 Implement JWT auth service (depends on schema)
|
|
138
|
+
- [ ] 🌊 Write and run test suite
|
|
139
|
+
- [ ] ❄️ Deploy to staging
|
|
140
|
+
|
|
141
|
+
## Ambiguity Flags
|
|
142
|
+
- **"PostgreSQL"** — Suggestion: Confirm DB host / connection string
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Quality Criteria
|
|
146
|
+
|
|
147
|
+
### RISE Alignment
|
|
148
|
+
- ✅ **Creating Focus**: Agents create structured decompositions, not solve decomposition problems
|
|
149
|
+
- ✅ **Structural Dynamics**: Natural flow from vision to action via Four Directions
|
|
150
|
+
- ✅ **Advancing Patterns**: Each stored decomposition builds toward informed execution
|
|
151
|
+
- ✅ **Desired Outcomes**: Actionable action stack + surfaced ambiguities at each call
|
|
152
|
+
|
|
153
|
+
### Anti-Patterns Avoided
|
|
154
|
+
- ❌ Embedding LLM — engine builds prompts only; callers supply their own LLM
|
|
155
|
+
- ❌ Opacity — all decompositions persisted as human-readable markdown
|
|
156
|
+
- ❌ Single-shot execution — two-step workflow enables review before acting
|
|
157
|
+
- ❌ Lost ambiguities — explicit `ambiguities[]` array surfaces vague intent
|