ktg-plugin-marketplace/plugins/ms-ai-architect/tests/kb-update
Kjell Tore Guttormsen 30d7a2024c feat(ms-ai-architect): add install-kb-cron standalone helper for cross-OS cron registration [skip-docs]
Step 11 of v1.12.0 plan (.claude/projects/2026-05-04-kb-update-fork-and-own/plan.md).

scripts/install-kb-cron.mjs lives at the scripts/ root (not inside
scripts/kb-update/) because it is a plugin-wide install tool, not part of
the KB-update pipeline itself. Reads the appropriate template from
scripts/kb-update/templates/, fills {{NODE_BIN}}, {{PLUGIN_ROOT}},
{{LOG_FILE}}, {{SCHEDULE_HOUR/MINUTE/DAY_OF_WEEK}} placeholders, writes
to the platform-specific scheduler dir, and registers the job:

  macOS  - launchctl bootstrap gui/<uid> <plist>  (load -w fallback)
  Linux  - systemctl --user daemon-reload && enable --now <timer>
  Windows - powershell -ExecutionPolicy Bypass -File <ps1>  (beta)

Flags: --print-only, --target macos|linux|windows, --uninstall, --purge,
--node-bin, --claude-bin, --schedule "M H * * D" (default: Wed 04:23).

UID resolution for launchctl is guarded by process.getuid() POSIX-only
(undefined on Windows). MCP server presence in ~/.claude.json is
warning-only per brief Spørsmål 7. WSL detected via /proc/version.
Cross-OS rendering supported via --print-only --target <other>; install
on a non-host target rejects with explicit error.

11 subprocess + filesystem-snapshot tests in
tests/kb-update/test-install-cron.test.mjs verify --print-only produces
filled templates with no unsubstituted {{...}} placeholders, --print-only
writes nothing under HOME, --uninstall is idempotent on an empty HOME,
--schedule substitutes correctly, and invalid flags reject with non-zero
exit. Tests never invoke launchctl/systemctl/Register-ScheduledTask
against real schedulers.

Tests: 110/110 pass (was 99 before this step).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 11:26:54 +02:00
..
test-atomic-write.test.mjs feat(ms-ai-architect): add lib/atomic-write for crash-safe state files [skip-docs] 2026-05-05 10:32:13 +02:00
test-auth-mode.test.mjs feat(ms-ai-architect): add lib/auth-mode for cron-safe auth detection [skip-docs] 2026-05-05 10:52:53 +02:00
test-backup-restore.test.mjs feat(ms-ai-architect): add lib/backup with sentinel-guarded rollback [skip-docs] 2026-05-05 10:50:10 +02:00
test-cost-estimat.test.mjs feat(ms-ai-architect): add lib/cost-estimat heuristic for API-key budget [skip-docs] 2026-05-05 10:34:37 +02:00
test-cross-platform-paths.test.mjs feat(ms-ai-architect): add lib/cross-platform-paths for cache/log/state/backup dirs [skip-docs] 2026-05-05 10:30:31 +02:00
test-install-cron.test.mjs feat(ms-ai-architect): add install-kb-cron standalone helper for cross-OS cron registration [skip-docs] 2026-05-05 11:26:54 +02:00
test-lock-file.test.mjs feat(ms-ai-architect): add lib/lock-file with PID+mtime stale detection [skip-docs] 2026-05-05 10:47:05 +02:00
test-log-rotate.test.mjs feat(ms-ai-architect): add lib/log-rotate for bounded log disk use [skip-docs] 2026-05-05 10:54:50 +02:00
test-session-start-status.test.mjs feat(ms-ai-architect): session-start hook reads kb-update-status for failure surfacing [skip-docs] 2026-05-05 11:12:37 +02:00
test-template-generation.test.mjs feat(ms-ai-architect): add cross-OS scheduling templates (launchd/systemd/Windows) [skip-docs] 2026-05-05 11:02:44 +02:00
test-weekly-kb-cron-flags.test.mjs feat(ms-ai-architect): rewrite weekly-kb-cron with portable paths, auth-mode-aware pre-flight, lock+backup+rollback [skip-docs] 2026-05-05 11:10:17 +02:00