@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
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Paula Oliveira
|
|
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
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Paula Oliveira
|
|
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
21
|
SOFTWARE.
|
package/README.en.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# PDD — Patch-Driven Development
|
|
2
|
-

|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
> Ship safe changes in living systems.
|
|
7
|
-
|
|
8
|
-
PDD is an open-source framework focused on **bugfixes and incremental feature development in existing systems**.
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## The Problem
|
|
13
|
-
|
|
14
|
-
Most development is not greenfield.
|
|
15
|
-
|
|
16
|
-
It is:
|
|
17
|
-
- fixing bugs in production
|
|
18
|
-
- evolving legacy systems
|
|
19
|
-
- adding features without breaking things
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## The Solution: PDD
|
|
24
|
-
|
|
25
|
-
PDD focuses on:
|
|
26
|
-
- understanding existing systems
|
|
27
|
-
- identifying root causes
|
|
28
|
-
- applying minimal safe changes
|
|
29
|
-
- validating with evidence
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Core Flow
|
|
34
|
-
|
|
35
|
-
Issue → Recon → Delta Spec → Patch Plan → Change → Verify
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Principles
|
|
40
|
-
|
|
41
|
-
- Change-first
|
|
42
|
-
- Evidence before edit
|
|
43
|
-
- Minimal safe delta
|
|
44
|
-
- Root-cause over symptom patch
|
|
45
|
-
- Regression-aware
|
|
46
|
-
- Reuse existing patterns
|
|
47
|
-
- Verifiable outcomes
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Structure
|
|
52
|
-
|
|
53
|
-
.pdd/
|
|
54
|
-
examples/
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Vision
|
|
59
|
-
|
|
60
|
-
Make AI-assisted development safe for real-world systems.
|
|
1
|
+
# PDD — Patch-Driven Development
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
> Ship safe changes in living systems.
|
|
7
|
+
|
|
8
|
+
PDD is an open-source framework focused on **bugfixes and incremental feature development in existing systems**.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## The Problem
|
|
13
|
+
|
|
14
|
+
Most development is not greenfield.
|
|
15
|
+
|
|
16
|
+
It is:
|
|
17
|
+
- fixing bugs in production
|
|
18
|
+
- evolving legacy systems
|
|
19
|
+
- adding features without breaking things
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## The Solution: PDD
|
|
24
|
+
|
|
25
|
+
PDD focuses on:
|
|
26
|
+
- understanding existing systems
|
|
27
|
+
- identifying root causes
|
|
28
|
+
- applying minimal safe changes
|
|
29
|
+
- validating with evidence
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Core Flow
|
|
34
|
+
|
|
35
|
+
Issue → Recon → Delta Spec → Patch Plan → Change → Verify
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Principles
|
|
40
|
+
|
|
41
|
+
- Change-first
|
|
42
|
+
- Evidence before edit
|
|
43
|
+
- Minimal safe delta
|
|
44
|
+
- Root-cause over symptom patch
|
|
45
|
+
- Regression-aware
|
|
46
|
+
- Reuse existing patterns
|
|
47
|
+
- Verifiable outcomes
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Structure
|
|
52
|
+
|
|
53
|
+
.pdd/
|
|
54
|
+
examples/
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Vision
|
|
59
|
+
|
|
60
|
+
Make AI-assisted development safe for real-world systems.
|
package/README.md
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
# PDD — Patch-Driven Development
|
|
2
|
-
|
|
3
|
-
> Safe changes in real systems.
|
|
4
|
-
|
|
5
|
-
PDD is a framework focused on executing safe changes in existing systems.
|
|
6
|
-
|
|
7
|
-
## CLI
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pdd init
|
|
11
|
-
pdd fix "bug"
|
|
12
|
-
pdd fix "bug" --dry-run
|
|
13
|
-
pdd fix "bug" --no-validate
|
|
14
|
-
pdd fix "bug" --open-pr
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
# PDD — Patch-Driven Development
|
|
2
|
+
|
|
3
|
+
> Safe changes in real systems.
|
|
4
|
+
|
|
5
|
+
PDD is a framework focused on executing safe changes in existing systems.
|
|
6
|
+
|
|
7
|
+
## CLI
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pdd init
|
|
11
|
+
pdd fix "bug"
|
|
12
|
+
pdd fix "bug" --dry-run
|
|
13
|
+
pdd fix "bug" --no-validate
|
|
14
|
+
pdd fix "bug" --open-pr
|
|
15
|
+
pdd-ai --provider=openai --task=analysis "bug"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Flow
|
|
19
|
+
|
|
20
|
+
1. describe issue
|
|
21
|
+
2. generate artifacts
|
|
22
|
+
3. validate
|
|
23
|
+
4. prepare PR (IDE handles opening)
|
|
24
|
+
|
|
25
|
+
## Goal
|
|
26
|
+
|
|
27
|
+
Reliable execution engine for safe software changes.
|
package/README.pt-BR.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# PDD — Patch-Driven Development
|
|
2
|
-
|
|
3
|
-
> Entregue mudanças seguras em sistemas existentes.
|
|
4
|
-
|
|
5
|
-
PDD é um framework focado em aplicar mudanças seguras em sistemas reais.
|
|
6
|
-
|
|
7
|
-
## CLI
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pdd init
|
|
11
|
-
pdd fix "bug"
|
|
12
|
-
```
|
|
1
|
+
# PDD — Patch-Driven Development
|
|
2
|
+
|
|
3
|
+
> Entregue mudanças seguras em sistemas existentes.
|
|
4
|
+
|
|
5
|
+
PDD é um framework focado em aplicar mudanças seguras em sistemas reais.
|
|
6
|
+
|
|
7
|
+
## CLI
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pdd init
|
|
11
|
+
pdd fix "bug"
|
|
12
|
+
```
|
package/bin/pdd-ai.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { runAiFixAnalysis } from '../src/ai/run-fix-analysis.js';
|
|
4
|
-
|
|
5
|
-
async function main() {
|
|
6
|
-
try {
|
|
7
|
-
const result = await runAiFixAnalysis(process.argv.slice(2));
|
|
8
|
-
|
|
9
|
-
console.log('\n🤖 PDD AI Analysis');
|
|
10
|
-
console.log('----------------------');
|
|
11
|
-
console.log(`Provider: ${result.provider}`);
|
|
12
|
-
console.log(`Model: ${result.model}`);
|
|
13
|
-
console.log(`Issue: ${result.issue}`);
|
|
14
|
-
console.log('\nResult:\n');
|
|
15
|
-
|
|
16
|
-
console.log(JSON.stringify(result.result, null, 2));
|
|
17
|
-
} catch (err) {
|
|
18
|
-
console.error('❌ Error:', err.message);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
main();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runAiFixAnalysis } from '../src/ai/run-fix-analysis.js';
|
|
4
|
+
|
|
5
|
+
async function main() {
|
|
6
|
+
try {
|
|
7
|
+
const result = await runAiFixAnalysis(process.argv.slice(2));
|
|
8
|
+
|
|
9
|
+
console.log('\n🤖 PDD AI Analysis');
|
|
10
|
+
console.log('----------------------');
|
|
11
|
+
console.log(`Provider: ${result.provider}`);
|
|
12
|
+
console.log(`Model: ${result.model}`);
|
|
13
|
+
console.log(`Issue: ${result.issue}`);
|
|
14
|
+
console.log('\nResult:\n');
|
|
15
|
+
|
|
16
|
+
console.log(JSON.stringify(result.result, null, 2));
|
|
17
|
+
} catch (err) {
|
|
18
|
+
console.error('❌ Error:', err.message);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main();
|
package/bin/pdd-pro.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { runCli } from '../src/cli/index.js';
|
|
4
|
-
|
|
5
|
-
runCli().catch(err => {
|
|
6
|
-
console.error(err);
|
|
7
|
-
process.exitCode = 1;
|
|
8
|
-
});
|
|
2
|
+
|
|
3
|
+
import { runCli } from '../src/cli/index.js';
|
|
4
|
+
|
|
5
|
+
runCli().catch(err => {
|
|
6
|
+
console.error(err);
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
});
|
package/bin/pdd.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
const command = process.argv[2];
|
|
7
|
-
|
|
8
|
-
if (command === 'init') {
|
|
9
|
-
const targetDir = process.cwd();
|
|
10
|
-
const pddDir = path.join(targetDir, '.pdd');
|
|
11
|
-
|
|
12
|
-
if (fs.existsSync(pddDir)) {
|
|
13
|
-
console.log('PDD already initialized.');
|
|
14
|
-
process.exit(0);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
fs.mkdirSync(pddDir, { recursive: true });
|
|
18
|
-
fs.mkdirSync(path.join(pddDir, 'templates'));
|
|
19
|
-
fs.mkdirSync(path.join(pddDir, 'commands'));
|
|
20
|
-
fs.mkdirSync(path.join(pddDir, 'memory'));
|
|
21
|
-
|
|
22
|
-
fs.writeFileSync(path.join(pddDir, 'README.md'), 'PDD initialized');
|
|
23
|
-
|
|
24
|
-
console.log('✅ PDD initialized successfully.');
|
|
25
|
-
} else {
|
|
26
|
-
console.log('Usage: pdd init');
|
|
27
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
const command = process.argv[2];
|
|
7
|
+
|
|
8
|
+
if (command === 'init') {
|
|
9
|
+
const targetDir = process.cwd();
|
|
10
|
+
const pddDir = path.join(targetDir, '.pdd');
|
|
11
|
+
|
|
12
|
+
if (fs.existsSync(pddDir)) {
|
|
13
|
+
console.log('PDD already initialized.');
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fs.mkdirSync(pddDir, { recursive: true });
|
|
18
|
+
fs.mkdirSync(path.join(pddDir, 'templates'));
|
|
19
|
+
fs.mkdirSync(path.join(pddDir, 'commands'));
|
|
20
|
+
fs.mkdirSync(path.join(pddDir, 'memory'));
|
|
21
|
+
|
|
22
|
+
fs.writeFileSync(path.join(pddDir, 'README.md'), 'PDD initialized');
|
|
23
|
+
|
|
24
|
+
console.log('✅ PDD initialized successfully.');
|
|
25
|
+
} else {
|
|
26
|
+
console.log('Usage: pdd init');
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pcoliveira90/pdd",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Patch-Driven Development CLI — safe, resilient and guided code changes",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"pdd": "bin/pdd-pro.js"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@pcoliveira90/pdd",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Patch-Driven Development CLI — safe, resilient and guided code changes",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pdd": "bin/pdd-pro.js",
|
|
8
|
+
"pdd-ai": "bin/pdd-ai.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "node bin/pdd-pro.js",
|
|
16
|
+
"dev": "node bin/pdd-pro.js",
|
|
17
|
+
"test": "echo \"No tests yet\"",
|
|
18
|
+
"lint": "echo \"No lint configured\"",
|
|
19
|
+
"prepublishOnly": "npm pack"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"cli",
|
|
26
|
+
"developer-tools",
|
|
27
|
+
"patch",
|
|
28
|
+
"refactoring",
|
|
29
|
+
"ai-workflow",
|
|
30
|
+
"engineering",
|
|
31
|
+
"pdd"
|
|
32
|
+
],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/pcoliveira90/pdd.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/pcoliveira90/pdd/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/pcoliveira90/pdd#readme",
|
|
41
|
+
"author": "Paula Oliveira",
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
}
|
package/src/ai/analyze-change.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
function readIfExists(filePath) {
|
|
5
|
-
if (!fs.existsSync(filePath)) return null;
|
|
6
|
-
return fs.readFileSync(filePath, 'utf-8');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function buildAiAnalysisContext(baseDir = process.cwd()) {
|
|
10
|
-
const context = {
|
|
11
|
-
constitution: readIfExists(path.join(baseDir, '.pdd', 'constitution.md')),
|
|
12
|
-
deltaSpec: readIfExists(path.join(baseDir, '.pdd', 'templates', 'delta-spec.md')),
|
|
13
|
-
patchPlan: readIfExists(path.join(baseDir, '.pdd', 'templates', 'patch-plan.md')),
|
|
14
|
-
verification: readIfExists(path.join(baseDir, '.pdd', 'templates', 'verification-report.md'))
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return context;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function buildBugfixPrompt({ issue, baseDir = process.cwd() }) {
|
|
21
|
-
const context = buildAiAnalysisContext(baseDir);
|
|
22
|
-
|
|
23
|
-
return [
|
|
24
|
-
'You are a senior engineer working in an existing system.',
|
|
25
|
-
'Follow Patch-Driven Development principles.',
|
|
26
|
-
'Focus on root cause, minimal safe delta, and regression awareness.',
|
|
27
|
-
'',
|
|
28
|
-
'Issue:',
|
|
29
|
-
issue,
|
|
30
|
-
'',
|
|
31
|
-
'Available context:',
|
|
32
|
-
JSON.stringify(context, null, 2),
|
|
33
|
-
'',
|
|
34
|
-
'Return:',
|
|
35
|
-
'- root cause hypothesis',
|
|
36
|
-
'- impacted areas',
|
|
37
|
-
'- minimal safe delta',
|
|
38
|
-
'- regression risks',
|
|
39
|
-
'- validation plan'
|
|
40
|
-
].join('\n');
|
|
41
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
function readIfExists(filePath) {
|
|
5
|
+
if (!fs.existsSync(filePath)) return null;
|
|
6
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function buildAiAnalysisContext(baseDir = process.cwd()) {
|
|
10
|
+
const context = {
|
|
11
|
+
constitution: readIfExists(path.join(baseDir, '.pdd', 'constitution.md')),
|
|
12
|
+
deltaSpec: readIfExists(path.join(baseDir, '.pdd', 'templates', 'delta-spec.md')),
|
|
13
|
+
patchPlan: readIfExists(path.join(baseDir, '.pdd', 'templates', 'patch-plan.md')),
|
|
14
|
+
verification: readIfExists(path.join(baseDir, '.pdd', 'templates', 'verification-report.md'))
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function buildBugfixPrompt({ issue, baseDir = process.cwd() }) {
|
|
21
|
+
const context = buildAiAnalysisContext(baseDir);
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
'You are a senior engineer working in an existing system.',
|
|
25
|
+
'Follow Patch-Driven Development principles.',
|
|
26
|
+
'Focus on root cause, minimal safe delta, and regression awareness.',
|
|
27
|
+
'',
|
|
28
|
+
'Issue:',
|
|
29
|
+
issue,
|
|
30
|
+
'',
|
|
31
|
+
'Available context:',
|
|
32
|
+
JSON.stringify(context, null, 2),
|
|
33
|
+
'',
|
|
34
|
+
'Return:',
|
|
35
|
+
'- root cause hypothesis',
|
|
36
|
+
'- impacted areas',
|
|
37
|
+
'- minimal safe delta',
|
|
38
|
+
'- regression risks',
|
|
39
|
+
'- validation plan'
|
|
40
|
+
].join('\n');
|
|
41
|
+
}
|
package/src/ai/engine.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
export function getAiProviderConfig(provider = 'openai') {
|
|
2
|
-
const providers = {
|
|
3
|
-
openai: {
|
|
4
|
-
name: 'openai',
|
|
5
|
-
envKey: 'OPENAI_API_KEY',
|
|
6
|
-
baseUrlEnv: 'OPENAI_BASE_URL',
|
|
7
|
-
defaultModel: 'gpt-5'
|
|
8
|
-
},
|
|
9
|
-
claude: {
|
|
10
|
-
name: 'claude',
|
|
11
|
-
envKey: 'ANTHROPIC_API_KEY',
|
|
12
|
-
baseUrlEnv: 'ANTHROPIC_BASE_URL',
|
|
13
|
-
defaultModel: 'claude-sonnet-4-20250514'
|
|
14
|
-
},
|
|
15
|
-
openrouter: {
|
|
16
|
-
name: 'openrouter',
|
|
17
|
-
envKey: 'OPENROUTER_API_KEY',
|
|
18
|
-
baseUrlEnv: 'OPENROUTER_BASE_URL',
|
|
19
|
-
defaultModel: 'openai/gpt-4.1-mini'
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const config = providers[provider];
|
|
24
|
-
|
|
25
|
-
if (!config) {
|
|
26
|
-
throw new Error(`Unsupported AI provider: ${provider}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return config;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function listSupportedProviders() {
|
|
33
|
-
return ['openai', 'claude', 'openrouter'];
|
|
34
|
-
}
|
|
1
|
+
export function getAiProviderConfig(provider = 'openai') {
|
|
2
|
+
const providers = {
|
|
3
|
+
openai: {
|
|
4
|
+
name: 'openai',
|
|
5
|
+
envKey: 'OPENAI_API_KEY',
|
|
6
|
+
baseUrlEnv: 'OPENAI_BASE_URL',
|
|
7
|
+
defaultModel: 'gpt-5'
|
|
8
|
+
},
|
|
9
|
+
claude: {
|
|
10
|
+
name: 'claude',
|
|
11
|
+
envKey: 'ANTHROPIC_API_KEY',
|
|
12
|
+
baseUrlEnv: 'ANTHROPIC_BASE_URL',
|
|
13
|
+
defaultModel: 'claude-sonnet-4-20250514'
|
|
14
|
+
},
|
|
15
|
+
openrouter: {
|
|
16
|
+
name: 'openrouter',
|
|
17
|
+
envKey: 'OPENROUTER_API_KEY',
|
|
18
|
+
baseUrlEnv: 'OPENROUTER_BASE_URL',
|
|
19
|
+
defaultModel: 'openai/gpt-4.1-mini'
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const config = providers[provider];
|
|
24
|
+
|
|
25
|
+
if (!config) {
|
|
26
|
+
throw new Error(`Unsupported AI provider: ${provider}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function listSupportedProviders() {
|
|
33
|
+
return ['openai', 'claude', 'openrouter'];
|
|
34
|
+
}
|