@khanhcan148/mk 0.1.25 → 0.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanhcan148/mk",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "CLI to install and manage MyClaudeKit (.claude/) in your projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -110,6 +110,11 @@ try {
110
110
  process.exit(1);
111
111
  }
112
112
 
113
+ // Verbose flag: MK_VERBOSE=1 enables per-agent progress lines and IAC-1 warnings.
114
+ // When spawned by runCodexConversion, the parent passes MK_VERBOSE based on its
115
+ // verbose option so the child inherits the same quietness setting.
116
+ const VERBOSE = process.env.MK_VERBOSE === '1';
117
+
113
118
  // ---------------------------------------------------------------------------
114
119
  // IAC-1 patterns: Claude-only constructs to flag in agent bodies
115
120
  // ---------------------------------------------------------------------------
@@ -127,6 +132,7 @@ const IAC1_PATTERNS = [
127
132
  * @param {string} body Raw Markdown body (frontmatter stripped)
128
133
  */
129
134
  function checkIac1(agentName, body) {
135
+ if (!VERBOSE) return;
130
136
  const lines = body.split('\n');
131
137
  for (const { pattern, label } of IAC1_PATTERNS) {
132
138
  for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
@@ -341,10 +347,12 @@ for (const mdPath of mdFiles) {
341
347
  }
342
348
  }
343
349
 
344
- process.stdout.write(
345
- `[convert-agents-to-codex] Done. ${successCount} converted, ${errorCount} errors.\n`
346
- );
347
- process.stdout.write(`[convert-agents-to-codex] Output: ${outputDir}\n`);
350
+ if (VERBOSE) {
351
+ process.stdout.write(
352
+ `[convert-agents-to-codex] Done. ${successCount} converted, ${errorCount} errors.\n`
353
+ );
354
+ process.stdout.write(`[convert-agents-to-codex] Output: ${outputDir}\n`);
355
+ }
348
356
 
349
357
  if (errors.length > 0) {
350
358
  process.stderr.write(`[convert-agents-to-codex] Errors:\n${errors.join('\n')}\n`);
@@ -154,6 +154,9 @@ function buildToml() {
154
154
  export async function convertHooksToCodex(opts = {}) {
155
155
  const projectRoot = opts.projectRoot ? resolve(opts.projectRoot) : PACKAGE_ROOT;
156
156
  const outputDir = opts.outputDir ? resolve(opts.outputDir) : join(projectRoot, '.codex');
157
+ // verbose: caller passes explicit boolean; fallback to MK_VERBOSE env var for
158
+ // the case where this module is imported by a spawned child process.
159
+ const verbose = opts.verbose ?? process.env.MK_VERBOSE === '1';
157
160
 
158
161
  const warnings = [];
159
162
  const dropped = [];
@@ -163,7 +166,9 @@ export async function convertHooksToCodex(opts = {}) {
163
166
  const msg = `[convert-hooks-to-codex] WARNING: Dropping ${name} (${source} event has no Codex equivalent)`;
164
167
  warnings.push(msg);
165
168
  dropped.push(name);
166
- process.stderr.write(msg + '\n');
169
+ if (verbose) {
170
+ process.stderr.write(msg + '\n');
171
+ }
167
172
  }
168
173
 
169
174
  // Count emitted hooks
@@ -88,6 +88,11 @@ for (let i = 0; i < args.length; i++) {
88
88
 
89
89
  const modelMap = loadModelMap(modelMapPath);
90
90
 
91
+ // Verbose flag: MK_VERBOSE=1 enables per-skill progress lines.
92
+ // When spawned by runCodexConversion, the parent passes MK_VERBOSE based on its
93
+ // verbose option so the child inherits the same quietness setting.
94
+ const VERBOSE = process.env.MK_VERBOSE === '1';
95
+
91
96
  const kitRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
92
97
  const inputDir = inputDirArg || join(kitRoot, '.claude', 'skills');
93
98
  const outputDir = outputDirArg || join(kitRoot, '.codex', 'skills');
@@ -219,7 +224,9 @@ let errorCount = 0;
219
224
  const errors = [];
220
225
 
221
226
  function logInfo(msg) {
222
- process.stderr.write(`${LOG_PREFIX} ${msg}\n`);
227
+ if (VERBOSE) {
228
+ process.stderr.write(`${LOG_PREFIX} ${msg}\n`);
229
+ }
223
230
  }
224
231
 
225
232
  function logError(msg) {
@@ -336,10 +343,12 @@ for (const dirent of skillDirs) {
336
343
  }
337
344
  }
338
345
 
339
- process.stdout.write(
340
- `${LOG_PREFIX} Done. ${successCount} converted, ${errorCount} errors.\n`
341
- );
342
- process.stdout.write(`${LOG_PREFIX} Output: ${outputDir}\n`);
346
+ if (VERBOSE) {
347
+ process.stdout.write(
348
+ `${LOG_PREFIX} Done. ${successCount} converted, ${errorCount} errors.\n`
349
+ );
350
+ process.stdout.write(`${LOG_PREFIX} Output: ${outputDir}\n`);
351
+ }
343
352
 
344
353
  if (errors.length > 0) {
345
354
  process.stderr.write(`${LOG_PREFIX} Errors:\n${errors.join('\n')}\n`);
@@ -258,13 +258,18 @@ export async function runCodexConversion(options = {}) {
258
258
  console.log(chalk.cyan(` → ${agentsOut}`));
259
259
  }
260
260
 
261
+ // Propagate verbose flag to child converter processes via MK_VERBOSE env var.
262
+ // Child processes use { stdio: 'inherit' } so their stdout/stderr bypass the
263
+ // parent-level verbose gate — the env var is the only way to suppress them.
264
+ const childEnv = { ...process.env, MK_VERBOSE: verbose ? '1' : '0' };
265
+
261
266
  // Start both spawns concurrently.
262
267
  const skillsPromise = isDirectory(skillsDir)
263
268
  ? new Promise((resolveExit) => {
264
269
  const child = spawn(
265
270
  process.execPath,
266
271
  [SKILLS_CONVERTER_SCRIPT, '--input', skillsDir, '--output', skillsOut],
267
- { stdio: 'inherit' }
272
+ { stdio: 'inherit', env: childEnv }
268
273
  );
269
274
  child.on('close', (exitCode) => resolveExit(exitCode ?? 1));
270
275
  child.on('error', (err) => {
@@ -275,7 +280,7 @@ export async function runCodexConversion(options = {}) {
275
280
  : Promise.resolve(0);
276
281
 
277
282
  const agentsPromise = new Promise((resolveExit) => {
278
- const child = spawn(process.execPath, args, { stdio: 'inherit' });
283
+ const child = spawn(process.execPath, args, { stdio: 'inherit', env: childEnv });
279
284
  child.on('close', (exitCode) => resolveExit(exitCode ?? 1));
280
285
  child.on('error', (err) => {
281
286
  console.error(chalk.red(`error: failed to spawn converter: ${err.message}`));
@@ -306,7 +311,7 @@ export async function runCodexConversion(options = {}) {
306
311
  mirrorDirWithRewrite(workflowsDir, workflowsOut);
307
312
  }
308
313
 
309
- const hooksResult = await convertHooksToCodex({ projectRoot, outputDir: codexRoot });
314
+ const hooksResult = await convertHooksToCodex({ projectRoot, outputDir: codexRoot, verbose });
310
315
  if (verbose && hooksResult.dropped.length > 0) {
311
316
  console.warn(
312
317
  chalk.yellow(