@educa-corp/sdd-framework 0.7.2 → 0.7.3

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/bin/index.js CHANGED
@@ -5,6 +5,21 @@ const path = require('path');
5
5
 
6
6
  const ROOT = path.join(__dirname, '..');
7
7
 
8
+ // NGUỒN ASSET ĐỂ CÀI — luôn là `core/`, không bao giờ là dir ở gốc.
9
+ //
10
+ // `core/` là bản dựng sẵn và là thứ DUY NHẤT được ship (package.json → files:
11
+ // bin/ core/ scripts/ docs/). Các dir `modules/`, `hooks/`, `steps/`, `templates/`,
12
+ // `rules/`, `skills/` ở gốc là NGUỒN BUILD — chúng chỉ tồn tại trong dev checkout.
13
+ //
14
+ // Vì sao khai một hằng số cho việc này (hồi quy 0.7.0 / G59): đợt dọn tập publish bỏ
15
+ // `modules/` + `hooks/` khỏi `files`, nhưng BA chỗ trong file này vẫn đọc
16
+ // `path.join(ROOT, 'modules'|'hooks')`. Trong dev checkout chúng vẫn có nên test và
17
+ // `npm run build` đều xanh; trong tarball thì KHÔNG, và `--module` crash cứng bằng
18
+ // ENOENT giữa `--init` — chết TRƯỚC bước `--hooks`, nên một cờ hỏng làm chết cờ kia và
19
+ // project bị cài dở (thiếu .claude/settings.json).
20
+ // Test `bin/ chỉ đọc dir CÓ trong package.json files` canh việc này từ nay.
21
+ const CORE_DIR = path.join(ROOT, 'core');
22
+
8
23
  const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
9
24
  const VERSION = pkg.version;
10
25
 
@@ -14,6 +29,12 @@ const VERSION = pkg.version;
14
29
  // of this file is evaluated, and `const` does not hoist.
15
30
  const MANIFEST_NAME = '.install-manifest.json';
16
31
 
32
+ // Asset được YÊU CẦU tường minh (--module, --hooks, module của service) mà bản cài không
33
+ // có. Gom lại thay vì crash giữa `--init`: crash để lại project cài DỞ — đúng ca hồi quy
34
+ // 0.7.0, nơi ENOENT ở bước --module làm bước --hooks không bao giờ chạy. Nhưng cũng KHÔNG
35
+ // im lặng: exit 1 ở cuối, vì người dùng đã xin thứ họ không nhận được.
36
+ const assetErrors = [];
37
+
17
38
  const args = process.argv.slice(2);
18
39
  const isMigrateSpecs = args.includes('--migrate-specs');
19
40
  const isMigrateBddPf = args.includes('--migrate-bdd-platform');
@@ -301,11 +322,20 @@ if (isInit) {
301
322
  console.log(`⚠️ Unknown module: "${moduleName}"`);
302
323
  console.log(` Available: ${AVAILABLE_MODULES.join(', ')}`);
303
324
  } else {
304
- const srcModuleDir = path.join(ROOT, 'modules', moduleName);
325
+ const srcModuleDir = path.join(CORE_DIR, 'modules', moduleName);
305
326
  const destModuleDir = path.join(agentDir, 'modules', moduleName);
306
- fs.mkdirSync(destModuleDir, { recursive: true });
307
- copyDirRecursive(srcModuleDir, destModuleDir);
308
- console.log(`✅ Module "${moduleName}" installed to: .agent/modules/${moduleName}`);
327
+ // Guard TRƯỚC khi copy. Bản gọi thẳng copyDirRecursive và ENOENT làm chết cả
328
+ // `--init` giữa đường — bước `--hooks` ngay dưới không bao giờ chạy, project bị cài
329
+ // dở. Một cờ hỏng không được phép làm chết cờ khác.
330
+ if (!fs.existsSync(srcModuleDir)) {
331
+ console.log(`❌ Module "${moduleName}" không có trong bản cài: ${path.relative(ROOT, srcModuleDir)}`);
332
+ console.log(` Bản cài thiếu/hỏng — cài lại, hoặc xoá cache npx rồi chạy lại.`);
333
+ assetErrors.push(`module ${moduleName}`);
334
+ } else {
335
+ fs.mkdirSync(destModuleDir, { recursive: true });
336
+ copyDirRecursive(srcModuleDir, destModuleDir);
337
+ console.log(`✅ Module "${moduleName}" installed to: .agent/modules/${moduleName}`);
338
+ }
309
339
  }
310
340
  }
311
341
 
@@ -440,12 +470,18 @@ if (isInit) {
440
470
  if (!AVAILABLE_MODULES.includes(svc.module)) {
441
471
  console.log(` ⚠️ Unknown module "${svc.module}" — skipped`);
442
472
  } else {
443
- const srcMod = path.join(ROOT, 'modules', svc.module);
473
+ const srcMod = path.join(CORE_DIR, 'modules', svc.module);
444
474
  const destMod = path.join(svcAgentDir, 'modules', svc.module);
445
475
  if (fs.existsSync(srcMod)) {
446
476
  fs.mkdirSync(destMod, { recursive: true });
447
477
  copyDirRecursive(srcMod, destMod);
448
478
  console.log(` ✅ ${svc.name}/.agent/modules/${svc.module}/`);
479
+ } else {
480
+ // Bản cũ bỏ qua ÂM THẦM ở đây: người dùng khai module cho service, không nhận
481
+ // được gì, và không dòng nào báo. Cùng nguồn lỗi với ca --module ở trên nhưng
482
+ // hỏng theo hướng im lặng — tệ hơn.
483
+ console.log(` ❌ ${svc.name}: module "${svc.module}" không có trong bản cài`);
484
+ assetErrors.push(`${svc.name}/module ${svc.module}`);
449
485
  }
450
486
  }
451
487
  }
@@ -577,6 +613,12 @@ if (isInit) {
577
613
  console.log('To upgrade later: /update-framework (trong Claude Code)');
578
614
  console.log(' (or: npx @educa-corp/sdd-framework@latest --init)');
579
615
  console.log('');
616
+ if (assetErrors.length) {
617
+ console.log('');
618
+ console.log(`❌ ${assetErrors.length} asset được yêu cầu nhưng bản cài không có: ${assetErrors.join(' · ')}`);
619
+ console.log(' Phần còn lại của --init đã hoàn tất — nhưng exit 1 vì bạn đã xin thứ không nhận được.');
620
+ process.exit(1);
621
+ }
580
622
  process.exit(0);
581
623
  }
582
624
 
@@ -963,7 +1005,7 @@ function installDataGuardHook() {
963
1005
 
964
1006
  // 1. Copy hook script
965
1007
  fs.mkdirSync(hooksDir, { recursive: true });
966
- const srcHook = path.join(ROOT, 'hooks', 'data-guard.js');
1008
+ const srcHook = path.join(CORE_DIR, 'hooks', 'data-guard.js');
967
1009
  const destHook = path.join(hooksDir, 'data-guard.js');
968
1010
  fs.copyFileSync(srcHook, destHook);
969
1011
  console.log(` ✅ Hook copied to: .claude/hooks/data-guard.js`);
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.7.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@educa-corp/sdd-framework",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Spec Driven Development workflow framework for Claude Code",
5
5
  "bin": {
6
6
  "sdd-framework": "./bin/index.js"