@jvittechs/j 1.0.46 → 1.0.48

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/dist/cli.js CHANGED
@@ -149,7 +149,7 @@ import { basename as basename5 } from "path";
149
149
  // package.json
150
150
  var package_default = {
151
151
  name: "@jvittechs/j",
152
- version: "1.0.46",
152
+ version: "1.0.48",
153
153
  description: "A unified CLI tool for JV-IT TECHS developers to manage Jai1 Framework. Supports both `j` and `jai1` commands. Please contact TeamAI for usage instructions.",
154
154
  type: "module",
155
155
  bin: {
@@ -919,22 +919,18 @@ var MigrateIdeService = class {
919
919
  } catch {
920
920
  return items;
921
921
  }
922
- const files = await fs4.readdir(dirPath);
923
- for (const file of files) {
924
- if (!file.endsWith(".md")) continue;
925
- const filepath = path.join(dirPath, file);
926
- const stat = await fs4.stat(filepath);
927
- if (!stat.isFile()) continue;
922
+ const mdFiles = await this.collectMdFiles(dirPath, dirPath);
923
+ for (const { filepath, relativeName } of mdFiles) {
928
924
  const content = await fs4.readFile(filepath, "utf-8");
929
925
  let frontmatter = {};
930
926
  try {
931
927
  const { data } = matter(content);
932
928
  frontmatter = data;
933
929
  } catch (e) {
934
- console.warn(`\u26A0\uFE0F Skipping ${file}: Invalid YAML frontmatter`);
930
+ console.warn(`\u26A0\uFE0F Skipping ${relativeName}: Invalid YAML frontmatter`);
935
931
  continue;
936
932
  }
937
- const name = path.basename(file, ".md");
933
+ const name = relativeName;
938
934
  const trigger = this.extractTrigger(frontmatter);
939
935
  const alwaysApply = this.isAlwaysTrigger(trigger);
940
936
  items.push({
@@ -1124,6 +1120,34 @@ ${bodyContent}
1124
1120
  return path.join(this.projectPath, config.basePath, contentPath, filename);
1125
1121
  }
1126
1122
  // Helper methods
1123
+ /**
1124
+ * Recursively collect .md files from a directory.
1125
+ * Supports both flat layout (core v1) and subdirectory layout (core v2).
1126
+ * Returns relative name preserving subdirectory structure:
1127
+ * - Flat: 'commit-it' (from commit-it.md)
1128
+ * - Subdir: 'dev/feature' (from dev/feature.md)
1129
+ */
1130
+ async collectMdFiles(rootDir, currentDir) {
1131
+ const results = [];
1132
+ let entries;
1133
+ try {
1134
+ entries = await fs4.readdir(currentDir, { withFileTypes: true });
1135
+ } catch {
1136
+ return results;
1137
+ }
1138
+ for (const entry of entries) {
1139
+ const fullPath = path.join(currentDir, entry.name);
1140
+ if (entry.isDirectory()) {
1141
+ const subResults = await this.collectMdFiles(rootDir, fullPath);
1142
+ results.push(...subResults);
1143
+ } else if (entry.isFile() && entry.name.endsWith(".md")) {
1144
+ const relativePath = path.relative(rootDir, fullPath);
1145
+ const relativeName = relativePath.replace(/\.md$/, "");
1146
+ results.push({ filepath: fullPath, relativeName });
1147
+ }
1148
+ }
1149
+ return results;
1150
+ }
1127
1151
  /**
1128
1152
  * Extract trigger from frontmatter
1129
1153
  * Jai1 source format uses 'trigger' field (Windsurf/Antigravity compatible)
@@ -10937,8 +10961,10 @@ async function handleWatch(address, options) {
10937
10961
  const startTime = Date.now();
10938
10962
  if (!options.json) {
10939
10963
  console.log(chalk25.bold.cyan(`\u{1F440} Watching inbox: ${address}`));
10940
- console.log(chalk25.dim(` Polling every ${intervalSec}s${timeoutSec ? ` \xB7 timeout ${timeoutSec}s` : ""} \xB7 Ctrl+C to stop
10941
- `));
10964
+ console.log(chalk25.dim(
10965
+ ` Polling every ${intervalSec}s` + (timeoutSec ? ` \xB7 timeout ${timeoutSec}s` : "") + (options.keep ? " \xB7 keep watching" : " \xB7 stops after first email") + ` \xB7 Ctrl+C to stop
10966
+ `
10967
+ ));
10942
10968
  }
10943
10969
  const init = await api.getInbox(address, 30);
10944
10970
  if (init.success && init.data) {
@@ -10986,6 +11012,10 @@ async function handleWatch(address, options) {
10986
11012
  }
10987
11013
  }
10988
11014
  console.log();
11015
+ if (!options.keep) {
11016
+ clearInterval(timer);
11017
+ process.exit(0);
11018
+ }
10989
11019
  }
10990
11020
  }
10991
11021
  };
@@ -11000,10 +11030,11 @@ async function handleWatch(address, options) {
11000
11030
  });
11001
11031
  }
11002
11032
  function createMailWatchCommand() {
11003
- return new Command52("watch").description("L\u1EAFng nghe email m\u1EDBi (polling)").argument("<address>", "\u0110\u1ECBa ch\u1EC9 email c\u1EA7n theo d\xF5i").option("-i, --interval <seconds>", "Kho\u1EA3ng th\u1EDDi gian poll (gi\xE2y, m\u1EB7c \u0111\u1ECBnh: 15)", "15").option("-t, --timeout <seconds>", "D\u1EEBng sau N gi\xE2y (m\u1EB7c \u0111\u1ECBnh: ch\u1EA1y m\xE3i)").option("-j, --json", "Output s\u1EF1 ki\u1EC7n email m\u1EDBi d\u1EA1ng JSON (m\u1ED7i d\xF2ng 1 event)").addHelpText("after", `
11033
+ return new Command52("watch").description("L\u1EAFng nghe email m\u1EDBi (polling)").argument("<address>", "\u0110\u1ECBa ch\u1EC9 email c\u1EA7n theo d\xF5i").option("-i, --interval <seconds>", "Kho\u1EA3ng th\u1EDDi gian poll (gi\xE2y, m\u1EB7c \u0111\u1ECBnh: 15)", "15").option("-t, --timeout <seconds>", "D\u1EEBng sau N gi\xE2y (m\u1EB7c \u0111\u1ECBnh: ch\u1EA1y m\xE3i)").option("-k, --keep", "Ti\u1EBFp t\u1EE5c watch sau khi nh\u1EADn \u0111\u01B0\u1EE3c email (m\u1EB7c \u0111\u1ECBnh: d\u1EEBng sau email \u0111\u1EA7u ti\xEAn)").option("-j, --json", "Output s\u1EF1 ki\u1EC7n email m\u1EDBi d\u1EA1ng JSON (m\u1ED7i d\xF2ng 1 event)").addHelpText("after", `
11004
11034
  Examples:
11005
- $ j dev mail watch user@dollicons.com
11006
- $ j dev mail watch user@dollicons.com -i 30
11035
+ $ j dev mail watch user@dollicons.com # D\u1EEBng khi nh\u1EADn \u0111\u01B0\u1EE3c email \u0111\u1EA7u ti\xEAn
11036
+ $ j dev mail watch user@dollicons.com -k # Ti\u1EBFp t\u1EE5c watch
11037
+ $ j dev mail watch user@dollicons.com -i 30 -k
11007
11038
  $ j dev mail watch user@dollicons.com -t 300
11008
11039
  $ j dev mail watch user@dollicons.com -j | jq .
11009
11040
  `).action(async (address, options) => {