heraspec 0.1.15 → 0.1.17
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.md +109 -71
- package/bin/heraspec.js +1866 -89
- package/bin/heraspec.js.map +4 -4
- package/dist/cli/index.d.ts +2 -0
- package/dist/commands/audit.d.ts +37 -0
- package/dist/commands/create.d.ts +12 -0
- package/dist/commands/explore.d.ts +17 -0
- package/dist/commands/helper.d.ts +13 -0
- package/dist/commands/hotfix.d.ts +9 -0
- package/dist/commands/make-code.d.ts +14 -0
- package/dist/commands/make-docs.d.ts +36 -0
- package/dist/commands/make-test.d.ts +60 -0
- package/dist/commands/memory.d.ts +101 -0
- package/dist/commands/pack.d.ts +17 -0
- package/dist/commands/show.d.ts +8 -0
- package/dist/commands/skill.d.ts +8 -0
- package/dist/commands/suggest.d.ts +32 -0
- package/dist/commands/validate.d.ts +8 -0
- package/dist/core/archive.d.ts +14 -0
- package/dist/core/config.d.ts +33 -0
- package/dist/core/init.d.ts +101 -0
- package/dist/core/list.d.ts +7 -0
- package/dist/core/memory/config-advisor.d.ts +30 -0
- package/dist/core/memory/context-config.d.ts +14 -0
- package/dist/core/memory/context-generator.d.ts +19 -0
- package/dist/core/memory/index.d.ts +12 -0
- package/dist/core/memory/memory-schema.d.ts +34 -0
- package/dist/core/memory/memory-search.d.ts +45 -0
- package/dist/core/memory/memory-store.d.ts +71 -0
- package/dist/core/memory/memory-types.d.ts +159 -0
- package/dist/core/memory/memory-vector.d.ts +23 -0
- package/dist/core/parsers/code-parser.d.ts +53 -0
- package/dist/core/parsers/markdown-parser.d.ts +18 -0
- package/dist/core/restore.d.ts +9 -0
- package/dist/core/schemas/base.schema.d.ts +58 -0
- package/dist/core/schemas/change.schema.d.ts +35 -0
- package/dist/core/schemas/index.d.ts +7 -0
- package/dist/core/schemas/spec.schema.d.ts +52 -0
- package/dist/core/skills/index.d.ts +6 -0
- package/dist/core/skills/skill-manager.d.ts +28 -0
- package/dist/core/skills/skill-parser.d.ts +24 -0
- package/dist/core/sync.d.ts +6 -0
- package/dist/core/templates/index.d.ts +10 -0
- package/dist/core/templates/skills/README.md +4 -1
- package/dist/core/templates/skills/content-channel/content-compliance/skill.md +83 -0
- package/dist/core/templates/skills/content-channel/content-prompts/skill.md +74 -0
- package/dist/core/templates/skills/content-channel/content-scaffolding/skill.md +82 -0
- package/dist/core/templates/skills/content-channel/content-scripting/skill.md +147 -0
- package/dist/core/templates/skills/content-channel/content-strategy/skill.md +78 -0
- package/dist/core/templates/skills/content-channel/content-vault-sync/skill.md +74 -0
- package/dist/core/templates/skills/content-channel/content-voice-adapter/skill.md +143 -0
- package/dist/core/templates/skills/content-channel/skill.md +127 -0
- package/dist/core/templates/skills/perfex-module/code-quality-guidelines/skill.md +130 -0
- package/dist/core/templates/skills/perfex-module/envato-review-guidelines/skill.md +132 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/scripts/scaffold-module.js +151 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/skill.md +204 -110
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/Test_Module.php +79 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/controller-admin.php +71 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/controller-api.php +58 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/deploy.ps1 +97 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/helper.php +97 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/install.php +30 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/model-main.php +94 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/module-main.php +91 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/package.json +30 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/uninstall.php +11 -0
- package/dist/core/templates/skills/perfex-module/module-codebase/templates/webpack.config.js +163 -0
- package/dist/core/templates/skills/perfex-module/skill.md +50 -0
- package/dist/core/templates/skills-template-map.d.ts +29 -0
- package/dist/core/validation/validator.d.ts +26 -0
- package/dist/core/view.d.ts +4 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +383 -50
- package/dist/utils/file-system.d.ts +19 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/task-parser.d.ts +26 -0
- package/package.json +2 -2
package/bin/heraspec.js
CHANGED
|
@@ -161,7 +161,8 @@ var init_config = __esm({
|
|
|
161
161
|
"generic-webapp",
|
|
162
162
|
"backend-api",
|
|
163
163
|
"frontend-app",
|
|
164
|
-
"multi-stack"
|
|
164
|
+
"multi-stack",
|
|
165
|
+
"content-channel"
|
|
165
166
|
];
|
|
166
167
|
HERASPEC_MARKERS = {
|
|
167
168
|
PROJECT_MD: "project.md",
|
|
@@ -318,9 +319,32 @@ var init_skills_template_map = __esm({
|
|
|
318
319
|
isCrossCutting: true
|
|
319
320
|
},
|
|
320
321
|
// Perfex module skills
|
|
322
|
+
"perfex-module": {
|
|
323
|
+
templateFileName: "perfex-module/skill.md",
|
|
324
|
+
isCrossCutting: true,
|
|
325
|
+
resourceDirs: [
|
|
326
|
+
"perfex-module/module-codebase",
|
|
327
|
+
"perfex-module/code-quality-guidelines",
|
|
328
|
+
"perfex-module/envato-review-guidelines"
|
|
329
|
+
]
|
|
330
|
+
},
|
|
321
331
|
"perfex-module:module-codebase": {
|
|
322
332
|
templateFileName: "perfex-module/module-codebase/skill.md",
|
|
323
333
|
isCrossCutting: false,
|
|
334
|
+
projectType: "perfex-module",
|
|
335
|
+
resourceDirs: [
|
|
336
|
+
"perfex-module/module-codebase/templates",
|
|
337
|
+
"perfex-module/module-codebase/scripts"
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
"perfex-module:code-quality-guidelines": {
|
|
341
|
+
templateFileName: "perfex-module/code-quality-guidelines/skill.md",
|
|
342
|
+
isCrossCutting: false,
|
|
343
|
+
projectType: "perfex-module"
|
|
344
|
+
},
|
|
345
|
+
"perfex-module:envato-review-guidelines": {
|
|
346
|
+
templateFileName: "perfex-module/envato-review-guidelines/skill.md",
|
|
347
|
+
isCrossCutting: false,
|
|
324
348
|
projectType: "perfex-module"
|
|
325
349
|
},
|
|
326
350
|
"wordpress:ux-element": {
|
|
@@ -355,6 +379,84 @@ var init_skills_template_map = __esm({
|
|
|
355
379
|
templateFileName: "wordpress/plugin-directory/skill.md",
|
|
356
380
|
isCrossCutting: false,
|
|
357
381
|
projectType: "wordpress-plugin"
|
|
382
|
+
},
|
|
383
|
+
// Content Channel skills
|
|
384
|
+
"content-channel": {
|
|
385
|
+
templateFileName: "content-channel/skill.md",
|
|
386
|
+
isCrossCutting: true,
|
|
387
|
+
resourceDirs: [
|
|
388
|
+
"content-channel/content-strategy",
|
|
389
|
+
"content-channel/content-scaffolding",
|
|
390
|
+
"content-channel/content-scripting",
|
|
391
|
+
"content-channel/content-voice-adapter",
|
|
392
|
+
"content-channel/content-prompts",
|
|
393
|
+
"content-channel/content-compliance",
|
|
394
|
+
"content-channel/content-vault-sync"
|
|
395
|
+
]
|
|
396
|
+
},
|
|
397
|
+
"content-channel:content-strategy": {
|
|
398
|
+
templateFileName: "content-channel/content-strategy/skill.md",
|
|
399
|
+
isCrossCutting: false,
|
|
400
|
+
projectType: "content-channel"
|
|
401
|
+
},
|
|
402
|
+
"content-channel:content-scaffolding": {
|
|
403
|
+
templateFileName: "content-channel/content-scaffolding/skill.md",
|
|
404
|
+
isCrossCutting: false,
|
|
405
|
+
projectType: "content-channel"
|
|
406
|
+
},
|
|
407
|
+
"content-channel:content-scripting": {
|
|
408
|
+
templateFileName: "content-channel/content-scripting/skill.md",
|
|
409
|
+
isCrossCutting: false,
|
|
410
|
+
projectType: "content-channel"
|
|
411
|
+
},
|
|
412
|
+
"content-channel:content-voice-adapter": {
|
|
413
|
+
templateFileName: "content-channel/content-voice-adapter/skill.md",
|
|
414
|
+
isCrossCutting: false,
|
|
415
|
+
projectType: "content-channel"
|
|
416
|
+
},
|
|
417
|
+
"content-channel:content-prompts": {
|
|
418
|
+
templateFileName: "content-channel/content-prompts/skill.md",
|
|
419
|
+
isCrossCutting: false,
|
|
420
|
+
projectType: "content-channel"
|
|
421
|
+
},
|
|
422
|
+
"content-channel:content-compliance": {
|
|
423
|
+
templateFileName: "content-channel/content-compliance/skill.md",
|
|
424
|
+
isCrossCutting: false,
|
|
425
|
+
projectType: "content-channel"
|
|
426
|
+
},
|
|
427
|
+
"content-channel:content-vault-sync": {
|
|
428
|
+
templateFileName: "content-channel/content-vault-sync/skill.md",
|
|
429
|
+
isCrossCutting: false,
|
|
430
|
+
projectType: "content-channel"
|
|
431
|
+
},
|
|
432
|
+
// Direct aliases (cross-cutting)
|
|
433
|
+
"content-strategy": {
|
|
434
|
+
templateFileName: "content-channel/content-strategy/skill.md",
|
|
435
|
+
isCrossCutting: true
|
|
436
|
+
},
|
|
437
|
+
"content-scaffolding": {
|
|
438
|
+
templateFileName: "content-channel/content-scaffolding/skill.md",
|
|
439
|
+
isCrossCutting: true
|
|
440
|
+
},
|
|
441
|
+
"content-scripting": {
|
|
442
|
+
templateFileName: "content-channel/content-scripting/skill.md",
|
|
443
|
+
isCrossCutting: true
|
|
444
|
+
},
|
|
445
|
+
"content-voice-adapter": {
|
|
446
|
+
templateFileName: "content-channel/content-voice-adapter/skill.md",
|
|
447
|
+
isCrossCutting: true
|
|
448
|
+
},
|
|
449
|
+
"content-prompts": {
|
|
450
|
+
templateFileName: "content-channel/content-prompts/skill.md",
|
|
451
|
+
isCrossCutting: true
|
|
452
|
+
},
|
|
453
|
+
"content-compliance": {
|
|
454
|
+
templateFileName: "content-channel/content-compliance/skill.md",
|
|
455
|
+
isCrossCutting: true
|
|
456
|
+
},
|
|
457
|
+
"content-vault-sync": {
|
|
458
|
+
templateFileName: "content-channel/content-vault-sync/skill.md",
|
|
459
|
+
isCrossCutting: true
|
|
358
460
|
}
|
|
359
461
|
};
|
|
360
462
|
}
|
|
@@ -591,9 +693,9 @@ var init_memory_store = __esm({
|
|
|
591
693
|
);
|
|
592
694
|
}
|
|
593
695
|
const dir = path2.dirname(this.dbPath);
|
|
594
|
-
const
|
|
595
|
-
if (!
|
|
596
|
-
|
|
696
|
+
const fs5 = __require("fs");
|
|
697
|
+
if (!fs5.existsSync(dir)) {
|
|
698
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
597
699
|
}
|
|
598
700
|
this.db = new Database(this.dbPath);
|
|
599
701
|
if (needsMigration(this.db)) {
|
|
@@ -616,12 +718,12 @@ var init_memory_store = __esm({
|
|
|
616
718
|
logDbSizeChange() {
|
|
617
719
|
try {
|
|
618
720
|
const project = this.detectProjectName();
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
let totalSize =
|
|
721
|
+
const fs5 = __require("fs");
|
|
722
|
+
if (fs5.existsSync(this.dbPath)) {
|
|
723
|
+
let totalSize = fs5.statSync(this.dbPath).size;
|
|
622
724
|
const walPath = this.dbPath + "-wal";
|
|
623
|
-
if (
|
|
624
|
-
totalSize +=
|
|
725
|
+
if (fs5.existsSync(walPath)) {
|
|
726
|
+
totalSize += fs5.statSync(walPath).size;
|
|
625
727
|
}
|
|
626
728
|
const now = /* @__PURE__ */ new Date();
|
|
627
729
|
this.db.prepare(`
|
|
@@ -820,8 +922,8 @@ var init_memory_store = __esm({
|
|
|
820
922
|
}
|
|
821
923
|
let dbSizeBytes = 0;
|
|
822
924
|
try {
|
|
823
|
-
const
|
|
824
|
-
const stats =
|
|
925
|
+
const fs5 = __require("fs");
|
|
926
|
+
const stats = fs5.statSync(this.dbPath);
|
|
825
927
|
dbSizeBytes = stats.size;
|
|
826
928
|
} catch {
|
|
827
929
|
}
|
|
@@ -890,12 +992,12 @@ var init_memory_store = __esm({
|
|
|
890
992
|
let savingsPercent = tokensWithoutMemory > 0 ? savingsTokens / tokensWithoutMemory * 100 : 0;
|
|
891
993
|
let dbSizeBytes = 0;
|
|
892
994
|
try {
|
|
893
|
-
const
|
|
894
|
-
if (
|
|
895
|
-
dbSizeBytes =
|
|
995
|
+
const fs5 = __require("fs");
|
|
996
|
+
if (fs5.existsSync(this.dbPath)) {
|
|
997
|
+
dbSizeBytes = fs5.statSync(this.dbPath).size;
|
|
896
998
|
const walPath = this.dbPath + "-wal";
|
|
897
|
-
if (
|
|
898
|
-
dbSizeBytes +=
|
|
999
|
+
if (fs5.existsSync(walPath)) {
|
|
1000
|
+
dbSizeBytes += fs5.statSync(walPath).size;
|
|
899
1001
|
}
|
|
900
1002
|
}
|
|
901
1003
|
} catch {
|
|
@@ -981,10 +1083,10 @@ var init_memory_store = __esm({
|
|
|
981
1083
|
}
|
|
982
1084
|
detectProjectName() {
|
|
983
1085
|
try {
|
|
984
|
-
const
|
|
1086
|
+
const fs5 = __require("fs");
|
|
985
1087
|
const pkgPath = path2.join(process.cwd(), "package.json");
|
|
986
|
-
if (
|
|
987
|
-
const pkg = JSON.parse(
|
|
1088
|
+
if (fs5.existsSync(pkgPath)) {
|
|
1089
|
+
const pkg = JSON.parse(fs5.readFileSync(pkgPath, "utf-8"));
|
|
988
1090
|
return pkg.name || path2.basename(process.cwd());
|
|
989
1091
|
}
|
|
990
1092
|
} catch {
|
|
@@ -1397,11 +1499,11 @@ import path3 from "path";
|
|
|
1397
1499
|
function loadContextConfig(projectPath = ".") {
|
|
1398
1500
|
const configPath = path3.join(projectPath, HERASPEC_DIR_NAME, MEMORY_DIR_NAME, CONFIG_FILENAME);
|
|
1399
1501
|
try {
|
|
1400
|
-
const
|
|
1401
|
-
if (!
|
|
1502
|
+
const fs5 = __require("fs");
|
|
1503
|
+
if (!fs5.existsSync(configPath)) {
|
|
1402
1504
|
return { ...DEFAULT_CONTEXT_CONFIG };
|
|
1403
1505
|
}
|
|
1404
|
-
const raw = JSON.parse(
|
|
1506
|
+
const raw = JSON.parse(fs5.readFileSync(configPath, "utf-8"));
|
|
1405
1507
|
return mergeConfig(raw);
|
|
1406
1508
|
} catch {
|
|
1407
1509
|
return { ...DEFAULT_CONTEXT_CONFIG };
|
|
@@ -1410,9 +1512,9 @@ function loadContextConfig(projectPath = ".") {
|
|
|
1410
1512
|
function saveContextConfig(config, projectPath = ".") {
|
|
1411
1513
|
const configDir = path3.join(projectPath, HERASPEC_DIR_NAME, MEMORY_DIR_NAME);
|
|
1412
1514
|
const configPath = path3.join(configDir, CONFIG_FILENAME);
|
|
1413
|
-
const
|
|
1414
|
-
if (!
|
|
1415
|
-
|
|
1515
|
+
const fs5 = __require("fs");
|
|
1516
|
+
if (!fs5.existsSync(configDir)) {
|
|
1517
|
+
fs5.mkdirSync(configDir, { recursive: true });
|
|
1416
1518
|
}
|
|
1417
1519
|
const serializable = {
|
|
1418
1520
|
totalObservationCount: config.totalObservationCount,
|
|
@@ -1423,7 +1525,7 @@ function saveContextConfig(config, projectPath = ".") {
|
|
|
1423
1525
|
maxTokens: config.maxTokens,
|
|
1424
1526
|
showLastSummary: config.showLastSummary
|
|
1425
1527
|
};
|
|
1426
|
-
|
|
1528
|
+
fs5.writeFileSync(configPath, JSON.stringify(serializable, null, 2), "utf-8");
|
|
1427
1529
|
}
|
|
1428
1530
|
function mergeConfig(raw) {
|
|
1429
1531
|
const defaults = DEFAULT_CONTEXT_CONFIG;
|
|
@@ -1508,12 +1610,12 @@ var init_context_generator = __esm({
|
|
|
1508
1610
|
writeContextFile(projectPath = ".") {
|
|
1509
1611
|
const context = this.generateContext(projectPath);
|
|
1510
1612
|
const contextPath = __require("path").join(projectPath, "heraspec", "memory", "context.md");
|
|
1511
|
-
const
|
|
1613
|
+
const fs5 = __require("fs");
|
|
1512
1614
|
const dir = __require("path").dirname(contextPath);
|
|
1513
|
-
if (!
|
|
1514
|
-
|
|
1615
|
+
if (!fs5.existsSync(dir)) {
|
|
1616
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
1515
1617
|
}
|
|
1516
|
-
|
|
1618
|
+
fs5.writeFileSync(contextPath, context, "utf-8");
|
|
1517
1619
|
return contextPath;
|
|
1518
1620
|
}
|
|
1519
1621
|
// ============ Private ============
|
|
@@ -2563,8 +2665,12 @@ var init_skill_parser = __esm({
|
|
|
2563
2665
|
const sectionName = line.replace(/^##+\s+/, "").toLowerCase();
|
|
2564
2666
|
currentSection = sectionName;
|
|
2565
2667
|
if (sectionName.includes("m\u1EE5c \u0111\xEDch") || sectionName.includes("purpose")) {
|
|
2566
|
-
|
|
2567
|
-
|
|
2668
|
+
for (let j = i + 1; j < lines.length && !lines[j].startsWith("##"); j++) {
|
|
2669
|
+
const nextLine = lines[j].trim();
|
|
2670
|
+
if (nextLine) {
|
|
2671
|
+
skill.purpose = nextLine;
|
|
2672
|
+
break;
|
|
2673
|
+
}
|
|
2568
2674
|
}
|
|
2569
2675
|
}
|
|
2570
2676
|
continue;
|
|
@@ -2671,7 +2777,7 @@ var init_skill_manager = __esm({
|
|
|
2671
2777
|
projectType,
|
|
2672
2778
|
skillName
|
|
2673
2779
|
);
|
|
2674
|
-
if (await FileSystemUtils.fileExists(path6.join(projectSkillPath, "skill.md"))) {
|
|
2780
|
+
if (await FileSystemUtils.fileExists(path6.join(projectSkillPath, "skill.md")) || await FileSystemUtils.fileExists(path6.join(projectSkillPath, "SKILL.md"))) {
|
|
2675
2781
|
return projectSkillPath;
|
|
2676
2782
|
}
|
|
2677
2783
|
const crossCuttingPath = path6.join(
|
|
@@ -2680,7 +2786,7 @@ var init_skill_manager = __esm({
|
|
|
2680
2786
|
SKILLS_DIR_NAME,
|
|
2681
2787
|
skillName
|
|
2682
2788
|
);
|
|
2683
|
-
if (await FileSystemUtils.fileExists(path6.join(crossCuttingPath, "skill.md"))) {
|
|
2789
|
+
if (await FileSystemUtils.fileExists(path6.join(crossCuttingPath, "skill.md")) || await FileSystemUtils.fileExists(path6.join(crossCuttingPath, "SKILL.md"))) {
|
|
2684
2790
|
return crossCuttingPath;
|
|
2685
2791
|
}
|
|
2686
2792
|
return null;
|
|
@@ -2718,9 +2824,15 @@ var init_skill_manager = __esm({
|
|
|
2718
2824
|
if (isProjectType) {
|
|
2719
2825
|
const projectSkills = await this.listSkillsInDirectory(entryPath, entry);
|
|
2720
2826
|
skills.push(...projectSkills);
|
|
2827
|
+
if (await FileSystemUtils.fileExists(path6.join(entryPath, "skill.md")) || await FileSystemUtils.fileExists(path6.join(entryPath, "SKILL.md"))) {
|
|
2828
|
+
skills.push({
|
|
2829
|
+
projectType: entry,
|
|
2830
|
+
skillName: entry,
|
|
2831
|
+
path: entryPath
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2721
2834
|
} else {
|
|
2722
|
-
|
|
2723
|
-
if (await FileSystemUtils.fileExists(skillMdPath)) {
|
|
2835
|
+
if (await FileSystemUtils.fileExists(path6.join(entryPath, "skill.md")) || await FileSystemUtils.fileExists(path6.join(entryPath, "SKILL.md"))) {
|
|
2724
2836
|
skills.push({
|
|
2725
2837
|
skillName: entry,
|
|
2726
2838
|
path: entryPath
|
|
@@ -2757,8 +2869,7 @@ var init_skill_manager = __esm({
|
|
|
2757
2869
|
const entryPath = path6.join(dir, entry);
|
|
2758
2870
|
const stats = await FileSystemUtils.stat(entryPath);
|
|
2759
2871
|
if (stats.isDirectory()) {
|
|
2760
|
-
|
|
2761
|
-
if (await FileSystemUtils.fileExists(skillMdPath)) {
|
|
2872
|
+
if (await FileSystemUtils.fileExists(path6.join(entryPath, "skill.md")) || await FileSystemUtils.fileExists(path6.join(entryPath, "SKILL.md"))) {
|
|
2762
2873
|
skills.push({
|
|
2763
2874
|
projectType,
|
|
2764
2875
|
skillName: entry,
|
|
@@ -3091,17 +3202,7 @@ var init_skill = __esm({
|
|
|
3091
3202
|
}
|
|
3092
3203
|
const isUpdate = await FileSystemUtils.fileExists(destPath);
|
|
3093
3204
|
if (isUpdate) {
|
|
3094
|
-
spinner.info(`Skill "${skillName}" already exists at ${destPath}
|
|
3095
|
-
spinner.start(`Removing old version to update with latest...`);
|
|
3096
|
-
try {
|
|
3097
|
-
await FileSystemUtils.removeDirectory(destPath, true);
|
|
3098
|
-
spinner.succeed(`Removed old skill "${skillName}"`);
|
|
3099
|
-
} catch (error) {
|
|
3100
|
-
spinner.fail(`Failed to remove old skill: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3101
|
-
process.exitCode = 1;
|
|
3102
|
-
return;
|
|
3103
|
-
}
|
|
3104
|
-
spinner.start(`Adding updated skill "${skillName}"...`);
|
|
3205
|
+
spinner.info(`Skill "${skillName}" already exists at ${destPath} - updating template files (custom files preserved)...`);
|
|
3105
3206
|
}
|
|
3106
3207
|
await FileSystemUtils.createDirectory(destPath);
|
|
3107
3208
|
const coreTemplatesDir = await getCoreTemplatesDir();
|
|
@@ -3117,6 +3218,10 @@ var init_skill = __esm({
|
|
|
3117
3218
|
return;
|
|
3118
3219
|
}
|
|
3119
3220
|
await FileSystemUtils.copyFile(templateFile, path7.join(destPath, "skill.md"));
|
|
3221
|
+
const upperTemplateFile = path7.join(path7.dirname(templateFile), "SKILL.md");
|
|
3222
|
+
if (await FileSystemUtils.fileExists(upperTemplateFile)) {
|
|
3223
|
+
await FileSystemUtils.copyFile(upperTemplateFile, path7.join(destPath, "SKILL.md"));
|
|
3224
|
+
}
|
|
3120
3225
|
if (templateInfo.viFileName) {
|
|
3121
3226
|
const viFile = path7.join(coreTemplatesDir, templateInfo.viFileName);
|
|
3122
3227
|
if (await FileSystemUtils.fileExists(viFile)) {
|
|
@@ -3190,6 +3295,12 @@ When the user types messages starting with a slash (/), you MUST intercept them
|
|
|
3190
3295
|
## Overview
|
|
3191
3296
|
Describe your project here.
|
|
3192
3297
|
|
|
3298
|
+
## Project Types
|
|
3299
|
+
- List your project type(s) here (e.g., content-channel, node-service, wordpress-plugin, wordpress-theme, perfex-module, laravel-package, generic-webapp, backend-api, frontend-app, multi-stack)
|
|
3300
|
+
|
|
3301
|
+
## Tech Stack
|
|
3302
|
+
- List primary languages, frameworks, runtime, and key libraries
|
|
3303
|
+
|
|
3193
3304
|
## Architecture
|
|
3194
3305
|
Describe the high-level architecture: entry points, module structure, data flow.
|
|
3195
3306
|
|
|
@@ -3265,7 +3376,7 @@ The following commands are classified by risk level. You **MUST NOT** execute th
|
|
|
3265
3376
|
- Existing architecture patterns
|
|
3266
3377
|
- Coding standards
|
|
3267
3378
|
|
|
3268
|
-
> **IGNORE backup files**: Files like
|
|
3379
|
+
> **IGNORE backup files**: Files like \`project.back1.md\`, \`project.back2.md\`, etc. are automatic backups created during \`heraspec init\` updates. NEVER read or reference them unless explicitly asked by the user. Only \`project.md\` is the source of truth.
|
|
3269
3380
|
|
|
3270
3381
|
**Then scaffold:**
|
|
3271
3382
|
- \`heraspec/changes/<slug>/\` - Create proposal.md, tasks.md, design.md (optional)
|
|
@@ -3380,6 +3491,39 @@ The following commands are classified by risk level. You **MUST NOT** execute th
|
|
|
3380
3491
|
- **CRITICAL**: Agent MUST present full report and **wait for user confirmation** before making changes
|
|
3381
3492
|
- Reference guideline numbers (e.g., "Guideline 7: User Tracking Consent")
|
|
3382
3493
|
|
|
3494
|
+
**Special case - Perfex Module Engineering skills:**
|
|
3495
|
+
- Tasks: \`(projectType: perfex-module, skill: module-codebase)\` or \`(projectType: perfex-module, skill: code-quality-guidelines)\` or \`(skill: perfex-module)\`
|
|
3496
|
+
- Install: \`heraspec skill add perfex-module\` or \`heraspec skill add module-codebase --project-type perfex-module\` or \`heraspec skill add code-quality-guidelines --project-type perfex-module\`
|
|
3497
|
+
- Agent reads: \`heraspec/skills/perfex-module/skill.md\`, \`heraspec/skills/perfex-module/module-codebase/skill.md\`, and \`heraspec/skills/perfex-module/code-quality-guidelines/skill.md\`
|
|
3498
|
+
- Agent MUST adhere to **10 Enterprise Code Quality & Clean Code Standards**:
|
|
3499
|
+
1. **Separation of Concerns (Zero Inline Code)**: 0 inline <script> or <style> blocks in views and documentation HTML.
|
|
3500
|
+
2. **Static Analysis Neutrality**: 0 occurrences of high-risk scanner triggers (inject, seeder, bypass, eval, unserialize).
|
|
3501
|
+
3. **Safe Stylesheet Loading**: Use editor.dom.loadCSS() for TinyMCE/iframes; never inject raw CSS string arrays.
|
|
3502
|
+
4. **Scoped Admin JS**: Enclose scripts in window.addEventListener('load') + strict IIFE.
|
|
3503
|
+
5. **Concurrency & Performance**: Always call session_write_close() at the start of read/search AJAX endpoints.
|
|
3504
|
+
6. **Clean Release Packaging**: Exclude package.json, webpack.config.js, tests/, scratch/, .git in deploy.ps1.
|
|
3505
|
+
7. **Defensive PHP Security & Guards**: 100% PHP files start with defined('BASEPATH') or exit('No direct script access allowed');. Use CI Query Builder with auto-escaping.
|
|
3506
|
+
8. **DOM XSS Prevention (CWE-79)**: Use .textContent, .innerText, or strict HTML escaping helper; purify rich text.
|
|
3507
|
+
9. **100% Multilingual Parity**: 100% labels and messages use _l('key') with zero missing keys across languages.
|
|
3508
|
+
10. **Zero Emojis**: 0 Unicode emojis across custom code, comments, views, documentation, and UI.
|
|
3509
|
+
- Use templates from \`heraspec/skills/perfex-module/module-codebase/templates/\` (module-main.php, install.php, uninstall.php, controller-admin.php, controller-api.php, model-main.php, helper.php, deploy.ps1, webpack.config.js).
|
|
3510
|
+
|
|
3511
|
+
**Special case - Content & Channel Development skills (projectType: content-channel):**
|
|
3512
|
+
- Tasks: \`(projectType: content-channel, skill: content-strategy)\`, \`(skill: content-scaffolding)\`, \`(skill: content-scripting)\`, \`(skill: content-voice-adapter)\`, \`(skill: content-prompts)\`, \`(skill: content-compliance)\`, \`(skill: content-vault-sync)\`, or \`(skill: content-channel)\`
|
|
3513
|
+
- Install: \`heraspec skill add content-channel\` or \`heraspec skill add <skill-name> --project-type content-channel\`
|
|
3514
|
+
- Agent reads corresponding skill instructions in \`heraspec/skills/<skill-name>/skill.md\` or \`heraspec/skills/content-channel/<skill-name>/skill.md\`.
|
|
3515
|
+
- Agent MUST adhere to **7 Core Content Production Standards**:
|
|
3516
|
+
1. **Golden Naming Rule**: ZERO \`[K\xEAnh]\`, \`[Channel]\`, or \`K\xEAnh:\` prefixes in channel/folder names. 100% pure brand names only.
|
|
3517
|
+
2. **MTxStudio 2-Level Tree Hierarchy**: Every channel must map to standard categories: \`_plan\` (\`type: "docs"\`), \`_posts\` (\`type: "article"\`), \`_prompts\` (\`type: "prompts"\`), \`_music\` (\`type: "music"\`), and optional \`_affiliate\` (\`type: "docs"\`).
|
|
3518
|
+
3. **Strict TTS Acoustic Rules (Natural Flow)**:
|
|
3519
|
+
- Short sentences: 12 - 20 words max per sentence (never exceed 25 words or 120 chars).
|
|
3520
|
+
- Comma clauses: 8 - 12 words max.
|
|
3521
|
+
- Repetition Bug Prevention: Never place 2 reduplicative words (t\u1EEB l\xE1y) adjacently; always separate with a natural comma \`,\`.
|
|
3522
|
+
- Clean text: Zero artificial bracket tags; rely entirely on natural punctuation (\`.\`, \`,\`, \`...\`, \`!\`) and sentence rhythm for voice pacing.
|
|
3523
|
+
4. **Strict Poetry & Verse Formatting**: Never use \`join(' ')\` or combine verses into a single line. EVERY verse line MUST preserve its \`\\n\` newline.
|
|
3524
|
+
5. **Mandatory 3-Position Disclaimer (Decree 15/2020/ND-CP)**: For horror, health, psychological healing, and finance niches, disclaimers are mandatory at: (1) Intro Warning Card 0:00-0:04, (2) Caption Footer / Pinned Comment, (3) Spoken Narration.
|
|
3525
|
+
6. **Safe Vault Sync (Zero SQLite Tampering)**: NEVER write directly to \`mtxstudio.db\`. All channel exports must go through \`Facebook/export_vault_json.py\` to generate sanitized JSON bundles (\`mtxstudio_vault_import.json\`, \`all_channels_bundle.json\`) with UTF-8 encoding and zero en-dash/em-dash characters.
|
|
3526
|
+
7. **Channel Voice Adaptation (Transmutation)**: When repurposing raw texts, always use \`content-voice-adapter\` to de-bias off-brand elements and reframe the message through the designated channel's core philosophy and natural voice style.
|
|
3383
3527
|
|
|
3384
3528
|
- Follow tasks.md
|
|
3385
3529
|
- Mark tasks completed: \`- [x]\`
|
|
@@ -3432,6 +3576,7 @@ Tasks grouped by project type and skill:
|
|
|
3432
3576
|
> heraspec skill add documents"
|
|
3433
3577
|
- **DO NOT** create a task plan or attempt manual generation without the skill language.
|
|
3434
3578
|
3. **Execute After Install**: Only after the skill folder is created (or installed), read the \`skill.md\` and proceed with the task.
|
|
3579
|
+
4. **Ignore Vietnamese Skill Files**: You MUST only read the English \`skill.md\` file inside the skill folder. Completely ignore all \`*.vi.md\` files (e.g., \`skill.vi.md\`), as they are strictly for reference purposes by human developers.
|
|
3435
3580
|
|
|
3436
3581
|
**Example prompt for Documents skill:**
|
|
3437
3582
|
If you need to generate multi-format documentation, use this prompt:
|
|
@@ -3442,6 +3587,42 @@ If you need to generate multi-format documentation, use this prompt:
|
|
|
3442
3587
|
> - Premium Documentation Landing Page (documentations/documentation-landing-page.html)
|
|
3443
3588
|
> - CRITICAL: Save all files in the /documentations directory (create it if missing)."
|
|
3444
3589
|
|
|
3590
|
+
**Example prompts for Content Channel Development (content-channel skills):**
|
|
3591
|
+
- **Channel Strategy (\`content-strategy\`)**:
|
|
3592
|
+
> "S\u1EED d\u1EE5ng skill content-strategy \u0111\u1EC3 l\u1EADp B\u1EA3n K\u1EBF Ho\u1EA1ch 30 Ng\xE0y (plan.md) cho k\xEAnh m\u1EDBi:
|
|
3593
|
+
> - T\xEAn k\xEAnh: [T\xEAn thu\u1EA7n t\xFAy, v\xED d\u1EE5: G\xF3c An Tr\xFA]
|
|
3594
|
+
> - Ng\xE1ch: [V\xED d\u1EE5: Thi\u1EC1n \u0111\u1ECBnh & L\u1ED1i s\u1ED1ng t\u1ED1i gi\u1EA3n]
|
|
3595
|
+
> - Kh\xE1n gi\u1EA3 m\u1EE5c ti\xEAu: [V\xED d\u1EE5: 25 - 40 tu\u1ED5i, nh\xE2n vi\xEAn v\u0103n ph\xF2ng stress]
|
|
3596
|
+
> - Y\xEAu c\u1EA7u: X\xE2y d\u1EF1ng 5 tr\u1EE5 c\u1ED9t n\u1ED9i dung, l\u1ED9 tr\xECnh Cold Start 14 ng\xE0y (70% Reels / 30% In-stream), khung gi\u1EDD v\xE0ng v\xE0 b\u1EA3ng ph\xE2n b\u1ED5 30 b\xE0i vi\u1EBFt chi ti\u1EBFt."
|
|
3597
|
+
|
|
3598
|
+
- **Channel Scaffolding (\`content-scaffolding\`)**:
|
|
3599
|
+
> "S\u1EED d\u1EE5ng skill content-scaffolding \u0111\u1EC3 kh\u1EDFi t\u1EA1o c\u1EA5u tr\xFAc th\u01B0 m\u1EE5c k\xEAnh m\u1EDBi:
|
|
3600
|
+
> - T\xEAn k\xEAnh: [V\xED d\u1EE5: Th\xE2n An T\xE2m L\u1EA1c] | Folder: [Than-An-Tam-Lac]
|
|
3601
|
+
> - Slogan: [V\xED d\u1EE5: Th\xE2n c\xF3 an, t\xE2m m\u1EDBi l\u1EA1c] | Icon Lucide: [Heart] | M\xE0u: [#10b981]
|
|
3602
|
+
> - Y\xEAu c\u1EA7u: Tu\xE2n th\u1EE7 quy t\u1EAFc c\u1EA5m ti\u1EC1n t\u1ED1 [K\xEAnh], t\u1EA1o posts/README.md v\xE0 \u0111\u0103ng k\xFD v\xE0o CHANNELS_CONFIG trong export_vault_json.py."
|
|
3603
|
+
|
|
3604
|
+
- **Raw Text Transmutation (\`content-voice-adapter\`)**:
|
|
3605
|
+
> "S\u1EED d\u1EE5ng skill content-voice-adapter \u0111\u1EC3 chuy\u1EC3n th\u1EC3 \u0111o\u1EA1n v\u0103n b\u1EA3n th\xF4 d\u01B0\u1EDBi \u0111\xE2y th\xE0nh K\u1ECBch b\u1EA3n Video chu\u1EA9n cho k\xEAnh [T\xEAn K\xEAnh] (Th\u1EC3 lo\u1EA1i: [Ch\u1EEFa l\xE0nh / Truy\u1EC7n ma / D\u01B0\u1EE1ng sinh / Chi\xEAm nghi\u1EC7m...]):
|
|
3606
|
+
> [D\xC1N \u0110O\u1EA0N V\u0102N B\u1EA2N TH\xD4 V\xC0O \u0110\xC2Y]
|
|
3607
|
+
> Y\xEAu c\u1EA7u qua 4 b\u01B0\u1EDBc: (1) L\u1ECDc l\u1EC7ch tone theo ma tr\u1EADn th\u1EC3 lo\u1EA1i (ch\u1EEFa l\xE0nh: l\u1ECDc m\xEA t\xEDn/\u0111\u1ED5 l\u1ED7i; truy\u1EC7n ma: l\u1ECDc m\xE1u me/vi ph\u1EA1m N\u0110 15 t\xEAn ng\u01B0\u1EDDi th\u1EADt/c\u1EE3t nh\u1EA3; d\u01B0\u1EE1ng sinh: l\u1ECDc ph\u1EA3n khoa h\u1ECDc/th\u1EA7n th\xE1nh h\xF3a; chi\xEAm nghi\u1EC7m: l\u1ECDc than th\u1EDF n\u1EA1n nh\xE2n), (2) T\xE1i c\u1EA5u tr\xFAc theo DNA tri\u1EBFt l\xFD v\xE0 \u0111\u1EA1i t\u1EEB nh\xE2n x\u01B0ng c\u1EE7a k\xEAnh, (3) T\u1ED1i \u01B0u \xE2m h\u1ECDc TTS 12-20 t\u1EEB/c\xE2u s\u1EA1ch th\u1EBB ngo\u1EB7c vu\xF4ng, (4) \u0110\xF3ng g\xF3i 6 ph\u1EA7n chu\u1EA9n MTxStudio k\xE8m Storyboard prompt, Caption v\xE0 Disclaimer ph\xE1p l\xFD ph\xF9 h\u1EE3p th\u1EC3 lo\u1EA1i."
|
|
3608
|
+
|
|
3609
|
+
- **Scriptwriting from Scratch (\`content-scripting\`)**:
|
|
3610
|
+
> "S\u1EED d\u1EE5ng skill content-scripting \u0111\u1EC3 vi\u1EBFt K\u1ECBch b\u1EA3n T\u1EADp [S\u1ED1 t\u1EADp]: '[Ti\xEAu \u0111\u1EC1]' cho k\xEAnh [T\xEAn K\xEAnh]:
|
|
3611
|
+
> - Tr\u1EE5 c\u1ED9t: [T\xEAn tr\u1EE5 c\u1ED9t n\u1ED9i dung] | \u0110\u1ECBnh d\u1EA1ng: [Video In-stream 16:9 ho\u1EB7c Reels 9:16]
|
|
3612
|
+
> - Y\xEAu c\u1EA7u \xE2m h\u1ECDc TTS: C\xE2u ng\u1EAFn 12-20 t\u1EEB, ng\u1EAFt nh\u1ECBp d\u1EA5u ph\u1EA9y r\xF5 r\xE0ng, kh\xF4ng \u0111i\u1EC7p \xE2m t\u1EEB l\xE1y, TUY\u1EC6T \u0110\u1ED0I KH\xD4NG ch\xE8n th\u1EBB ngo\u1EB7c vu\xF4ng ([l\u1EA5y h\u01A1i], [th\u1EDF d\xE0i]), b\u1EA3o to\xE0n th\u01A1 ca m\u1ED7i c\xE2u 1 d\xF2ng (\\n), xu\u1EA5t \u0111\u1EA7y \u0111\u1EE7 6 ph\u1EA7n k\xE8m Storyboard v\xE0 Caption Facebook."
|
|
3613
|
+
|
|
3614
|
+
- **AI Visual & Suno BGM Prompts (\`content-prompts\`)**:
|
|
3615
|
+
> "S\u1EED d\u1EE5ng skill content-prompts \u0111\u1EC3 t\u1EA1o b\u1ED9 Prompt Visual v\xE0 \xC2m nh\u1EA1c cho k\xEAnh [T\xEAn K\xEAnh]:
|
|
3616
|
+
> - C\u1EA7n t\u1EA1o: Prompt Avatar 1:1, Cover 16:9, B\u1EA3ng 5 Prompts Storyboard b\xE0i vi\u1EBFt '[T\xEAn b\xE0i vi\u1EBFt]', v\xE0 Prompt Suno AI BGM kh\xF4ng l\u1EDDi."
|
|
3617
|
+
|
|
3618
|
+
- **Legal Compliance & Disclaimer (\`content-compliance\`)**:
|
|
3619
|
+
> "S\u1EED d\u1EE5ng skill content-compliance \u0111\u1EC3 ki\u1EC3m duy\u1EC7t k\u1ECBch b\u1EA3n v\xE0 sinh Disclaimer cho video thu\u1ED9c th\u1EC3 lo\u1EA1i [Truy\u1EC7n Ma / D\u01B0\u1EE1ng Sinh / T\xE2m L\xFD / T\xE0i Ch\xEDnh]:
|
|
3620
|
+
> - Cung c\u1EA5p Disclaimer chu\u1EA9n ph\xE1p l\xFD (Ngh\u1ECB \u0111\u1ECBnh 15/2020/N\u0110-CP) \u0111\u1EB7t \u1EDF ch\xE2n Caption.
|
|
3621
|
+
> - Cung c\u1EA5p Prompt m\xE0n h\xECnh c\u1EA3nh b\xE1o Intro Warning Card (0:00 - 0:04, t\u1EF7 l\u1EC7 16:9)."
|
|
3622
|
+
|
|
3623
|
+
- **Vault Synchronization (\`content-vault-sync\`)**:
|
|
3624
|
+
> "S\u1EED d\u1EE5ng skill content-vault-sync \u0111\u1EC3 \u0111\u1ED3ng b\u1ED9 d\u1EEF li\u1EC7u: Ki\u1EC3m tra t\xEDnh to\xE0n v\u1EB9n c\xE1c k\xEAnh trong Facebook/, ch\u1EA1y export_vault_json.py \u0111\u1EC3 t\xE1i xu\u1EA5t mtxstudio_vault_import.json v\xE0 all_channels_bundle.json, b\xE1o c\xE1o s\u1ED1 l\u01B0\u1EE3ng k\xEAnh, danh m\u1EE5c v\xE0 k\u1ECBch b\u1EA3n \u0111\xE3 \u0111\xF3ng g\xF3i th\xE0nh c\xF4ng."
|
|
3625
|
+
|
|
3445
3626
|
**Dynamic Documentation Generation**:
|
|
3446
3627
|
When generating documentation, do NOT simply fill a template. The Agent MUST:
|
|
3447
3628
|
1. **Create** the \`/documentations\` directory if it does not exist.
|
|
@@ -3478,12 +3659,12 @@ Example with multiple skills in one change:
|
|
|
3478
3659
|
|
|
3479
3660
|
## Proactive Memory-Aware Development
|
|
3480
3661
|
|
|
3481
|
-
If
|
|
3662
|
+
If \`heraspec/skills/project-memory/\` exists, the agent MUST proactively use memory to maintain project context. DO NOT wait for the user to prompt you to use memory.
|
|
3482
3663
|
|
|
3483
3664
|
### CRITICAL RULES FOR AUTOMATIC MEMORY USAGE
|
|
3484
|
-
1. **Always Check Context First**: At the beginning of a complex task or when encountering an unfamiliar codebase area, you MUST autonomously run
|
|
3485
|
-
2. **Auto-Log via Archive**: You DO NOT need to run
|
|
3486
|
-
3. **Session Summary**: (Optional) When wrapping up a large session, you can run
|
|
3665
|
+
1. **Always Check Context First**: At the beginning of a complex task or when encountering an unfamiliar codebase area, you MUST autonomously run \`heraspec memory context\` or \`heraspec memory search "keywords"\` BEFORE writing any code.
|
|
3666
|
+
2. **Auto-Log via Archive**: You DO NOT need to run \`heraspec memory log\` manually. Every time you successfully implement a feature and run \`heraspec archive <change-name>\`, the system will automatically read your proposal and log the memory observation under the hood. Just use \`heraspec archive\` as normal!
|
|
3667
|
+
3. **Session Summary**: (Optional) When wrapping up a large session, you can run \`heraspec memory summarize --request "..." --completed "..."\` to compress knowledge, though \`archive\` already auto-logs completed features.
|
|
3487
3668
|
|
|
3488
3669
|
### When to SKIP Memory
|
|
3489
3670
|
- Simple bug fixes, typo corrections, formatting changes
|
|
@@ -3491,10 +3672,10 @@ If \\\`heraspec/skills/project-memory/\\\` exists, the agent MUST proactively us
|
|
|
3491
3672
|
- When doing what the agent's built-in context already covers
|
|
3492
3673
|
|
|
3493
3674
|
### Smart Code Exploration
|
|
3494
|
-
If
|
|
3495
|
-
-
|
|
3496
|
-
-
|
|
3497
|
-
-
|
|
3675
|
+
If \`heraspec/skills/smart-explore/\` exists, prefer token-efficient exploration:
|
|
3676
|
+
- \`heraspec explore outline <file>\` \u2192 View structure (~1K tokens vs ~12K full file)
|
|
3677
|
+
- \`heraspec explore search "<query>" <path>\` \u2192 Find symbols across codebase
|
|
3678
|
+
- \`heraspec explore unfold <file> <symbol>\` \u2192 Read just one function
|
|
3498
3679
|
`;
|
|
3499
3680
|
}
|
|
3500
3681
|
static getSkillsSection() {
|
|
@@ -3615,6 +3796,7 @@ var InitCommand = class {
|
|
|
3615
3796
|
await this.updateInstalledSkills(heraspecPath);
|
|
3616
3797
|
}
|
|
3617
3798
|
await this.checkAndBootstrapMemory(heraspecPath, resolvedPath, spinner);
|
|
3799
|
+
await this.checkAndBootstrapContentChannel(heraspecPath, resolvedPath, spinner);
|
|
3618
3800
|
await this.updateRelatedMarkdownFiles(resolvedPath);
|
|
3619
3801
|
spinner.stop();
|
|
3620
3802
|
try {
|
|
@@ -4037,36 +4219,78 @@ ${section.content.trimEnd()}`);
|
|
|
4037
4219
|
}
|
|
4038
4220
|
return null;
|
|
4039
4221
|
}
|
|
4222
|
+
/**
|
|
4223
|
+
* Refactor legacy installed skills if new standards or companion skills were added to HeraSpec.
|
|
4224
|
+
* Ensures backward compatibility and non-destructive enhancement for existing projects.
|
|
4225
|
+
*/
|
|
4226
|
+
async refactorLegacySkills(skillsDir, coreTemplatesDir) {
|
|
4227
|
+
const perfexSkillDir = path8.join(skillsDir, "perfex-module");
|
|
4228
|
+
if (await FileSystemUtils.fileExists(perfexSkillDir)) {
|
|
4229
|
+
const rootSkillMd = path8.join(perfexSkillDir, "skill.md");
|
|
4230
|
+
const rootSkillUpperMd = path8.join(perfexSkillDir, "SKILL.md");
|
|
4231
|
+
const templateRootSkill = path8.join(coreTemplatesDir, "perfex-module", "skill.md");
|
|
4232
|
+
const templateRootUpper = path8.join(coreTemplatesDir, "perfex-module", "SKILL.md");
|
|
4233
|
+
if (!await FileSystemUtils.fileExists(rootSkillMd) && await FileSystemUtils.fileExists(templateRootSkill)) {
|
|
4234
|
+
await FileSystemUtils.copyFile(templateRootSkill, rootSkillMd);
|
|
4235
|
+
}
|
|
4236
|
+
if (!await FileSystemUtils.fileExists(rootSkillUpperMd) && await FileSystemUtils.fileExists(templateRootUpper)) {
|
|
4237
|
+
await FileSystemUtils.copyFile(templateRootUpper, rootSkillUpperMd);
|
|
4238
|
+
}
|
|
4239
|
+
const qualityGuidelinesDir = path8.join(perfexSkillDir, "code-quality-guidelines");
|
|
4240
|
+
const templateQualityDir = path8.join(coreTemplatesDir, "perfex-module", "code-quality-guidelines");
|
|
4241
|
+
if (!await FileSystemUtils.fileExists(qualityGuidelinesDir) && await FileSystemUtils.fileExists(templateQualityDir)) {
|
|
4242
|
+
console.log(chalk2.cyan(" \u2713 Refactored perfex-module: added code-quality-guidelines skill"));
|
|
4243
|
+
await FileSystemUtils.copyDirectory(templateQualityDir, qualityGuidelinesDir);
|
|
4244
|
+
}
|
|
4245
|
+
const codebaseDir = path8.join(perfexSkillDir, "module-codebase");
|
|
4246
|
+
const templateCodebaseDir = path8.join(coreTemplatesDir, "perfex-module", "module-codebase");
|
|
4247
|
+
if (await FileSystemUtils.fileExists(codebaseDir) && await FileSystemUtils.fileExists(templateCodebaseDir)) {
|
|
4248
|
+
await FileSystemUtils.copyDirectory(templateCodebaseDir, codebaseDir);
|
|
4249
|
+
}
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4040
4252
|
/**
|
|
4041
4253
|
* Update installed built-in skills on re-init.
|
|
4042
4254
|
*
|
|
4043
4255
|
* Rules:
|
|
4044
4256
|
* - Only update skills that exist in SKILL_TEMPLATE_MAP (built-in / known skills)
|
|
4045
4257
|
* - Skip skills NOT in the template map (custom skills added by the project)
|
|
4258
|
+
* - Strictly preserve custom project skills: NEVER delete or overwrite them
|
|
4046
4259
|
* - For each matching skill: update skill.md + re-copy resourceDirs from template
|
|
4047
|
-
*
|
|
4260
|
+
* safely preserving any user files in templates/, scripts/, examples/ sub-folders
|
|
4048
4261
|
*/
|
|
4049
4262
|
async updateInstalledSkills(heraspecPath) {
|
|
4050
4263
|
const skillsDir = path8.join(heraspecPath, SKILLS_DIR_NAME);
|
|
4051
4264
|
if (!await FileSystemUtils.fileExists(skillsDir)) return;
|
|
4052
4265
|
const coreTemplatesDir = await this.getCoreTemplatesDir();
|
|
4053
4266
|
if (!coreTemplatesDir) return;
|
|
4267
|
+
await this.refactorLegacySkills(skillsDir, coreTemplatesDir);
|
|
4054
4268
|
const allTemplates = getAllSkillTemplates();
|
|
4055
4269
|
let updatedCount = 0;
|
|
4056
|
-
|
|
4270
|
+
const preservedSkills = [];
|
|
4057
4271
|
const installedSkillPaths = await this.collectInstalledSkillPaths(skillsDir);
|
|
4058
4272
|
for (const { skillPath, skillName, projectType } of installedSkillPaths) {
|
|
4059
4273
|
const templateInfo = getSkillTemplateInfo(skillName, projectType);
|
|
4060
4274
|
if (!templateInfo) {
|
|
4061
|
-
|
|
4275
|
+
const displayName = projectType ? `${projectType}/${skillName}` : skillName;
|
|
4276
|
+
if (!preservedSkills.includes(displayName)) {
|
|
4277
|
+
preservedSkills.push(displayName);
|
|
4278
|
+
}
|
|
4062
4279
|
continue;
|
|
4063
4280
|
}
|
|
4064
4281
|
const templateFile = path8.join(coreTemplatesDir, templateInfo.templateFileName);
|
|
4065
4282
|
if (!await FileSystemUtils.fileExists(templateFile)) {
|
|
4066
|
-
|
|
4283
|
+
const displayName = projectType ? `${projectType}/${skillName}` : skillName;
|
|
4284
|
+
if (!preservedSkills.includes(displayName)) {
|
|
4285
|
+
preservedSkills.push(displayName);
|
|
4286
|
+
}
|
|
4067
4287
|
continue;
|
|
4068
4288
|
}
|
|
4069
4289
|
await FileSystemUtils.copyFile(templateFile, path8.join(skillPath, "skill.md"));
|
|
4290
|
+
const upperTemplateFile = path8.join(path8.dirname(templateFile), "SKILL.md");
|
|
4291
|
+
if (await FileSystemUtils.fileExists(upperTemplateFile)) {
|
|
4292
|
+
await FileSystemUtils.copyFile(upperTemplateFile, path8.join(skillPath, "SKILL.md"));
|
|
4293
|
+
}
|
|
4070
4294
|
if (templateInfo.viFileName) {
|
|
4071
4295
|
const viFile = path8.join(coreTemplatesDir, templateInfo.viFileName);
|
|
4072
4296
|
if (await FileSystemUtils.fileExists(viFile)) {
|
|
@@ -4078,9 +4302,6 @@ ${section.content.trimEnd()}`);
|
|
|
4078
4302
|
const srcResourceDir = path8.join(coreTemplatesDir, resourceDir);
|
|
4079
4303
|
const destResourceDir = path8.join(skillPath, path8.basename(resourceDir));
|
|
4080
4304
|
if (await FileSystemUtils.fileExists(srcResourceDir)) {
|
|
4081
|
-
if (await FileSystemUtils.fileExists(destResourceDir)) {
|
|
4082
|
-
await FileSystemUtils.removeDirectory(destResourceDir, true);
|
|
4083
|
-
}
|
|
4084
4305
|
await FileSystemUtils.copyDirectory(srcResourceDir, destResourceDir);
|
|
4085
4306
|
}
|
|
4086
4307
|
}
|
|
@@ -4091,7 +4312,13 @@ ${section.content.trimEnd()}`);
|
|
|
4091
4312
|
updatedCount++;
|
|
4092
4313
|
}
|
|
4093
4314
|
if (updatedCount > 0) {
|
|
4094
|
-
console.log(chalk2.gray(` \u2713 Updated ${updatedCount} built-in skill(s)
|
|
4315
|
+
console.log(chalk2.gray(` \u2713 Updated ${updatedCount} built-in skill(s)`));
|
|
4316
|
+
}
|
|
4317
|
+
if (preservedSkills.length > 0) {
|
|
4318
|
+
console.log(chalk2.green(` \u2713 Preserved ${preservedSkills.length} custom project skill(s) (never deleted or overwritten):`));
|
|
4319
|
+
for (const skill of preservedSkills) {
|
|
4320
|
+
console.log(chalk2.gray(` \u2022 ${skill}`));
|
|
4321
|
+
}
|
|
4095
4322
|
}
|
|
4096
4323
|
}
|
|
4097
4324
|
/**
|
|
@@ -4110,23 +4337,29 @@ ${section.content.trimEnd()}`);
|
|
|
4110
4337
|
"generic-webapp",
|
|
4111
4338
|
"backend-api",
|
|
4112
4339
|
"frontend-app",
|
|
4113
|
-
"multi-stack"
|
|
4340
|
+
"multi-stack",
|
|
4341
|
+
"content-channel"
|
|
4114
4342
|
];
|
|
4115
4343
|
for (const entry of entries) {
|
|
4344
|
+
if (entry === "README.md" || entry === "UI_UX_SKILL_QUICK_REFERENCE.md") continue;
|
|
4116
4345
|
const entryPath = path8.join(skillsDir, entry);
|
|
4117
4346
|
const stats = await FileSystemUtils.stat(entryPath);
|
|
4118
4347
|
if (!stats.isDirectory()) continue;
|
|
4119
4348
|
if (knownProjectTypes.includes(entry)) {
|
|
4120
4349
|
const subEntries = await FileSystemUtils.readDirectory(entryPath);
|
|
4121
4350
|
for (const sub of subEntries) {
|
|
4351
|
+
if (["templates", "scripts", "examples", "data", "knowledge", "tests", "docs"].includes(sub)) continue;
|
|
4122
4352
|
const subPath = path8.join(entryPath, sub);
|
|
4123
4353
|
const subStats = await FileSystemUtils.stat(subPath);
|
|
4124
|
-
if (subStats.isDirectory()
|
|
4354
|
+
if (subStats.isDirectory()) {
|
|
4125
4355
|
result.push({ skillPath: subPath, skillName: sub, projectType: entry });
|
|
4126
4356
|
}
|
|
4127
4357
|
}
|
|
4358
|
+
if (await FileSystemUtils.fileExists(path8.join(entryPath, "skill.md")) || await FileSystemUtils.fileExists(path8.join(entryPath, "SKILL.md"))) {
|
|
4359
|
+
result.push({ skillPath: entryPath, skillName: entry, projectType: entry });
|
|
4360
|
+
}
|
|
4128
4361
|
} else {
|
|
4129
|
-
if (await FileSystemUtils.fileExists(path8.join(entryPath, "skill.md"))) {
|
|
4362
|
+
if (await FileSystemUtils.fileExists(path8.join(entryPath, "skill.md")) || await FileSystemUtils.fileExists(path8.join(entryPath, "SKILL.md"))) {
|
|
4130
4363
|
result.push({ skillPath: entryPath, skillName: entry });
|
|
4131
4364
|
}
|
|
4132
4365
|
}
|
|
@@ -4199,6 +4432,70 @@ ${section.content.trimEnd()}`);
|
|
|
4199
4432
|
}
|
|
4200
4433
|
spinner.start();
|
|
4201
4434
|
}
|
|
4435
|
+
/**
|
|
4436
|
+
* Automatically install content-channel skills if project type is content-channel
|
|
4437
|
+
*/
|
|
4438
|
+
async checkAndBootstrapContentChannel(heraspecPath, projectPath, spinner) {
|
|
4439
|
+
const configPath = path8.join(heraspecPath, HERASPEC_MARKERS.CONFIG_YAML);
|
|
4440
|
+
const projectMdPath = path8.join(heraspecPath, HERASPEC_MARKERS.PROJECT_MD);
|
|
4441
|
+
let isContentChannel = false;
|
|
4442
|
+
if (await FileSystemUtils.fileExists(configPath)) {
|
|
4443
|
+
const configContent = await FileSystemUtils.readFile(configPath);
|
|
4444
|
+
if (/\bprojectType:\s*["']?content-channel["']?/i.test(configContent)) {
|
|
4445
|
+
isContentChannel = true;
|
|
4446
|
+
}
|
|
4447
|
+
}
|
|
4448
|
+
if (!isContentChannel && await FileSystemUtils.fileExists(projectMdPath)) {
|
|
4449
|
+
const projectContent = await FileSystemUtils.readFile(projectMdPath);
|
|
4450
|
+
if (/##\s*Project Types\s*\n\s*-\s*content-channel\b/i.test(projectContent)) {
|
|
4451
|
+
isContentChannel = true;
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
if (!isContentChannel) {
|
|
4455
|
+
const hasFacebook = await FileSystemUtils.fileExists(path8.join(projectPath, "Facebook"));
|
|
4456
|
+
const hasPosts = await FileSystemUtils.fileExists(path8.join(projectPath, "posts"));
|
|
4457
|
+
const hasPrompts = await FileSystemUtils.fileExists(path8.join(projectPath, "prompts"));
|
|
4458
|
+
if (hasFacebook || hasPosts && hasPrompts) {
|
|
4459
|
+
isContentChannel = true;
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
if (isContentChannel) {
|
|
4463
|
+
const channelSkills = [
|
|
4464
|
+
"content-strategy",
|
|
4465
|
+
"content-scaffolding",
|
|
4466
|
+
"content-scripting",
|
|
4467
|
+
"content-voice-adapter",
|
|
4468
|
+
"content-prompts",
|
|
4469
|
+
"content-compliance",
|
|
4470
|
+
"content-vault-sync"
|
|
4471
|
+
];
|
|
4472
|
+
const skillsDir = path8.join(heraspecPath, SKILLS_DIR_NAME);
|
|
4473
|
+
const missingSkills = [];
|
|
4474
|
+
for (const skillName of channelSkills) {
|
|
4475
|
+
const flatPath = path8.join(skillsDir, skillName);
|
|
4476
|
+
const scopedPath = path8.join(skillsDir, "content-channel", skillName);
|
|
4477
|
+
if (!await FileSystemUtils.fileExists(flatPath) && !await FileSystemUtils.fileExists(scopedPath)) {
|
|
4478
|
+
missingSkills.push(skillName);
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
if (missingSkills.length > 0) {
|
|
4482
|
+
spinner.stop();
|
|
4483
|
+
console.log(chalk2.cyan(`
|
|
4484
|
+
\u{1F3AC} Detected content-channel project. Installing ${missingSkills.length} channel skill(s)...`));
|
|
4485
|
+
try {
|
|
4486
|
+
const { SkillCommand: SkillCommand2 } = await Promise.resolve().then(() => (init_skill(), skill_exports));
|
|
4487
|
+
const skillCommand = new SkillCommand2();
|
|
4488
|
+
for (const skillName of missingSkills) {
|
|
4489
|
+
await skillCommand.add(skillName, void 0, projectPath);
|
|
4490
|
+
}
|
|
4491
|
+
console.log(chalk2.green(`\u2713 Channel skills suite ready for production.
|
|
4492
|
+
`));
|
|
4493
|
+
} catch (err) {
|
|
4494
|
+
}
|
|
4495
|
+
spinner.start();
|
|
4496
|
+
}
|
|
4497
|
+
}
|
|
4498
|
+
}
|
|
4202
4499
|
/**
|
|
4203
4500
|
* Get the knowledge source directory from CLI package
|
|
4204
4501
|
*/
|
|
@@ -4651,7 +4948,7 @@ After copying UI/UX skill to your project, see:
|
|
|
4651
4948
|
return `<!-- HeraSpec Section -->
|
|
4652
4949
|
## HeraSpec Development
|
|
4653
4950
|
|
|
4654
|
-
This project uses [HeraSpec](https://github.com/
|
|
4951
|
+
This project uses [HeraSpec](https://github.com/PolyXGO/HeraSpec) for spec-driven development.
|
|
4655
4952
|
|
|
4656
4953
|
### Quick Start
|
|
4657
4954
|
|
|
@@ -4700,7 +4997,7 @@ heraspec skill add unit-test
|
|
|
4700
4997
|
heraspec skill show ui-ux
|
|
4701
4998
|
\`\`\`
|
|
4702
4999
|
|
|
4703
|
-
For more information, see the [HeraSpec documentation](https://github.com/
|
|
5000
|
+
For more information, see the [HeraSpec documentation](https://github.com/PolyXGO/HeraSpec#readme).
|
|
4704
5001
|
|
|
4705
5002
|
---
|
|
4706
5003
|
|
|
@@ -5673,7 +5970,8 @@ var ProjectTypeSchema = z.enum([
|
|
|
5673
5970
|
"generic-webapp",
|
|
5674
5971
|
"backend-api",
|
|
5675
5972
|
"frontend-app",
|
|
5676
|
-
"multi-stack"
|
|
5973
|
+
"multi-stack",
|
|
5974
|
+
"content-channel"
|
|
5677
5975
|
]);
|
|
5678
5976
|
var SpecMetaSchema = z.object({
|
|
5679
5977
|
projectType: z.union([
|
|
@@ -5753,19 +6051,31 @@ var Validator = class {
|
|
|
5753
6051
|
const spec = parser.parseSpec(specName);
|
|
5754
6052
|
const result = SpecSchema.safeParse(spec);
|
|
5755
6053
|
if (!result.success) {
|
|
5756
|
-
result.error.
|
|
5757
|
-
errors.push(
|
|
6054
|
+
result.error.issues.forEach((err) => {
|
|
6055
|
+
errors.push({
|
|
6056
|
+
message: `${err.path.join(".")}: ${err.message}`,
|
|
6057
|
+
autoFixable: false
|
|
6058
|
+
});
|
|
5758
6059
|
});
|
|
5759
6060
|
}
|
|
5760
6061
|
if (spec.requirements.length === 0) {
|
|
5761
|
-
errors.push(
|
|
6062
|
+
errors.push({
|
|
6063
|
+
message: "Spec must have at least one requirement",
|
|
6064
|
+
autoFixable: false
|
|
6065
|
+
});
|
|
5762
6066
|
}
|
|
5763
6067
|
for (const req of spec.requirements) {
|
|
5764
6068
|
if (!req.description || req.description.trim().length === 0) {
|
|
5765
|
-
errors.push(
|
|
6069
|
+
errors.push({
|
|
6070
|
+
message: `Requirement "${req.name}" must have a description`,
|
|
6071
|
+
autoFixable: false
|
|
6072
|
+
});
|
|
5766
6073
|
}
|
|
5767
6074
|
if (!req.scenarios || req.scenarios.length === 0) {
|
|
5768
|
-
warnings.push(
|
|
6075
|
+
warnings.push({
|
|
6076
|
+
message: `Requirement "${req.name}" has no scenarios`,
|
|
6077
|
+
autoFixable: false
|
|
6078
|
+
});
|
|
5769
6079
|
}
|
|
5770
6080
|
}
|
|
5771
6081
|
return {
|
|
@@ -5776,7 +6086,10 @@ var Validator = class {
|
|
|
5776
6086
|
} catch (error) {
|
|
5777
6087
|
return {
|
|
5778
6088
|
valid: false,
|
|
5779
|
-
errors: [
|
|
6089
|
+
errors: [{
|
|
6090
|
+
message: error instanceof Error ? error.message : "Unknown error",
|
|
6091
|
+
autoFixable: false
|
|
6092
|
+
}],
|
|
5780
6093
|
warnings: []
|
|
5781
6094
|
};
|
|
5782
6095
|
}
|
|
@@ -5943,6 +6256,15 @@ var Validator = class {
|
|
|
5943
6256
|
const match = content.match(reqRegex);
|
|
5944
6257
|
return match ? match[0].trim() : null;
|
|
5945
6258
|
}
|
|
6259
|
+
getParseErrorSuggestion(errorMessage) {
|
|
6260
|
+
if (errorMessage.includes("YAML") || errorMessage.includes("frontmatter")) {
|
|
6261
|
+
return "Check the YAML frontmatter syntax at the top of the file.";
|
|
6262
|
+
}
|
|
6263
|
+
if (errorMessage.includes("header") || errorMessage.includes("heading")) {
|
|
6264
|
+
return "Ensure headers follow markdown format (# Title, ## Section).";
|
|
6265
|
+
}
|
|
6266
|
+
return void 0;
|
|
6267
|
+
}
|
|
5946
6268
|
};
|
|
5947
6269
|
|
|
5948
6270
|
// src/commands/validate.ts
|
|
@@ -6073,7 +6395,13 @@ var HelperCommand = class {
|
|
|
6073
6395
|
{ cmd: "heraspec archive [name]", desc: "Archive completed change" },
|
|
6074
6396
|
{ cmd: "heraspec restore [name]", desc: "Restore change from archive" },
|
|
6075
6397
|
{ cmd: "heraspec skill list", desc: "List available skills" },
|
|
6076
|
-
{ cmd: "heraspec
|
|
6398
|
+
{ cmd: "heraspec create <name>", desc: "Scaffold new module/plugin with clean architecture" },
|
|
6399
|
+
{ cmd: "heraspec audit [path]", desc: "Audit code quality, security & clean standards" },
|
|
6400
|
+
{ cmd: "heraspec audit --fix", desc: "Auto-fix safe code quality issues (e.g. PHP guards)" },
|
|
6401
|
+
{ cmd: "heraspec pack [path]", desc: "Build and package production .zip release" },
|
|
6402
|
+
{ cmd: "heraspec memory context", desc: "Generate token-efficient agent context markdown" },
|
|
6403
|
+
{ cmd: "heraspec memory query <query>", desc: "Semantic search project memory" },
|
|
6404
|
+
{ cmd: "heraspec explore outline <file>", desc: "Show structural skeleton of a file" },
|
|
6077
6405
|
{ cmd: "heraspec make docs", desc: "Generate product documentation" },
|
|
6078
6406
|
{ cmd: "heraspec make docs --agent <name>", desc: "Generate docs with AI agent" },
|
|
6079
6407
|
{ cmd: "heraspec make test", desc: "Generate test cases from specs" },
|
|
@@ -6083,7 +6411,7 @@ var HelperCommand = class {
|
|
|
6083
6411
|
{ cmd: "heraspec helper", desc: "Show this guide" }
|
|
6084
6412
|
];
|
|
6085
6413
|
commands.forEach(({ cmd, desc }) => {
|
|
6086
|
-
console.log(chalk8.cyan(` ${cmd.padEnd(
|
|
6414
|
+
console.log(chalk8.cyan(` ${cmd.padEnd(38)}`) + chalk8.white(desc));
|
|
6087
6415
|
});
|
|
6088
6416
|
console.log("\n" + "\u2500".repeat(70) + "\n");
|
|
6089
6417
|
}
|
|
@@ -6131,6 +6459,21 @@ var HelperCommand = class {
|
|
|
6131
6459
|
console.log(chalk8.white.bold("9. WordPress Plugin Check:\n"));
|
|
6132
6460
|
console.log(chalk8.gray(' "Use skill plugin-check to check, then resolve *all* issues mentioned for plugin `[TARGET_PLUGIN]`"\n'));
|
|
6133
6461
|
console.log(chalk8.gray(' "Ensure careful handling and verify that related features still function correctly."\n'));
|
|
6462
|
+
console.log(chalk8.white.bold("10. Content & Multi-Channel Production (content-channel skills):\n"));
|
|
6463
|
+
console.log(chalk8.gray(" # Master Strategy & 30-Day Plan:\n"));
|
|
6464
|
+
console.log(chalk8.cyan(' "S\u1EED d\u1EE5ng skill content-strategy \u0111\u1EC3 l\u1EADp B\u1EA3n K\u1EBF Ho\u1EA1ch 30 Ng\xE0y (plan.md) cho k\xEAnh m\u1EDBi [T\xEAn K\xEAnh]"\n'));
|
|
6465
|
+
console.log(chalk8.gray(" # Scaffolding 2-Level MTxStudio Hierarchy:\n"));
|
|
6466
|
+
console.log(chalk8.cyan(' "S\u1EED d\u1EE5ng skill content-scaffolding \u0111\u1EC3 kh\u1EDFi t\u1EA1o c\u1EA5u tr\xFAc th\u01B0 m\u1EE5c k\xEAnh m\u1EDBi [T\xEAn K\xEAnh]"\n'));
|
|
6467
|
+
console.log(chalk8.gray(" # Transmute Raw Text to Channel DNA:\n"));
|
|
6468
|
+
console.log(chalk8.cyan(' "S\u1EED d\u1EE5ng skill content-voice-adapter \u0111\u1EC3 chuy\u1EC3n th\u1EC3 \u0111o\u1EA1n v\u0103n b\u1EA3n th\xF4 th\xE0nh K\u1ECBch b\u1EA3n Video cho k\xEAnh [T\xEAn K\xEAnh]"\n'));
|
|
6469
|
+
console.log(chalk8.gray(" # TTS-Optimized Scriptwriting (12-20 words/sentence, zero bracket tags):\n"));
|
|
6470
|
+
console.log(chalk8.cyan(' "S\u1EED d\u1EE5ng skill content-scripting \u0111\u1EC3 vi\u1EBFt K\u1ECBch b\u1EA3n T\u1EADp [X] cho k\xEAnh [T\xEAn K\xEAnh]"\n'));
|
|
6471
|
+
console.log(chalk8.gray(" # Visual & Suno BGM Prompts:\n"));
|
|
6472
|
+
console.log(chalk8.cyan(' "S\u1EED d\u1EE5ng skill content-prompts \u0111\u1EC3 t\u1EA1o b\u1ED9 Prompt Visual v\xE0 \xC2m nh\u1EA1c cho k\xEAnh [T\xEAn K\xEAnh]"\n'));
|
|
6473
|
+
console.log(chalk8.gray(" # Legal Compliance & 3-Position Disclaimer (Decree 15/2020/ND-CP):\n"));
|
|
6474
|
+
console.log(chalk8.cyan(' "S\u1EED d\u1EE5ng skill content-compliance \u0111\u1EC3 ki\u1EC3m duy\u1EC7t k\u1ECBch b\u1EA3n v\xE0 sinh Disclaimer cho video"\n'));
|
|
6475
|
+
console.log(chalk8.gray(" # Safe Vault Synchronization to MTxStudio:\n"));
|
|
6476
|
+
console.log(chalk8.cyan(' "S\u1EED d\u1EE5ng skill content-vault-sync \u0111\u1EC3 \u0111\u1ED3ng b\u1ED9 d\u1EEF li\u1EC7u v\xE0 t\xE1i xu\u1EA5t mtxstudio_vault_import.json"\n'));
|
|
6134
6477
|
console.log("\u2500".repeat(70) + "\n");
|
|
6135
6478
|
}
|
|
6136
6479
|
showWorkflow() {
|
|
@@ -6196,6 +6539,27 @@ var HelperCommand = class {
|
|
|
6196
6539
|
"Safety check: Verify features functionality"
|
|
6197
6540
|
],
|
|
6198
6541
|
prompt: '"Use skill plugin-check to check plugin [target-plugin]"'
|
|
6542
|
+
},
|
|
6543
|
+
{
|
|
6544
|
+
step: "8. Content Production: Daily Scripting (Workflow A)",
|
|
6545
|
+
actions: [
|
|
6546
|
+
"Raw Input \u2794 content-voice-adapter (De-bias & Reframing)",
|
|
6547
|
+
"content-compliance (3-position disclaimer & intro warning card)",
|
|
6548
|
+
"Save to Facebook/[Channel]/posts/{index}_{slug}.md",
|
|
6549
|
+
"content-vault-sync (Export sanitized mtxstudio_vault_import.json)"
|
|
6550
|
+
],
|
|
6551
|
+
prompt: '"S\u1EED d\u1EE5ng skill content-voice-adapter \u0111\u1EC3 chuy\u1EC3n th\u1EC3 v\u0103n b\u1EA3n th\xF4 cho k\xEAnh [T\xEAn K\xEAnh]"'
|
|
6552
|
+
},
|
|
6553
|
+
{
|
|
6554
|
+
step: "9. Content Production: New Channel Onboarding (Workflow B)",
|
|
6555
|
+
actions: [
|
|
6556
|
+
"Idea \u2794 content-strategy (plan.md, 5 pillars, $100 RPM model)",
|
|
6557
|
+
"content-scaffolding (2-level MTxStudio tree, zero [K\xEAnh] prefix)",
|
|
6558
|
+
"content-prompts (Avatar 1:1, Cover 16:9, Warning Card & Suno BGM)",
|
|
6559
|
+
"content-scripting (Batch episode authoring, 12-20 words/sentence)",
|
|
6560
|
+
"content-vault-sync (Register and package 1-click import JSON)"
|
|
6561
|
+
],
|
|
6562
|
+
prompt: '"S\u1EED d\u1EE5ng skill content-strategy \u0111\u1EC3 l\u1EADp B\u1EA3n K\u1EBF Ho\u1EA1ch 30 Ng\xE0y cho k\xEAnh m\u1EDBi [T\xEAn K\xEAnh]"'
|
|
6199
6563
|
}
|
|
6200
6564
|
];
|
|
6201
6565
|
steps.forEach(({ step, actions, prompt }) => {
|
|
@@ -6231,7 +6595,17 @@ var HelperCommand = class {
|
|
|
6231
6595
|
"Validate with suggestions: heraspec validate <name> (includes fix suggestions)",
|
|
6232
6596
|
"Get feature suggestions: heraspec suggest (analyzes project and suggests enhancements)",
|
|
6233
6597
|
"Use test skills: unit-test, integration-test, e2e-test for test implementation",
|
|
6234
|
-
'Plugin Check: Use "skill plugin-check" to ensure code quality and safety'
|
|
6598
|
+
'Plugin Check: Use "skill plugin-check" to ensure code quality and safety',
|
|
6599
|
+
"Quality & Security Audit: heraspec audit (checks 7 clean architecture and OWASP rules)",
|
|
6600
|
+
"Auto-fix Audit Issues: heraspec audit --fix (safely adds missing direct access guards)",
|
|
6601
|
+
"Production Packaging: heraspec pack (auto-builds assets & strips dev bloat into release .zip)",
|
|
6602
|
+
"Scaffold Clean Architecture: heraspec create <name> --type perfex-module|wordpress-plugin",
|
|
6603
|
+
"Content Channel: Golden Naming Rule - NEVER prefix with [K\xEAnh] or [Channel]; use pure brand names",
|
|
6604
|
+
"Content Channel: MTxStudio 2-level tree strictly maps to _plan, _posts, _prompts, _music, _affiliate",
|
|
6605
|
+
"Content Channel TTS: 12-20 words/sentence, 8-12 words/clause, no adjacent reduplicatives, ZERO artificial bracket tags ([l\u1EA5y h\u01A1i], [th\u1EDF d\xE0i])",
|
|
6606
|
+
'Content Channel Verse: Preserve poetry newlines (\\n) on each verse line; never collapse with join(" ")',
|
|
6607
|
+
"Content Channel Compliance: 3-position disclaimer (Intro Card 0:00-0:04, Caption footer / Pinned comment, Spoken narration)",
|
|
6608
|
+
"Content Channel Vault: Zero direct SQLite writes; always export sanitized UTF-8 JSON bundles via export_vault_json.py"
|
|
6235
6609
|
];
|
|
6236
6610
|
tips.forEach((tip) => {
|
|
6237
6611
|
console.log(chalk8.white(` \u2022 ${tip}`));
|
|
@@ -6341,8 +6715,8 @@ Found ${specFiles.length} feature(s)`));
|
|
|
6341
6715
|
* Recursively find spec files
|
|
6342
6716
|
*/
|
|
6343
6717
|
async findSpecFilesRecursive(dir, files) {
|
|
6344
|
-
const
|
|
6345
|
-
const entries = await
|
|
6718
|
+
const fs5 = await import("fs/promises");
|
|
6719
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
6346
6720
|
for (const entry of entries) {
|
|
6347
6721
|
const entryPath = path16.join(dir, entry.name);
|
|
6348
6722
|
if (entry.isDirectory()) {
|
|
@@ -6605,8 +6979,8 @@ Test type: ${testType}`));
|
|
|
6605
6979
|
* Recursively find spec files
|
|
6606
6980
|
*/
|
|
6607
6981
|
async findSpecFilesRecursive(dir, files) {
|
|
6608
|
-
const
|
|
6609
|
-
const entries = await
|
|
6982
|
+
const fs5 = await import("fs/promises");
|
|
6983
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
6610
6984
|
for (const entry of entries) {
|
|
6611
6985
|
const entryPath = path17.join(dir, entry.name);
|
|
6612
6986
|
if (entry.isDirectory()) {
|
|
@@ -6865,8 +7239,8 @@ Specs analyzed: ${specFiles.length}`));
|
|
|
6865
7239
|
return specFiles.sort();
|
|
6866
7240
|
}
|
|
6867
7241
|
async findSpecFilesRecursive(dir, files) {
|
|
6868
|
-
const
|
|
6869
|
-
const entries = await
|
|
7242
|
+
const fs5 = await import("fs/promises");
|
|
7243
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
6870
7244
|
for (const entry of entries) {
|
|
6871
7245
|
const entryPath = path18.join(dir, entry.name);
|
|
6872
7246
|
if (entry.isDirectory()) {
|
|
@@ -7086,8 +7460,8 @@ Found ${specs.length} existing feature(s)`));
|
|
|
7086
7460
|
* Recursively find spec files
|
|
7087
7461
|
*/
|
|
7088
7462
|
async findSpecFilesRecursive(dir, files) {
|
|
7089
|
-
const
|
|
7090
|
-
const entries = await
|
|
7463
|
+
const fs5 = await import("fs/promises");
|
|
7464
|
+
const entries = await fs5.readdir(dir, { withFileTypes: true });
|
|
7091
7465
|
for (const entry of entries) {
|
|
7092
7466
|
const entryPath = path19.join(dir, entry.name);
|
|
7093
7467
|
if (entry.isDirectory()) {
|
|
@@ -7651,6 +8025,1382 @@ Symbol "${symbolName}" not found in ${filePath}`));
|
|
|
7651
8025
|
}
|
|
7652
8026
|
};
|
|
7653
8027
|
|
|
8028
|
+
// src/commands/audit.ts
|
|
8029
|
+
init_file_system();
|
|
8030
|
+
init_config();
|
|
8031
|
+
import path22 from "path";
|
|
8032
|
+
import { promises as fs3 } from "fs";
|
|
8033
|
+
import chalk15 from "chalk";
|
|
8034
|
+
import ora12 from "ora";
|
|
8035
|
+
var AuditCommand = class {
|
|
8036
|
+
issues = [];
|
|
8037
|
+
passedCount = 0;
|
|
8038
|
+
async execute(targetPath = ".", options) {
|
|
8039
|
+
const startTime = Date.now();
|
|
8040
|
+
const spinner = ora12("Auditing codebase for quality, security & clean standards...").start();
|
|
8041
|
+
try {
|
|
8042
|
+
const resolvedPath = path22.resolve(targetPath);
|
|
8043
|
+
if (!await FileSystemUtils.fileExists(resolvedPath)) {
|
|
8044
|
+
spinner.fail(`Directory not found: ${resolvedPath}`);
|
|
8045
|
+
process.exitCode = 1;
|
|
8046
|
+
return;
|
|
8047
|
+
}
|
|
8048
|
+
const projectType = options?.type || await this.detectProjectType(resolvedPath);
|
|
8049
|
+
spinner.text = `Auditing ${chalk15.cyan(projectType)} codebase at: ${resolvedPath}`;
|
|
8050
|
+
this.issues = [];
|
|
8051
|
+
this.passedCount = 0;
|
|
8052
|
+
const allFiles = await this.collectFiles(resolvedPath);
|
|
8053
|
+
await this.auditPhpGuards(allFiles, projectType, options?.fix);
|
|
8054
|
+
await this.auditZeroInlineCode(allFiles);
|
|
8055
|
+
await this.auditTriggerWords(allFiles);
|
|
8056
|
+
if (projectType.includes("perfex") || projectType.includes("backend")) {
|
|
8057
|
+
await this.auditSessionConcurrency(allFiles);
|
|
8058
|
+
}
|
|
8059
|
+
await this.auditLanguageParity(resolvedPath);
|
|
8060
|
+
await this.auditEmojis(allFiles);
|
|
8061
|
+
await this.auditPackagingRules(resolvedPath);
|
|
8062
|
+
const durationMs = Date.now() - startTime;
|
|
8063
|
+
spinner.stop();
|
|
8064
|
+
const report = {
|
|
8065
|
+
passed: this.passedCount,
|
|
8066
|
+
warnings: this.issues.filter((i) => i.type === "warning").length,
|
|
8067
|
+
errors: this.issues.filter((i) => i.type === "error").length,
|
|
8068
|
+
issues: this.issues,
|
|
8069
|
+
projectType,
|
|
8070
|
+
durationMs
|
|
8071
|
+
};
|
|
8072
|
+
this.printReport(resolvedPath, report, options?.fix);
|
|
8073
|
+
if (report.errors > 0) {
|
|
8074
|
+
process.exitCode = 1;
|
|
8075
|
+
}
|
|
8076
|
+
} catch (error) {
|
|
8077
|
+
spinner.fail(`Audit error: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
8078
|
+
process.exitCode = 1;
|
|
8079
|
+
}
|
|
8080
|
+
}
|
|
8081
|
+
async detectProjectType(projectPath) {
|
|
8082
|
+
const projectMdPath = path22.join(projectPath, HERASPEC_DIR_NAME, HERASPEC_MARKERS.PROJECT_MD);
|
|
8083
|
+
if (await FileSystemUtils.fileExists(projectMdPath)) {
|
|
8084
|
+
const content = await FileSystemUtils.readFile(projectMdPath);
|
|
8085
|
+
if (content.includes("perfex-module") || content.includes("perfex")) return "perfex-module";
|
|
8086
|
+
if (content.includes("wordpress-plugin")) return "wordpress-plugin";
|
|
8087
|
+
if (content.includes("wordpress-theme")) return "wordpress-theme";
|
|
8088
|
+
}
|
|
8089
|
+
const entries = await FileSystemUtils.readDirectory(projectPath);
|
|
8090
|
+
for (const entry of entries) {
|
|
8091
|
+
if (entry.endsWith(".php")) {
|
|
8092
|
+
const fileContent = await FileSystemUtils.readFile(path22.join(projectPath, entry));
|
|
8093
|
+
if (fileContent.includes("register_activation_hook") || fileContent.includes("hooks()->add_action")) {
|
|
8094
|
+
return "perfex-module";
|
|
8095
|
+
}
|
|
8096
|
+
if (fileContent.includes("Plugin Name:") || fileContent.includes("add_action(")) {
|
|
8097
|
+
return "wordpress-plugin";
|
|
8098
|
+
}
|
|
8099
|
+
}
|
|
8100
|
+
}
|
|
8101
|
+
return "generic-php";
|
|
8102
|
+
}
|
|
8103
|
+
async collectFiles(rootDir) {
|
|
8104
|
+
const files = [];
|
|
8105
|
+
const ignoreDirs = /* @__PURE__ */ new Set([
|
|
8106
|
+
"node_modules",
|
|
8107
|
+
".git",
|
|
8108
|
+
"dist",
|
|
8109
|
+
"build",
|
|
8110
|
+
"vendor",
|
|
8111
|
+
"uploads",
|
|
8112
|
+
"heraspec",
|
|
8113
|
+
".heraspec",
|
|
8114
|
+
".agents",
|
|
8115
|
+
".ai",
|
|
8116
|
+
"ScreenShot",
|
|
8117
|
+
"tests",
|
|
8118
|
+
"test",
|
|
8119
|
+
"scratch"
|
|
8120
|
+
]);
|
|
8121
|
+
const walk = async (currentDir) => {
|
|
8122
|
+
const entries = await fs3.readdir(currentDir, { withFileTypes: true });
|
|
8123
|
+
for (const entry of entries) {
|
|
8124
|
+
if (entry.isDirectory()) {
|
|
8125
|
+
if (!ignoreDirs.has(entry.name)) {
|
|
8126
|
+
await walk(path22.join(currentDir, entry.name));
|
|
8127
|
+
}
|
|
8128
|
+
} else if (entry.isFile()) {
|
|
8129
|
+
files.push(path22.join(currentDir, entry.name));
|
|
8130
|
+
}
|
|
8131
|
+
}
|
|
8132
|
+
};
|
|
8133
|
+
await walk(rootDir);
|
|
8134
|
+
return files;
|
|
8135
|
+
}
|
|
8136
|
+
async auditPhpGuards(files, projectType, fix = false) {
|
|
8137
|
+
const phpFiles = files.filter((f) => f.endsWith(".php"));
|
|
8138
|
+
const isWp = projectType.includes("wordpress");
|
|
8139
|
+
const guardPattern = isWp ? /defined\s*\(\s*['"]ABSPATH['"]\s*\)/i : /defined\s*\(\s*['"]BASEPATH['"]\s*\)/i;
|
|
8140
|
+
const requiredGuard = isWp ? "defined('ABSPATH') or exit;" : "defined('BASEPATH') or exit('No direct script access allowed');";
|
|
8141
|
+
for (const file of phpFiles) {
|
|
8142
|
+
const content = await FileSystemUtils.readFile(file);
|
|
8143
|
+
if (!guardPattern.test(content)) {
|
|
8144
|
+
if (fix) {
|
|
8145
|
+
const updated = content.replace(/^<\?php\s*/i, `<?php
|
|
8146
|
+
${requiredGuard}
|
|
8147
|
+
|
|
8148
|
+
`);
|
|
8149
|
+
await FileSystemUtils.writeFile(file, updated);
|
|
8150
|
+
this.passedCount++;
|
|
8151
|
+
this.issues.push({
|
|
8152
|
+
type: "info",
|
|
8153
|
+
rule: "PHP Direct Access Guard",
|
|
8154
|
+
file,
|
|
8155
|
+
message: `Auto-fixed: Added direct access guard to ${path22.basename(file)}`
|
|
8156
|
+
});
|
|
8157
|
+
} else {
|
|
8158
|
+
this.issues.push({
|
|
8159
|
+
type: "error",
|
|
8160
|
+
rule: "PHP Direct Access Guard",
|
|
8161
|
+
file,
|
|
8162
|
+
line: 1,
|
|
8163
|
+
message: `Missing direct script access guard (${isWp ? "ABSPATH" : "BASEPATH"}).`,
|
|
8164
|
+
suggestion: `Add "${requiredGuard}" at the top of the file.`,
|
|
8165
|
+
fixable: true
|
|
8166
|
+
});
|
|
8167
|
+
}
|
|
8168
|
+
} else {
|
|
8169
|
+
this.passedCount++;
|
|
8170
|
+
}
|
|
8171
|
+
}
|
|
8172
|
+
}
|
|
8173
|
+
async auditZeroInlineCode(files) {
|
|
8174
|
+
const viewFiles = files.filter((f) => f.includes("views") || f.includes("templates") || f.endsWith(".html"));
|
|
8175
|
+
for (const file of viewFiles) {
|
|
8176
|
+
const content = await FileSystemUtils.readFile(file);
|
|
8177
|
+
const lines = content.split("\n");
|
|
8178
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8179
|
+
const line = lines[i];
|
|
8180
|
+
if (/<script\b[^>]*>/i.test(line) && !line.includes('type="application/ld+json"') && !line.includes('type="application/json"')) {
|
|
8181
|
+
this.issues.push({
|
|
8182
|
+
type: "error",
|
|
8183
|
+
rule: "Zero Inline JavaScript",
|
|
8184
|
+
file,
|
|
8185
|
+
line: i + 1,
|
|
8186
|
+
message: `Found inline <script> tag in view template.`,
|
|
8187
|
+
suggestion: "Move all logic to external standalone .js files in assets/js/ and compile to dist/."
|
|
8188
|
+
});
|
|
8189
|
+
}
|
|
8190
|
+
if (/<style\b[^>]*>/i.test(line)) {
|
|
8191
|
+
this.issues.push({
|
|
8192
|
+
type: "error",
|
|
8193
|
+
rule: "Zero Inline CSS",
|
|
8194
|
+
file,
|
|
8195
|
+
line: i + 1,
|
|
8196
|
+
message: `Found inline <style> tag in view template.`,
|
|
8197
|
+
suggestion: "Move all styles to external stylesheets in assets/css/."
|
|
8198
|
+
});
|
|
8199
|
+
}
|
|
8200
|
+
if (/\bstyle\s*=\s*["'][^"']+["']/i.test(line)) {
|
|
8201
|
+
this.issues.push({
|
|
8202
|
+
type: "warning",
|
|
8203
|
+
rule: "Zero Inline Style Attributes",
|
|
8204
|
+
file,
|
|
8205
|
+
line: i + 1,
|
|
8206
|
+
message: `Found inline style="..." attribute in HTML element.`,
|
|
8207
|
+
suggestion: "Use semantic CSS utility classes in external stylesheets."
|
|
8208
|
+
});
|
|
8209
|
+
}
|
|
8210
|
+
}
|
|
8211
|
+
this.passedCount++;
|
|
8212
|
+
}
|
|
8213
|
+
}
|
|
8214
|
+
async auditTriggerWords(files) {
|
|
8215
|
+
const codeFiles = files.filter((f) => f.endsWith(".php") || f.endsWith(".js"));
|
|
8216
|
+
const riskyWords = [
|
|
8217
|
+
{ word: "injectStyles", reason: "Triggers AST scanner code/script injection alerts", replacement: "extendStyles or applyStyles" },
|
|
8218
|
+
{ word: "injectScript", reason: "Triggers AST scanner code/script injection alerts", replacement: "enqueueScript or appendScript" },
|
|
8219
|
+
{ word: "_seeder.php", reason: "Flagged by bot scanners as potential database tampering backdoor", replacement: "_demo_data.php" },
|
|
8220
|
+
{ word: "bypass", reason: "Flagged as potential authentication or authorization bypass vulnerability", replacement: "permit or allow" }
|
|
8221
|
+
];
|
|
8222
|
+
for (const file of codeFiles) {
|
|
8223
|
+
const content = await FileSystemUtils.readFile(file);
|
|
8224
|
+
for (const item of riskyWords) {
|
|
8225
|
+
if (content.includes(item.word)) {
|
|
8226
|
+
this.issues.push({
|
|
8227
|
+
type: "warning",
|
|
8228
|
+
rule: "Static Analysis Scanner Neutrality",
|
|
8229
|
+
file,
|
|
8230
|
+
message: `Found high-risk token "${item.word}": ${item.reason}.`,
|
|
8231
|
+
suggestion: `Replace with neutral terminology like "${item.replacement}".`
|
|
8232
|
+
});
|
|
8233
|
+
}
|
|
8234
|
+
}
|
|
8235
|
+
this.passedCount++;
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8238
|
+
async auditSessionConcurrency(files) {
|
|
8239
|
+
const controllerFiles = files.filter((f) => f.includes("controllers") && f.endsWith(".php"));
|
|
8240
|
+
for (const file of controllerFiles) {
|
|
8241
|
+
const content = await FileSystemUtils.readFile(file);
|
|
8242
|
+
const lines = content.split("\n");
|
|
8243
|
+
let insideSearchMethod = false;
|
|
8244
|
+
let hasSessionClose = false;
|
|
8245
|
+
let methodStartLine = 1;
|
|
8246
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8247
|
+
const line = lines[i];
|
|
8248
|
+
if (/public\s+function\s+(search|autocomplete|lookup|get_)/i.test(line)) {
|
|
8249
|
+
insideSearchMethod = true;
|
|
8250
|
+
hasSessionClose = false;
|
|
8251
|
+
methodStartLine = i + 1;
|
|
8252
|
+
}
|
|
8253
|
+
if (insideSearchMethod) {
|
|
8254
|
+
if (line.includes("session_write_close()")) {
|
|
8255
|
+
hasSessionClose = true;
|
|
8256
|
+
}
|
|
8257
|
+
if (line.includes("function ") && i + 1 > methodStartLine) {
|
|
8258
|
+
if (!hasSessionClose) {
|
|
8259
|
+
this.issues.push({
|
|
8260
|
+
type: "warning",
|
|
8261
|
+
rule: "Concurrency & Session Lock Prevention",
|
|
8262
|
+
file,
|
|
8263
|
+
line: methodStartLine,
|
|
8264
|
+
message: `AJAX read/search method does not release PHP session file lock.`,
|
|
8265
|
+
suggestion: `Add "session_write_close();" at the start of the method to support non-blocking concurrent requests.`
|
|
8266
|
+
});
|
|
8267
|
+
}
|
|
8268
|
+
insideSearchMethod = false;
|
|
8269
|
+
}
|
|
8270
|
+
}
|
|
8271
|
+
}
|
|
8272
|
+
this.passedCount++;
|
|
8273
|
+
}
|
|
8274
|
+
}
|
|
8275
|
+
async auditLanguageParity(rootDir) {
|
|
8276
|
+
const enLangDir = path22.join(rootDir, "language", "english");
|
|
8277
|
+
const viLangDir = path22.join(rootDir, "language", "vietnamese");
|
|
8278
|
+
if (!await FileSystemUtils.fileExists(enLangDir)) return;
|
|
8279
|
+
const enFiles = (await FileSystemUtils.readDirectory(enLangDir)).filter((f) => f.endsWith("_lang.php"));
|
|
8280
|
+
for (const langFile of enFiles) {
|
|
8281
|
+
const enPath = path22.join(enLangDir, langFile);
|
|
8282
|
+
const viPath = path22.join(viLangDir, langFile);
|
|
8283
|
+
const enKeys = this.extractLangKeys(await FileSystemUtils.readFile(enPath));
|
|
8284
|
+
if (await FileSystemUtils.fileExists(viPath)) {
|
|
8285
|
+
const viKeys = this.extractLangKeys(await FileSystemUtils.readFile(viPath));
|
|
8286
|
+
const missingInVi = [...enKeys].filter((k) => !viKeys.has(k));
|
|
8287
|
+
const missingInEn = [...viKeys].filter((k) => !enKeys.has(k));
|
|
8288
|
+
if (missingInVi.length > 0) {
|
|
8289
|
+
this.issues.push({
|
|
8290
|
+
type: "warning",
|
|
8291
|
+
rule: "Internationalization (i18n) Parity",
|
|
8292
|
+
file: viPath,
|
|
8293
|
+
message: `Vietnamese catalog is missing ${missingInVi.length} key(s) found in English: ${missingInVi.slice(0, 3).join(", ")}${missingInVi.length > 3 ? "..." : ""}`,
|
|
8294
|
+
suggestion: "Maintain 100% parity across all language catalogs."
|
|
8295
|
+
});
|
|
8296
|
+
}
|
|
8297
|
+
if (missingInEn.length > 0) {
|
|
8298
|
+
this.issues.push({
|
|
8299
|
+
type: "warning",
|
|
8300
|
+
rule: "Internationalization (i18n) Parity",
|
|
8301
|
+
file: enPath,
|
|
8302
|
+
message: `English catalog is missing ${missingInEn.length} key(s) found in Vietnamese: ${missingInEn.slice(0, 3).join(", ")}${missingInEn.length > 3 ? "..." : ""}`,
|
|
8303
|
+
suggestion: "Maintain 100% parity across all language catalogs."
|
|
8304
|
+
});
|
|
8305
|
+
}
|
|
8306
|
+
if (missingInVi.length === 0 && missingInEn.length === 0) {
|
|
8307
|
+
this.passedCount++;
|
|
8308
|
+
}
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
}
|
|
8312
|
+
extractLangKeys(content) {
|
|
8313
|
+
const keys = /* @__PURE__ */ new Set();
|
|
8314
|
+
const matches = content.matchAll(/\$lang\[['"]([^'"]+)['"]\]/g);
|
|
8315
|
+
for (const match of matches) {
|
|
8316
|
+
keys.add(match[1]);
|
|
8317
|
+
}
|
|
8318
|
+
return keys;
|
|
8319
|
+
}
|
|
8320
|
+
async auditEmojis(files) {
|
|
8321
|
+
const codeFiles = files.filter((f) => f.endsWith(".php") || f.endsWith(".js") || f.endsWith(".css"));
|
|
8322
|
+
const emojiRegex = /[\u{1F300}-\u{1F9FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]/u;
|
|
8323
|
+
for (const file of codeFiles) {
|
|
8324
|
+
const content = await FileSystemUtils.readFile(file);
|
|
8325
|
+
const lines = content.split("\n");
|
|
8326
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8327
|
+
if (emojiRegex.test(lines[i])) {
|
|
8328
|
+
this.issues.push({
|
|
8329
|
+
type: "info",
|
|
8330
|
+
rule: "Enterprise Typography & Zero-Emoji",
|
|
8331
|
+
file,
|
|
8332
|
+
line: i + 1,
|
|
8333
|
+
message: `Found Unicode emoji in enterprise source code or comment.`,
|
|
8334
|
+
suggestion: "Remove emojis to maintain clean, enterprise-grade typography."
|
|
8335
|
+
});
|
|
8336
|
+
}
|
|
8337
|
+
}
|
|
8338
|
+
this.passedCount++;
|
|
8339
|
+
}
|
|
8340
|
+
}
|
|
8341
|
+
async auditPackagingRules(rootDir) {
|
|
8342
|
+
const devFiles = ["package.json", "webpack.config.js"];
|
|
8343
|
+
const hasDevFiles = await Promise.all(devFiles.map((f) => FileSystemUtils.fileExists(path22.join(rootDir, f))));
|
|
8344
|
+
const hasDeployScript = await FileSystemUtils.fileExists(path22.join(rootDir, "deploy.ps1"));
|
|
8345
|
+
if (hasDevFiles.some(Boolean) && !hasDeployScript) {
|
|
8346
|
+
this.issues.push({
|
|
8347
|
+
type: "warning",
|
|
8348
|
+
rule: "Clean Release Packaging",
|
|
8349
|
+
file: rootDir,
|
|
8350
|
+
message: "Module contains build scripts (package.json/webpack) but lacks an automated packaging filter (deploy.ps1 or heraspec pack).",
|
|
8351
|
+
suggestion: "Ensure build scripts are strictly stripped from final release zip."
|
|
8352
|
+
});
|
|
8353
|
+
} else {
|
|
8354
|
+
this.passedCount++;
|
|
8355
|
+
}
|
|
8356
|
+
}
|
|
8357
|
+
printReport(targetPath, report, fix = false) {
|
|
8358
|
+
console.log("\n" + "\u2550".repeat(65));
|
|
8359
|
+
console.log(chalk15.bold(`\u{1F4CB} HeraSpec Code Quality & Security Audit Report`));
|
|
8360
|
+
console.log(`\u{1F4CD} Target: ${chalk15.gray(targetPath)}`);
|
|
8361
|
+
console.log(`\u{1F4E6} Type: ${chalk15.cyan(report.projectType)}`);
|
|
8362
|
+
console.log(`\u23F1 Time: ${chalk15.gray(report.durationMs + "ms")}`);
|
|
8363
|
+
console.log("\u2550".repeat(65) + "\n");
|
|
8364
|
+
if (report.issues.length === 0) {
|
|
8365
|
+
console.log(chalk15.green.bold("\u{1F389} 100% COMPLIANT! All quality, security & clean standards passed.\n"));
|
|
8366
|
+
return;
|
|
8367
|
+
}
|
|
8368
|
+
for (const issue of report.issues) {
|
|
8369
|
+
const relFile = path22.relative(targetPath, issue.file) || issue.file;
|
|
8370
|
+
const loc = issue.line ? `:${issue.line}` : "";
|
|
8371
|
+
const tag = issue.type === "error" ? chalk15.bgRed.black(" ERROR ") : issue.type === "warning" ? chalk15.bgYellow.black(" WARN ") : chalk15.bgCyan.black(" INFO ");
|
|
8372
|
+
console.log(`${tag} ${chalk15.bold(issue.rule)}`);
|
|
8373
|
+
console.log(` ${chalk15.gray(relFile + loc)}: ${issue.message}`);
|
|
8374
|
+
if (issue.suggestion) {
|
|
8375
|
+
console.log(` ${chalk15.cyan("\u{1F4A1} Suggestion:")} ${issue.suggestion}`);
|
|
8376
|
+
}
|
|
8377
|
+
console.log();
|
|
8378
|
+
}
|
|
8379
|
+
console.log("\u2500".repeat(65));
|
|
8380
|
+
console.log(
|
|
8381
|
+
`Summary: ${chalk15.green(`${report.passed} checks passed`)}, ${report.warnings > 0 ? chalk15.yellow(`${report.warnings} warnings`) : "0 warnings"}, ${report.errors > 0 ? chalk15.red.bold(`${report.errors} errors`) : chalk15.green("0 errors")}`
|
|
8382
|
+
);
|
|
8383
|
+
if (report.errors > 0) {
|
|
8384
|
+
console.log(chalk15.red("\n\u274C Codebase failed critical quality/security checks. Please resolve errors before publishing."));
|
|
8385
|
+
if (!fix) {
|
|
8386
|
+
console.log(chalk15.gray('Tip: Run "heraspec audit --fix" to automatically remediate fixable issues.\n'));
|
|
8387
|
+
}
|
|
8388
|
+
} else {
|
|
8389
|
+
console.log(chalk15.green.bold("\n\u2714 Ready for production release!\n"));
|
|
8390
|
+
}
|
|
8391
|
+
}
|
|
8392
|
+
};
|
|
8393
|
+
|
|
8394
|
+
// src/commands/create.ts
|
|
8395
|
+
init_file_system();
|
|
8396
|
+
init_skill();
|
|
8397
|
+
import path23 from "path";
|
|
8398
|
+
import chalk16 from "chalk";
|
|
8399
|
+
import ora13 from "ora";
|
|
8400
|
+
var CreateCommand = class {
|
|
8401
|
+
async execute(name, options) {
|
|
8402
|
+
if (!name) {
|
|
8403
|
+
console.error(chalk16.red("Error: Please specify a name"));
|
|
8404
|
+
console.log("Usage: heraspec create <name> --type <perfex-module|wordpress-plugin|wordpress-theme>");
|
|
8405
|
+
process.exitCode = 1;
|
|
8406
|
+
return;
|
|
8407
|
+
}
|
|
8408
|
+
const projectType = options.type || "perfex-module";
|
|
8409
|
+
const isChannel = projectType === "content-channel";
|
|
8410
|
+
const cleanName = isChannel ? name.replace(/^\[?(Kênh|Channel)\]?\s*[:-]?\s*/i, "").replace(/[^a-zA-Z0-9_-]/g, "-") : name.toLowerCase().replace(/[^a-z0-9_-]/g, "_");
|
|
8411
|
+
const pascalName = cleanName.split(/[_-]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
8412
|
+
const upperName = cleanName.toUpperCase().replace(/-/g, "_");
|
|
8413
|
+
const friendlyTitle = options.title || (isChannel ? cleanName.replace(/-/g, " ") : pascalName);
|
|
8414
|
+
const description = options.description || (isChannel ? `K\xEAnh n\u1ED9i dung \u0111a n\u1EC1n t\u1EA3ng ${friendlyTitle}` : `${friendlyTitle} component`);
|
|
8415
|
+
let defaultSubdir = cleanName;
|
|
8416
|
+
if (projectType.includes("perfex")) {
|
|
8417
|
+
defaultSubdir = path23.join("modules", cleanName);
|
|
8418
|
+
} else if (isChannel) {
|
|
8419
|
+
defaultSubdir = cleanName;
|
|
8420
|
+
}
|
|
8421
|
+
const targetDir = options.out ? path23.resolve(options.out, cleanName) : path23.resolve(process.cwd(), defaultSubdir);
|
|
8422
|
+
const spinner = ora13(`Scaffolding ${chalk16.cyan(projectType)} "${cleanName}"...`).start();
|
|
8423
|
+
try {
|
|
8424
|
+
if (await FileSystemUtils.fileExists(targetDir)) {
|
|
8425
|
+
spinner.fail(`Target directory already exists: ${targetDir}`);
|
|
8426
|
+
process.exitCode = 1;
|
|
8427
|
+
return;
|
|
8428
|
+
}
|
|
8429
|
+
await FileSystemUtils.createDirectory(targetDir);
|
|
8430
|
+
if (projectType === "perfex-module") {
|
|
8431
|
+
await this.scaffoldPerfexModule(targetDir, {
|
|
8432
|
+
cleanName,
|
|
8433
|
+
pascalName,
|
|
8434
|
+
upperName,
|
|
8435
|
+
friendlyTitle,
|
|
8436
|
+
description
|
|
8437
|
+
});
|
|
8438
|
+
} else if (projectType === "wordpress-plugin") {
|
|
8439
|
+
await this.scaffoldWordPressPlugin(targetDir, {
|
|
8440
|
+
cleanName,
|
|
8441
|
+
pascalName,
|
|
8442
|
+
upperName,
|
|
8443
|
+
friendlyTitle,
|
|
8444
|
+
description
|
|
8445
|
+
});
|
|
8446
|
+
} else if (projectType === "content-channel") {
|
|
8447
|
+
await this.scaffoldContentChannel(targetDir, {
|
|
8448
|
+
cleanName,
|
|
8449
|
+
pascalName,
|
|
8450
|
+
upperName,
|
|
8451
|
+
friendlyTitle,
|
|
8452
|
+
description
|
|
8453
|
+
});
|
|
8454
|
+
} else {
|
|
8455
|
+
spinner.fail(`Scaffolding template for "${projectType}" is not yet supported.`);
|
|
8456
|
+
process.exitCode = 1;
|
|
8457
|
+
return;
|
|
8458
|
+
}
|
|
8459
|
+
if (projectType !== "content-channel") {
|
|
8460
|
+
spinner.text = "Initializing HeraSpec and installing skill suite...";
|
|
8461
|
+
const initCommand = new InitCommand();
|
|
8462
|
+
await initCommand.execute(targetDir);
|
|
8463
|
+
const skillCommand = new SkillCommand();
|
|
8464
|
+
if (projectType === "perfex-module") {
|
|
8465
|
+
await skillCommand.add("perfex-module", void 0, targetDir);
|
|
8466
|
+
} else if (projectType === "wordpress-plugin") {
|
|
8467
|
+
await skillCommand.add("plugin-standard", "wordpress", targetDir);
|
|
8468
|
+
}
|
|
8469
|
+
}
|
|
8470
|
+
spinner.succeed(chalk16.green(`Successfully created ${projectType} "${cleanName}"!`));
|
|
8471
|
+
console.log(`
|
|
8472
|
+
\u{1F4CD} Location: ${chalk16.gray(targetDir)}`);
|
|
8473
|
+
console.log("\n\u{1F680} Next steps:");
|
|
8474
|
+
console.log(chalk16.cyan(` cd ${path23.relative(process.cwd(), targetDir) || "."}`));
|
|
8475
|
+
if (projectType === "content-channel") {
|
|
8476
|
+
console.log(chalk16.gray(" # Write first script with: heraspec skill content-scripting"));
|
|
8477
|
+
const hasExportHere = await FileSystemUtils.fileExists(path23.resolve(process.cwd(), "export_vault_json.py"));
|
|
8478
|
+
const hasExportInFb = await FileSystemUtils.fileExists(path23.resolve(process.cwd(), "Facebook", "export_vault_json.py"));
|
|
8479
|
+
const exportCmd = hasExportHere ? "python export_vault_json.py" : hasExportInFb ? "python Facebook/export_vault_json.py" : "python export_vault_json.py";
|
|
8480
|
+
console.log(chalk16.gray(` # Export vault bundle with: ${exportCmd}
|
|
8481
|
+
`));
|
|
8482
|
+
} else {
|
|
8483
|
+
console.log(chalk16.gray(" heraspec audit # Run code quality & security checks"));
|
|
8484
|
+
console.log(chalk16.gray(" heraspec pack # Package for production release\n"));
|
|
8485
|
+
}
|
|
8486
|
+
} catch (error) {
|
|
8487
|
+
spinner.fail(`Failed to create project: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
8488
|
+
process.exitCode = 1;
|
|
8489
|
+
}
|
|
8490
|
+
}
|
|
8491
|
+
async scaffoldPerfexModule(targetDir, meta) {
|
|
8492
|
+
const dirs = [
|
|
8493
|
+
"controllers",
|
|
8494
|
+
"models",
|
|
8495
|
+
"helpers",
|
|
8496
|
+
"libraries",
|
|
8497
|
+
"views/admin",
|
|
8498
|
+
"language/english",
|
|
8499
|
+
"language/vietnamese",
|
|
8500
|
+
"assets/css/admin",
|
|
8501
|
+
"assets/js/admin",
|
|
8502
|
+
"assets/js/lib",
|
|
8503
|
+
"assets/css/lib",
|
|
8504
|
+
"dist/assets/css",
|
|
8505
|
+
"dist/assets/js",
|
|
8506
|
+
"tests",
|
|
8507
|
+
"documentations"
|
|
8508
|
+
];
|
|
8509
|
+
for (const d of dirs) {
|
|
8510
|
+
await FileSystemUtils.createDirectory(path23.join(targetDir, d));
|
|
8511
|
+
}
|
|
8512
|
+
const { cleanName, pascalName, upperName, friendlyTitle, description } = meta;
|
|
8513
|
+
const mainBootstrap = `<?php
|
|
8514
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8515
|
+
|
|
8516
|
+
/*
|
|
8517
|
+
Module Name: ${friendlyTitle}
|
|
8518
|
+
Description: ${description}
|
|
8519
|
+
Version: 1.0.0
|
|
8520
|
+
Requires at least: 2.9.*
|
|
8521
|
+
Author: PolyXGO
|
|
8522
|
+
Author URI: https://codecanyon.net/user/polyxgo
|
|
8523
|
+
*/
|
|
8524
|
+
|
|
8525
|
+
define('${upperName}_MODULE_NAME', '${cleanName}');
|
|
8526
|
+
define('${upperName}_VERSION', '1.0.0');
|
|
8527
|
+
|
|
8528
|
+
register_activation_hook(${upperName}_MODULE_NAME, '${cleanName}_activation_hook');
|
|
8529
|
+
register_deactivation_hook(${upperName}_MODULE_NAME, '${cleanName}_deactivation_hook');
|
|
8530
|
+
register_uninstall_hook(${upperName}_MODULE_NAME, '${cleanName}_uninstall_hook');
|
|
8531
|
+
|
|
8532
|
+
function ${cleanName}_activation_hook()
|
|
8533
|
+
{
|
|
8534
|
+
$CI = &get_instance();
|
|
8535
|
+
require_once(__DIR__ . '/install.php');
|
|
8536
|
+
}
|
|
8537
|
+
|
|
8538
|
+
function ${cleanName}_deactivation_hook()
|
|
8539
|
+
{
|
|
8540
|
+
}
|
|
8541
|
+
|
|
8542
|
+
function ${cleanName}_uninstall_hook()
|
|
8543
|
+
{
|
|
8544
|
+
require_once(__DIR__ . '/uninstall.php');
|
|
8545
|
+
}
|
|
8546
|
+
|
|
8547
|
+
register_language_files(${upperName}_MODULE_NAME, [${upperName}_MODULE_NAME]);
|
|
8548
|
+
|
|
8549
|
+
$CI = &get_instance();
|
|
8550
|
+
$CI->load->helper(${upperName}_MODULE_NAME . '/${cleanName}');
|
|
8551
|
+
|
|
8552
|
+
hooks()->add_action('admin_init', '${cleanName}_init_menu_items');
|
|
8553
|
+
|
|
8554
|
+
function ${cleanName}_init_menu_items()
|
|
8555
|
+
{
|
|
8556
|
+
$CI = &get_instance();
|
|
8557
|
+
if (has_permission('${cleanName}', '', 'view')) {
|
|
8558
|
+
$CI->app_menu->add_sidebar_menu_item('${cleanName}-menu', [
|
|
8559
|
+
'name' => _l('${cleanName}_menu_title'),
|
|
8560
|
+
'href' => admin_url('${cleanName}'),
|
|
8561
|
+
'icon' => 'fa-solid fa-cube',
|
|
8562
|
+
'position' => 30,
|
|
8563
|
+
]);
|
|
8564
|
+
}
|
|
8565
|
+
}
|
|
8566
|
+
|
|
8567
|
+
hooks()->add_action('app_admin_head', '${cleanName}_enqueue_admin_head');
|
|
8568
|
+
hooks()->add_action('app_admin_footer', '${cleanName}_enqueue_admin_footer');
|
|
8569
|
+
|
|
8570
|
+
function ${cleanName}_enqueue_admin_head()
|
|
8571
|
+
{
|
|
8572
|
+
$config = [
|
|
8573
|
+
'moduleName' => ${upperName}_MODULE_NAME,
|
|
8574
|
+
'version' => ${upperName}_VERSION,
|
|
8575
|
+
'adminUrl' => admin_url('${cleanName}/'),
|
|
8576
|
+
'csrfToken' => get_instance()->security->get_csrf_hash(),
|
|
8577
|
+
];
|
|
8578
|
+
$lang = [
|
|
8579
|
+
'confirmDelete' => _l('${cleanName}_confirm_delete'),
|
|
8580
|
+
'saveSuccess' => _l('${cleanName}_saved_successfully'),
|
|
8581
|
+
];
|
|
8582
|
+
|
|
8583
|
+
echo '<script>' . PHP_EOL;
|
|
8584
|
+
echo 'window.' . '${upperName}_CONFIG = ' . json_encode($config) . ';' . PHP_EOL;
|
|
8585
|
+
echo 'window.' . '${upperName}_LANG = ' . json_encode($lang) . ';' . PHP_EOL;
|
|
8586
|
+
echo '</script>' . PHP_EOL;
|
|
8587
|
+
|
|
8588
|
+
echo ${cleanName}_helper::render_module_css('admin/${cleanName}_admin');
|
|
8589
|
+
}
|
|
8590
|
+
|
|
8591
|
+
function ${cleanName}_enqueue_admin_footer()
|
|
8592
|
+
{
|
|
8593
|
+
echo ${cleanName}_helper::render_module_js('admin/${cleanName}_admin');
|
|
8594
|
+
}
|
|
8595
|
+
`;
|
|
8596
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, `${cleanName}.php`), mainBootstrap);
|
|
8597
|
+
const installPhp = `<?php
|
|
8598
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8599
|
+
|
|
8600
|
+
$CI = &get_instance();
|
|
8601
|
+
|
|
8602
|
+
if (!$CI->db->table_exists(db_prefix() . '${cleanName}_items')) {
|
|
8603
|
+
$CI->db->query('CREATE TABLE \`' . db_prefix() . '${cleanName}_items\` (
|
|
8604
|
+
\`id\` INT(11) NOT NULL AUTO_INCREMENT,
|
|
8605
|
+
\`rel_type\` VARCHAR(40) NOT NULL,
|
|
8606
|
+
\`rel_id\` INT(11) NOT NULL,
|
|
8607
|
+
\`title\` VARCHAR(255) NOT NULL,
|
|
8608
|
+
\`description\` TEXT NULL,
|
|
8609
|
+
\`status\` TINYINT(1) NOT NULL DEFAULT 1,
|
|
8610
|
+
\`date_created\` DATETIME NOT NULL,
|
|
8611
|
+
\`created_by\` INT(11) NOT NULL,
|
|
8612
|
+
PRIMARY KEY (\`id\`),
|
|
8613
|
+
KEY \`idx_rel_lookup\` (\`rel_type\`, \`rel_id\`),
|
|
8614
|
+
KEY \`idx_status_created\` (\`status\`, \`date_created\`)
|
|
8615
|
+
) ENGINE=InnoDB DEFAULT CHARSET=' . $CI->db->char_set . ';');
|
|
8616
|
+
}
|
|
8617
|
+
|
|
8618
|
+
if (empty(get_option('${cleanName}_enabled'))) {
|
|
8619
|
+
add_option('${cleanName}_enabled', '1', 1);
|
|
8620
|
+
}
|
|
8621
|
+
`;
|
|
8622
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "install.php"), installPhp);
|
|
8623
|
+
const uninstallPhp = `<?php
|
|
8624
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8625
|
+
|
|
8626
|
+
$CI = &get_instance();
|
|
8627
|
+
delete_option('${cleanName}_enabled');
|
|
8628
|
+
`;
|
|
8629
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "uninstall.php"), uninstallPhp);
|
|
8630
|
+
const helperPhp = `<?php
|
|
8631
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8632
|
+
|
|
8633
|
+
class ${cleanName}_helper
|
|
8634
|
+
{
|
|
8635
|
+
public static function get_file_timestamp($relative_path)
|
|
8636
|
+
{
|
|
8637
|
+
$full_path = rtrim(FCPATH, '/\\\\') . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $relative_path);
|
|
8638
|
+
return file_exists($full_path) ? filemtime($full_path) : '1.0.0';
|
|
8639
|
+
}
|
|
8640
|
+
|
|
8641
|
+
public static function render_module_js($subpath)
|
|
8642
|
+
{
|
|
8643
|
+
$rel_dist = 'dist/assets/js/' . $subpath . '.min.js';
|
|
8644
|
+
$rel_src = 'assets/js/' . $subpath . '.js';
|
|
8645
|
+
|
|
8646
|
+
$full_dist = rtrim(FCPATH, '/\\\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . ${upperName}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_dist);
|
|
8647
|
+
$chosen = file_exists($full_dist) ? $rel_dist : $rel_src;
|
|
8648
|
+
$path = 'modules/' . ${upperName}_MODULE_NAME . '/' . $chosen;
|
|
8649
|
+
$url = module_dir_url(${upperName}_MODULE_NAME, $chosen);
|
|
8650
|
+
$v = self::get_file_timestamp($path);
|
|
8651
|
+
|
|
8652
|
+
return '<script src="' . $url . '?v=' . $v . '"></script>' . PHP_EOL;
|
|
8653
|
+
}
|
|
8654
|
+
|
|
8655
|
+
public static function render_module_css($subpath)
|
|
8656
|
+
{
|
|
8657
|
+
$rel_dist = 'dist/assets/css/' . $subpath . '.min.css';
|
|
8658
|
+
$rel_src = 'assets/css/' . $subpath . '.css';
|
|
8659
|
+
|
|
8660
|
+
$full_dist = rtrim(FCPATH, '/\\\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . ${upperName}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_dist);
|
|
8661
|
+
$chosen = file_exists($full_dist) ? $rel_dist : $rel_src;
|
|
8662
|
+
$path = 'modules/' . ${upperName}_MODULE_NAME . '/' . $chosen;
|
|
8663
|
+
$url = module_dir_url(${upperName}_MODULE_NAME, $chosen);
|
|
8664
|
+
$v = self::get_file_timestamp($path);
|
|
8665
|
+
|
|
8666
|
+
return '<link rel="stylesheet" href="' . $url . '?v=' . $v . '">' . PHP_EOL;
|
|
8667
|
+
}
|
|
8668
|
+
}
|
|
8669
|
+
`;
|
|
8670
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "helpers", `${cleanName}_helper.php`), helperPhp);
|
|
8671
|
+
const adminController = `<?php
|
|
8672
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8673
|
+
|
|
8674
|
+
class ${pascalName} extends AdminController
|
|
8675
|
+
{
|
|
8676
|
+
public function __construct()
|
|
8677
|
+
{
|
|
8678
|
+
parent::__construct();
|
|
8679
|
+
$this->load->model('${cleanName}/${cleanName}_model');
|
|
8680
|
+
}
|
|
8681
|
+
|
|
8682
|
+
public function index()
|
|
8683
|
+
{
|
|
8684
|
+
if (!has_permission('${cleanName}', '', 'view')) {
|
|
8685
|
+
access_denied('${cleanName}');
|
|
8686
|
+
}
|
|
8687
|
+
|
|
8688
|
+
$data['title'] = _l('${cleanName}_management');
|
|
8689
|
+
$data['items'] = $this->${cleanName}_model->get_all();
|
|
8690
|
+
|
|
8691
|
+
$this->load->view('${cleanName}/admin/manage', $data);
|
|
8692
|
+
}
|
|
8693
|
+
}
|
|
8694
|
+
`;
|
|
8695
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "controllers", `${pascalName}.php`), adminController);
|
|
8696
|
+
const apiController = `<?php
|
|
8697
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8698
|
+
|
|
8699
|
+
class Api extends AdminController
|
|
8700
|
+
{
|
|
8701
|
+
public function __construct()
|
|
8702
|
+
{
|
|
8703
|
+
parent::__construct();
|
|
8704
|
+
$this->load->model('${cleanName}/${cleanName}_model');
|
|
8705
|
+
}
|
|
8706
|
+
|
|
8707
|
+
public function search()
|
|
8708
|
+
{
|
|
8709
|
+
session_write_close();
|
|
8710
|
+
|
|
8711
|
+
if (!has_permission('${cleanName}', '', 'view')) {
|
|
8712
|
+
ajax_access_denied();
|
|
8713
|
+
}
|
|
8714
|
+
|
|
8715
|
+
$query = $this->input->get('q', true);
|
|
8716
|
+
$results = $this->${cleanName}_model->search($query);
|
|
8717
|
+
|
|
8718
|
+
echo json_encode(['success' => true, 'data' => $results]);
|
|
8719
|
+
}
|
|
8720
|
+
}
|
|
8721
|
+
`;
|
|
8722
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "controllers", "Api.php"), apiController);
|
|
8723
|
+
const modelPhp = `<?php
|
|
8724
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8725
|
+
|
|
8726
|
+
class ${cleanName}_model extends App_Model
|
|
8727
|
+
{
|
|
8728
|
+
protected $table;
|
|
8729
|
+
|
|
8730
|
+
public function __construct()
|
|
8731
|
+
{
|
|
8732
|
+
parent::__construct();
|
|
8733
|
+
$this->table = db_prefix() . '${cleanName}_items';
|
|
8734
|
+
}
|
|
8735
|
+
|
|
8736
|
+
public function get_all()
|
|
8737
|
+
{
|
|
8738
|
+
$this->db->order_by('date_created', 'DESC');
|
|
8739
|
+
return $this->db->get($this->table)->result_array();
|
|
8740
|
+
}
|
|
8741
|
+
|
|
8742
|
+
public function search($query, $limit = 20)
|
|
8743
|
+
{
|
|
8744
|
+
$this->db->select('id, rel_type, rel_id, title, status');
|
|
8745
|
+
$this->db->from($this->table);
|
|
8746
|
+
if (!empty($query)) {
|
|
8747
|
+
$this->db->like('title', $query);
|
|
8748
|
+
}
|
|
8749
|
+
$this->db->where('status', 1);
|
|
8750
|
+
$this->db->limit($limit);
|
|
8751
|
+
return $this->db->get()->result_array();
|
|
8752
|
+
}
|
|
8753
|
+
}
|
|
8754
|
+
`;
|
|
8755
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "models", `${cleanName}_model.php`), modelPhp);
|
|
8756
|
+
const enLang = `<?php
|
|
8757
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8758
|
+
|
|
8759
|
+
$lang['${cleanName}_menu_title'] = '${friendlyTitle}';
|
|
8760
|
+
$lang['${cleanName}_management'] = '${friendlyTitle} Management';
|
|
8761
|
+
$lang['${cleanName}_confirm_delete'] = 'Are you sure you want to delete this item?';
|
|
8762
|
+
$lang['${cleanName}_saved_successfully'] = 'Saved successfully.';
|
|
8763
|
+
`;
|
|
8764
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "language", "english", `${cleanName}_lang.php`), enLang);
|
|
8765
|
+
const viLang = `<?php
|
|
8766
|
+
defined('BASEPATH') or exit('No direct script access allowed');
|
|
8767
|
+
|
|
8768
|
+
$lang['${cleanName}_menu_title'] = '${friendlyTitle}';
|
|
8769
|
+
$lang['${cleanName}_management'] = 'Qu\u1EA3n l\xFD ${friendlyTitle}';
|
|
8770
|
+
$lang['${cleanName}_confirm_delete'] = 'B\u1EA1n c\xF3 ch\u1EAFc ch\u1EAFn mu\u1ED1n x\xF3a m\u1EE5c n\xE0y?';
|
|
8771
|
+
$lang['${cleanName}_saved_successfully'] = 'L\u01B0u th\xE0nh c\xF4ng.';
|
|
8772
|
+
`;
|
|
8773
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "language", "vietnamese", `${cleanName}_lang.php`), viLang);
|
|
8774
|
+
const adminView = `<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
|
|
8775
|
+
<?php init_head(); ?>
|
|
8776
|
+
<div id="wrapper">
|
|
8777
|
+
<div class="content">
|
|
8778
|
+
<div class="row">
|
|
8779
|
+
<div class="col-md-12">
|
|
8780
|
+
<div class="panel_s">
|
|
8781
|
+
<div class="panel-body">
|
|
8782
|
+
<h4 class="no-margin font-bold"><?php echo html_escape($title); ?></h4>
|
|
8783
|
+
<hr class="hr-panel-heading" />
|
|
8784
|
+
<div class="${cleanName}-container" data-module="${cleanName}">
|
|
8785
|
+
<p><?php echo _l('${cleanName}_management'); ?></p>
|
|
8786
|
+
</div>
|
|
8787
|
+
</div>
|
|
8788
|
+
</div>
|
|
8789
|
+
</div>
|
|
8790
|
+
</div>
|
|
8791
|
+
</div>
|
|
8792
|
+
</div>
|
|
8793
|
+
<?php init_tail(); ?>
|
|
8794
|
+
`;
|
|
8795
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "views", "admin", "manage.php"), adminView);
|
|
8796
|
+
const adminJs = `window.addEventListener('load', function () {
|
|
8797
|
+
(function ($) {
|
|
8798
|
+
'use strict';
|
|
8799
|
+
// ${friendlyTitle} Admin Logic
|
|
8800
|
+
})(typeof jQuery !== 'undefined' ? jQuery : window.$);
|
|
8801
|
+
});
|
|
8802
|
+
`;
|
|
8803
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "assets", "js", "admin", `${cleanName}_admin.js`), adminJs);
|
|
8804
|
+
const adminCss = `.${cleanName}-container {
|
|
8805
|
+
padding: 10px 0;
|
|
8806
|
+
}
|
|
8807
|
+
`;
|
|
8808
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "assets", "css", "admin", `${cleanName}_admin.css`), adminCss);
|
|
8809
|
+
const testPhp = `<?php
|
|
8810
|
+
class Test_${pascalName}
|
|
8811
|
+
{
|
|
8812
|
+
public function run()
|
|
8813
|
+
{
|
|
8814
|
+
echo "Running automated quality tests for ${pascalName}...\\n";
|
|
8815
|
+
$files = glob(__DIR__ . '/../*.php');
|
|
8816
|
+
$passed = 0;
|
|
8817
|
+
foreach ($files as $file) {
|
|
8818
|
+
$content = file_get_contents($file);
|
|
8819
|
+
assert(strpos($content, "defined('BASEPATH')") !== false, basename($file) . " missing BASEPATH guard.");
|
|
8820
|
+
$passed++;
|
|
8821
|
+
}
|
|
8822
|
+
echo "All {$passed} checks passed 100%!\\n";
|
|
8823
|
+
}
|
|
8824
|
+
}
|
|
8825
|
+
$test = new Test_${pascalName}();
|
|
8826
|
+
$test->run();
|
|
8827
|
+
`;
|
|
8828
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "tests", `Test_${pascalName}.php`), testPhp);
|
|
8829
|
+
}
|
|
8830
|
+
async scaffoldWordPressPlugin(targetDir, meta) {
|
|
8831
|
+
const { cleanName, pascalName, upperName, friendlyTitle, description } = meta;
|
|
8832
|
+
const dirs = ["includes", "admin", "public", "languages", "assets/css", "assets/js"];
|
|
8833
|
+
for (const d of dirs) {
|
|
8834
|
+
await FileSystemUtils.createDirectory(path23.join(targetDir, d));
|
|
8835
|
+
}
|
|
8836
|
+
const mainPlugin = `<?php
|
|
8837
|
+
/**
|
|
8838
|
+
* Plugin Name: ${friendlyTitle}
|
|
8839
|
+
* Description: ${description}
|
|
8840
|
+
* Version: 1.0.0
|
|
8841
|
+
* Author: PolyXGO
|
|
8842
|
+
* License: GPL v2 or later
|
|
8843
|
+
* Text Domain: ${cleanName}
|
|
8844
|
+
* Domain Path: /languages
|
|
8845
|
+
*/
|
|
8846
|
+
|
|
8847
|
+
defined('ABSPATH') or exit;
|
|
8848
|
+
|
|
8849
|
+
define('${upperName}_VERSION', '1.0.0');
|
|
8850
|
+
define('${upperName}_PATH', plugin_dir_path(__FILE__));
|
|
8851
|
+
define('${upperName}_URL', plugin_dir_url(__FILE__));
|
|
8852
|
+
|
|
8853
|
+
register_activation_hook(__FILE__, '${cleanName}_activate');
|
|
8854
|
+
register_deactivation_hook(__FILE__, '${cleanName}_deactivate');
|
|
8855
|
+
|
|
8856
|
+
function ${cleanName}_activate() {
|
|
8857
|
+
}
|
|
8858
|
+
|
|
8859
|
+
function ${cleanName}_deactivate() {
|
|
8860
|
+
}
|
|
8861
|
+
`;
|
|
8862
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, `${cleanName}.php`), mainPlugin);
|
|
8863
|
+
const uninstallPhp = `<?php
|
|
8864
|
+
defined('WP_UNINSTALL_PLUGIN') or exit;
|
|
8865
|
+
`;
|
|
8866
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "uninstall.php"), uninstallPhp);
|
|
8867
|
+
}
|
|
8868
|
+
async scaffoldContentChannel(targetDir, meta) {
|
|
8869
|
+
const { friendlyTitle, description } = meta;
|
|
8870
|
+
const pureBrandName = friendlyTitle.replace(/^\[?(Kênh|Channel)\]?\s*[:-]?\s*/i, "").trim();
|
|
8871
|
+
const dirs = ["posts", "prompts", "affiliate"];
|
|
8872
|
+
for (const d of dirs) {
|
|
8873
|
+
await FileSystemUtils.createDirectory(path23.join(targetDir, d));
|
|
8874
|
+
}
|
|
8875
|
+
const planMd = `# K\u1EBE HO\u1EA0CH PH\xC1T TRI\u1EC2N K\xCANH: ${pureBrandName}
|
|
8876
|
+
|
|
8877
|
+
## 1. \u0110\u1ECANH V\u1ECA TH\u01AF\u01A0NG HI\u1EC6U & KH\xC1N GI\u1EA2
|
|
8878
|
+
* **T\xEAn k\xEAnh thu\u1EA7n t\xFAy**: ${pureBrandName}
|
|
8879
|
+
* **Slogan**: ${description}
|
|
8880
|
+
* **M\xE0u s\u1EAFc nh\u1EADn di\u1EC7n**: #10b981 | **Icon Lucide**: Sparkles
|
|
8881
|
+
* **Kh\xE1n gi\u1EA3 m\u1EE5c ti\xEAu**: 20 - 45 tu\u1ED5i
|
|
8882
|
+
* **Khung gi\u1EDD \u0111\u0103ng v\xE0ng**: 06:30 s\xE1ng v\xE0 20:30 t\u1ED1i
|
|
8883
|
+
|
|
8884
|
+
---
|
|
8885
|
+
|
|
8886
|
+
## 2. MA TR\u1EACN 5 TR\u1EE4 C\u1ED8T N\u1ED8I DUNG
|
|
8887
|
+
1. **Tr\u1EE5 c\u1ED9t 1 (C\xE2u chuy\u1EC7n c\u1ED1t l\xF5i)**: 30% th\u1EDDi l\u01B0\u1EE3ng - K\u1EC3 chuy\u1EC7n truy\u1EC1n c\u1EA3m h\u1EE9ng, x\xE2y d\u1EF1ng l\xF2ng tin
|
|
8888
|
+
2. **Tr\u1EE5 c\u1ED9t 2 (Ch\u1EA1m n\u1ED7i \u0111au & Hook th\u1EF1c t\u1EBF)**: 25% th\u1EDDi l\u01B0\u1EE3ng - Video ng\u1EAFn Reels gi\u1EA3i quy\u1EBFt v\u01B0\u1EDBng m\u1EAFc th\u01B0\u1EDDng g\u1EB7p
|
|
8889
|
+
3. **Tr\u1EE5 c\u1ED9t 3 (Ki\u1EBFn th\u1EE9c & Ch\u1EC9 d\u1EABn th\u1EF1c h\xE0nh)**: 20% th\u1EDDi l\u01B0\u1EE3ng - H\u01B0\u1EDBng d\u1EABn chi ti\u1EBFt, th\u1EF1c t\u1EBF, d\u1EC5 \xE1p d\u1EE5ng
|
|
8890
|
+
4. **Tr\u1EE5 c\u1ED9t 4 (T\u01B0\u01A1ng t\xE1c & Chia s\u1EBB c\u1ED9ng \u0111\u1ED3ng)**: 15% th\u1EDDi l\u01B0\u1EE3ng - \u0110\u1EB7t c\xE2u h\u1ECFi, th\u1EA3o lu\u1EADn, g\xF3c nh\xECn chi\xEAm nghi\u1EC7m
|
|
8891
|
+
5. **Tr\u1EE5 c\u1ED9t 5 (Ti\u1EBFp th\u1ECB & S\u1EA3n ph\u1EA9m t\u1EF1 nhi\xEAn)**: 10% th\u1EDDi l\u01B0\u1EE3ng - Gi\u1EDBi thi\u1EC7u s\u1EA3n ph\u1EA9m h\u1EEFu \xEDch, soft-sell
|
|
8892
|
+
|
|
8893
|
+
---
|
|
8894
|
+
|
|
8895
|
+
## 3. L\u1ED8 TR\xCCNH 14 NG\xC0Y COLD START (KH\u1EDEI \u0110\u1ED8NG K\xCANH)
|
|
8896
|
+
* **T\u1EF7 l\u1EC7**: 70% Reels (9:16) + 30% Video In-stream (16:9)
|
|
8897
|
+
* **Tu\u1EA7n 1 (L\xE0m \u1EA5m t\u1EC7p kh\xE1n gi\u1EA3)**: 1-2 Reels/ng\xE0y, 1 video d\xE0i m\u1ED7i 2 ng\xE0y
|
|
8898
|
+
* **Tu\u1EA7n 2 (T\u0103ng t\u1ED1c gi\u1EEF ch\xE2n)**: 2 Reels/ng\xE0y + 1 video d\xE0i/ng\xE0y
|
|
8899
|
+
|
|
8900
|
+
---
|
|
8901
|
+
|
|
8902
|
+
## 4. MA TR\u1EACN DOANH THU & M\u1EE4C TI\xCAU $100 RPM
|
|
8903
|
+
* M\u1EE5c ti\xEAu ban \u0111\u1EA7u: \u0110\u1EA1t 10.000 ng\u01B0\u1EDDi theo d\xF5i v\xE0 \u0111\u1EE7 \u0111i\u1EC1u ki\u1EC7n ki\u1EBFm ti\u1EC1n In-stream
|
|
8904
|
+
* T\u1EF7 l\u1EC7 RPM k\u1EF3 v\u1ECDng: $0.02 - $0.05 / 1.000 l\u01B0\u1EE3t xem h\u1EE3p l\u1EC7
|
|
8905
|
+
`;
|
|
8906
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "plan.md"), planMd);
|
|
8907
|
+
const postsReadme = `# DANH S\xC1CH B\xC0I VI\u1EBET & K\u1ECACH B\u1EA2N K\xCANH: ${pureBrandName}
|
|
8908
|
+
|
|
8909
|
+
| Index | Ti\xEAu \u0110\u1EC1 B\xE0i Vi\u1EBFt | Tr\u1EE5 C\u1ED9t | \u0110\u1ECBnh D\u1EA1ng | Tr\u1EA1ng Th\xE1i | Ng\xE0y \u0110\u0103ng |
|
|
8910
|
+
| :--- | :--- | :--- | :--- | :--- | :--- |
|
|
8911
|
+
| 01 | [T\u1EADp 01] Kh\u1EDFi \u0111\u1EA7u h\xE0nh tr\xECnh an tr\xFA | Tr\u1EE5 c\u1ED9t 1 | In-stream 16:9 | S\u1EB5n s\xE0ng | Tu\u1EA7n 1 |
|
|
8912
|
+
| 02 | [T\u1EADp 02] 3 Th\xF3i quen nh\u1ECF m\u1ED7i ng\xE0y | Tr\u1EE5 c\u1ED9t 2 | Reels 9:16 | B\u1EA3n th\u1EA3o | Tu\u1EA7n 1 |
|
|
8913
|
+
`;
|
|
8914
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "posts", "README.md"), postsReadme);
|
|
8915
|
+
const starterPost = `# T\u1EACP 01: KH\u1EDEI \u0110\u1EA6U H\xC0NH TR\xCCNH T\u0128NH L\u1EB6NG
|
|
8916
|
+
|
|
8917
|
+
- **Tr\u1EE5 c\u1ED9t n\u1ED9i dung:** Tr\u1EE5 c\u1ED9t 1 (C\xE2u chuy\u1EC7n c\u1ED1t l\xF5i & \u0110\u1ECBnh v\u1ECB)
|
|
8918
|
+
- **\u0110\u1ECBnh d\u1EA1ng t\u1ED1i \u01B0u:** Reels / Shorts (9:16) & Video Tuy\u1EC3n T\u1EADp (16:9)
|
|
8919
|
+
- **Th\u1EDDi l\u01B0\u1EE3ng \u01B0\u1EDBc t\xEDnh:** 55 gi\xE2y
|
|
8920
|
+
- **Gi\u1ECDng \u0111\u1ECDc \u0111\u1EC1 xu\u1EA5t:** Nam/N\u1EEF tr\u1EA7m \u1EA5m, nh\u1EA3 ch\u1EEF ch\u1EADm r\xE3i (115 t\u1EEB/ph\xFAt)
|
|
8921
|
+
- **Nh\u1EA1c n\u1EC1n BGM:** Acoustic Guitar m\u1ED9c & Ti\u1EBFng su\u1ED1i reo (-24dB)
|
|
8922
|
+
|
|
8923
|
+
---
|
|
8924
|
+
|
|
8925
|
+
## 1. HOOK M\u1EDE \u0110\u1EA6U (3 - 5 GI\xC2Y \u0110\u1EA6U)
|
|
8926
|
+
> "Gi\u1EEFa nh\u1EEFng \u1ED3n \xE0o v\u1ED9i v\xE3 c\u1EE7a ph\u1ED1 th\u1ECB, \u0111\xE3 bao l\xE2u r\u1ED3i b\u1EA1n ch\u01B0a cho t\xE2m m\xECnh m\u1ED9t kho\u1EA3ng l\u1EB7ng b\xECnh y\xEAn?..."
|
|
8927
|
+
|
|
8928
|
+
---
|
|
8929
|
+
|
|
8930
|
+
## 2. K\u1ECACH B\u1EA2N THUY\u1EBET MINH & L\u1EDCI THO\u1EA0I CHI TI\u1EBET
|
|
8931
|
+
### Kh\u1ED5 1: B\u01B0\u1EDBc ch\xE2n t\xECm v\u1EC1 an tr\xFA
|
|
8932
|
+
C\xF3 nh\u1EEFng ng\xE0y m\u1EC7t m\u1ECFi r\xE3 r\u1EDDi,
|
|
8933
|
+
Ch\u1EC9 th\xE8m m\u1ED9t g\xF3c nh\u1ECF th\u1EA3nh th\u01A1i.
|
|
8934
|
+
Ng\u1ED3i b\xEAn \u1EA5m tr\xE0 th\u01A1m ng\xE1t v\u1ECB,
|
|
8935
|
+
Nghe l\xF2ng ph\u1EB3ng l\u1EB7ng t\u1EF1a m\xE2y tr\xF4i.
|
|
8936
|
+
|
|
8937
|
+
### Kh\u1ED5 2: Bu\xF4ng b\u1ECF mu\u1ED9n phi\u1EC1n
|
|
8938
|
+
H\xEDt v\xE0o m\u1ED9t h\u01A1i th\u1EADt s\xE2u,
|
|
8939
|
+
Th\u1EDF ra nh\u1EEFng nh\u1ECDc nh\u1EB1n ch\u1EA5t ch\u1EE9a.
|
|
8940
|
+
B\xECnh y\xEAn v\u1ED1n ch\u1EB3ng \u1EDF \u0111\xE2u xa,
|
|
8941
|
+
B\xECnh y\xEAn n\u1EB1m ngay trong t\xE2m m\xECnh l\xFAc n\xE0y.
|
|
8942
|
+
|
|
8943
|
+
---
|
|
8944
|
+
|
|
8945
|
+
### PH\xC2N C\u1EA2NH VISUAL STORYBOARD
|
|
8946
|
+
| M\u1ED1c th\u1EDDi gian | M\xF4 t\u1EA3 h\xECnh \u1EA3nh & Visual B-roll | Prompt AI (Midjourney / Stable Diffusion) |
|
|
8947
|
+
| :--- | :--- | :--- |
|
|
8948
|
+
| **00:00 - 00:15** | C\u1EADn c\u1EA3nh t\xE1ch tr\xE0 g\u1ED1m m\u1ED9c b\u1ED1c kh\xF3i nh\u1EB9 b\xEAn khung c\u1EEDa s\u1ED5 s\u1EDBm | \`Cinematic close-up of a handmade ceramic tea cup with gentle steam rising on a weathered rustic wooden table by a morning window, soft golden sun rays filtering through bamboo blinds, dust motes in light, tranquil peaceful Zen mood, 8k --ar 16:9\` |
|
|
8949
|
+
| **00:15 - 00:35** | G\xF3c v\u01B0\u1EDDn thi\u1EC1n v\u1EDBi hoa sen tr\u1EAFng v\xE0 l\u1ED1i \u0111i r\u1EA3i s\u1ECFi tr\u1EAFng | \`Peaceful Zen garden with smooth river stones, a blooming white lotus flower in a rustic clay bowl, morning dew drops, gentle water ripples, serene minimalist atmosphere, photorealistic --ar 16:9\` |
|
|
8950
|
+
| **00:35 - 00:55** | B\xF3ng ng\u01B0\u1EDDi ng\u1ED3i thi\u1EC1n t\u0129nh l\u1EB7ng d\u01B0\u1EDBi b\xF3ng c\xE2y xanh m\xE1t | \`Silhouette of a peaceful person sitting in mindful meditation under a large banyan tree on a misty green hill, soft pastel sunrise sky, cinematic wide shot, atmospheric depth, deeply relaxing --ar 16:9\` |
|
|
8951
|
+
|
|
8952
|
+
---
|
|
8953
|
+
|
|
8954
|
+
## 4. CAPTION FACEBOOK B\xC0I \u0110\u0102NG
|
|
8955
|
+
Gi\u1EEFa nh\u1EEFng \u1ED3n \xE0o v\u1ED9i v\xE3 c\u1EE7a ph\u1ED1 th\u1ECB, \u0111\xE3 bao l\xE2u r\u1ED3i b\u1EA1n ch\u01B0a cho t\xE2m m\xECnh m\u1ED9t kho\u1EA3ng l\u1EB7ng b\xECnh y\xEAn?...
|
|
8956
|
+
|
|
8957
|
+
H\xEDt m\u1ED9t h\u01A1i th\u1EADt s\xE2u, bu\xF4ng xu\u1ED1ng nh\u1EEFng lo toan c\u1EE7a ng\xE0y d\xE0i. H\xE3y c\xF9ng l\u1EAFng \u0111\u1ECDng t\xE2m h\u1ED3n v\xE0 l\xE0m b\u1EA1n v\u1EDBi ch\xEDnh m\xECnh trong t\u1EEBng ph\xFAt gi\xE2y hi\u1EC7n t\u1EA1i nh\xE9.
|
|
8958
|
+
|
|
8959
|
+
\u{1F48C} L\u01B0u \xFD: Video mang t\xEDnh ch\u1EA5t t\u1EF1 s\u1EF1 chi\xEAm nghi\u1EC7m, lan t\u1ECFa s\u1EF1 t\u0129nh t\xE2m v\xE0 t\xEDch c\u1EF1c cho cu\u1ED9c s\u1ED1ng.
|
|
8960
|
+
|
|
8961
|
+
#${meta.cleanName.replace(/-/g, "")} #GocAnTru #ThienDinh #TinhTam #BinhYenTuThan #SongCham
|
|
8962
|
+
|
|
8963
|
+
---
|
|
8964
|
+
|
|
8965
|
+
## 5. S\u1EA2N PH\u1EA8M AFFILIATE G\u1EAEN K\xC8M
|
|
8966
|
+
| T\xEAn S\u1EA3n Ph\u1EA9m | T\u1EA7ng S\u1EA3n Ph\u1EA9m | V\u1ECB Tr\xED \u0110\u1EB7t Link | C\xE2u L\u1ED3ng Gh\xE9p Soft-sell |
|
|
8967
|
+
| :--- | :--- | :--- | :--- |
|
|
8968
|
+
| **Tr\xE0 th\u1EA3o m\u1ED9c hoa c\xFAc s\u1EA5y l\u1EA1nh thanh nhi\u1EC7t d\u01B0\u1EE1ng t\xE2m** | T\u1EA7ng A | Pinned Comment | *"M\u1ED9t t\xE1ch tr\xE0 \u1EA5m th\u01A1m d\u1ECBu v\xE0o m\u1ED7i s\u1EDBm mai s\u1EBD gi\xFAp b\u1EA1n kh\u1EDFi \u0111\u1EA7u ng\xE0y m\u1EDBi trong an l\xE0nh..."* |
|
|
8969
|
+
`;
|
|
8970
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "posts", "01_Tap_01_Khoi_Dau_Hanh_Trinh.md"), starterPost);
|
|
8971
|
+
const avatarTxt = `=== OPTION 1: LOGO BI\u1EC2U T\u01AF\u1EE2NG K\xCANH ${pureBrandName.toUpperCase()} (KHUY\xCAN D\xD9NG) ===
|
|
8972
|
+
Title: Avatar Logo T\u0129nh T\xE2m & Sen Tr\u1EAFng M\u1ED9c M\u1EA1c
|
|
8973
|
+
Prompt: Minimalist circular Zen logo icon representing ${pureBrandName}, clean aesthetic, gentle warm lighting, high resolution, vector graphic style, centered composition, modern typography --ar 1:1 --v 6.0
|
|
8974
|
+
Gi\u1EA3i ngh\u0129a: Bi\u1EC3u t\u01B0\u1EE3ng mang phong c\xE1ch t\u0129nh l\u1EB7ng, h\xE0i h\xF2a, ph\xF9 h\u1EE3p \u0111\u1EA1i di\u1EC7n cho th\u01B0\u01A1ng hi\u1EC7u k\xEAnh.
|
|
8975
|
+
|
|
8976
|
+
=== OPTION 2: B\xC0N TR\xC0 G\u1ED0M & CU\u1ED0N S\u1ED4 T\xC2M T\xCCNH ===
|
|
8977
|
+
Title: Avatar T\xE1ch Tr\xE0 G\u1ED1m M\u1ED9c & N\u1EBFn Th\u01A1m Ban Mai
|
|
8978
|
+
Prompt: Aesthetic still life on a dark rustic wooden veranda, a handcrafted ceramic teacup with gentle rising steam, an open vintage journal with fountain pen, soft warm morning window light, peaceful hygge mood, depth of field --ar 1:1 --v 6.0
|
|
8979
|
+
Gi\u1EA3i ngh\u0129a: H\xECnh \u1EA3nh \u1EA5m c\xFAng, th\u01B0 th\xE1i, g\u1EE3i m\u1EDF kh\xF4ng gian chi\xEAm nghi\u1EC7m.
|
|
8980
|
+
`;
|
|
8981
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "prompts", "avatar_prompts.txt"), avatarTxt);
|
|
8982
|
+
const coverTxt = `=== OPTION 1: TO\xC0N C\u1EA2NH HI\xCAN NH\xC0 G\u1ED6 B\xCAN R\u1EEANG TR\xDAC (KHUY\xCAN D\xD9NG) ===
|
|
8983
|
+
Title: Cover Hi\xEAn Nh\xE0 An Tr\xFA B\xEAn \u0110\u1ED3i N\xFAi S\u01B0\u01A1ng M\u1EDD
|
|
8984
|
+
Prompt: Wide panoramic cinematic shot of a peaceful wooden sanctuary porch overlooking misty rolling green hills and a gentle bamboo forest at golden dawn, soft ambient morning haze, ample negative space on the left and center for typography, photorealistic, serene atmosphere --ar 16:9 --v 6.0
|
|
8985
|
+
Gi\u1EA3i ngh\u0129a: Khung h\xECnh r\u1ED9ng v\u1EDBi t\u1EF7 l\u1EC7 v\xE0ng, c\xF3 kho\u1EA3ng tr\u1ED1ng tinh t\u1EBF \u0111\u1EC3 \u0111\u1EB7t logo v\xE0 slogan c\u1EE7a k\xEAnh.
|
|
8986
|
+
|
|
8987
|
+
=== OPTION 2: D\xD2NG SU\u1ED0I THI\u1EC0N & KHU V\u01AF\u1EDCN \u0110\xC1 R\xCAU PHONG ===
|
|
8988
|
+
Title: Cover D\xF2ng Su\u1ED1i Trong V\u1EAFt V\u01B0\u1EDDn Thi\u1EC1n
|
|
8989
|
+
Prompt: Panoramic landscape of a tranquil Zen rock garden with a crystal clear cascading water stream, mossy boulders, delicate lotus blossoms, golden sunrise light filtering through pine branches, 8k resolution --ar 16:9 --v 6.0
|
|
8990
|
+
Gi\u1EA3i ngh\u0129a: C\u1EA3nh s\u1EAFc thi\xEAn nhi\xEAn thu\u1EA7n khi\u1EBFt mang l\u1EA1i s\u1EF1 m\xE1t l\xE0nh v\xE0 t\u0129nh t\u1EA1i.
|
|
8991
|
+
`;
|
|
8992
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "prompts", "cover_prompts.txt"), coverTxt);
|
|
8993
|
+
const promptsTxt = `=== PH\xC2N C\u1EA2NH 01: T\xC1CH TR\xC0 B\u1ED0C KH\xD3I B\xCAN HI\xCAN S\u1EDAM ===
|
|
8994
|
+
Title: T\xE1ch Tr\xE0 G\u1ED1m M\u1ED9c B\xEAn Hi\xEAn Nh\xE0 S\u1EDBm
|
|
8995
|
+
Prompt: Cinematic close-up of a handmade ceramic tea cup with gentle steam rising on a weathered rustic wooden table by a morning window, soft golden sun rays filtering through bamboo blinds, dust motes in light, tranquil peaceful Zen mood, 8k --ar 16:9
|
|
8996
|
+
|
|
8997
|
+
=== PH\xC2N C\u1EA2NH 02: GI\u1ECCT S\u01AF\u01A0NG \u0110\u1ECCNG TR\xCAN L\xC1 SEN ===
|
|
8998
|
+
Title: Gi\u1ECDt S\u01B0\u01A1ng Mai \u0110\u1ECDng Tr\xEAn C\xE1nh Sen
|
|
8999
|
+
Prompt: Macro shot of sparkling clear water droplets on a broad vibrant green lotus leaf, gentle morning breeze causing ripples, soft morning sunlight, peaceful nature meditation, ultra-sharp detail --ar 16:9
|
|
9000
|
+
|
|
9001
|
+
=== PH\xC2N C\u1EA2NH 03: CON \u0110\u01AF\u1EDCNG R\u1EA2I S\u1ECEI V\u01AF\u1EDCN THI\u1EC0N ===
|
|
9002
|
+
Title: L\u1ED1i \u0110i R\u1EA3i S\u1ECFi Tr\u1EAFng D\u01B0\u1EDBi H\xE0ng Tr\xFAc
|
|
9003
|
+
Prompt: Low angle ground shot of a winding white pebble pathway through a lush green bamboo grove, soft morning mist, peaceful stillness, Zen tranquility, cinematic film grain --ar 16:9
|
|
9004
|
+
|
|
9005
|
+
=== PH\xC2N C\u1EA2NH 04: NG\u1ECCN N\u1EBEN TH\u01A0M LUNG LINH \u0110\xCAM KHUYA ===
|
|
9006
|
+
Title: Ng\u1ECDn N\u1EBFn Th\u01A1m T\u0129nh L\u1EB7ng Ban \u0110\xEAm
|
|
9007
|
+
Prompt: Intimate macro shot of a scented candle flame gently flickering in a cozy dimly lit room, warm amber glow illuminating open book pages, soft bokeh background, relaxing atmosphere --ar 16:9
|
|
9008
|
+
`;
|
|
9009
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "prompts", "scene_broll_prompts.txt"), promptsTxt);
|
|
9010
|
+
const sunoTxt = `=== PHONG C\xC1CH 01: GUITAR ACOUSTIC & TI\u1EBENG SU\u1ED0I REO (KHUY\xCAN D\xD9NG) ===
|
|
9011
|
+
Title: Giai \u0110i\u1EC7u Thi\u1EC1n \u0110\u1ECBnh Guitar M\u1ED9c & N\u01B0\u1EDBc Ch\u1EA3y
|
|
9012
|
+
Prompt: Pure instrumental solo acoustic nylon guitar, very slow peaceful tempo 60 bpm, soothing meditative melody, gentle natural flowing stream water ambient sound in background, no drums, no bass, no vocal, intimate warm acoustic recording, peaceful, healing, emotional
|
|
9013
|
+
Style Tags: acoustic guitar, fingerpicking, stream sound, ambient, peaceful, emotional, 60 bpm
|
|
9014
|
+
|
|
9015
|
+
=== PHONG C\xC1CH 02: S\xC1O TR\xDAC & TI\u1EBENG CHU\xD4NG GI\xD3 B\xCCNH Y\xCAN ===
|
|
9016
|
+
Title: Kh\xFAc Nh\u1EA1c S\xE1o Tr\xFAc & Chu\xF4ng Gi\xF3 An Tr\xFA
|
|
9017
|
+
Prompt: Traditional bamboo flute shakuhachi and gentle temple wind chimes, slow 55 bpm, serene flowing melody, mountain mist ambience, deeply contemplative, tranquil, healing, no vocals, no beat
|
|
9018
|
+
Style Tags: bamboo flute, wind chime, zen, meditative, peaceful, tranquil, 55 bpm
|
|
9019
|
+
`;
|
|
9020
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "prompts", "suno_music_prompts.txt"), sunoTxt);
|
|
9021
|
+
const guideTxt = `H\u01AF\u1EDANG D\u1EAAN S\u1EEC D\u1EE4NG TH\u01AF VI\u1EC6N PROMPTS VISUAL & SUNO BGM: ${pureBrandName}
|
|
9022
|
+
1. Master Prompt: S\u1EED d\u1EE5ng prompt_viet_kich_ban_master.txt \u0111\u1EC3 t\u1EA1o k\u1ECBch b\u1EA3n m\u1EDBi chu\u1EA9n DNA k\xEAnh v\u1EDBi ChatGPT/Claude.
|
|
9023
|
+
2. Avatar: S\u1EED d\u1EE5ng c\xE1c prompt trong avatar_prompts.txt tr\xEAn Midjourney / Flux v\u1EDBi t\u1EF7 l\u1EC7 --ar 1:1.
|
|
9024
|
+
3. Cover: S\u1EED d\u1EE5ng cover_prompts.txt v\u1EDBi t\u1EF7 l\u1EC7 --ar 16:9 cho \u1EA3nh b\xECa Fanpage/YouTube.
|
|
9025
|
+
4. Scene B-roll: D\xF9ng scene_broll_prompts.txt \u0111\u1EC3 t\u1EA1o c\xE1c c\u1EA3nh quay minh h\u1ECDa cho video.
|
|
9026
|
+
5. BGM: Sao ch\xE9p Prompt trong suno_music_prompts.txt d\xE1n v\xE0o Suno AI (ch\u1EBF \u0111\u1ED9 Custom Mode, t\xEDch ch\u1ECDn Instrumental).
|
|
9027
|
+
`;
|
|
9028
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "prompts", "huong_dan_su_dung.txt"), guideTxt);
|
|
9029
|
+
const masterPromptTxt = `# C\xC2U L\u1EC6NH MASTER SO\u1EA0N K\u1ECACH B\u1EA2N CHU\u1EA8N DNA: ${pureBrandName.toUpperCase()}
|
|
9030
|
+
|
|
9031
|
+
> \u{1F4A1} **H\u01AF\u1EDANG D\u1EAAN S\u1EEC D\u1EE4NG NHANH:**
|
|
9032
|
+
> 1. B\u1EA5m n\xFAt **"Sao ch\xE9p to\xE0n b\u1ED9"** \u1EDF g\xF3c tr\xEAn b\xEAn ph\u1EA3i (ho\u1EB7c copy kh\u1ED1i l\u1EC7nh b\xEAn d\u01B0\u1EDBi).
|
|
9033
|
+
> 2. M\u1EDF ChatGPT, Claude ho\u1EB7c DeepSeek, d\xE1n to\xE0n b\u1ED9 c\xE2u l\u1EC7nh v\xE0o khung chat.
|
|
9034
|
+
> 3. Thay th\u1EBF \u0111o\u1EA1n \`[D\xC1N TI\xCAU \u0110\u1EC0, \xDD T\u01AF\u1EDENG HO\u1EB6C \u0110O\u1EA0N V\u0102N B\u1EA2N TH\xD4 V\xC0O \u0110\xC2Y]\` b\u1EB1ng \xFD t\u01B0\u1EDFng c\u1EE7a b\u1EA1n.
|
|
9035
|
+
> 4. AI s\u1EBD l\u1EADp t\u1EE9c s\xE1ng t\xE1c k\u1ECBch b\u1EA3n ho\xE0n ch\u1EC9nh theo \u0111\xFAng quy chu\u1EA9n 6 ph\u1EA7n, \u0111\xFAng DNA k\xEAnh v\xE0 s\u1EB5n s\xE0ng n\u1EA1p v\xE0o MTxStudio!
|
|
9036
|
+
|
|
9037
|
+
---
|
|
9038
|
+
|
|
9039
|
+
\`\`\`text
|
|
9040
|
+
[ROLE & CONTEXT]
|
|
9041
|
+
B\u1EA1n l\xE0 Bi\xEAn k\u1ECBch tr\u01B0\u1EDFng v\xE0 Chuy\xEAn gia \u0111\u1ECBnh h\xECnh phong c\xE1ch cho k\xEAnh: "${pureBrandName}".
|
|
9042
|
+
- Slogan k\xEAnh: "${description}"
|
|
9043
|
+
- Th\u1EC3 lo\u1EA1i & L\u0129nh v\u1EF1c: N\u1ED9i dung s\u1ED1 & Truy\u1EC1n th\xF4ng \u0111a ph\u01B0\u01A1ng ti\u1EC7n
|
|
9044
|
+
- Kh\xE1n gi\u1EA3 m\u1EE5c ti\xEAu: 20 - 45 tu\u1ED5i
|
|
9045
|
+
- Khung gi\u1EDD \u0111\u0103ng v\xE0ng: 06:30 s\xE1ng v\xE0 20:30 t\u1ED1i
|
|
9046
|
+
- M\xE0u s\u1EAFc nh\u1EADn di\u1EC7n: #10b981 | Icon \u0111\u1EA1i di\u1EC7n: Sparkles
|
|
9047
|
+
- Phong c\xE1ch gi\u1ECDng \u0111\u1ECDc: Gi\u1ECDng \u0111\u1ECDc truy\u1EC1n c\u1EA3m, \u1EA5m \xE1p, t\u1ED1c \u0111\u1ED9 115 - 120 t\u1EEB/ph\xFAt; Nh\u1EA1c n\u1EC1n nh\u1EB9 nh\xE0ng (-24dB)
|
|
9048
|
+
- Phong c\xE1ch h\xECnh \u1EA3nh nh\u1EADn di\u1EC7n: Cinematic high quality aesthetic, tranquil atmosphere, golden hour lighting (--ar 16:9)
|
|
9049
|
+
|
|
9050
|
+
[NHI\u1EC6M V\u1EE4]
|
|
9051
|
+
H\xE3y s\xE1ng t\xE1c ho\u1EB7c chuy\u1EC3n th\u1EC3 th\xE0nh m\u1ED9t K\u1ECBch b\u1EA3n Video/Audio ho\xE0n ch\u1EC9nh theo chu\u1EA9n 6 ph\u1EA7n c\u1EE7a MTxStudio cho:
|
|
9052
|
+
Ch\u1EE7 \u0111\u1EC1 / B\xE0i vi\u1EBFt th\xF4:
|
|
9053
|
+
"""
|
|
9054
|
+
[D\xC1N TI\xCAU \u0110\u1EC0, \xDD T\u01AF\u1EDENG HO\u1EB6C \u0110O\u1EA0N V\u0102N B\u1EA2N TH\xD4 V\xC0O \u0110\xC2Y]
|
|
9055
|
+
"""
|
|
9056
|
+
|
|
9057
|
+
[4 B\u01AF\u1EDAC B\u1EAET BU\u1ED8C KHI X\u1EEC L\xDD]
|
|
9058
|
+
1. L\u1ECCC L\u1EC6CH TONE (DE-BIASING):
|
|
9059
|
+
- Lo\u1EA1i b\u1ECF tri\u1EC7t \u0111\u1EC3: N\u1ED9i dung ph\u1EA3n c\u1EA3m, tin gi\u1EA3, ti\xEAu c\u1EF1c \u0111\u1ED9c h\u1EA1i, gi\u1EADt g\xE2n c\xE2u view r\u1EBB ti\u1EC1n, vi ph\u1EA1m ti\xEAu chu\u1EA9n c\u1ED9ng \u0111\u1ED3ng.
|
|
9060
|
+
- Gi\u1EEF l\u1EA1i h\u1EA1t m\u1EA7m c\u1EA3m x\xFAc nh\xE2n v\u0103n, \u0111\xFAc k\u1EBFt gi\xE1 tr\u1ECB t\xEDch c\u1EF1c ph\xF9 h\u1EE3p v\u1EDBi t\xF4n ch\u1EC9 k\xEAnh.
|
|
9061
|
+
|
|
9062
|
+
2. T\xC1I \u0110\u1ECANH H\xCCNH THEO DNA K\xCANH:
|
|
9063
|
+
- Ng\xF4i x\u01B0ng: T\xF4i - B\u1EA1n / Ch\xFAng ta
|
|
9064
|
+
- C\u1EA3m x\xFAc m\u1EE5c ti\xEAu: Truy\u1EC1n c\u1EA3m h\u1EE9ng, k\u1EBFt n\u1ED1i c\u1EA3m x\xFAc, \u0111em l\u1EA1i gi\xE1 tr\u1ECB h\u1EEFu \xEDch v\xE0 b\xECnh y\xEAn t\u1EF1 th\xE2n
|
|
9065
|
+
- Phong c\xE1ch d\u1EABn d\u1EAFt: Ng\u01B0\u1EDDi chia s\u1EBB ch\xE2n th\xE0nh, s\xE2u s\u1EAFc, \u0111\u1ED3ng h\xE0nh c\xF9ng kh\xE1n gi\u1EA3
|
|
9066
|
+
|
|
9067
|
+
3. T\u1ED0I \u01AFU \xC2M H\u1ECCC GI\u1ECCNG \u0110\u1ECCC AI (TTS ACOUSTICS):
|
|
9068
|
+
- \u0110\u1ED9 d\xE0i c\xE2u: Tuy\u1EC7t \u0111\u1ED1i ng\u1EAFn g\u1ECDn, t\u1EEB 12 \u0111\u1EBFn 20 t\u1EEB/c\xE2u (kh\xF4ng qu\xE1 25 t\u1EEB).
|
|
9069
|
+
- V\u1EBF c\xE2u ng\u1EAFt ph\u1EA9y: 8 \u0111\u1EBFn 12 t\u1EEB. D\xF9ng d\u1EA5u ch\u1EA5m c\xE2u ng\u1EAFt d\u1EE9t kho\xE1t, kh\xF4ng n\u1ED1i c\xE2u d\xE0i l\xEA th\xEA.
|
|
9070
|
+
- Ch\u1ED1ng l\u1EB7p t\u1EEB l\xE1y: Kh\xF4ng x\u1EBFp 2 t\u1EEB l\xE1y li\u1EC1n k\u1EC1; ch\xE8n d\u1EA5u ph\u1EA9y ho\u1EB7c th\u1EBB ngh\u1EC9 tr\u01B0\u1EDBc t\u1EEB l\xE1y c\xF3 thanh \u0111i\u1EC7u tr\u1EAFc.
|
|
9071
|
+
- Th\u1EBB bi\u1EC3u c\u1EA3m MTxStudio: S\u1EED d\u1EE5ng c\xE1c th\u1EBB chu\u1EA9n trong danh m\u1EE5c 42 th\u1EBB \xE2m h\u1ECDc: [l\u1EA5y h\u01A1i], [th\u1EDF d\xE0i], [th\u1EDF ph\xE0o], [c\u01B0\u1EDDi kh\u1EBD], [c\u01B0\u1EDDi nh\u1EB9], [th\xEC th\u1EA7m], [ng\u1EAFt ng\u1EAFn], [ng\u1EAFt d\xE0i], [n\xF3i ch\u1EADm l\u1EA1i].
|
|
9072
|
+
- B\u1EA3o to\xE0n th\u01A1 ca: N\u1EBFu c\xF3 th\u01A1/v\xE8, M\u1ED6I C\xC2U TH\u01A0 B\u1EAET BU\u1ED8C N\u1EB0M TR\xCAN 1 D\xD2NG RI\xCANG (\\n).
|
|
9073
|
+
- Kh\u1EED k\xFD t\u1EF1 l\u1EA1: Kh\xF4ng d\xF9ng en-dash (\u2013) hay em-dash (\u2014), ch\u1EC9 d\xF9ng d\u1EA5u g\u1EA1ch n\u1ED1i (-).
|
|
9074
|
+
|
|
9075
|
+
4. \u0110\xD3NG G\xD3I 6 PH\u1EA6N CHU\u1EA8N MTxSTUDIO:
|
|
9076
|
+
Xu\u1EA5t b\u1EA3n \u0111\u1ECBnh d\u1EA1ng Markdown v\u1EDBi c\xE1c ti\xEAu \u0111\u1EC1 m\u1EE5c CH\xCDNH X\xC1C sau:
|
|
9077
|
+
|
|
9078
|
+
# T\u1EACP [S\u1ED1 t\u1EADp]: [TI\xCAU \u0110\u1EC0 IN HOA]
|
|
9079
|
+
|
|
9080
|
+
- **Tr\u1EE5 c\u1ED9t n\u1ED9i dung:** [T\xEAn tr\u1EE5 c\u1ED9t theo plan 30 ng\xE0y]
|
|
9081
|
+
- **\u0110\u1ECBnh d\u1EA1ng t\u1ED1i \u01B0u:** [Reels 9:16 / Video In-stream 16:9]
|
|
9082
|
+
- **Th\u1EDDi l\u01B0\u1EE3ng \u01B0\u1EDBc t\xEDnh:** [50 gi\xE2y - 3 ph\xFAt]
|
|
9083
|
+
- **Gi\u1ECDng \u0111\u1ECDc \u0111\u1EC1 xu\u1EA5t:** [Nam/N\u1EEF, t\u1ED1c \u0111\u1ED9 t\u1EEB/ph\xFAt]
|
|
9084
|
+
- **Nh\u1EA1c n\u1EC1n BGM:** [M\xF4 t\u1EA3 nh\u1EA1c c\u1EE5 & \xE2m l\u01B0\u1EE3ng -24dB]
|
|
9085
|
+
|
|
9086
|
+
---
|
|
9087
|
+
|
|
9088
|
+
## 1. HOOK M\u1EDE \u0110\u1EA6U (3 - 5 GI\xC2Y \u0110\u1EA6U)
|
|
9089
|
+
> "[C\xE2u m\u1EDF m\xE0n \u0111\xE1nh th\u1EB3ng v\xE0o t\xE2m l\xFD, t\xF2 m\xF2 ho\u1EB7c n\u1ED7i \u0111au]"
|
|
9090
|
+
|
|
9091
|
+
---
|
|
9092
|
+
|
|
9093
|
+
## 2. K\u1ECACH B\u1EA2N THUY\u1EBET MINH & L\u1EDCI THO\u1EA0I CHI TI\u1EBET
|
|
9094
|
+
### Kh\u1ED5 1: [Ti\xEAu \u0111\u1EC1 ph\xE2n \u0111o\u1EA1n]
|
|
9095
|
+
[N\u1ED9i dung audio tho\u1EA1i s\u1EA1ch, c\xE2u ng\u1EAFn 12-20 t\u1EEB, ng\u1EAFt nh\u1ECBp ph\u1EA9y t\u1EF1 nhi\xEAn, ch\xE8n th\u1EBB bi\u1EC3u c\u1EA3m chu\u1EA9n...]
|
|
9096
|
+
|
|
9097
|
+
### Kh\u1ED5 2: [Ti\xEAu \u0111\u1EC1 ph\xE2n \u0111o\u1EA1n]
|
|
9098
|
+
[...]
|
|
9099
|
+
|
|
9100
|
+
---
|
|
9101
|
+
|
|
9102
|
+
### PH\xC2N C\u1EA2NH VISUAL STORYBOARD
|
|
9103
|
+
| M\u1ED1c th\u1EDDi gian | M\xF4 t\u1EA3 h\xECnh \u1EA3nh & Visual B-roll | Prompt AI (Midjourney / Stable Diffusion) |
|
|
9104
|
+
| :--- | :--- | :--- |
|
|
9105
|
+
| **00:00 - 00:15** | [M\xF4 t\u1EA3 ph\xE2n c\u1EA3nh] | \`[Prompt ti\u1EBFng Anh chi ti\u1EBFt, \u0111\xFAng art style c\u1EE7a k\xEAnh, 8k --ar 16:9]\` |
|
|
9106
|
+
| **00:15 - 00:45** | [M\xF4 t\u1EA3 ph\xE2n c\u1EA3nh] | \`[Prompt ti\u1EBFng Anh chi ti\u1EBFt, \u0111\xFAng art style c\u1EE7a k\xEAnh, 8k --ar 16:9]\` |
|
|
9107
|
+
|
|
9108
|
+
---
|
|
9109
|
+
|
|
9110
|
+
## 4. CAPTION FACEBOOK B\xC0I \u0110\u0102NG
|
|
9111
|
+
[Caption thu h\xFAt]
|
|
9112
|
+
|
|
9113
|
+
[T\u1EF1 s\u1EF1 ho\u1EB7c t\xF3m t\u1EAFt \xFD ngh\u0129a]
|
|
9114
|
+
|
|
9115
|
+
[C\xE2u h\u1ECFi k\xEAu g\u1ECDi t\u01B0\u01A1ng t\xE1c]
|
|
9116
|
+
|
|
9117
|
+
#${meta.cleanName.replace(/-/g, "")} #MTxStudio
|
|
9118
|
+
|
|
9119
|
+
---
|
|
9120
|
+
|
|
9121
|
+
## 5. S\u1EA2N PH\u1EA8M AFFILIATE G\u1EAEN K\xC8M
|
|
9122
|
+
| T\xEAn S\u1EA3n Ph\u1EA9m | T\u1EA7ng S\u1EA3n Ph\u1EA9m | V\u1ECB Tr\xED \u0110\u1EB7t Link | C\xE2u L\u1ED3ng Gh\xE9p Soft-sell |
|
|
9123
|
+
| :--- | :--- | :--- | :--- |
|
|
9124
|
+
| [T\xEAn S\u1EA3n Ph\u1EA9m] | T\u1EA7ng A / T\u1EA7ng B | Pinned Comment | "[C\xE2u l\u1ED3ng gh\xE9p t\u1EF1 nhi\xEAn]" |
|
|
9125
|
+
|
|
9126
|
+
---
|
|
9127
|
+
|
|
9128
|
+
## 6. KHUY\u1EBEN C\xC1O PH\xC1P L\xDD & DISCLAIMER
|
|
9129
|
+
N\u1ED9i dung do k\xEAnh ${pureBrandName} s\u1EA3n xu\u1EA5t nh\u1EB1m m\u1EE5c \u0111\xEDch chia s\u1EBB v\xE0 lan t\u1ECFa gi\xE1 tr\u1ECB t\xEDch c\u1EF1c cho cu\u1ED9c s\u1ED1ng.
|
|
9130
|
+
\`\`\`
|
|
9131
|
+
`;
|
|
9132
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "prompts", "prompt_viet_kich_ban_master.txt"), masterPromptTxt);
|
|
9133
|
+
const affiliateReadme = `# DANH M\u1EE4C S\u1EA2N PH\u1EA8M TI\u1EBEP TH\u1ECA LI\xCAN K\u1EBET (AFFILIATE CATALOG)
|
|
9134
|
+
## K\xCANH: ${pureBrandName}
|
|
9135
|
+
|
|
9136
|
+
> **Tri\u1EBFt l\xFD b\xE1n h\xE0ng Soft-sell 80/20:**
|
|
9137
|
+
> S\u1EA3n ph\u1EA9m \u0111\u01B0\u1EE3c gi\u1EDBi thi\u1EC7u nh\u01B0 nh\u1EEFng v\u1EADt ph\u1EA9m \u0111\u1ED3ng h\xE0nh c\xF9ng kho\u1EA3nh kh\u1EAFc t\u0129nh t\xE2m, ch\u0103m s\xF3c c\u01A1 th\u1EC3 nh\u1EB9 nh\xE0ng, tuy\u1EC7t \u0111\u1ED1i kh\xF4ng ch\xE8o k\xE9o th\u01B0\u01A1ng m\u1EA1i g\u01B0\u1EE3ng \xE9p.
|
|
9138
|
+
|
|
9139
|
+
---
|
|
9140
|
+
|
|
9141
|
+
### NH\xD3M 1: V\u1EACT PH\u1EA8M T\u0128NH T\xC2M & KH\xD4NG GIAN B\xCCNH AN (T\u1EA6NG A)
|
|
9142
|
+
|
|
9143
|
+
| STT | T\xEAn S\u1EA3n Ph\u1EA9m | N\u1EC1n T\u1EA3ng | Kho\u1EA3ng Gi\xE1 | Hoa H\u1ED3ng D\u1EF1 Ki\u1EBFn | V\u1ECB Tr\xED \u0110\u1EB7t Link | C\xE2u M\u1EDF \u0110\u1EA7u Soft-sell (Hook l\u1ED3ng gh\xE9p) |
|
|
9144
|
+
|:--- |:--- |:--- |:--- |:--- |:--- |:--- |
|
|
9145
|
+
| 01 | **N\u1EBFn th\u01A1m s\xE1p \u0111\u1EADu n\xE0nh h\u01B0\u01A1ng g\u1ED7 tr\u1EA7m & qu\u1EBF \u1EA5m** | Shopee / TikTok Shop | 135.000\u0111 - 220.000\u0111 | 15% - 22% | Pinned Comment / Bio Link | *"Th\u1EAFp m\u1ED9t ng\u1ECDn n\u1EBFn h\u01B0\u01A1ng tr\u1EA7m d\u1ECBu nh\u1EB9, \u0111\u1EC3 t\xE2m m\xECnh ch\u1EADm l\u1EA1i sau m\u1ED9t ng\xE0y d\xE0i..."* |
|
|
9146
|
+
| 02 | **Tr\xE0 th\u1EA3o m\u1ED9c hoa c\xFAc s\u1EA5y l\u1EA1nh nguy\xEAn b\xF4ng d\u01B0\u1EE1ng t\xE2m** | Shopee / TikTok Shop | 75.000\u0111 - 145.000\u0111 | 18% - 24% | Pinned Comment | *"M\u1ED9t t\xE1ch tr\xE0 \u1EA5m th\u01A1m d\u1ECBu v\xE0o m\u1ED7i s\u1EDBm mai s\u1EBD gi\xFAp b\u1EA1n kh\u1EDFi \u0111\u1EA7u ng\xE0y m\u1EDBi trong an l\xE0nh..."* |
|
|
9147
|
+
| 03 | **Chu\xF4ng xoay T\xE2y T\u1EA1ng (Singing Bowl) \xE2m thanh ch\u1EEFa l\xE0nh** | Shopee / TikTok Shop | 250.000\u0111 - 450.000\u0111 | 15% - 20% | Bio Link | *"Ti\u1EBFng chu\xF4ng ng\xE2n vang thanh tho\xE1t gi\xFAp gom t\xE2m v\u1EC1 v\u1EDBi hi\u1EC7n t\u1EA1i, tan bi\u1EBFn m\u1ECDi c\u0103ng th\u1EB3ng..."* |
|
|
9148
|
+
`;
|
|
9149
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "affiliate", "README.md"), affiliateReadme);
|
|
9150
|
+
await FileSystemUtils.writeFile(path23.join(targetDir, "affiliate", "danh_muc_san_pham.md"), affiliateReadme);
|
|
9151
|
+
}
|
|
9152
|
+
};
|
|
9153
|
+
|
|
9154
|
+
// src/commands/pack.ts
|
|
9155
|
+
init_file_system();
|
|
9156
|
+
init_config();
|
|
9157
|
+
import path24 from "path";
|
|
9158
|
+
import os from "os";
|
|
9159
|
+
import { promises as fs4 } from "fs";
|
|
9160
|
+
import { execSync } from "child_process";
|
|
9161
|
+
import chalk17 from "chalk";
|
|
9162
|
+
import ora14 from "ora";
|
|
9163
|
+
var PackCommand = class {
|
|
9164
|
+
defaultExcludeDirs = /* @__PURE__ */ new Set([
|
|
9165
|
+
"node_modules",
|
|
9166
|
+
".git",
|
|
9167
|
+
".github",
|
|
9168
|
+
".svn",
|
|
9169
|
+
".vscode",
|
|
9170
|
+
".idea",
|
|
9171
|
+
HERASPEC_DIR_NAME,
|
|
9172
|
+
".heraspec",
|
|
9173
|
+
".agents",
|
|
9174
|
+
".ai",
|
|
9175
|
+
"scratch",
|
|
9176
|
+
"tests",
|
|
9177
|
+
"test",
|
|
9178
|
+
"tests-build",
|
|
9179
|
+
"cypress",
|
|
9180
|
+
"ScreenShot",
|
|
9181
|
+
"screenshots",
|
|
9182
|
+
"docs/internal",
|
|
9183
|
+
"_private_note",
|
|
9184
|
+
"releases"
|
|
9185
|
+
]);
|
|
9186
|
+
defaultExcludeFiles = /* @__PURE__ */ new Set([
|
|
9187
|
+
"package.json",
|
|
9188
|
+
"package-lock.json",
|
|
9189
|
+
"webpack.config.js",
|
|
9190
|
+
"webpack.config.mjs",
|
|
9191
|
+
"tsconfig.json",
|
|
9192
|
+
"build.js",
|
|
9193
|
+
"rollup.config.js",
|
|
9194
|
+
"vite.config.js",
|
|
9195
|
+
".gitignore",
|
|
9196
|
+
".npmignore",
|
|
9197
|
+
".editorconfig",
|
|
9198
|
+
"deploy.ps1",
|
|
9199
|
+
"phpunit.xml",
|
|
9200
|
+
"Thumbs.db",
|
|
9201
|
+
".DS_Store"
|
|
9202
|
+
]);
|
|
9203
|
+
async execute(targetPath = ".", options = {}) {
|
|
9204
|
+
const spinner = ora14("Preparing production release package...").start();
|
|
9205
|
+
const startTime = Date.now();
|
|
9206
|
+
try {
|
|
9207
|
+
const projectRoot = path24.resolve(targetPath);
|
|
9208
|
+
if (!await FileSystemUtils.fileExists(projectRoot)) {
|
|
9209
|
+
spinner.fail(`Target path does not exist: ${projectRoot}`);
|
|
9210
|
+
process.exitCode = 1;
|
|
9211
|
+
return;
|
|
9212
|
+
}
|
|
9213
|
+
const cleanName = options.name || await this.detectProjectName(projectRoot);
|
|
9214
|
+
const version2 = options.version || await this.detectProjectVersion(projectRoot);
|
|
9215
|
+
spinner.text = `Packaging ${chalk17.cyan(cleanName)} (v${version2})...`;
|
|
9216
|
+
const shouldBuild = options.build !== false;
|
|
9217
|
+
if (shouldBuild) {
|
|
9218
|
+
await this.buildAssetsIfConfigured(projectRoot, spinner);
|
|
9219
|
+
}
|
|
9220
|
+
const tempId = `heraspec-pack-${Date.now()}-${Math.random().toString(36).substring(2, 7)}`;
|
|
9221
|
+
const stageBaseDir = path24.join(os.tmpdir(), tempId);
|
|
9222
|
+
const stageFolder = path24.join(stageBaseDir, cleanName);
|
|
9223
|
+
await FileSystemUtils.createDirectory(stageFolder);
|
|
9224
|
+
spinner.text = "Staging production files (filtering dev bloat)...";
|
|
9225
|
+
const fileCount = await this.stageProductionFiles(projectRoot, stageFolder);
|
|
9226
|
+
if (fileCount === 0) {
|
|
9227
|
+
spinner.fail("No valid production files found to package.");
|
|
9228
|
+
await FileSystemUtils.removeDirectory(stageBaseDir, true);
|
|
9229
|
+
process.exitCode = 1;
|
|
9230
|
+
return;
|
|
9231
|
+
}
|
|
9232
|
+
const outputDir = options.out ? path24.resolve(options.out) : path24.join(projectRoot, "releases");
|
|
9233
|
+
await FileSystemUtils.createDirectory(outputDir);
|
|
9234
|
+
const archiveName = `${cleanName}-v${version2}.zip`;
|
|
9235
|
+
const archivePath = path24.join(outputDir, archiveName);
|
|
9236
|
+
if (await FileSystemUtils.fileExists(archivePath)) {
|
|
9237
|
+
await FileSystemUtils.removeFile(archivePath);
|
|
9238
|
+
}
|
|
9239
|
+
spinner.text = `Compressing ${chalk17.cyan(archiveName)}...`;
|
|
9240
|
+
await this.createZipArchive(stageBaseDir, cleanName, archivePath);
|
|
9241
|
+
const archiveStat = await fs4.stat(archivePath);
|
|
9242
|
+
const sizeKb = (archiveStat.size / 1024).toFixed(1);
|
|
9243
|
+
const sizeMb = (archiveStat.size / (1024 * 1024)).toFixed(2);
|
|
9244
|
+
const displaySize = archiveStat.size >= 1024 * 1024 ? `${sizeMb} MB` : `${sizeKb} KB`;
|
|
9245
|
+
try {
|
|
9246
|
+
await FileSystemUtils.removeDirectory(stageBaseDir, true);
|
|
9247
|
+
} catch {
|
|
9248
|
+
}
|
|
9249
|
+
const elapsedMs = Date.now() - startTime;
|
|
9250
|
+
spinner.succeed(chalk17.green(`Packaged ${chalk17.bold(archiveName)} in ${elapsedMs}ms`));
|
|
9251
|
+
console.log("\n" + "\u2550".repeat(60));
|
|
9252
|
+
console.log(chalk17.bold("\u{1F4E6} Production Release Archive Ready"));
|
|
9253
|
+
console.log("\u2550".repeat(60));
|
|
9254
|
+
console.log(` File: ${chalk17.cyan(path24.relative(process.cwd(), archivePath) || archivePath)}`);
|
|
9255
|
+
console.log(` Size: ${chalk17.yellow(displaySize)} (${archiveStat.size.toLocaleString()} bytes)`);
|
|
9256
|
+
console.log(` Files: ${chalk17.green(fileCount)} files included`);
|
|
9257
|
+
console.log(` Root Folder: ${chalk17.cyan(cleanName + "/")}`);
|
|
9258
|
+
console.log(` Exclusions: ${chalk17.gray("node_modules, .git, tests, dev tools stripped")}`);
|
|
9259
|
+
console.log("\u2550".repeat(60) + "\n");
|
|
9260
|
+
} catch (error) {
|
|
9261
|
+
spinner.fail(`Packaging failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
9262
|
+
process.exitCode = 1;
|
|
9263
|
+
}
|
|
9264
|
+
}
|
|
9265
|
+
async detectProjectName(projectRoot) {
|
|
9266
|
+
const configPath = path24.join(projectRoot, HERASPEC_DIR_NAME, HERASPEC_MARKERS.CONFIG_YAML);
|
|
9267
|
+
if (await FileSystemUtils.fileExists(configPath)) {
|
|
9268
|
+
const content = await FileSystemUtils.readFile(configPath);
|
|
9269
|
+
const match = content.match(/projectName:\s*["']?([^"'\n\r]+)["']?/);
|
|
9270
|
+
if (match && match[1]) {
|
|
9271
|
+
return match[1].toLowerCase().replace(/[^a-z0-9_-]/g, "_");
|
|
9272
|
+
}
|
|
9273
|
+
}
|
|
9274
|
+
const entries = await fs4.readdir(projectRoot, { withFileTypes: true });
|
|
9275
|
+
for (const entry of entries) {
|
|
9276
|
+
if (entry.isFile() && entry.name.endsWith(".php")) {
|
|
9277
|
+
const filePath = path24.join(projectRoot, entry.name);
|
|
9278
|
+
const content = await FileSystemUtils.readFile(filePath);
|
|
9279
|
+
if (content.includes("Module Name:") || content.includes("Plugin Name:")) {
|
|
9280
|
+
return entry.name.replace(/\.php$/, "");
|
|
9281
|
+
}
|
|
9282
|
+
}
|
|
9283
|
+
}
|
|
9284
|
+
const packageJsonPath2 = path24.join(projectRoot, "package.json");
|
|
9285
|
+
if (await FileSystemUtils.fileExists(packageJsonPath2)) {
|
|
9286
|
+
try {
|
|
9287
|
+
const pkg = JSON.parse(await FileSystemUtils.readFile(packageJsonPath2));
|
|
9288
|
+
if (pkg.name) {
|
|
9289
|
+
return pkg.name.replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9_-]/g, "_");
|
|
9290
|
+
}
|
|
9291
|
+
} catch {
|
|
9292
|
+
}
|
|
9293
|
+
}
|
|
9294
|
+
return path24.basename(projectRoot).toLowerCase().replace(/[^a-z0-9_-]/g, "_");
|
|
9295
|
+
}
|
|
9296
|
+
async detectProjectVersion(projectRoot) {
|
|
9297
|
+
const entries = await fs4.readdir(projectRoot, { withFileTypes: true });
|
|
9298
|
+
for (const entry of entries) {
|
|
9299
|
+
if (entry.isFile() && entry.name.endsWith(".php")) {
|
|
9300
|
+
const filePath = path24.join(projectRoot, entry.name);
|
|
9301
|
+
const content = await FileSystemUtils.readFile(filePath);
|
|
9302
|
+
const headerMatch = content.match(/Version:\s*([0-9]+\.[0-9]+(?:\.[0-9]+)?)/i);
|
|
9303
|
+
if (headerMatch && headerMatch[1]) return headerMatch[1];
|
|
9304
|
+
const constMatch = content.match(/define\s*\(\s*['"][^'"]*VERSION['"]\s*,\s*['"]([0-9]+\.[0-9]+(?:\.[0-9]+)?)['"]\s*\)/i);
|
|
9305
|
+
if (constMatch && constMatch[1]) return constMatch[1];
|
|
9306
|
+
}
|
|
9307
|
+
}
|
|
9308
|
+
const packageJsonPath2 = path24.join(projectRoot, "package.json");
|
|
9309
|
+
if (await FileSystemUtils.fileExists(packageJsonPath2)) {
|
|
9310
|
+
try {
|
|
9311
|
+
const pkg = JSON.parse(await FileSystemUtils.readFile(packageJsonPath2));
|
|
9312
|
+
if (pkg.version) return pkg.version;
|
|
9313
|
+
} catch {
|
|
9314
|
+
}
|
|
9315
|
+
}
|
|
9316
|
+
return "1.0.0";
|
|
9317
|
+
}
|
|
9318
|
+
async buildAssetsIfConfigured(projectRoot, spinner) {
|
|
9319
|
+
const packageJsonPath2 = path24.join(projectRoot, "package.json");
|
|
9320
|
+
if (!await FileSystemUtils.fileExists(packageJsonPath2)) return;
|
|
9321
|
+
try {
|
|
9322
|
+
const pkg = JSON.parse(await FileSystemUtils.readFile(packageJsonPath2));
|
|
9323
|
+
if (!pkg.scripts || !pkg.scripts.build) return;
|
|
9324
|
+
spinner.text = "Running asset production build (npm run build)...";
|
|
9325
|
+
execSync("npm run build", {
|
|
9326
|
+
cwd: projectRoot,
|
|
9327
|
+
stdio: "pipe",
|
|
9328
|
+
timeout: 12e4
|
|
9329
|
+
});
|
|
9330
|
+
spinner.succeed("Asset production build completed successfully.");
|
|
9331
|
+
spinner.start();
|
|
9332
|
+
} catch (buildError) {
|
|
9333
|
+
spinner.warn(`Asset build command failed or timed out: ${buildError instanceof Error ? buildError.message : "Unknown error"}`);
|
|
9334
|
+
spinner.start();
|
|
9335
|
+
}
|
|
9336
|
+
}
|
|
9337
|
+
async stageProductionFiles(srcDir, destDir) {
|
|
9338
|
+
let fileCount = 0;
|
|
9339
|
+
const copyRecursive = async (currentSrc, currentDest) => {
|
|
9340
|
+
await fs4.mkdir(currentDest, { recursive: true });
|
|
9341
|
+
const entries = await fs4.readdir(currentSrc, { withFileTypes: true });
|
|
9342
|
+
for (const entry of entries) {
|
|
9343
|
+
const srcPath = path24.join(currentSrc, entry.name);
|
|
9344
|
+
const destPath = path24.join(currentDest, entry.name);
|
|
9345
|
+
if (entry.isDirectory()) {
|
|
9346
|
+
if (this.defaultExcludeDirs.has(entry.name)) continue;
|
|
9347
|
+
if (entry.name.startsWith(".")) continue;
|
|
9348
|
+
await copyRecursive(srcPath, destPath);
|
|
9349
|
+
} else if (entry.isFile()) {
|
|
9350
|
+
if (this.defaultExcludeFiles.has(entry.name)) continue;
|
|
9351
|
+
if (entry.name.startsWith(".")) continue;
|
|
9352
|
+
if (entry.name.endsWith(".test.php") || entry.name.endsWith(".spec.ts") || entry.name.endsWith(".log")) continue;
|
|
9353
|
+
await fs4.copyFile(srcPath, destPath);
|
|
9354
|
+
fileCount++;
|
|
9355
|
+
}
|
|
9356
|
+
}
|
|
9357
|
+
};
|
|
9358
|
+
await copyRecursive(srcDir, destDir);
|
|
9359
|
+
return fileCount;
|
|
9360
|
+
}
|
|
9361
|
+
async createZipArchive(stageBaseDir, folderToPack, zipDestination) {
|
|
9362
|
+
const isWindows = process.platform === "win32";
|
|
9363
|
+
try {
|
|
9364
|
+
execSync(`tar -a -cf "${zipDestination}" "${folderToPack}"`, {
|
|
9365
|
+
cwd: stageBaseDir,
|
|
9366
|
+
stdio: "pipe"
|
|
9367
|
+
});
|
|
9368
|
+
if (await FileSystemUtils.fileExists(zipDestination)) {
|
|
9369
|
+
return;
|
|
9370
|
+
}
|
|
9371
|
+
} catch {
|
|
9372
|
+
}
|
|
9373
|
+
if (isWindows) {
|
|
9374
|
+
try {
|
|
9375
|
+
const sourcePath = path24.join(stageBaseDir, folderToPack);
|
|
9376
|
+
const psCommand = `Compress-Archive -Path "${sourcePath}" -DestinationPath "${zipDestination}" -Force`;
|
|
9377
|
+
execSync(`powershell.exe -NoProfile -NonInteractive -Command "${psCommand}"`, {
|
|
9378
|
+
cwd: stageBaseDir,
|
|
9379
|
+
stdio: "pipe"
|
|
9380
|
+
});
|
|
9381
|
+
if (await FileSystemUtils.fileExists(zipDestination)) {
|
|
9382
|
+
return;
|
|
9383
|
+
}
|
|
9384
|
+
} catch (psErr) {
|
|
9385
|
+
throw new Error(`Compression failed via tar and PowerShell: ${psErr.message}`);
|
|
9386
|
+
}
|
|
9387
|
+
} else {
|
|
9388
|
+
try {
|
|
9389
|
+
execSync(`zip -r "${zipDestination}" "${folderToPack}"`, {
|
|
9390
|
+
cwd: stageBaseDir,
|
|
9391
|
+
stdio: "pipe"
|
|
9392
|
+
});
|
|
9393
|
+
if (await FileSystemUtils.fileExists(zipDestination)) {
|
|
9394
|
+
return;
|
|
9395
|
+
}
|
|
9396
|
+
} catch (zipErr) {
|
|
9397
|
+
throw new Error(`Compression failed via tar and zip: ${zipErr.message}`);
|
|
9398
|
+
}
|
|
9399
|
+
}
|
|
9400
|
+
throw new Error("Could not create archive. Please ensure tar, zip, or PowerShell is installed.");
|
|
9401
|
+
}
|
|
9402
|
+
};
|
|
9403
|
+
|
|
7654
9404
|
// src/cli/index.ts
|
|
7655
9405
|
var require4 = createRequire3(import.meta.url);
|
|
7656
9406
|
var __filename3 = fileURLToPath3(import.meta.url);
|
|
@@ -7982,5 +9732,32 @@ exploreCmd.command("unfold <file> <symbol>").description("Show full implementati
|
|
|
7982
9732
|
process.exit(1);
|
|
7983
9733
|
}
|
|
7984
9734
|
});
|
|
9735
|
+
program.command("audit [path]").description("Audit codebase for code quality, security, and clean architecture standards").option("--fix", "Automatically fix safe violations (e.g. missing direct access guards)").option("--type <type>", "Specify project type (perfex-module, wordpress-plugin, wordpress-theme)").action(async (targetPath, options) => {
|
|
9736
|
+
try {
|
|
9737
|
+
const auditCommand = new AuditCommand();
|
|
9738
|
+
await auditCommand.execute(targetPath || ".", options);
|
|
9739
|
+
} catch (error) {
|
|
9740
|
+
console.error(`Error: ${error.message}`);
|
|
9741
|
+
process.exit(1);
|
|
9742
|
+
}
|
|
9743
|
+
});
|
|
9744
|
+
program.command("create <name>").description("Scaffold a new module, plugin, theme, or content channel with clean architecture standards").option("--type <type>", "Project type (perfex-module, wordpress-plugin, wordpress-theme, content-channel)", "perfex-module").option("--title <title>", "Friendly display title for the project").option("--description <description>", "Project description").option("--out <dir>", "Target output directory").action(async (name, options) => {
|
|
9745
|
+
try {
|
|
9746
|
+
const createCommand = new CreateCommand();
|
|
9747
|
+
await createCommand.execute(name, options);
|
|
9748
|
+
} catch (error) {
|
|
9749
|
+
console.error(`Error: ${error.message}`);
|
|
9750
|
+
process.exit(1);
|
|
9751
|
+
}
|
|
9752
|
+
});
|
|
9753
|
+
program.command("pack [path]").description("Build and package codebase into clean, production-ready .zip archive").option("-o, --out <directory>", "Output directory for the archive (default: ./releases)").option("--name <name>", "Override archive root folder name").option("--version <version>", "Override version tag").option("--no-build", "Skip automatic asset compilation (npm run build)").action(async (targetPath, options) => {
|
|
9754
|
+
try {
|
|
9755
|
+
const packCommand = new PackCommand();
|
|
9756
|
+
await packCommand.execute(targetPath || ".", options);
|
|
9757
|
+
} catch (error) {
|
|
9758
|
+
console.error(`Error: ${error.message}`);
|
|
9759
|
+
process.exit(1);
|
|
9760
|
+
}
|
|
9761
|
+
});
|
|
7985
9762
|
program.parse();
|
|
7986
9763
|
//# sourceMappingURL=heraspec.js.map
|