heraspec 0.1.15 → 0.1.16

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.
Files changed (69) hide show
  1. package/README.md +46 -12
  2. package/bin/heraspec.js +1296 -75
  3. package/bin/heraspec.js.map +4 -4
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/commands/audit.d.ts +37 -0
  6. package/dist/commands/create.d.ts +11 -0
  7. package/dist/commands/explore.d.ts +17 -0
  8. package/dist/commands/helper.d.ts +13 -0
  9. package/dist/commands/hotfix.d.ts +9 -0
  10. package/dist/commands/make-code.d.ts +14 -0
  11. package/dist/commands/make-docs.d.ts +36 -0
  12. package/dist/commands/make-test.d.ts +60 -0
  13. package/dist/commands/memory.d.ts +101 -0
  14. package/dist/commands/pack.d.ts +17 -0
  15. package/dist/commands/show.d.ts +8 -0
  16. package/dist/commands/skill.d.ts +8 -0
  17. package/dist/commands/suggest.d.ts +32 -0
  18. package/dist/commands/validate.d.ts +8 -0
  19. package/dist/core/archive.d.ts +14 -0
  20. package/dist/core/config.d.ts +33 -0
  21. package/dist/core/init.d.ts +97 -0
  22. package/dist/core/list.d.ts +7 -0
  23. package/dist/core/memory/config-advisor.d.ts +30 -0
  24. package/dist/core/memory/context-config.d.ts +14 -0
  25. package/dist/core/memory/context-generator.d.ts +19 -0
  26. package/dist/core/memory/index.d.ts +12 -0
  27. package/dist/core/memory/memory-schema.d.ts +34 -0
  28. package/dist/core/memory/memory-search.d.ts +45 -0
  29. package/dist/core/memory/memory-store.d.ts +71 -0
  30. package/dist/core/memory/memory-types.d.ts +159 -0
  31. package/dist/core/memory/memory-vector.d.ts +23 -0
  32. package/dist/core/parsers/code-parser.d.ts +53 -0
  33. package/dist/core/parsers/markdown-parser.d.ts +18 -0
  34. package/dist/core/restore.d.ts +9 -0
  35. package/dist/core/schemas/base.schema.d.ts +55 -0
  36. package/dist/core/schemas/change.schema.d.ts +35 -0
  37. package/dist/core/schemas/index.d.ts +7 -0
  38. package/dist/core/schemas/spec.schema.d.ts +50 -0
  39. package/dist/core/skills/index.d.ts +6 -0
  40. package/dist/core/skills/skill-manager.d.ts +28 -0
  41. package/dist/core/skills/skill-parser.d.ts +24 -0
  42. package/dist/core/sync.d.ts +6 -0
  43. package/dist/core/templates/index.d.ts +10 -0
  44. package/dist/core/templates/skills/README.md +4 -1
  45. package/dist/core/templates/skills/perfex-module/code-quality-guidelines/skill.md +130 -0
  46. package/dist/core/templates/skills/perfex-module/envato-review-guidelines/skill.md +132 -0
  47. package/dist/core/templates/skills/perfex-module/module-codebase/scripts/scaffold-module.js +151 -0
  48. package/dist/core/templates/skills/perfex-module/module-codebase/skill.md +204 -110
  49. package/dist/core/templates/skills/perfex-module/module-codebase/templates/Test_Module.php +79 -0
  50. package/dist/core/templates/skills/perfex-module/module-codebase/templates/controller-admin.php +71 -0
  51. package/dist/core/templates/skills/perfex-module/module-codebase/templates/controller-api.php +58 -0
  52. package/dist/core/templates/skills/perfex-module/module-codebase/templates/deploy.ps1 +97 -0
  53. package/dist/core/templates/skills/perfex-module/module-codebase/templates/helper.php +97 -0
  54. package/dist/core/templates/skills/perfex-module/module-codebase/templates/install.php +30 -0
  55. package/dist/core/templates/skills/perfex-module/module-codebase/templates/model-main.php +94 -0
  56. package/dist/core/templates/skills/perfex-module/module-codebase/templates/module-main.php +91 -0
  57. package/dist/core/templates/skills/perfex-module/module-codebase/templates/package.json +30 -0
  58. package/dist/core/templates/skills/perfex-module/module-codebase/templates/uninstall.php +11 -0
  59. package/dist/core/templates/skills/perfex-module/module-codebase/templates/webpack.config.js +163 -0
  60. package/dist/core/templates/skills/perfex-module/skill.md +50 -0
  61. package/dist/core/templates/skills-template-map.d.ts +29 -0
  62. package/dist/core/validation/validator.d.ts +26 -0
  63. package/dist/core/view.d.ts +4 -0
  64. package/dist/index.d.ts +11 -0
  65. package/dist/index.js +155 -35
  66. package/dist/utils/file-system.d.ts +19 -0
  67. package/dist/utils/index.d.ts +6 -0
  68. package/dist/utils/task-parser.d.ts +26 -0
  69. package/package.json +2 -2
