@pcoliveira90/pdd 0.2.1-beta.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.
@@ -0,0 +1,174 @@
1
+ export const PDD_TEMPLATE_VERSION = '0.2.0';
2
+
3
+ export const CORE_TEMPLATES = {
4
+ '.pdd/constitution.md': `# PDD Constitution
5
+
6
+ ## 1. Change First
7
+ Every task is a change in an existing system.
8
+
9
+ ## 2. Evidence Before Edit
10
+ Never change code without understanding current behavior.
11
+
12
+ ## 3. Minimal Safe Delta
13
+ Prefer the smallest safe change.
14
+
15
+ ## 4. Root Cause
16
+ Fix the cause, not the symptom.
17
+
18
+ ## 5. Regression Awareness
19
+ Always consider what can break.
20
+
21
+ ## 6. Reuse Patterns
22
+ Prefer existing patterns over new ones.
23
+
24
+ ## 7. Verifiable Outcome
25
+ Every change must be validated.
26
+ `,
27
+ '.pdd/templates/delta-spec.md': `# Delta Spec
28
+
29
+ ## Change ID
30
+
31
+ ## Type
32
+ bugfix | feature | refactor-safe | hotfix
33
+
34
+ ## Context
35
+
36
+ ## Current Behavior
37
+
38
+ ## Expected Behavior
39
+
40
+ ## Evidence
41
+
42
+ ## Root Cause Hypothesis
43
+
44
+ ## Impacted Areas
45
+
46
+ ## Constraints
47
+
48
+ ## Minimal Safe Delta
49
+
50
+ ## Alternatives Considered
51
+
52
+ ## Acceptance Criteria
53
+
54
+ ## Verification Strategy
55
+ `,
56
+ '.pdd/templates/patch-plan.md': `# Patch Plan
57
+
58
+ ## Files to Inspect
59
+
60
+ ## Files to Change
61
+
62
+ ## Execution Steps
63
+ 1. Reproduce issue
64
+ 2. Confirm root cause
65
+ 3. Apply change
66
+ 4. Adjust tests
67
+ 5. Run validations
68
+
69
+ ## Regression Risks
70
+
71
+ ## Rollback Strategy
72
+ `,
73
+ '.pdd/templates/verification-report.md': `# Verification Report
74
+
75
+ ## Reproduction
76
+
77
+ ## Changes Made
78
+
79
+ ## Tests Run
80
+
81
+ ## Manual Validation
82
+
83
+ ## Residual Risks
84
+
85
+ ## Final Status
86
+ approved | needs-review | partial
87
+ `,
88
+ '.pdd/commands/pdd-recon.md': `# pdd.recon
89
+
90
+ ## Purpose
91
+ Understand the current system before making changes.
92
+
93
+ ## Output
94
+ - flow mapping
95
+ - impacted files
96
+ - risks
97
+ - unknowns
98
+ `,
99
+ '.pdd/commands/pdd-fix.md': `# pdd.fix
100
+
101
+ ## Purpose
102
+ Fix bugs with minimal safe delta.
103
+
104
+ ## Steps
105
+ 1. reproduce issue
106
+ 2. confirm root cause
107
+ 3. apply minimal fix
108
+ 4. validate
109
+ `,
110
+ '.pdd/commands/pdd-feature.md': `# pdd.feature
111
+
112
+ ## Purpose
113
+ Add features safely in existing systems.
114
+
115
+ ## Steps
116
+ 1. understand current behavior
117
+ 2. define minimal extension
118
+ 3. ensure compatibility
119
+ 4. validate
120
+ `,
121
+ '.pdd/commands/pdd-verify.md': `# pdd.verify
122
+
123
+ ## Purpose
124
+ Validate changes and ensure safety.
125
+
126
+ ## Checklist
127
+ - tests pass
128
+ - no regression detected
129
+ - expected behavior confirmed
130
+ `,
131
+ '.pdd/memory/system-map.md': `# System Map
132
+
133
+ ## Purpose
134
+ Map the structure of the system.
135
+
136
+ ## Modules
137
+ -
138
+
139
+ ## Entry Points
140
+ -
141
+
142
+ ## Dependencies
143
+ -
144
+
145
+ ## Hotspots
146
+ -
147
+ `,
148
+ '.pdd/version.json': JSON.stringify({ templateVersion: '0.2.0' }, null, 2) + '\n'
149
+ };
150
+
151
+ export const IDE_ADAPTERS = {
152
+ claude: {
153
+ '.claude/commands/pdd.md': `# /pdd
154
+
155
+ ## Goal
156
+ Execute Patch-Driven Development workflow.
157
+
158
+ ## Usage
159
+ /pdd fix <issue>
160
+ `
161
+ },
162
+ cursor: {
163
+ '.cursor/pdd.prompt.md': `# PDD Cursor Prompt
164
+
165
+ Goal: execute PDD workflow for a given issue.
166
+ `
167
+ },
168
+ copilot: {
169
+ '.github/copilot/pdd.prompt.md': `# PDD Copilot Prompt
170
+
171
+ You are executing a Patch-Driven Development workflow.
172
+ `
173
+ }
174
+ };
@@ -0,0 +1,68 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ function ensureDir(filePath) {
5
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
6
+ }
7
+
8
+ function readFileOrNull(filePath) {
9
+ if (!fs.existsSync(filePath)) return null;
10
+ return fs.readFileSync(filePath, 'utf-8');
11
+ }
12
+
13
+ function writeFile(baseDir, relativePath, content) {
14
+ const fullPath = path.join(baseDir, relativePath);
15
+ ensureDir(fullPath);
16
+ fs.writeFileSync(fullPath, content, 'utf-8');
17
+ }
18
+
19
+ export function buildTemplateUpgradePlan(baseDir, templates) {
20
+ const plan = {
21
+ created: [],
22
+ conflicts: [],
23
+ skipped: []
24
+ };
25
+
26
+ for (const [relativePath, templateContent] of Object.entries(templates)) {
27
+ const fullPath = path.join(baseDir, relativePath);
28
+ const currentContent = readFileOrNull(fullPath);
29
+
30
+ if (currentContent === null) {
31
+ plan.created.push(relativePath);
32
+ continue;
33
+ }
34
+
35
+ if (currentContent === templateContent) {
36
+ plan.skipped.push(relativePath);
37
+ continue;
38
+ }
39
+
40
+ plan.conflicts.push(relativePath);
41
+ }
42
+
43
+ return plan;
44
+ }
45
+
46
+ export function applyTemplateUpgradePlan(baseDir, templates, plan, force = false) {
47
+ const summary = {
48
+ created: [],
49
+ updated: [],
50
+ conflicts: [...plan.conflicts],
51
+ skipped: [...plan.skipped]
52
+ };
53
+
54
+ for (const relativePath of plan.created) {
55
+ writeFile(baseDir, relativePath, templates[relativePath]);
56
+ summary.created.push(relativePath);
57
+ }
58
+
59
+ if (force) {
60
+ for (const relativePath of plan.conflicts) {
61
+ writeFile(baseDir, relativePath, templates[relativePath]);
62
+ summary.updated.push(relativePath);
63
+ }
64
+ summary.conflicts = [];
65
+ }
66
+
67
+ return summary;
68
+ }
@@ -0,0 +1,38 @@
1
+ import fs from 'fs';
2
+ import { execSync } from 'child_process';
3
+
4
+ function runCommand(command) {
5
+ console.log(`→ ${command}`);
6
+ execSync(command, { stdio: 'inherit' });
7
+ }
8
+
9
+ export function runValidation(baseDir = process.cwd()) {
10
+ console.log('Running validation...');
11
+
12
+ const packageJsonPath = `${baseDir}/package.json`;
13
+ if (!fs.existsSync(packageJsonPath)) {
14
+ console.log('No package.json found. Skipping validation.');
15
+ return;
16
+ }
17
+
18
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
19
+ const scripts = pkg.scripts || {};
20
+ const commands = [];
21
+
22
+ if (scripts.test) commands.push('npm test');
23
+ if (scripts.lint) commands.push('npm run lint');
24
+ if (scripts.build) commands.push('npm run build');
25
+
26
+ if (commands.length === 0) {
27
+ console.log('No validation scripts found. Skipping validation.');
28
+ return;
29
+ }
30
+
31
+ try {
32
+ commands.forEach(runCommand);
33
+ } catch {
34
+ throw new Error('Validation failed');
35
+ }
36
+
37
+ console.log('Validation passed');
38
+ }