@pcoliveira90/pdd 0.3.0 → 0.3.1
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.en.md +55 -40
- package/README.md +62 -14
- package/README.pt-BR.md +69 -6
- package/bin/pdd-ai.js +1 -0
- package/bin/pdd.js +5 -24
- package/package.json +3 -3
- package/src/ai/run-fix-analysis.js +16 -3
- package/src/cli/doctor-command.js +30 -13
- package/src/core/fix-runner.js +2 -3
- package/src/core/patch-generator.js +10 -11
- package/src/core/pr-manager.js +7 -7
- package/src/core/template-registry.js +1 -1
- package/src/core/validator.js +3 -3
package/README.en.md
CHANGED
|
@@ -1,60 +1,75 @@
|
|
|
1
|
-
# PDD
|
|
2
|
-

|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
> Ship safe changes in living systems.
|
|
1
|
+
# PDD - Patch-Driven Development
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@pcoliveira90/pdd)
|
|
4
|
+
[](https://github.com/pcoliveira90/pdd/actions/workflows/cli-self-validation.yml)
|
|
5
|
+
[](https://github.com/pcoliveira90/pdd/blob/main/LICENSE)
|
|
6
|
+
[](https://nodejs.org/)
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
> Safe changes in real systems.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
PDD is a CLI-first framework for bugfix and feature work in existing codebases.
|
|
11
|
+
It standardizes how teams investigate, plan, validate, and document changes.
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
Language versions: [Default README](README.md) | [Português (Brasil)](README.pt-BR.md)
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
- fixing bugs in production
|
|
18
|
-
- evolving legacy systems
|
|
19
|
-
- adding features without breaking things
|
|
15
|
+
## Why PDD
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
- Worktree-first execution for safer parallel development
|
|
18
|
+
- Structured change artifacts (`delta-spec`, `patch-plan`, `verification-report`)
|
|
19
|
+
- Consistent workflow for Cursor, Claude Code, and GitHub Copilot
|
|
20
|
+
- Built-in quality gates (`doctor`, validation, baseline CI checks)
|
|
22
21
|
|
|
23
|
-
##
|
|
22
|
+
## Quick Start
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
- applying minimal safe changes
|
|
29
|
-
- validating with evidence
|
|
24
|
+
```bash
|
|
25
|
+
# 1) Create a linked worktree (recommended and enforced for mutating flows)
|
|
26
|
+
git worktree add ../pdd-worktrees/my-change -b feature/my-change
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
# 2) Initialize PDD in the repository
|
|
29
|
+
pdd init --here
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
# 3) Run a fix workflow
|
|
32
|
+
pdd fix "login not saving incomeStatus"
|
|
33
|
+
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## Core Commands
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
```bash
|
|
38
|
+
pdd init --here
|
|
39
|
+
pdd doctor
|
|
40
|
+
pdd status
|
|
41
|
+
pdd fix "bug description" [--dry-run] [--no-validate] [--open-pr]
|
|
42
|
+
pdd version
|
|
43
|
+
```
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
AI analysis command:
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
- Root-cause over symptom patch
|
|
45
|
-
- Regression-aware
|
|
46
|
-
- Reuse existing patterns
|
|
47
|
-
- Verifiable outcomes
|
|
47
|
+
```bash
|
|
48
|
+
pdd-ai --provider=openai --task=analysis "bug description"
|
|
49
|
+
```
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
## Workflow Summary
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
1. Understand current behavior and root cause
|
|
54
|
+
2. Generate change artifacts under `changes/<change-id>/`
|
|
55
|
+
3. Validate tests/lint/build
|
|
56
|
+
4. Prepare PR artifacts and review in IDE
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
examples/
|
|
58
|
+
## IDE Alignment
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
PDD keeps equivalent intents across tools:
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
- Cursor: `.cursor/commands/pdd-*.md`
|
|
63
|
+
- Claude Code: `.claude/commands/pdd-*.md`
|
|
64
|
+
- GitHub Copilot: `.github/prompts/pdd-*.prompt.md`
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
## Documentation
|
|
67
|
+
|
|
68
|
+
- `docs/getting-started.md`
|
|
69
|
+
- `docs/installation-and-setup.md`
|
|
70
|
+
- `docs/fix-workflow.md`
|
|
71
|
+
- `docs/manifesto.md`
|
|
72
|
+
|
|
73
|
+
## Goal
|
|
74
|
+
|
|
75
|
+
Reliable execution engine for safe software changes.
|
package/README.md
CHANGED
|
@@ -1,26 +1,74 @@
|
|
|
1
|
-
# PDD
|
|
1
|
+
# PDD - Patch-Driven Development
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@pcoliveira90/pdd)
|
|
4
|
+
[](https://github.com/pcoliveira90/pdd/actions/workflows/cli-self-validation.yml)
|
|
5
|
+
[](https://github.com/pcoliveira90/pdd/blob/main/LICENSE)
|
|
6
|
+
[](https://nodejs.org/)
|
|
2
7
|
|
|
3
8
|
> Safe changes in real systems.
|
|
4
9
|
|
|
5
|
-
PDD is a framework
|
|
10
|
+
PDD is a CLI-first framework for bugfix and feature work in existing codebases.
|
|
11
|
+
It standardizes how teams investigate, plan, validate, and document changes.
|
|
12
|
+
|
|
13
|
+
Language versions: [English](README.en.md) | [Português (Brasil)](README.pt-BR.md)
|
|
14
|
+
|
|
15
|
+
## Why PDD
|
|
16
|
+
|
|
17
|
+
- Worktree-first execution for safer parallel development
|
|
18
|
+
- Structured change artifacts (`delta-spec`, `patch-plan`, `verification-report`)
|
|
19
|
+
- Consistent workflow for Cursor, Claude Code, and GitHub Copilot
|
|
20
|
+
- Built-in quality gates (`doctor`, validation, baseline CI checks)
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# 1) Create a linked worktree (recommended and enforced for mutating flows)
|
|
26
|
+
git worktree add ../pdd-worktrees/my-change -b feature/my-change
|
|
27
|
+
|
|
28
|
+
# 2) Initialize PDD in the repository
|
|
29
|
+
pdd init --here
|
|
30
|
+
|
|
31
|
+
# 3) Run a fix workflow
|
|
32
|
+
pdd fix "login not saving incomeStatus"
|
|
33
|
+
```
|
|
6
34
|
|
|
7
|
-
##
|
|
35
|
+
## Core Commands
|
|
8
36
|
|
|
9
37
|
```bash
|
|
10
|
-
pdd init
|
|
11
|
-
pdd
|
|
12
|
-
pdd
|
|
13
|
-
pdd fix "bug" --no-validate
|
|
14
|
-
pdd
|
|
15
|
-
pdd-ai --provider=openai --task=analysis "bug"
|
|
38
|
+
pdd init --here
|
|
39
|
+
pdd doctor
|
|
40
|
+
pdd status
|
|
41
|
+
pdd fix "bug description" [--dry-run] [--no-validate] [--open-pr]
|
|
42
|
+
pdd version
|
|
16
43
|
```
|
|
17
44
|
|
|
18
|
-
|
|
45
|
+
AI analysis command:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pdd-ai --provider=openai --task=analysis "bug description"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Workflow Summary
|
|
52
|
+
|
|
53
|
+
1. Understand current behavior and root cause
|
|
54
|
+
2. Generate change artifacts under `changes/<change-id>/`
|
|
55
|
+
3. Validate tests/lint/build
|
|
56
|
+
4. Prepare PR artifacts and review in IDE
|
|
57
|
+
|
|
58
|
+
## IDE Alignment
|
|
59
|
+
|
|
60
|
+
PDD keeps equivalent intents across tools:
|
|
61
|
+
|
|
62
|
+
- Cursor: `.cursor/commands/pdd-*.md`
|
|
63
|
+
- Claude Code: `.claude/commands/pdd-*.md`
|
|
64
|
+
- GitHub Copilot: `.github/prompts/pdd-*.prompt.md`
|
|
65
|
+
|
|
66
|
+
## Documentation
|
|
19
67
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
68
|
+
- `docs/getting-started.md`
|
|
69
|
+
- `docs/installation-and-setup.md`
|
|
70
|
+
- `docs/fix-workflow.md`
|
|
71
|
+
- `docs/manifesto.md`
|
|
24
72
|
|
|
25
73
|
## Goal
|
|
26
74
|
|
package/README.pt-BR.md
CHANGED
|
@@ -1,12 +1,75 @@
|
|
|
1
|
-
# PDD
|
|
1
|
+
# PDD - Patch-Driven Development
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@pcoliveira90/pdd)
|
|
4
|
+
[](https://github.com/pcoliveira90/pdd/actions/workflows/cli-self-validation.yml)
|
|
5
|
+
[](https://github.com/pcoliveira90/pdd/blob/main/LICENSE)
|
|
6
|
+
[](https://nodejs.org/)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
> Entregue mudancas seguras em sistemas reais.
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
PDD e um framework orientado a CLI para bugfix e evolucao de features em sistemas existentes.
|
|
11
|
+
Ele padroniza como o time investiga, planeja, valida e documenta mudancas.
|
|
12
|
+
|
|
13
|
+
Versoes por idioma: [README padrao](README.md) | [English](README.en.md)
|
|
14
|
+
|
|
15
|
+
## Por que usar PDD
|
|
16
|
+
|
|
17
|
+
- Execucao worktree-first para desenvolvimento paralelo mais seguro
|
|
18
|
+
- Artefatos estruturados de mudanca (`delta-spec`, `patch-plan`, `verification-report`)
|
|
19
|
+
- Fluxo consistente para Cursor, Claude Code e GitHub Copilot
|
|
20
|
+
- Quality gates nativos (`doctor`, validacao e checagens de CI)
|
|
21
|
+
|
|
22
|
+
## Inicio rapido
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# 1) Crie uma worktree vinculada (recomendado e exigido para fluxos mutaveis)
|
|
26
|
+
git worktree add ../pdd-worktrees/minha-mudanca -b feature/minha-mudanca
|
|
27
|
+
|
|
28
|
+
# 2) Inicialize o PDD no repositorio
|
|
29
|
+
pdd init --here
|
|
30
|
+
|
|
31
|
+
# 3) Rode um fluxo de correcao
|
|
32
|
+
pdd fix "login nao salva incomeStatus"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Comandos principais
|
|
8
36
|
|
|
9
37
|
```bash
|
|
10
|
-
pdd init
|
|
11
|
-
pdd
|
|
38
|
+
pdd init --here
|
|
39
|
+
pdd doctor
|
|
40
|
+
pdd status
|
|
41
|
+
pdd fix "descricao do bug" [--dry-run] [--no-validate] [--open-pr]
|
|
42
|
+
pdd version
|
|
12
43
|
```
|
|
44
|
+
|
|
45
|
+
Comando de analise por IA:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pdd-ai --provider=openai --task=analysis "descricao do bug"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Resumo do fluxo
|
|
52
|
+
|
|
53
|
+
1. Entender comportamento atual e causa raiz
|
|
54
|
+
2. Gerar artefatos em `changes/<change-id>/`
|
|
55
|
+
3. Validar testes/lint/build
|
|
56
|
+
4. Preparar artefatos de PR e revisar na IDE
|
|
57
|
+
|
|
58
|
+
## Alinhamento entre IDEs
|
|
59
|
+
|
|
60
|
+
O PDD mantem intencoes equivalentes entre ferramentas:
|
|
61
|
+
|
|
62
|
+
- Cursor: `.cursor/commands/pdd-*.md`
|
|
63
|
+
- Claude Code: `.claude/commands/pdd-*.md`
|
|
64
|
+
- GitHub Copilot: `.github/prompts/pdd-*.prompt.md`
|
|
65
|
+
|
|
66
|
+
## Documentacao
|
|
67
|
+
|
|
68
|
+
- `docs/getting-started.md`
|
|
69
|
+
- `docs/installation-and-setup.md`
|
|
70
|
+
- `docs/fix-workflow.md`
|
|
71
|
+
- `docs/manifesto.md`
|
|
72
|
+
|
|
73
|
+
## Objetivo
|
|
74
|
+
|
|
75
|
+
Motor de execucao confiavel para mudancas seguras em software real.
|
package/bin/pdd-ai.js
CHANGED
|
@@ -9,6 +9,7 @@ async function main() {
|
|
|
9
9
|
console.log('\n🤖 PDD AI Analysis');
|
|
10
10
|
console.log('----------------------');
|
|
11
11
|
console.log(`Provider: ${result.provider}`);
|
|
12
|
+
console.log(`Task: ${result.task}`);
|
|
12
13
|
console.log(`Model: ${result.model}`);
|
|
13
14
|
console.log(`Issue: ${result.issue}`);
|
|
14
15
|
console.log('\nResult:\n');
|
package/bin/pdd.js
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import path from 'path';
|
|
3
|
+
import { runCli } from '../src/cli/index.js';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
}
|
|
5
|
+
runCli(process.argv.slice(2)).catch(err => {
|
|
6
|
+
console.error(err);
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pcoliveira90/pdd",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Patch-Driven Development CLI — safe, resilient and guided code changes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"start": "node bin/pdd-pro.js",
|
|
16
16
|
"dev": "node bin/pdd-pro.js",
|
|
17
|
-
"test": "
|
|
18
|
-
"lint": "
|
|
17
|
+
"test": "node --test",
|
|
18
|
+
"lint": "node ./scripts/lint-js.mjs",
|
|
19
19
|
"prepublishOnly": "npm pack"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
@@ -13,7 +13,14 @@ function extractArgValue(args, name, fallback = null) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function getIssueFromArgs(args) {
|
|
16
|
-
const filtered = args.filter(
|
|
16
|
+
const filtered = args.filter(
|
|
17
|
+
arg =>
|
|
18
|
+
!arg.startsWith('--provider') &&
|
|
19
|
+
!arg.startsWith('--model') &&
|
|
20
|
+
!arg.startsWith('--task') &&
|
|
21
|
+
arg !== 'fix' &&
|
|
22
|
+
arg !== '--ai'
|
|
23
|
+
);
|
|
17
24
|
return filtered.join(' ').trim();
|
|
18
25
|
}
|
|
19
26
|
|
|
@@ -138,10 +145,11 @@ export async function runAiFixAnalysis(argv = process.argv.slice(2)) {
|
|
|
138
145
|
const provider = extractArgValue(argv, '--provider', 'openai');
|
|
139
146
|
const providerConfig = getAiProviderConfig(provider);
|
|
140
147
|
const model = extractArgValue(argv, '--model', providerConfig.defaultModel);
|
|
148
|
+
const task = extractArgValue(argv, '--task', 'analysis');
|
|
141
149
|
const issue = getIssueFromArgs(argv);
|
|
142
150
|
|
|
143
151
|
if (!issue) {
|
|
144
|
-
throw new Error('Missing issue description. Example: pdd
|
|
152
|
+
throw new Error('Missing issue description. Example: pdd-ai --provider=openai --task=analysis "login not saving incomeStatus"');
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
const apiKey = process.env[providerConfig.envKey];
|
|
@@ -150,7 +158,11 @@ export async function runAiFixAnalysis(argv = process.argv.slice(2)) {
|
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
const baseUrl = resolveBaseUrl(providerConfig);
|
|
153
|
-
const prompt =
|
|
161
|
+
const prompt = [
|
|
162
|
+
`Task mode: ${task}`,
|
|
163
|
+
'',
|
|
164
|
+
buildBugfixPrompt({ issue })
|
|
165
|
+
].join('\n');
|
|
154
166
|
|
|
155
167
|
let raw;
|
|
156
168
|
if (provider === 'openai') {
|
|
@@ -167,6 +179,7 @@ export async function runAiFixAnalysis(argv = process.argv.slice(2)) {
|
|
|
167
179
|
|
|
168
180
|
return {
|
|
169
181
|
provider,
|
|
182
|
+
task,
|
|
170
183
|
model,
|
|
171
184
|
issue,
|
|
172
185
|
result: parsed
|
|
@@ -8,26 +8,42 @@ function exists(baseDir, relativePath) {
|
|
|
8
8
|
return fs.existsSync(path.join(baseDir, relativePath));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
function existsAny(baseDir, relativePaths) {
|
|
12
|
+
return relativePaths.some(relativePath => exists(baseDir, relativePath));
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
function cursorAdapterInstalled(baseDir) {
|
|
12
|
-
return (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
return existsAny(baseDir, [
|
|
17
|
+
'.cursor/rules/pdd.mdc',
|
|
18
|
+
'.cursor/commands/pdd.md',
|
|
19
|
+
'.cursor/commands/pdd-recon.md',
|
|
20
|
+
'.cursor/commands/pdd-fix.md',
|
|
21
|
+
'.cursor/commands/pdd-feature.md',
|
|
22
|
+
'.cursor/commands/pdd-verify.md',
|
|
23
|
+
'.cursor/pdd.prompt.md'
|
|
24
|
+
]);
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
function claudeAdapterInstalled(baseDir) {
|
|
20
|
-
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
return existsAny(baseDir, [
|
|
29
|
+
'.claude/CLAUDE.md',
|
|
30
|
+
'.claude/commands/pdd.md',
|
|
31
|
+
'.claude/commands/pdd-recon.md',
|
|
32
|
+
'.claude/commands/pdd-fix.md',
|
|
33
|
+
'.claude/commands/pdd-feature.md',
|
|
34
|
+
'.claude/commands/pdd-verify.md'
|
|
35
|
+
]);
|
|
24
36
|
}
|
|
25
37
|
|
|
26
38
|
function copilotAdapterInstalled(baseDir) {
|
|
27
|
-
return (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
return existsAny(baseDir, [
|
|
40
|
+
'.github/copilot-instructions.md',
|
|
41
|
+
'.github/copilot/pdd.prompt.md',
|
|
42
|
+
'.github/prompts/pdd-recon.prompt.md',
|
|
43
|
+
'.github/prompts/pdd-fix.prompt.md',
|
|
44
|
+
'.github/prompts/pdd-feature.prompt.md',
|
|
45
|
+
'.github/prompts/pdd-verify.prompt.md'
|
|
46
|
+
]);
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
function readVersion(baseDir) {
|
|
@@ -90,6 +106,7 @@ export function runDoctor(baseDir = process.cwd(), argv = []) {
|
|
|
90
106
|
} else {
|
|
91
107
|
console.log('🎉 Templates up to date');
|
|
92
108
|
}
|
|
109
|
+
console.log('ℹ️ Note: CLI package version and template version are tracked separately.');
|
|
93
110
|
|
|
94
111
|
if (!adapters.claude && !adapters.cursor && !adapters.copilot) {
|
|
95
112
|
console.log('ℹ️ No IDE adapters installed');
|
package/src/core/fix-runner.js
CHANGED
|
@@ -75,11 +75,11 @@ export async function runResilientFixWorkflow({
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
const changeId = `change-${Date.now()}`;
|
|
78
|
+
let phase = 'patch-generation';
|
|
78
79
|
setActiveChange(baseDir, changeId, 'in-progress');
|
|
79
80
|
|
|
80
81
|
try {
|
|
81
|
-
|
|
82
|
-
const patch = generatePatchArtifacts({ issue, baseDir });
|
|
82
|
+
const patch = generatePatchArtifacts({ issue, baseDir, changeId });
|
|
83
83
|
|
|
84
84
|
if (!noValidate) {
|
|
85
85
|
phase = 'validation';
|
|
@@ -113,7 +113,6 @@ export async function runResilientFixWorkflow({
|
|
|
113
113
|
files: patch.files
|
|
114
114
|
};
|
|
115
115
|
} catch (error) {
|
|
116
|
-
const phase = current.status === 'in-progress' ? current.lastPhase || 'unknown' : 'unknown';
|
|
117
116
|
const payload = buildFailurePayload({ issue, changeId, phase, error });
|
|
118
117
|
const artifacts = persistFailureArtifacts(baseDir, payload);
|
|
119
118
|
|
|
@@ -18,15 +18,14 @@ function slugify(value) {
|
|
|
18
18
|
.slice(0, 48);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function generatePatchArtifacts({ issue, baseDir = process.cwd() }) {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const changeDir = path.join(baseDir, 'changes', changeId);
|
|
21
|
+
export function generatePatchArtifacts({ issue, baseDir = process.cwd(), changeId = null }) {
|
|
22
|
+
const resolvedChangeId = changeId || `change-${Date.now()}-${slugify(issue || 'update')}`;
|
|
23
|
+
const changeDir = path.join(baseDir, 'changes', resolvedChangeId);
|
|
25
24
|
|
|
26
25
|
const files = [
|
|
27
|
-
path.join('changes',
|
|
28
|
-
path.join('changes',
|
|
29
|
-
path.join('changes',
|
|
26
|
+
path.join('changes', resolvedChangeId, 'delta-spec.md'),
|
|
27
|
+
path.join('changes', resolvedChangeId, 'patch-plan.md'),
|
|
28
|
+
path.join('changes', resolvedChangeId, 'verification-report.md')
|
|
30
29
|
];
|
|
31
30
|
|
|
32
31
|
writeFile(
|
|
@@ -34,7 +33,7 @@ export function generatePatchArtifacts({ issue, baseDir = process.cwd() }) {
|
|
|
34
33
|
`# Delta Spec
|
|
35
34
|
|
|
36
35
|
## Change ID
|
|
37
|
-
${
|
|
36
|
+
${resolvedChangeId}
|
|
38
37
|
|
|
39
38
|
## Issue
|
|
40
39
|
${issue}
|
|
@@ -71,7 +70,7 @@ bugfix | feature | refactor-safe | hotfix
|
|
|
71
70
|
`# Patch Plan
|
|
72
71
|
|
|
73
72
|
## Change ID
|
|
74
|
-
${
|
|
73
|
+
${resolvedChangeId}
|
|
75
74
|
|
|
76
75
|
## Issue
|
|
77
76
|
${issue}
|
|
@@ -98,7 +97,7 @@ ${issue}
|
|
|
98
97
|
`# Verification Report
|
|
99
98
|
|
|
100
99
|
## Change ID
|
|
101
|
-
${
|
|
100
|
+
${resolvedChangeId}
|
|
102
101
|
|
|
103
102
|
## Issue
|
|
104
103
|
${issue}
|
|
@@ -119,7 +118,7 @@ pending
|
|
|
119
118
|
);
|
|
120
119
|
|
|
121
120
|
return {
|
|
122
|
-
changeId,
|
|
121
|
+
changeId: resolvedChangeId,
|
|
123
122
|
changeDir,
|
|
124
123
|
files
|
|
125
124
|
};
|
package/src/core/pr-manager.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { execFileSync } from 'child_process';
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
function runGit(args, baseDir = process.cwd()) {
|
|
6
|
+
execFileSync('git', args, { stdio: 'inherit', cwd: baseDir });
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export async function openPullRequest({ issue, changeId, changeDir }) {
|
|
9
|
+
export async function openPullRequest({ issue, changeId, changeDir, baseDir = process.cwd() }) {
|
|
10
10
|
const branch = `pdd/${changeId}`;
|
|
11
11
|
const title = `fix: ${issue}`;
|
|
12
12
|
|
|
13
13
|
fs.writeFileSync(path.join(changeDir, 'pr-title.txt'), title);
|
|
14
14
|
fs.writeFileSync(path.join(changeDir, 'pr-body.md'), issue);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
runGit(['checkout', '-b', branch], baseDir);
|
|
17
|
+
runGit(['add', '.'], baseDir);
|
|
18
|
+
runGit(['commit', '-m', title], baseDir);
|
|
19
19
|
|
|
20
20
|
console.log('PR ready (use IDE to open)');
|
|
21
21
|
}
|
|
@@ -171,7 +171,7 @@ Map the structure of the system.
|
|
|
171
171
|
## Hotspots
|
|
172
172
|
-
|
|
173
173
|
`,
|
|
174
|
-
'.pdd/version.json': JSON.stringify({ templateVersion:
|
|
174
|
+
'.pdd/version.json': JSON.stringify({ templateVersion: PDD_TEMPLATE_VERSION }, null, 2) + '\n'
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
export const IDE_ADAPTERS = {
|
package/src/core/validator.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { execSync } from 'child_process';
|
|
3
3
|
|
|
4
|
-
function runCommand(command) {
|
|
4
|
+
function runCommand(command, baseDir) {
|
|
5
5
|
console.log(`→ ${command}`);
|
|
6
|
-
execSync(command, { stdio: 'inherit' });
|
|
6
|
+
execSync(command, { stdio: 'inherit', cwd: baseDir });
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function runValidation(baseDir = process.cwd()) {
|
|
@@ -29,7 +29,7 @@ export function runValidation(baseDir = process.cwd()) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
try {
|
|
32
|
-
commands.forEach(runCommand);
|
|
32
|
+
commands.forEach(command => runCommand(command, baseDir));
|
|
33
33
|
} catch {
|
|
34
34
|
throw new Error('Validation failed');
|
|
35
35
|
}
|