@pcoliveira90/pdd 0.2.5 → 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.
@@ -1,91 +1,91 @@
1
- export function buildDoctorRemediationPlan({ coreChecks, adapters, installedVersion, currentVersion }) {
2
- const problems = [];
3
-
4
- const missingCore = Object.entries(coreChecks)
5
- .filter(([, ok]) => !ok)
6
- .map(([key]) => key);
7
-
8
- if (missingCore.length > 0) {
9
- problems.push({
10
- severity: 'high',
11
- code: 'missing-core',
12
- summary: 'Core PDD files are missing',
13
- details: missingCore,
14
- action: 'Run `pdd doctor --fix` to restore missing core files.'
15
- });
16
- }
17
-
18
- if (!installedVersion) {
19
- problems.push({
20
- severity: 'high',
21
- code: 'missing-version',
22
- summary: 'Template version metadata is missing',
23
- details: ['.pdd/version.json'],
24
- action: 'Run `pdd doctor --fix` or `pdd init --here --force`.'
25
- });
26
- } else if (installedVersion !== currentVersion) {
27
- problems.push({
28
- severity: 'medium',
29
- code: 'outdated-templates',
30
- summary: `Templates are outdated (${installedVersion} → ${currentVersion})`,
31
- details: [],
32
- action: 'Run `pdd init --here --upgrade` to update templates safely.'
33
- });
34
- }
35
-
36
- const missingAdapters = Object.entries(adapters)
37
- .filter(([, ok]) => !ok)
38
- .map(([key]) => key);
39
-
40
- if (missingAdapters.length === Object.keys(adapters).length) {
41
- problems.push({
42
- severity: 'low',
43
- code: 'no-adapters',
44
- summary: 'No IDE adapters are installed',
45
- details: missingAdapters,
46
- action: 'Run `pdd init --here --ide=claude` (or cursor/copilot).'
47
- });
48
- }
49
-
50
- const ordered = problems.sort((a, b) => rankSeverity(a.severity) - rankSeverity(b.severity));
51
-
52
- return {
53
- ok: ordered.length === 0,
54
- problems: ordered,
55
- nextAction: ordered[0]?.action || null
56
- };
57
- }
58
-
59
- function rankSeverity(severity) {
60
- switch (severity) {
61
- case 'high':
62
- return 0;
63
- case 'medium':
64
- return 1;
65
- default:
66
- return 2;
67
- }
68
- }
69
-
70
- export function printDoctorRemediationPlan(plan) {
71
- if (plan.ok) {
72
- console.log('✅ No guided remediation needed.');
73
- return;
74
- }
75
-
76
- console.log('');
77
- console.log('🧭 Guided remediation');
78
-
79
- plan.problems.forEach((problem, index) => {
80
- console.log(`${index + 1}. [${problem.severity.toUpperCase()}] ${problem.summary}`);
81
- if (problem.details.length > 0) {
82
- console.log(` Details: ${problem.details.join(', ')}`);
83
- }
84
- console.log(` Action: ${problem.action}`);
85
- });
86
-
87
- if (plan.nextAction) {
88
- console.log('');
89
- console.log(`👉 Recommended next step: ${plan.nextAction}`);
90
- }
91
- }
1
+ export function buildDoctorRemediationPlan({ coreChecks, adapters, installedVersion, currentVersion }) {
2
+ const problems = [];
3
+
4
+ const missingCore = Object.entries(coreChecks)
5
+ .filter(([, ok]) => !ok)
6
+ .map(([key]) => key);
7
+
8
+ if (missingCore.length > 0) {
9
+ problems.push({
10
+ severity: 'high',
11
+ code: 'missing-core',
12
+ summary: 'Core PDD files are missing',
13
+ details: missingCore,
14
+ action: 'Run `pdd doctor --fix` to restore missing core files.'
15
+ });
16
+ }
17
+
18
+ if (!installedVersion) {
19
+ problems.push({
20
+ severity: 'high',
21
+ code: 'missing-version',
22
+ summary: 'Template version metadata is missing',
23
+ details: ['.pdd/version.json'],
24
+ action: 'Run `pdd doctor --fix` or `pdd init --here --force`.'
25
+ });
26
+ } else if (installedVersion !== currentVersion) {
27
+ problems.push({
28
+ severity: 'medium',
29
+ code: 'outdated-templates',
30
+ summary: `Templates are outdated (${installedVersion} → ${currentVersion})`,
31
+ details: [],
32
+ action: 'Run `pdd init --here --upgrade` to update templates safely.'
33
+ });
34
+ }
35
+
36
+ const missingAdapters = Object.entries(adapters)
37
+ .filter(([, ok]) => !ok)
38
+ .map(([key]) => key);
39
+
40
+ if (missingAdapters.length === Object.keys(adapters).length) {
41
+ problems.push({
42
+ severity: 'low',
43
+ code: 'no-adapters',
44
+ summary: 'No IDE adapters are installed',
45
+ details: missingAdapters,
46
+ action: 'Run `pdd init --here --ide=claude` (or cursor/copilot).'
47
+ });
48
+ }
49
+
50
+ const ordered = problems.sort((a, b) => rankSeverity(a.severity) - rankSeverity(b.severity));
51
+
52
+ return {
53
+ ok: ordered.length === 0,
54
+ problems: ordered,
55
+ nextAction: ordered[0]?.action || null
56
+ };
57
+ }
58
+
59
+ function rankSeverity(severity) {
60
+ switch (severity) {
61
+ case 'high':
62
+ return 0;
63
+ case 'medium':
64
+ return 1;
65
+ default:
66
+ return 2;
67
+ }
68
+ }
69
+
70
+ export function printDoctorRemediationPlan(plan) {
71
+ if (plan.ok) {
72
+ console.log('✅ No guided remediation needed.');
73
+ return;
74
+ }
75
+
76
+ console.log('');
77
+ console.log('🧭 Guided remediation');
78
+
79
+ plan.problems.forEach((problem, index) => {
80
+ console.log(`${index + 1}. [${problem.severity.toUpperCase()}] ${problem.summary}`);
81
+ if (problem.details.length > 0) {
82
+ console.log(` Details: ${problem.details.join(', ')}`);
83
+ }
84
+ console.log(` Action: ${problem.action}`);
85
+ });
86
+
87
+ if (plan.nextAction) {
88
+ console.log('');
89
+ console.log(`👉 Recommended next step: ${plan.nextAction}`);
90
+ }
91
+ }
@@ -1,71 +1,71 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- const DEFAULT_STATE = {
5
- activeChange: null,
6
- status: 'idle',
7
- lastChange: null,
8
- updatedAt: null
9
- };
10
-
11
- function ensureDir(filePath) {
12
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
13
- }
14
-
15
- function getStatePath(baseDir = process.cwd()) {
16
- return path.join(baseDir, '.pdd/state.json');
17
- }
18
-
19
- export function readProjectState(baseDir = process.cwd()) {
20
- const statePath = getStatePath(baseDir);
21
- if (!fs.existsSync(statePath)) {
22
- return { ...DEFAULT_STATE };
23
- }
24
-
25
- try {
26
- const raw = JSON.parse(fs.readFileSync(statePath, 'utf-8'));
27
- return { ...DEFAULT_STATE, ...raw };
28
- } catch {
29
- return { ...DEFAULT_STATE };
30
- }
31
- }
32
-
33
- export function writeProjectState(baseDir = process.cwd(), nextState = {}) {
34
- const statePath = getStatePath(baseDir);
35
- ensureDir(statePath);
36
-
37
- const merged = {
38
- ...DEFAULT_STATE,
39
- ...nextState,
40
- updatedAt: new Date().toISOString()
41
- };
42
-
43
- fs.writeFileSync(statePath, JSON.stringify(merged, null, 2) + '\n', 'utf-8');
44
- return merged;
45
- }
46
-
47
- export function setActiveChange(baseDir = process.cwd(), changeId, status = 'in-progress') {
48
- return writeProjectState(baseDir, {
49
- activeChange: changeId,
50
- lastChange: changeId,
51
- status
52
- });
53
- }
54
-
55
- export function markProjectState(baseDir = process.cwd(), status = 'idle') {
56
- const current = readProjectState(baseDir);
57
- return writeProjectState(baseDir, {
58
- ...current,
59
- status,
60
- activeChange: status === 'in-progress' ? current.activeChange : null
61
- });
62
- }
63
-
64
- export function clearActiveChange(baseDir = process.cwd(), status = 'idle') {
65
- const current = readProjectState(baseDir);
66
- return writeProjectState(baseDir, {
67
- ...current,
68
- activeChange: null,
69
- status
70
- });
71
- }
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ const DEFAULT_STATE = {
5
+ activeChange: null,
6
+ status: 'idle',
7
+ lastChange: null,
8
+ updatedAt: null
9
+ };
10
+
11
+ function ensureDir(filePath) {
12
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
13
+ }
14
+
15
+ function getStatePath(baseDir = process.cwd()) {
16
+ return path.join(baseDir, '.pdd/state.json');
17
+ }
18
+
19
+ export function readProjectState(baseDir = process.cwd()) {
20
+ const statePath = getStatePath(baseDir);
21
+ if (!fs.existsSync(statePath)) {
22
+ return { ...DEFAULT_STATE };
23
+ }
24
+
25
+ try {
26
+ const raw = JSON.parse(fs.readFileSync(statePath, 'utf-8'));
27
+ return { ...DEFAULT_STATE, ...raw };
28
+ } catch {
29
+ return { ...DEFAULT_STATE };
30
+ }
31
+ }
32
+
33
+ export function writeProjectState(baseDir = process.cwd(), nextState = {}) {
34
+ const statePath = getStatePath(baseDir);
35
+ ensureDir(statePath);
36
+
37
+ const merged = {
38
+ ...DEFAULT_STATE,
39
+ ...nextState,
40
+ updatedAt: new Date().toISOString()
41
+ };
42
+
43
+ fs.writeFileSync(statePath, JSON.stringify(merged, null, 2) + '\n', 'utf-8');
44
+ return merged;
45
+ }
46
+
47
+ export function setActiveChange(baseDir = process.cwd(), changeId, status = 'in-progress') {
48
+ return writeProjectState(baseDir, {
49
+ activeChange: changeId,
50
+ lastChange: changeId,
51
+ status
52
+ });
53
+ }
54
+
55
+ export function markProjectState(baseDir = process.cwd(), status = 'idle') {
56
+ const current = readProjectState(baseDir);
57
+ return writeProjectState(baseDir, {
58
+ ...current,
59
+ status,
60
+ activeChange: status === 'in-progress' ? current.activeChange : null
61
+ });
62
+ }
63
+
64
+ export function clearActiveChange(baseDir = process.cwd(), status = 'idle') {
65
+ const current = readProjectState(baseDir);
66
+ return writeProjectState(baseDir, {
67
+ ...current,
68
+ activeChange: null,
69
+ status
70
+ });
71
+ }