@@ -0,0 +1,97 @@
1
+ <?php
2
+ defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+ /**
5
+ * {ModuleName} Helper
6
+ *
7
+ * Provides asset rendering with dist/ fallback, cache busting, and utility helpers.
8
+ */
9
+ class {module_name}_helper
10
+ {
11
+ /**
12
+ * Get file timestamp for zero-downtime cache busting
13
+ */
14
+ public static function get_file_timestamp($relative_path)
15
+ {
16
+ $full_path = rtrim(FCPATH, '/\\') . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $relative_path);
17
+ return file_exists($full_path) ? filemtime($full_path) : '1.0.0';
18
+ }
19
+
20
+ /**
21
+ * Render module custom JS with dist fallback & cache busting
22
+ *
23
+ * @param string $subpath Relative path inside assets/js/ (without .js extension)
24
+ * @return string HTML script tag
25
+ */
26
+ public static function render_module_js($subpath)
27
+ {
28
+ $rel_dist = 'dist/assets/js/' . $subpath . '.min.js';
29
+ $rel_src = 'assets/js/' . $subpath . '.js';
30
+
31
+ $full_dist = rtrim(FCPATH, '/\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . {MODULE_UPPERCASE}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_dist);
32
+ $full_src = rtrim(FCPATH, '/\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . {MODULE_UPPERCASE}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_src);
33
+
34
+ $chosen = file_exists($full_dist) ? $rel_dist : $rel_src;
35
+ $path = 'modules/' . {MODULE_UPPERCASE}_MODULE_NAME . '/' . $chosen;
36
+ $url = module_dir_url({MODULE_UPPERCASE}_MODULE_NAME, $chosen);
37
+ $v = self::get_file_timestamp($path);
38
+
39
+ return '<script src="' . $url . '?v=' . $v . '"></script>' . PHP_EOL;
40
+ }
41
+
42
+ /**
43
+ * Render module custom CSS with dist fallback & cache busting
44
+ *
45
+ * @param string $subpath Relative path inside assets/css/ (without .css extension)
46
+ * @return string HTML link tag
47
+ */
48
+ public static function render_module_css($subpath)
49
+ {
50
+ $rel_dist = 'dist/assets/css/' . $subpath . '.min.css';
51
+ $rel_src = 'assets/css/' . $subpath . '.css';
52
+
53
+ $full_dist = rtrim(FCPATH, '/\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . {MODULE_UPPERCASE}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_dist);
54
+ $full_src = rtrim(FCPATH, '/\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . {MODULE_UPPERCASE}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_src);
55
+
56
+ $chosen = file_exists($full_dist) ? $rel_dist : $rel_src;
57
+ $path = 'modules/' . {MODULE_UPPERCASE}_MODULE_NAME . '/' . $chosen;
58
+ $url = module_dir_url({MODULE_UPPERCASE}_MODULE_NAME, $chosen);
59
+ $v = self::get_file_timestamp($path);
60
+
61
+ return '<link rel="stylesheet" href="' . $url . '?v=' . $v . '">' . PHP_EOL;
62
+ }
63
+
64
+ /**
65
+ * Render third-party vendor library JS from lib/
66
+ */
67
+ public static function render_lib_js($library)
68
+ {
69
+ $rel_dist = 'dist/assets/js/lib/' . $library . '.js';
70
+ $rel_src = 'assets/js/lib/' . $library . '.js';
71
+
72
+ $full_dist = rtrim(FCPATH, '/\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . {MODULE_UPPERCASE}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_dist);
73
+ $chosen = file_exists($full_dist) ? $rel_dist : $rel_src;
74
+ $path = 'modules/' . {MODULE_UPPERCASE}_MODULE_NAME . '/' . $chosen;
75
+ $url = module_dir_url({MODULE_UPPERCASE}_MODULE_NAME, $chosen);
76
+ $v = self::get_file_timestamp($path);
77
+
78
+ return '<script src="' . $url . '?v=' . $v . '"></script>' . PHP_EOL;
79
+ }
80
+
81
+ /**
82
+ * Render third-party vendor library CSS from lib/
83
+ */
84
+ public static function render_lib_css($library)
85
+ {
86
+ $rel_dist = 'dist/assets/css/lib/' . $library . '.css';
87
+ $rel_src = 'assets/css/lib/' . $library . '.css';
88
+
89
+ $full_dist = rtrim(FCPATH, '/\\') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . {MODULE_UPPERCASE}_MODULE_NAME . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $rel_dist);
90
+ $chosen = file_exists($full_dist) ? $rel_dist : $rel_src;
91
+ $path = 'modules/' . {MODULE_UPPERCASE}_MODULE_NAME . '/' . $chosen;
92
+ $url = module_dir_url({MODULE_UPPERCASE}_MODULE_NAME, $chosen);
93
+ $v = self::get_file_timestamp($path);
94
+
95
+ return '<link rel="stylesheet" href="' . $url . '?v=' . $v . '">' . PHP_EOL;
96
+ }
97
+ }
@@ -0,0 +1,30 @@
1
+ <?php
2
+ defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+ $CI = &get_instance();
5
+
6
+ // Create primary entity table if not exists
7
+ if (!$CI->db->table_exists(db_prefix() . '{module_name}_items')) {
8
+ $CI->db->query('CREATE TABLE `' . db_prefix() . '{module_name}_items` (
9
+ `id` INT(11) NOT NULL AUTO_INCREMENT,
10
+ `rel_type` VARCHAR(40) NOT NULL,
11
+ `rel_id` INT(11) NOT NULL,
12
+ `title` VARCHAR(255) NOT NULL,
13
+ `description` TEXT NULL,
14
+ `status` TINYINT(1) NOT NULL DEFAULT 1,
15
+ `date_created` DATETIME NOT NULL,
16
+ `created_by` INT(11) NOT NULL,
17
+ PRIMARY KEY (`id`),
18
+ KEY `idx_rel_lookup` (`rel_type`, `rel_id`),
19
+ KEY `idx_status_created` (`status`, `date_created`)
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=' . $CI->db->char_set . ';');
21
+ }
22
+
23
+ // Add default module options if not exists
24
+ if (empty(get_option('{module_name}_enabled'))) {
25
+ add_option('{module_name}_enabled', '1', 1);
26
+ }
27
+
28
+ if (empty(get_option('{module_name}_version'))) {
29
+ add_option('{module_name}_version', '1.0.0', 1);
30
+ }
@@ -0,0 +1,94 @@
1
+ <?php
2
+ defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+ class {ModuleName}_model extends App_Model
5
+ {
6
+ protected $table;
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->table = db_prefix() . '{module_name}_items';
12
+ }
13
+
14
+ /**
15
+ * Get all items with optional filters
16
+ */
17
+ public function get_all($where = [])
18
+ {
19
+ if (!empty($where)) {
20
+ $this->db->where($where);
21
+ }
22
+ $this->db->order_by('date_created', 'DESC');
23
+ return $this->db->get($this->table)->result_array();
24
+ }
25
+
26
+ /**
27
+ * Get single item by ID
28
+ */
29
+ public function get($id)
30
+ {
31
+ $this->db->where('id', (int)$id);
32
+ return $this->db->get($this->table)->row_array();
33
+ }
34
+
35
+ /**
36
+ * Add new item
37
+ */
38
+ public function add($data)
39
+ {
40
+ $data['date_created'] = date('Y-m-d H:i:s');
41
+ $data['created_by'] = get_staff_user_id();
42
+
43
+ $this->db->insert($this->table, $data);
44
+ $insert_id = $this->db->insert_id();
45
+
46
+ if ($insert_id) {
47
+ log_activity('{ModuleName} Item Added [ID: ' . $insert_id . ']');
48
+ }
49
+
50
+ return $insert_id;
51
+ }
52
+
53
+ /**
54
+ * Update item by ID
55
+ */
56
+ public function update($id, $data)
57
+ {
58
+ $this->db->where('id', (int)$id);
59
+ $this->db->update($this->table, $data);
60
+
61
+ return $this->db->affected_rows() > 0;
62
+ }
63
+
64
+ /**
65
+ * Delete item by ID
66
+ */
67
+ public function delete($id)
68
+ {
69
+ $this->db->where('id', (int)$id);
70
+ $this->db->delete($this->table);
71
+
72
+ $deleted = $this->db->affected_rows() > 0;
73
+ if ($deleted) {
74
+ log_activity('{ModuleName} Item Deleted [ID: ' . (int)$id . ']');
75
+ }
76
+
77
+ return $deleted;
78
+ }
79
+
80
+ /**
81
+ * Search items using polymorphic composite index
82
+ */
83
+ public function search($query, $limit = 20)
84
+ {
85
+ $this->db->select('id, rel_type, rel_id, title, status, date_created');
86
+ $this->db->from($this->table);
87
+ if (!empty($query)) {
88
+ $this->db->like('title', $query);
89
+ }
90
+ $this->db->where('status', 1);
91
+ $this->db->limit($limit);
92
+ return $this->db->get()->result_array();
93
+ }
94
+ }
@@ -0,0 +1,91 @@
1
+ <?php
2
+ defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+ /*
5
+ Module Name: {MODULE_FRIENDLY_NAME}
6
+ Description: {MODULE_DESCRIPTION}
7
+ Version: 1.0.0
8
+ Requires at least: 2.9.*
9
+ Author: PolyXGO
10
+ Author URI: https://codecanyon.net/user/polyxgo
11
+ */
12
+
13
+ define('{MODULE_UPPERCASE}_MODULE_NAME', '{module_name}');
14
+ define('{MODULE_UPPERCASE}_VERSION', '1.0.0');
15
+
16
+ // Register activation, deactivation, and uninstall hooks
17
+ register_activation_hook({MODULE_UPPERCASE}_MODULE_NAME, '{module_name}_activation_hook');
18
+ register_deactivation_hook({MODULE_UPPERCASE}_MODULE_NAME, '{module_name}_deactivation_hook');
19
+ register_uninstall_hook({MODULE_UPPERCASE}_MODULE_NAME, '{module_name}_uninstall_hook');
20
+
21
+ function {module_name}_activation_hook()
22
+ {
23
+ $CI = &get_instance();
24
+ require_once(__DIR__ . '/install.php');
25
+ }
26
+
27
+ function {module_name}_deactivation_hook()
28
+ {
29
+ // Clean up temporary session flags or cache if needed
30
+ }
31
+
32
+ function {module_name}_uninstall_hook()
33
+ {
34
+ require_once(__DIR__ . '/uninstall.php');
35
+ }
36
+
37
+ // Register language files
38
+ register_language_files({MODULE_UPPERCASE}_MODULE_NAME, [{MODULE_UPPERCASE}_MODULE_NAME]);
39
+
40
+ // Autoload helper
41
+ $CI = &get_instance();
42
+ $CI->load->helper({MODULE_UPPERCASE}_MODULE_NAME . '/{module_name}');
43
+
44
+ // Hook: Register Admin Menu Item
45
+ hooks()->add_action('admin_init', '{module_name}_init_menu_items');
46
+
47
+ function {module_name}_init_menu_items()
48
+ {
49
+ $CI = &get_instance();
50
+ if (has_permission('{module_name}', '', 'view')) {
51
+ $CI->app_menu->add_sidebar_menu_item('{module_name}-menu', [
52
+ 'name' => _l('{module_name}_menu_title'),
53
+ 'href' => admin_url('{module_name}'),
54
+ 'icon' => 'fa-solid fa-cube',
55
+ 'position' => 30,
56
+ ]);
57
+ }
58
+ }
59
+
60
+ // Hook: Enqueue Admin Assets & Localization
61
+ hooks()->add_action('app_admin_head', '{module_name}_enqueue_admin_head');
62
+ hooks()->add_action('app_admin_footer', '{module_name}_enqueue_admin_footer');
63
+
64
+ function {module_name}_enqueue_admin_head()
65
+ {
66
+ // Centralized localization data - Zero inline script in views
67
+ $config = [
68
+ 'moduleName' => {MODULE_UPPERCASE}_MODULE_NAME,
69
+ 'version' => {MODULE_UPPERCASE}_VERSION,
70
+ 'adminUrl' => admin_url('{module_name}/'),
71
+ 'csrfToken' => get_instance()->security->get_csrf_hash(),
72
+ ];
73
+ $lang = [
74
+ 'confirmDelete' => _l('{module_name}_confirm_delete'),
75
+ 'saveSuccess' => _l('{module_name}_saved_successfully'),
76
+ ];
77
+
78
+ echo '<script>' . PHP_EOL;
79
+ echo 'window.' . '{MODULE_UPPERCASE}_CONFIG = ' . json_encode($config) . ';' . PHP_EOL;
80
+ echo 'window.' . '{MODULE_UPPERCASE}_LANG = ' . json_encode($lang) . ';' . PHP_EOL;
81
+ echo '</script>' . PHP_EOL;
82
+
83
+ // Load custom stylesheet with auto dist fallback and cache busting
84
+ echo {module_name}_helper::render_module_css('admin/{module_name}_admin');
85
+ }
86
+
87
+ function {module_name}_enqueue_admin_footer()
88
+ {
89
+ // Load custom scripts with auto dist fallback and cache busting
90
+ echo {module_name}_helper::render_module_js('admin/{module_name}_admin');
91
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "{module_name}",
3
+ "version": "1.0.0",
4
+ "description": "{MODULE_DESCRIPTION}",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "build": "webpack --mode production",
8
+ "dev": "webpack --mode development",
9
+ "watch": "webpack --mode development --watch"
10
+ },
11
+ "keywords": [
12
+ "perfex",
13
+ "perfex-crm",
14
+ "module"
15
+ ],
16
+ "author": "PolyXGO",
17
+ "license": "ISC",
18
+ "devDependencies": {
19
+ "@babel/core": "^7.24.7",
20
+ "@babel/preset-env": "^7.24.7",
21
+ "babel-loader": "^9.1.3",
22
+ "clean-css": "^5.3.3",
23
+ "clean-css-cli": "^5.6.3",
24
+ "fs-extra": "^11.2.0",
25
+ "glob": "^8.1.0",
26
+ "terser-webpack-plugin": "^5.3.10",
27
+ "webpack": "^5.92.0",
28
+ "webpack-cli": "^5.1.4"
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ <?php
2
+ defined('BASEPATH') or exit('No direct script access allowed');
3
+
4
+ $CI = &get_instance();
5
+
6
+ // Delete module registered options
7
+ delete_option('{module_name}_enabled');
8
+ delete_option('{module_name}_version');
9
+
10
+ // Optional: Drop database tables if complete cleanup is requested
11
+ // $CI->db->query('DROP TABLE IF EXISTS `' . db_prefix() . '{module_name}_items`');
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Webpack Configuration for Perfex CRM Module
3
+ *
4
+ * Compiles and minifies development assets from assets/ into dist/assets/
5
+ */
6
+
7
+ const is_console_remove = true;
8
+ const is_minimize = true;
9
+ const path = require("path");
10
+ const TerserPlugin = require("terser-webpack-plugin");
11
+ const glob = require("glob");
12
+ const fs = require("fs-extra");
13
+ const CleanCSS = require("clean-css");
14
+
15
+ // Plugin to delete the dist folder before compilation starts
16
+ class CleanDistFolderPlugin {
17
+ apply(compiler) {
18
+ compiler.hooks.beforeRun.tapAsync(
19
+ "CleanDistFolderPlugin",
20
+ (compilation, callback) => {
21
+ const distPath = path.resolve(__dirname, "dist");
22
+ if (fs.existsSync(distPath)) {
23
+ fs.removeSync(distPath);
24
+ }
25
+ callback();
26
+ }
27
+ );
28
+ }
29
+ }
30
+
31
+ // Plugin to copy library files directly to dist without mangling
32
+ class CopyLibFilesPlugin {
33
+ apply(compiler) {
34
+ compiler.hooks.afterEmit.tap("CopyLibFilesPlugin", () => {
35
+ const jsLibPath = path.resolve(__dirname, "./assets/js/lib");
36
+ const cssLibPath = path.resolve(__dirname, "./assets/css/lib");
37
+ const distJsLibPath = path.resolve(__dirname, "dist/assets/js/lib");
38
+ const distCssLibPath = path.resolve(__dirname, "dist/assets/css/lib");
39
+
40
+ if (fs.existsSync(jsLibPath)) {
41
+ fs.copySync(jsLibPath, distJsLibPath, { overwrite: true });
42
+ }
43
+
44
+ if (fs.existsSync(cssLibPath)) {
45
+ fs.copySync(cssLibPath, distCssLibPath, { overwrite: true });
46
+ }
47
+ });
48
+ }
49
+ }
50
+
51
+ // Plugin to minify custom CSS files using CleanCSS
52
+ class MinifyCssPlugin {
53
+ apply(compiler) {
54
+ compiler.hooks.afterEmit.tap("MinifyCssPlugin", () => {
55
+ const cssFiles = glob.sync("./assets/css/**/!(*.min).css", {
56
+ ignore: ["./assets/css/lib/**/*"],
57
+ });
58
+
59
+ const cleanCssInstance = new CleanCSS({
60
+ level: 1,
61
+ });
62
+
63
+ cssFiles.forEach((file) => {
64
+ const relativePath = path.relative("./assets", file);
65
+ const minifiedFile = path.resolve(
66
+ __dirname,
67
+ "dist/assets",
68
+ relativePath.replace(/\.css$/, ".min.css")
69
+ );
70
+
71
+ try {
72
+ const sourceContent = fs.readFileSync(file, "utf8");
73
+ const minifiedOutput = cleanCssInstance.minify(sourceContent);
74
+ if (minifiedOutput.styles) {
75
+ fs.outputFileSync(minifiedFile, minifiedOutput.styles);
76
+ }
77
+ } catch (err) {
78
+ console.error(`Error minifying ${file}:`, err);
79
+ }
80
+ });
81
+ });
82
+ }
83
+ }
84
+
85
+ // Scan custom JS files excluding lib and .min.js
86
+ const jsFiles = glob.sync("./assets/js/**/*.js", {
87
+ ignore: [
88
+ "./assets/js/lib/**/*",
89
+ "./assets/js/**/*.min.js"
90
+ ],
91
+ });
92
+
93
+ const jsEntry = jsFiles.reduce((entries, file) => {
94
+ const name = path
95
+ .relative("./assets", file)
96
+ .replace(/\\/g, "/")
97
+ .replace(/\.js$/, "");
98
+ entries[name] = `./${file}`;
99
+ return entries;
100
+ }, {});
101
+
102
+ module.exports = {
103
+ entry: jsEntry,
104
+ output: {
105
+ filename: (pathData) => {
106
+ const filePath = pathData.chunk.name.replace(/\\/g, "/");
107
+ return `${filePath}.min.js`;
108
+ },
109
+ path: path.resolve(__dirname, "dist/assets/"),
110
+ },
111
+ resolve: {
112
+ modules: [path.resolve(__dirname), "node_modules"],
113
+ extensions: [".js"],
114
+ },
115
+ optimization: {
116
+ minimize: is_minimize,
117
+ minimizer: [
118
+ new TerserPlugin({
119
+ test: /\.js$/,
120
+ exclude: /assets\/js\/lib\//,
121
+ extractComments: false,
122
+ terserOptions: {
123
+ compress: {
124
+ drop_console: is_console_remove,
125
+ dead_code: true,
126
+ drop_debugger: true,
127
+ },
128
+ mangle: {
129
+ keep_classnames: true,
130
+ keep_fnames: true,
131
+ },
132
+ output: {
133
+ comments: false,
134
+ },
135
+ },
136
+ }),
137
+ ],
138
+ },
139
+ module: {
140
+ rules: [
141
+ {
142
+ test: /\.js$/,
143
+ exclude: [
144
+ /node_modules/,
145
+ /assets\/js\/lib\//,
146
+ ],
147
+ use: {
148
+ loader: "babel-loader",
149
+ options: {
150
+ presets: ["@babel/preset-env"],
151
+ },
152
+ },
153
+ },
154
+ ],
155
+ },
156
+ mode: "production",
157
+ plugins: [
158
+ new CleanDistFolderPlugin(),
159
+ new CopyLibFilesPlugin(),
160
+ new MinifyCssPlugin(),
161
+ ],
162
+ devtool: false,
163
+ };
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: perfex-module
3
+ description: Comprehensive guideline and best practices for developing, refactoring, and delivering high-quality Perfex CRM modules following Clean Code standards, OWASP security, and production quality guidelines.
4
+ ---
5
+
6
+ # Perfex CRM Module Engineering & Quality Guidelines
7
+
8
+ This skill suite serves as the authoritative standard for developing, refactoring, packaging, and delivering production-ready, enterprise-grade Perfex CRM modules.
9
+
10
+ ## Skill Suite Navigation
11
+
12
+ 1. **[Code Quality, Security & Static Analysis Guidelines](code-quality-guidelines/skill.md)**
13
+ - Separation of Concerns: Zero Inline JS & CSS (runtime & documentation).
14
+ - AST & Scanner Neutrality: Professional naming conventions (`extend` instead of `inject`, `demo_data` instead of `seeder`, `allow` instead of `bypass`).
15
+ - Safe Dynamic Stylesheet Loading: TinyMCE & Iframe stylesheet synchronization (`editor.dom.loadCSS` and link element cloning).
16
+ - Admin JS Scoped Pattern: Conflict-proof JavaScript (`window.addEventListener('load')` + strict IIFE).
17
+ - Concurrency & Non-Blocking I/O: PHP Session lock prevention (`session_write_close()`).
18
+ - Clean Release Packaging: Exclude development tooling (`package.json`, `webpack.config.js`, `tests/`, `scratch/`).
19
+ - Defensive PHP Security: `BASEPATH` security check, CSRF tokens on all POST/AJAX, parameterized queries.
20
+ - DOM XSS Prevention: Safe element creation and HTMLPurifier configuration.
21
+ - Enterprise Internationalization: 100% multilingual parity (`_l('key')`) and zero emojis.
22
+
23
+ 2. **[Module Codebase & Clean Architecture](module-codebase/skill.md)**
24
+ - Standard directory layout (MVC + Helpers + Libraries + Dist + Assets + Tests + Documentations).
25
+ - Thin Controllers, Rich Models (Separation of Concerns).
26
+ - High-performance composite indexing for polymorphic CRM tables (`db_prefix()`).
27
+ - Context isolation firewall for Client Portal safety (no internal staff/leads leakage).
28
+ - Asset enqueuing with automatic fallback from minified `dist/` to `assets/` and `?v=` cache busting.
29
+ - Production scaffolding templates in `templates/`.
30
+
31
+ ---
32
+
33
+ ## Production Readiness & Quality Assurance Checklist
34
+
35
+ Before releasing or packaging a module:
36
+
37
+ - [ ] **1. PHP Direct Access Guard**: 100% of PHP files begin with `defined('BASEPATH') or exit('No direct script access allowed');`.
38
+ - [ ] **2. Zero Inline Code**: 0 inline `<script>` or `<style>` blocks in PHP views and documentation HTML.
39
+ - [ ] **3. Static Analysis Neutrality**: 0 occurrences of high-risk scanner triggers (`inject`, `seeder`, `bypass`, `eval`, `unserialize`).
40
+ - [ ] **4. Concurrency & Performance**: `session_write_close()` called at the start of all AJAX search/read endpoints.
41
+ - [ ] **5. Multilingual Parity**: 100% parity across language files (e.g. `language/english/` and `language/vietnamese/` with 0 missing keys).
42
+ - [ ] **6. Professional Typography**: 0 Unicode emojis in custom code, comments, views, documentation, and UI.
43
+ - [ ] **7. Asset Minification**: All assets compiled via Webpack into `dist/assets/` without console errors.
44
+ - [ ] **8. Automated Tests**: All test assertions pass 100% in `tests/Test_{ModuleName}.php`.
45
+ - [ ] **9. Clean Release Package**: Verify module zip strictly excludes `package.json`, `webpack.config.js`, `tests/`, `scratch/`, and `.git`.
46
+
47
+ ---
48
+
49
+ ## Reference Implementation
50
+ - **CrossTag for Perfex** (`modules/crosstag/`): Production benchmark with dual-engine autocompleter, composite database indexes, asset fallback pipeline, and 57/57 passing automated test assertions.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Skills Template Mapping
3
+ * Maps skill names to their template files and resources
4
+ */
5
+ export interface SkillTemplateInfo {
6
+ templateFileName: string;
7
+ isCrossCutting: boolean;
8
+ projectType?: string;
9
+ resourceDirs?: string[];
10
+ viFileName?: string;
11
+ }
12
+ /**
13
+ * Mapping of skill names to their template information
14
+ * Key format: "projectType:skillName" for project-specific, or "skillName" for cross-cutting
15
+ */
16
+ export declare const SKILL_TEMPLATE_MAP: Record<string, SkillTemplateInfo>;
17
+ /**
18
+ * Get template info for a skill
19
+ */
20
+ export declare function getSkillTemplateInfo(skillName: string, projectType?: string): SkillTemplateInfo | null;
21
+ /**
22
+ * Get all available skill templates
23
+ */
24
+ export declare function getAllSkillTemplates(): Array<{
25
+ skillName: string;
26
+ projectType?: string;
27
+ info: SkillTemplateInfo;
28
+ }>;
29
+ //# sourceMappingURL=skills-template-map.d.ts.map
@@ -0,0 +1,26 @@
1
+ export interface ValidationIssue {
2
+ message: string;
3
+ path?: string;
4
+ line?: number;
5
+ suggestion?: string;
6
+ autoFixable?: boolean;
7
+ }
8
+ export interface ValidationReport {
9
+ valid: boolean;
10
+ errors: ValidationIssue[];
11
+ warnings: ValidationIssue[];
12
+ suggestions?: string[];
13
+ }
14
+ export declare class Validator {
15
+ private strictMode;
16
+ constructor(strictMode?: boolean);
17
+ validateSpec(filePath: string): Promise<ValidationReport>;
18
+ validateChange(changePath: string): Promise<ValidationReport>;
19
+ private validateDeltaSpec;
20
+ private extractNameFromPath;
21
+ private findDeltaSpecs;
22
+ private captureFingerprints;
23
+ private extractRequirementBlock;
24
+ private getParseErrorSuggestion;
25
+ }
26
+ //# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare class ViewCommand {
2
+ execute(targetPath?: string): Promise<void>;
3
+ }
4
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * HeraSpec Main Export
3
+ */
4
+ export * from './core/config.js';
5
+ export * from './core/schemas/index.js';
6
+ export * from './core/init.js';
7
+ export * from './core/list.js';
8
+ export * from './core/archive.js';
9
+ export * from './core/sync.js';
10
+ export * from './core/validation/validator.js';
11
+ //# sourceMappingURL=index.d.ts.map