@pcoliveira90/pdd 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.en.md +60 -60
- package/README.md +27 -26
- package/README.pt-BR.md +12 -12
- package/bin/pdd-ai.js +23 -23
- package/bin/pdd-pro.js +7 -7
- package/bin/pdd.js +27 -27
- package/package.json +43 -42
- package/src/ai/analyze-change.js +41 -41
- package/src/ai/engine.js +34 -34
- package/src/ai/run-fix-analysis.js +174 -174
- package/src/cli/doctor-command.js +123 -101
- package/src/cli/doctor-fix.js +51 -51
- package/src/cli/index.js +164 -130
- package/src/cli/init-command.js +270 -270
- package/src/cli/status-command.js +33 -33
- package/src/core/fix-runner.js +135 -135
- package/src/core/ide-detector.js +94 -94
- package/src/core/patch-generator.js +126 -126
- package/src/core/pr-manager.js +21 -21
- package/src/core/project-review-agent.js +301 -301
- package/src/core/remediation-advisor.js +91 -91
- package/src/core/state-manager.js +71 -71
- package/src/core/template-registry.js +446 -320
- package/src/core/template-upgrade.js +68 -68
- package/src/core/validator.js +38 -38
- package/src/core/worktree-guard.js +54 -0
|
@@ -1,126 +1,126 @@
|
|
|
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 writeFile(filePath, content) {
|
|
9
|
-
ensureDir(filePath);
|
|
10
|
-
fs.writeFileSync(filePath, content, 'utf-8');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function slugify(value) {
|
|
14
|
-
return value
|
|
15
|
-
.toLowerCase()
|
|
16
|
-
.replace(/[^a-z0-9]+/g, '-')
|
|
17
|
-
.replace(/^-+|-+$/g, '')
|
|
18
|
-
.slice(0, 48);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function generatePatchArtifacts({ issue, baseDir = process.cwd() }) {
|
|
22
|
-
const timestamp = Date.now();
|
|
23
|
-
const changeId = `change-${timestamp}-${slugify(issue || 'update')}`;
|
|
24
|
-
const changeDir = path.join(baseDir, 'changes', changeId);
|
|
25
|
-
|
|
26
|
-
const files = [
|
|
27
|
-
path.join('changes', changeId, 'delta-spec.md'),
|
|
28
|
-
path.join('changes', changeId, 'patch-plan.md'),
|
|
29
|
-
path.join('changes', changeId, 'verification-report.md')
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
writeFile(
|
|
33
|
-
path.join(changeDir, 'delta-spec.md'),
|
|
34
|
-
`# Delta Spec
|
|
35
|
-
|
|
36
|
-
## Change ID
|
|
37
|
-
${changeId}
|
|
38
|
-
|
|
39
|
-
## Issue
|
|
40
|
-
${issue}
|
|
41
|
-
|
|
42
|
-
## Type
|
|
43
|
-
bugfix | feature | refactor-safe | hotfix
|
|
44
|
-
|
|
45
|
-
## Context
|
|
46
|
-
|
|
47
|
-
## Current Behavior
|
|
48
|
-
|
|
49
|
-
## Expected Behavior
|
|
50
|
-
|
|
51
|
-
## Evidence
|
|
52
|
-
|
|
53
|
-
## Root Cause Hypothesis
|
|
54
|
-
|
|
55
|
-
## Impacted Areas
|
|
56
|
-
|
|
57
|
-
## Constraints
|
|
58
|
-
|
|
59
|
-
## Minimal Safe Delta
|
|
60
|
-
|
|
61
|
-
## Alternatives Considered
|
|
62
|
-
|
|
63
|
-
## Acceptance Criteria
|
|
64
|
-
|
|
65
|
-
## Verification Strategy
|
|
66
|
-
`
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
writeFile(
|
|
70
|
-
path.join(changeDir, 'patch-plan.md'),
|
|
71
|
-
`# Patch Plan
|
|
72
|
-
|
|
73
|
-
## Change ID
|
|
74
|
-
${changeId}
|
|
75
|
-
|
|
76
|
-
## Issue
|
|
77
|
-
${issue}
|
|
78
|
-
|
|
79
|
-
## Files to Inspect
|
|
80
|
-
|
|
81
|
-
## Files to Change
|
|
82
|
-
|
|
83
|
-
## Execution Steps
|
|
84
|
-
1. Reproduce issue
|
|
85
|
-
2. Confirm root cause
|
|
86
|
-
3. Apply minimal change
|
|
87
|
-
4. Adjust tests
|
|
88
|
-
5. Run validations
|
|
89
|
-
|
|
90
|
-
## Regression Risks
|
|
91
|
-
|
|
92
|
-
## Rollback Strategy
|
|
93
|
-
`
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
writeFile(
|
|
97
|
-
path.join(changeDir, 'verification-report.md'),
|
|
98
|
-
`# Verification Report
|
|
99
|
-
|
|
100
|
-
## Change ID
|
|
101
|
-
${changeId}
|
|
102
|
-
|
|
103
|
-
## Issue
|
|
104
|
-
${issue}
|
|
105
|
-
|
|
106
|
-
## Reproduction
|
|
107
|
-
|
|
108
|
-
## Changes Made
|
|
109
|
-
|
|
110
|
-
## Tests Run
|
|
111
|
-
|
|
112
|
-
## Manual Validation
|
|
113
|
-
|
|
114
|
-
## Residual Risks
|
|
115
|
-
|
|
116
|
-
## Final Status
|
|
117
|
-
pending
|
|
118
|
-
`
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
changeId,
|
|
123
|
-
changeDir,
|
|
124
|
-
files
|
|
125
|
-
};
|
|
126
|
-
}
|
|
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 writeFile(filePath, content) {
|
|
9
|
+
ensureDir(filePath);
|
|
10
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function slugify(value) {
|
|
14
|
+
return value
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
17
|
+
.replace(/^-+|-+$/g, '')
|
|
18
|
+
.slice(0, 48);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function generatePatchArtifacts({ issue, baseDir = process.cwd() }) {
|
|
22
|
+
const timestamp = Date.now();
|
|
23
|
+
const changeId = `change-${timestamp}-${slugify(issue || 'update')}`;
|
|
24
|
+
const changeDir = path.join(baseDir, 'changes', changeId);
|
|
25
|
+
|
|
26
|
+
const files = [
|
|
27
|
+
path.join('changes', changeId, 'delta-spec.md'),
|
|
28
|
+
path.join('changes', changeId, 'patch-plan.md'),
|
|
29
|
+
path.join('changes', changeId, 'verification-report.md')
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
writeFile(
|
|
33
|
+
path.join(changeDir, 'delta-spec.md'),
|
|
34
|
+
`# Delta Spec
|
|
35
|
+
|
|
36
|
+
## Change ID
|
|
37
|
+
${changeId}
|
|
38
|
+
|
|
39
|
+
## Issue
|
|
40
|
+
${issue}
|
|
41
|
+
|
|
42
|
+
## Type
|
|
43
|
+
bugfix | feature | refactor-safe | hotfix
|
|
44
|
+
|
|
45
|
+
## Context
|
|
46
|
+
|
|
47
|
+
## Current Behavior
|
|
48
|
+
|
|
49
|
+
## Expected Behavior
|
|
50
|
+
|
|
51
|
+
## Evidence
|
|
52
|
+
|
|
53
|
+
## Root Cause Hypothesis
|
|
54
|
+
|
|
55
|
+
## Impacted Areas
|
|
56
|
+
|
|
57
|
+
## Constraints
|
|
58
|
+
|
|
59
|
+
## Minimal Safe Delta
|
|
60
|
+
|
|
61
|
+
## Alternatives Considered
|
|
62
|
+
|
|
63
|
+
## Acceptance Criteria
|
|
64
|
+
|
|
65
|
+
## Verification Strategy
|
|
66
|
+
`
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
writeFile(
|
|
70
|
+
path.join(changeDir, 'patch-plan.md'),
|
|
71
|
+
`# Patch Plan
|
|
72
|
+
|
|
73
|
+
## Change ID
|
|
74
|
+
${changeId}
|
|
75
|
+
|
|
76
|
+
## Issue
|
|
77
|
+
${issue}
|
|
78
|
+
|
|
79
|
+
## Files to Inspect
|
|
80
|
+
|
|
81
|
+
## Files to Change
|
|
82
|
+
|
|
83
|
+
## Execution Steps
|
|
84
|
+
1. Reproduce issue
|
|
85
|
+
2. Confirm root cause
|
|
86
|
+
3. Apply minimal change
|
|
87
|
+
4. Adjust tests
|
|
88
|
+
5. Run validations
|
|
89
|
+
|
|
90
|
+
## Regression Risks
|
|
91
|
+
|
|
92
|
+
## Rollback Strategy
|
|
93
|
+
`
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
writeFile(
|
|
97
|
+
path.join(changeDir, 'verification-report.md'),
|
|
98
|
+
`# Verification Report
|
|
99
|
+
|
|
100
|
+
## Change ID
|
|
101
|
+
${changeId}
|
|
102
|
+
|
|
103
|
+
## Issue
|
|
104
|
+
${issue}
|
|
105
|
+
|
|
106
|
+
## Reproduction
|
|
107
|
+
|
|
108
|
+
## Changes Made
|
|
109
|
+
|
|
110
|
+
## Tests Run
|
|
111
|
+
|
|
112
|
+
## Manual Validation
|
|
113
|
+
|
|
114
|
+
## Residual Risks
|
|
115
|
+
|
|
116
|
+
## Final Status
|
|
117
|
+
pending
|
|
118
|
+
`
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
changeId,
|
|
123
|
+
changeDir,
|
|
124
|
+
files
|
|
125
|
+
};
|
|
126
|
+
}
|
package/src/core/pr-manager.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
|
|
5
|
-
function exec(command) {
|
|
6
|
-
execSync(command, { stdio: 'inherit' });
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export async function openPullRequest({ issue, changeId, changeDir }) {
|
|
10
|
-
const branch = `pdd/${changeId}`;
|
|
11
|
-
const title = `fix: ${issue}`;
|
|
12
|
-
|
|
13
|
-
fs.writeFileSync(path.join(changeDir, 'pr-title.txt'), title);
|
|
14
|
-
fs.writeFileSync(path.join(changeDir, 'pr-body.md'), issue);
|
|
15
|
-
|
|
16
|
-
exec(`git checkout -b ${branch}`);
|
|
17
|
-
exec('git add .');
|
|
18
|
-
exec(`git commit -m "${title}"`);
|
|
19
|
-
|
|
20
|
-
console.log('PR ready (use IDE to open)');
|
|
21
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
|
|
5
|
+
function exec(command) {
|
|
6
|
+
execSync(command, { stdio: 'inherit' });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function openPullRequest({ issue, changeId, changeDir }) {
|
|
10
|
+
const branch = `pdd/${changeId}`;
|
|
11
|
+
const title = `fix: ${issue}`;
|
|
12
|
+
|
|
13
|
+
fs.writeFileSync(path.join(changeDir, 'pr-title.txt'), title);
|
|
14
|
+
fs.writeFileSync(path.join(changeDir, 'pr-body.md'), issue);
|
|
15
|
+
|
|
16
|
+
exec(`git checkout -b ${branch}`);
|
|
17
|
+
exec('git add .');
|
|
18
|
+
exec(`git commit -m "${title}"`);
|
|
19
|
+
|
|
20
|
+
console.log('PR ready (use IDE to open)');
|
|
21
|
+
}
|