@xcanwin/manyoyo 5.3.5 → 5.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/manyoyo.js CHANGED
@@ -15,6 +15,7 @@ const { initAgentConfigs } = require('../lib/init-config');
15
15
  const { buildImage } = require('../lib/image-build');
16
16
  const { resolveAgentResumeArg, buildAgentResumeCommand } = require('../lib/agent-resume');
17
17
  const { runPluginCommand } = require('../lib/plugin');
18
+ const { buildManyoyoLogPath } = require('../lib/log-path');
18
19
  const { version: BIN_VERSION, imageVersion: IMAGE_VERSION_DEFAULT } = require('../package.json');
19
20
  const IMAGE_VERSION_BASE = String(IMAGE_VERSION_DEFAULT || '1.0.0').split('-')[0];
20
21
  const IMAGE_VERSION_HELP_EXAMPLE = IMAGE_VERSION_DEFAULT || `${IMAGE_VERSION_BASE}-common`;
@@ -277,37 +278,26 @@ function getServeProcessSnapshot() {
277
278
  }
278
279
 
279
280
  function createServeLogger() {
280
- function pad2(n) {
281
- return String(n).padStart(2, '0');
282
- }
283
-
284
- function getLocalDateTag(date = new Date()) {
285
- const y = date.getFullYear();
286
- const m = pad2(date.getMonth() + 1);
287
- const d = pad2(date.getDate());
288
- return `${y}-${m}-${d}`;
289
- }
290
-
291
281
  function formatLocalTimestamp(date = new Date()) {
292
282
  const y = date.getFullYear();
293
- const m = pad2(date.getMonth() + 1);
294
- const d = pad2(date.getDate());
295
- const hh = pad2(date.getHours());
296
- const mm = pad2(date.getMinutes());
297
- const ss = pad2(date.getSeconds());
283
+ const m = String(date.getMonth() + 1).padStart(2, '0');
284
+ const d = String(date.getDate()).padStart(2, '0');
285
+ const hh = String(date.getHours()).padStart(2, '0');
286
+ const mm = String(date.getMinutes()).padStart(2, '0');
287
+ const ss = String(date.getSeconds()).padStart(2, '0');
298
288
  const ms = String(date.getMilliseconds()).padStart(3, '0');
299
289
  const offsetMinutes = -date.getTimezoneOffset();
300
290
  const sign = offsetMinutes >= 0 ? '+' : '-';
301
291
  const abs = Math.abs(offsetMinutes);
302
- const offH = pad2(Math.floor(abs / 60));
303
- const offM = pad2(abs % 60);
292
+ const offH = String(Math.floor(abs / 60)).padStart(2, '0');
293
+ const offM = String(abs % 60).padStart(2, '0');
304
294
  return `${y}-${m}-${d}T${hh}:${mm}:${ss}.${ms}${sign}${offH}:${offM}`;
305
295
  }
306
296
 
307
- const logDir = path.join(os.homedir(), '.manyoyo', 'logs');
297
+ const serveLog = buildManyoyoLogPath('serve');
298
+ const logDir = serveLog.dir;
308
299
  fs.mkdirSync(logDir, { recursive: true });
309
- const dateTag = getLocalDateTag();
310
- const logPath = path.join(logDir, `serve-${dateTag}.log`);
300
+ const logPath = serveLog.path;
311
301
 
312
302
  function write(level, message, extra) {
313
303
  const ts = formatLocalTimestamp();
@@ -0,0 +1,41 @@
1
+ const os = require('os');
2
+ const path = require('path');
3
+
4
+ function pad2(n) {
5
+ return String(n).padStart(2, '0');
6
+ }
7
+
8
+ function getLocalDateTag(date = new Date()) {
9
+ const y = date.getFullYear();
10
+ const m = pad2(date.getMonth() + 1);
11
+ const d = pad2(date.getDate());
12
+ return `${y}-${m}-${d}`;
13
+ }
14
+
15
+ function normalizeLogScope(scope) {
16
+ return String(scope || 'general')
17
+ .trim()
18
+ .replace(/[^A-Za-z0-9_.-]+/g, '-')
19
+ .replace(/^-+|-+$/g, '') || 'general';
20
+ }
21
+
22
+ function buildManyoyoLogPath(scope, date = new Date(), homeDir = os.homedir()) {
23
+ const safeScope = normalizeLogScope(scope);
24
+ const rootDir = path.join(homeDir, '.manyoyo', 'logs');
25
+ const dir = path.join(rootDir, safeScope);
26
+ const file = `${safeScope}-${getLocalDateTag(date)}.log`;
27
+
28
+ return {
29
+ rootDir,
30
+ dir,
31
+ path: path.join(dir, file),
32
+ scope: safeScope,
33
+ file
34
+ };
35
+ }
36
+
37
+ module.exports = {
38
+ getLocalDateTag,
39
+ normalizeLogScope,
40
+ buildManyoyoLogPath
41
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcanwin/manyoyo",
3
- "version": "5.3.5",
3
+ "version": "5.3.6",
4
4
  "imageVersion": "1.8.4-common",
5
5
  "description": "AI Agent CLI Security Sandbox for Docker and Podman",
6
6
  "keywords": [