sdd-toolkit 1.9.2 → 2.0.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/src/lib/docs.js CHANGED
@@ -1,69 +1,71 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- /**
5
- * Generates the necessary folder structure for the agents
6
- * Implements Smart Scaffolding: Only creates missing files/folders.
7
- */
8
- function generateWorkflowGuide(baseDir) {
9
- const docsDir = path.join(baseDir, '.sdd-toolkit');
10
-
11
- // 1. Define folder structure based on new logging architecture
12
- const folders = [
13
- path.join(docsDir, 'features'),
14
- path.join(docsDir, 'logs'),
15
- path.join(docsDir, 'logs', 'executions'),
16
- path.join(docsDir, 'logs', 'reviews'),
17
- path.join(docsDir, 'logs', 'archive'),
18
- ];
19
-
20
- let stats = { created: 0, verified: 0 };
21
-
22
- // Create folders
23
- folders.forEach(dir => {
24
- if (!fs.existsSync(dir)) {
25
- fs.mkdirSync(dir, { recursive: true });
26
- stats.created++;
27
- } else {
28
- stats.verified++;
29
- }
30
- });
31
-
32
- // 2. Define Templates Mapping
33
- // Assumes templates are located in project_root/templates/
34
- // __dirname is src/lib/, so templates is ../../templates
35
- const templatesDir = path.join(__dirname, '..', '..', 'templates');
36
-
37
- const templateFiles = [
38
- { src: 'guidelines.md', dest: 'guidelines.md' },
39
- { src: 'project.md', dest: 'project.md' },
40
- { src: 'requirements.md', dest: 'requirements.md' },
41
- { src: 'milestones.md', dest: 'milestones.md' },
42
- { src: 'task.md', dest: 'task.md' }
43
- ];
44
-
45
- // Create files if they don't exist
46
- templateFiles.forEach(tpl => {
47
- const destPath = path.join(docsDir, tpl.dest);
48
- if (!fs.existsSync(destPath)) {
49
- try {
50
- // Ensure template exists before reading
51
- const templatePath = path.join(templatesDir, tpl.src);
52
- if (fs.existsSync(templatePath)) {
53
- const content = fs.readFileSync(templatePath, 'utf8');
54
- fs.writeFileSync(destPath, content);
55
- stats.created++;
56
- }
57
- } catch (e) {
58
- // Fail silently/warn, do not crash the installer
59
- console.warn(`Warning: Could not scaffold ${tpl.dest}`);
60
- }
61
- } else {
62
- stats.verified++;
63
- }
64
- });
65
-
66
- return stats;
67
- }
68
-
69
- module.exports = { generateWorkflowGuide };
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * Generates the necessary folder structure for the agents
6
+ * Implements Smart Scaffolding: Only creates missing files/folders.
7
+ */
8
+ function generateWorkflowGuide(baseDir) {
9
+ const docsDir = path.join(baseDir, '.sdd-toolkit');
10
+
11
+ // 1. Define folder structure based on new logging architecture
12
+ const folders = [
13
+ path.join(docsDir, 'features'),
14
+ path.join(docsDir, 'logs'),
15
+ path.join(docsDir, 'logs', 'executions'),
16
+ path.join(docsDir, 'logs', 'reviews'),
17
+ path.join(docsDir, 'logs', 'archive'),
18
+ ];
19
+
20
+ let stats = { created: 0, verified: 0 };
21
+
22
+ // Create folders
23
+ folders.forEach(dir => {
24
+ if (!fs.existsSync(dir)) {
25
+ fs.mkdirSync(dir, { recursive: true });
26
+ stats.created++;
27
+ } else {
28
+ stats.verified++;
29
+ }
30
+ });
31
+
32
+ // 2. Define Templates Mapping
33
+ // Assumes templates are located in project_root/templates/
34
+ // __dirname is src/lib/, so templates is ../../templates
35
+ const templatesDir = path.join(__dirname, '..', '..', 'templates');
36
+
37
+ const templateFiles = [
38
+ { src: 'guidelines.md', dest: 'guidelines.md' },
39
+ { src: 'project.md', dest: 'project.md' },
40
+ { src: 'requirements.md', dest: 'requirements.md' },
41
+ { src: 'context.md', dest: 'context.md' },
42
+ { src: 'system.md', dest: 'system.md' },
43
+ { src: 'milestones.md', dest: 'milestones.md' },
44
+ { src: 'task.md', dest: 'task.md' }
45
+ ];
46
+
47
+ // Create files if they don't exist
48
+ templateFiles.forEach(tpl => {
49
+ const destPath = path.join(docsDir, tpl.dest);
50
+ if (!fs.existsSync(destPath)) {
51
+ try {
52
+ // Ensure template exists before reading
53
+ const templatePath = path.join(templatesDir, tpl.src);
54
+ if (fs.existsSync(templatePath)) {
55
+ const content = fs.readFileSync(templatePath, 'utf8');
56
+ fs.writeFileSync(destPath, content);
57
+ stats.created++;
58
+ }
59
+ } catch (e) {
60
+ // Fail silently/warn, do not crash the installer
61
+ console.warn(`Warning: Could not scaffold ${tpl.dest}`);
62
+ }
63
+ } else {
64
+ stats.verified++;
65
+ }
66
+ });
67
+
68
+ return stats;
69
+ }
70
+
71
+ module.exports = { generateWorkflowGuide };
package/src/lib/i18n.js CHANGED
@@ -1,65 +1,65 @@
1
- /**
2
- * Internal i18n Engine
3
- */
4
- const { TRANSLATIONS } = require('./messages');
5
-
6
- let currentLocale = 'en';
7
-
8
- function setLocale(locale) {
9
- // Normalize logic (pt-br -> pt_br) if passed incorrectly, though prompts usually give controlled values
10
- const normalized = locale.toLowerCase().replace('-', '_');
11
-
12
- if (TRANSLATIONS[normalized]) {
13
- currentLocale = normalized;
14
- } else {
15
- // Fallback to en
16
- currentLocale = 'en';
17
- }
18
- }
19
-
20
- function getLocale() {
21
- return currentLocale;
22
- }
23
-
24
- /**
25
- * Retrieves a string from the dictionary based on dot notation.
26
- * e.g. t('INTRO.TITLE')
27
- */
28
- function t(path, ...args) {
29
- const keys = path.split('.');
30
- let value = TRANSLATIONS[currentLocale];
31
-
32
- // Traverse the object for the current locale
33
- for (const key of keys) {
34
- if (value && value[key]) {
35
- value = value[key];
36
- } else {
37
- value = undefined;
38
- break;
39
- }
40
- }
41
-
42
- // If not found, Try Fallback to EN
43
- if (!value) {
44
- let fallback = TRANSLATIONS['en'];
45
- for (const k of keys) {
46
- if (fallback && fallback[k]) fallback = fallback[k];
47
- else {
48
- fallback = undefined;
49
- break;
50
- }
51
- }
52
- value = fallback;
53
- }
54
-
55
- // If still not found, return the path itself as a debug marker
56
- if (!value) return path;
57
-
58
- if (typeof value === 'function') {
59
- return value(...args);
60
- }
61
-
62
- return value;
63
- }
64
-
65
- module.exports = { t, setLocale, getLocale };
1
+ /**
2
+ * Internal i18n Engine
3
+ */
4
+ const { TRANSLATIONS } = require('./messages');
5
+
6
+ let currentLocale = 'en';
7
+
8
+ function setLocale(locale) {
9
+ // Normalize logic (pt-br -> pt_br) if passed incorrectly, though prompts usually give controlled values
10
+ const normalized = locale.toLowerCase().replace('-', '_');
11
+
12
+ if (TRANSLATIONS[normalized]) {
13
+ currentLocale = normalized;
14
+ } else {
15
+ // Fallback to en
16
+ currentLocale = 'en';
17
+ }
18
+ }
19
+
20
+ function getLocale() {
21
+ return currentLocale;
22
+ }
23
+
24
+ /**
25
+ * Retrieves a string from the dictionary based on dot notation.
26
+ * e.g. t('INTRO.TITLE')
27
+ */
28
+ function t(path, ...args) {
29
+ const keys = path.split('.');
30
+ let value = TRANSLATIONS[currentLocale];
31
+
32
+ // Traverse the object for the current locale
33
+ for (const key of keys) {
34
+ if (value && value[key]) {
35
+ value = value[key];
36
+ } else {
37
+ value = undefined;
38
+ break;
39
+ }
40
+ }
41
+
42
+ // If not found, Try Fallback to EN
43
+ if (!value) {
44
+ let fallback = TRANSLATIONS['en'];
45
+ for (const k of keys) {
46
+ if (fallback && fallback[k]) fallback = fallback[k];
47
+ else {
48
+ fallback = undefined;
49
+ break;
50
+ }
51
+ }
52
+ value = fallback;
53
+ }
54
+
55
+ // If still not found, return the path itself as a debug marker
56
+ if (!value) return path;
57
+
58
+ if (typeof value === 'function') {
59
+ return value(...args);
60
+ }
61
+
62
+ return value;
63
+ }
64
+
65
+ module.exports = { t, setLocale, getLocale };