"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const strict_1 = __importDefault(require("node:assert/strict"));
const schedule_1 = require("../commands/schedule");
(0, node_test_1.describe)('cronToSchtasksArgs', () => {
    (0, node_test_1.it)('every 15 minutes', () => {
        strict_1.default.deepEqual((0, schedule_1.cronToSchtasksArgs)('*/15 * * * *'), ['/sc', 'MINUTE', '/mo', '15']);
    });
    (0, node_test_1.it)('every 30 minutes', () => {
        strict_1.default.deepEqual((0, schedule_1.cronToSchtasksArgs)('*/30 * * * *'), ['/sc', 'MINUTE', '/mo', '30']);
    });
    (0, node_test_1.it)('every hour', () => {
        strict_1.default.deepEqual((0, schedule_1.cronToSchtasksArgs)('0 * * * *'), ['/sc', 'HOURLY', '/mo', '1']);
    });
    (0, node_test_1.it)('every 5 hours', () => {
        strict_1.default.deepEqual((0, schedule_1.cronToSchtasksArgs)('0 */5 * * *'), ['/sc', 'HOURLY', '/mo', '5']);
    });
    (0, node_test_1.it)('daily at 8am — zero-pads hour', () => {
        strict_1.default.deepEqual((0, schedule_1.cronToSchtasksArgs)('0 8 * * *'), ['/sc', 'DAILY', '/st', '08:00']);
    });
    (0, node_test_1.it)('daily at midnight (0 0)', () => {
        strict_1.default.deepEqual((0, schedule_1.cronToSchtasksArgs)('0 0 * * *'), ['/sc', 'DAILY', '/st', '00:00']);
    });
    (0, node_test_1.it)('returns null for unsupported expressions', () => {
        strict_1.default.equal((0, schedule_1.cronToSchtasksArgs)('0 9 * * 1'), null); // weekday not supported
        strict_1.default.equal((0, schedule_1.cronToSchtasksArgs)('*/5 */2 * * *'), null);
        strict_1.default.equal((0, schedule_1.cronToSchtasksArgs)('not a cron'), null);
    });
});
(0, node_test_1.describe)('buildUnixCronLine', () => {
    const cwd = '/home/user/myproject';
    const node = '/usr/local/bin/node';
    const aidev = '/usr/local/bin/aidev';
    (0, node_test_1.it)('starts with the cron expression', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        strict_1.default.ok(line.startsWith('*/15 * * * *'));
    });
    (0, node_test_1.it)('includes absolute node binary before aidev binary', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        const nodePos = line.indexOf(node);
        const aidevPos = line.indexOf(aidev);
        strict_1.default.ok(nodePos !== -1, 'node binary missing');
        strict_1.default.ok(aidevPos !== -1, 'aidev binary missing');
        strict_1.default.ok(nodePos < aidevPos, 'node must come before aidev');
    });
    (0, node_test_1.it)('includes cd to the project directory', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        strict_1.default.ok(line.includes(`cd ${cwd}`));
    });
    (0, node_test_1.it)('appends the aidev-cwd marker', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        strict_1.default.ok(line.includes(`# aidev-cwd:${cwd}`));
    });
    (0, node_test_1.it)('ends with "run" followed by the marker', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/30 * * * *', cwd, node, aidev);
        strict_1.default.ok(line.includes(`${aidev} run`));
        strict_1.default.ok(line.endsWith(`# aidev-cwd:${cwd}`));
    });
    (0, node_test_1.it)('uses the provided cron expression verbatim', () => {
        const expr = '0 8 * * *';
        const line = (0, schedule_1.buildUnixCronLine)(expr, cwd, node, aidev);
        strict_1.default.ok(line.startsWith(expr));
    });
    (0, node_test_1.it)('appends extra args after "run" inside the single-quoted command', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, ['-e', '/path/to/.env.aidev']);
        strict_1.default.ok(line.includes(`${aidev} run -e /path/to/.env.aidev'`));
    });
    (0, node_test_1.it)('produces no args segment when extraArgs is empty', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, []);
        strict_1.default.ok(line.includes(`${aidev} run'`));
    });
    (0, node_test_1.it)('double-quotes args containing whitespace', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, ['-e', '/path with space/.env']);
        strict_1.default.ok(line.includes('"/path with space/.env"'));
    });
    (0, node_test_1.it)('escapes shell metacharacters ($, `, ", \\) inside double-quoted args', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, ['--x=$VAR']);
        strict_1.default.ok(line.includes('"--x=\\$VAR"'));
    });
    (0, node_test_1.it)('rejects args containing single quotes', () => {
        strict_1.default.throws(() => (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, ["it's"]));
    });
});
(0, node_test_1.describe)('extractUnixCronArgs', () => {
    const cwd = '/home/user/myproject';
    const node = '/usr/local/bin/node';
    const aidev = '/usr/local/bin/aidev';
    (0, node_test_1.it)('returns [] when no args were embedded', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        strict_1.default.deepEqual((0, schedule_1.extractUnixCronArgs)(line), []);
    });
    (0, node_test_1.it)('round-trips simple args', () => {
        const args = ['-e', '/path/to/.env.aidev'];
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, args);
        strict_1.default.deepEqual((0, schedule_1.extractUnixCronArgs)(line), args);
    });
    (0, node_test_1.it)('round-trips args with whitespace', () => {
        const args = ['-e', '/path with space/.env'];
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, args);
        strict_1.default.deepEqual((0, schedule_1.extractUnixCronArgs)(line), args);
    });
    (0, node_test_1.it)('round-trips args with escaped shell metachars', () => {
        const args = ['--x=$VAR', '--y=`cmd`'];
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, args);
        strict_1.default.deepEqual((0, schedule_1.extractUnixCronArgs)(line), args);
    });
});
(0, node_test_1.describe)('shQuoteForCron', () => {
    (0, node_test_1.it)('leaves simple args unquoted', () => {
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('-e'), '-e');
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('/path/to/.env.aidev'), '/path/to/.env.aidev');
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('foo=bar'), 'foo=bar');
    });
    (0, node_test_1.it)('double-quotes args with whitespace', () => {
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('a b'), '"a b"');
    });
    (0, node_test_1.it)('escapes $, `, ", and \\ inside double quotes', () => {
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('$x'), '"\\$x"');
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('`x`'), '"\\`x\\`"');
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('a"b'), '"a\\"b"');
        strict_1.default.equal((0, schedule_1.shQuoteForCron)('a\\b'), '"a\\\\b"');
    });
    (0, node_test_1.it)('throws on single quotes', () => {
        strict_1.default.throws(() => (0, schedule_1.shQuoteForCron)("it's"));
    });
});
(0, node_test_1.describe)('tokenizeShellArgs', () => {
    (0, node_test_1.it)('parses unquoted tokens', () => {
        strict_1.default.deepEqual((0, schedule_1.tokenizeShellArgs)('-e /path/to/.env'), ['-e', '/path/to/.env']);
    });
    (0, node_test_1.it)('parses double-quoted tokens', () => {
        strict_1.default.deepEqual((0, schedule_1.tokenizeShellArgs)('-e "/path with space/.env"'), ['-e', '/path with space/.env']);
    });
    (0, node_test_1.it)('handles escapes inside double quotes', () => {
        strict_1.default.deepEqual((0, schedule_1.tokenizeShellArgs)('"\\$VAR"'), ['$VAR']);
    });
});
(0, node_test_1.describe)('cmdQuoteForSchtasks', () => {
    (0, node_test_1.it)('leaves simple args unquoted', () => {
        strict_1.default.equal((0, schedule_1.cmdQuoteForSchtasks)('-e'), '-e');
        strict_1.default.equal((0, schedule_1.cmdQuoteForSchtasks)('C:\\path\\to\\.env.aidev'), 'C:\\path\\to\\.env.aidev');
    });
    (0, node_test_1.it)('double-quotes args containing whitespace', () => {
        strict_1.default.equal((0, schedule_1.cmdQuoteForSchtasks)('C:\\path with space\\.env'), '"C:\\path with space\\.env"');
    });
    (0, node_test_1.it)('escapes embedded double quotes by doubling them', () => {
        strict_1.default.equal((0, schedule_1.cmdQuoteForSchtasks)('a"b'), '"a""b"');
    });
});
(0, node_test_1.describe)('windowsTaskName', () => {
    (0, node_test_1.it)('produces a name prefixed with aidev\\', () => {
        strict_1.default.ok((0, schedule_1.windowsTaskName)('C:\\Users\\dev\\myproject').startsWith('aidev\\'));
    });
    (0, node_test_1.it)('removes colons and backslashes from path', () => {
        const name = (0, schedule_1.windowsTaskName)('C:\\Users\\dev\\myproject');
        strict_1.default.ok(!name.includes(':'));
        strict_1.default.ok(!name.slice('aidev\\'.length).includes('\\'));
    });
    (0, node_test_1.it)('handles unix paths', () => {
        const name = (0, schedule_1.windowsTaskName)('/home/user/myproject');
        strict_1.default.ok(name.startsWith('aidev\\'));
        strict_1.default.ok(!name.includes('/'));
    });
    (0, node_test_1.it)('without cronExpr returns base name only', () => {
        const a = (0, schedule_1.windowsTaskName)('C:\\Users\\dev\\myproject');
        const b = (0, schedule_1.windowsTaskName)('C:\\Users\\dev\\myproject', undefined);
        strict_1.default.equal(a, b);
        strict_1.default.ok(!a.includes('--'));
    });
    (0, node_test_1.it)('with cronExpr produces unique names per schedule', () => {
        const cwd = 'C:\\Users\\dev\\myproject';
        const a = (0, schedule_1.windowsTaskName)(cwd, '0 8 * * *');
        const b = (0, schedule_1.windowsTaskName)(cwd, '0 16 * * *');
        strict_1.default.notEqual(a, b);
        strict_1.default.ok(a.startsWith('aidev\\'));
        strict_1.default.ok(b.startsWith('aidev\\'));
    });
    (0, node_test_1.it)('same cwd + cronExpr produces the same name', () => {
        const cwd = 'C:\\Users\\dev\\myproject';
        const a = (0, schedule_1.windowsTaskName)(cwd, '*/15 * * * *');
        const b = (0, schedule_1.windowsTaskName)(cwd, '*/15 * * * *');
        strict_1.default.equal(a, b);
    });
});
// ─── cronToLaunchdSchedule ────────────────────────────────────────────────────
(0, node_test_1.describe)('cronToLaunchdSchedule', () => {
    (0, node_test_1.it)('every 15 minutes → StartInterval 900s', () => {
        const s = (0, schedule_1.cronToLaunchdSchedule)('*/15 * * * *');
        strict_1.default.deepEqual(s, { key: 'StartInterval', seconds: 900 });
    });
    (0, node_test_1.it)('every 30 minutes → StartInterval 1800s', () => {
        const s = (0, schedule_1.cronToLaunchdSchedule)('*/30 * * * *');
        strict_1.default.deepEqual(s, { key: 'StartInterval', seconds: 1800 });
    });
    (0, node_test_1.it)('every hour (0 * * * *) → StartInterval 3600s', () => {
        const s = (0, schedule_1.cronToLaunchdSchedule)('0 * * * *');
        strict_1.default.deepEqual(s, { key: 'StartInterval', seconds: 3600 });
    });
    (0, node_test_1.it)('every 5 hours → StartInterval 18000s', () => {
        const s = (0, schedule_1.cronToLaunchdSchedule)('0 */5 * * *');
        strict_1.default.deepEqual(s, { key: 'StartInterval', seconds: 18000 });
    });
    (0, node_test_1.it)('daily at 8am → StartCalendarInterval hour=8 minute=0', () => {
        const s = (0, schedule_1.cronToLaunchdSchedule)('0 8 * * *');
        strict_1.default.deepEqual(s, { key: 'StartCalendarInterval', hour: 8, minute: 0 });
    });
    (0, node_test_1.it)('daily at midnight → StartCalendarInterval hour=0 minute=0', () => {
        const s = (0, schedule_1.cronToLaunchdSchedule)('0 0 * * *');
        strict_1.default.deepEqual(s, { key: 'StartCalendarInterval', hour: 0, minute: 0 });
    });
    (0, node_test_1.it)('returns null for unsupported expressions', () => {
        strict_1.default.equal((0, schedule_1.cronToLaunchdSchedule)('0 9 * * 1'), null);
        strict_1.default.equal((0, schedule_1.cronToLaunchdSchedule)('*/5 */2 * * *'), null);
        strict_1.default.equal((0, schedule_1.cronToLaunchdSchedule)('not a cron'), null);
    });
});
// ─── buildLaunchAgentPlist ────────────────────────────────────────────────────
(0, node_test_1.describe)('buildLaunchAgentPlist', () => {
    const label = 'com.aidev.run.abc123';
    const nodeBin = '/usr/local/bin/node';
    const aidevBin = '/usr/local/bin/aidev';
    const cwd = '/Users/dev/myproject';
    const intervalSchedule = { key: 'StartInterval', seconds: 900 };
    const calendarSchedule = { key: 'StartCalendarInterval', hour: 8, minute: 0 };
    (0, node_test_1.it)('generates valid XML plist header', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.startsWith('<?xml version="1.0" encoding="UTF-8"?>'));
        strict_1.default.ok(plist.includes('<!DOCTYPE plist'));
        strict_1.default.ok(plist.includes('<plist version="1.0">'));
    });
    (0, node_test_1.it)('includes the label', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.includes(`<string>${label}</string>`));
    });
    (0, node_test_1.it)('includes ProgramArguments with node, aidev, and "run"', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.includes('<key>ProgramArguments</key>'));
        strict_1.default.ok(plist.includes(`<string>${nodeBin}</string>`));
        strict_1.default.ok(plist.includes(`<string>${aidevBin}</string>`));
        strict_1.default.ok(plist.includes('<string>run</string>'));
    });
    (0, node_test_1.it)('includes WorkingDirectory', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.includes(`<string>${cwd}</string>`));
    });
    (0, node_test_1.it)('generates StartInterval for interval schedules', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.includes('<key>StartInterval</key>'));
        strict_1.default.ok(plist.includes('<integer>900</integer>'));
    });
    (0, node_test_1.it)('generates StartCalendarInterval for calendar schedules', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, calendarSchedule);
        strict_1.default.ok(plist.includes('<key>StartCalendarInterval</key>'));
        strict_1.default.ok(plist.includes('<key>Hour</key>'));
        strict_1.default.ok(plist.includes('<integer>8</integer>'));
        strict_1.default.ok(plist.includes('<key>Minute</key>'));
        strict_1.default.ok(plist.includes('<integer>0</integer>'));
    });
    (0, node_test_1.it)('does not contain XML-escaped values for normal paths', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        // Normal paths should not be escaped — no &amp; &lt; &gt;
        strict_1.default.ok(!plist.includes('&amp;'));
        strict_1.default.ok(!plist.includes('&lt;'));
        strict_1.default.ok(!plist.includes('&gt;'));
    });
    (0, node_test_1.it)('includes PATH environment variable', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.includes('<key>PATH</key>'));
        strict_1.default.ok(plist.includes('<key>EnvironmentVariables</key>'));
    });
    (0, node_test_1.it)('includes HOME environment variable', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.includes('<key>HOME</key>'));
    });
    (0, node_test_1.it)('sets RunAtLoad to false', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule);
        strict_1.default.ok(plist.includes('<key>RunAtLoad</key>'));
        strict_1.default.ok(plist.includes('<false/>'));
    });
    (0, node_test_1.it)('appends extra args as additional <string> entries after "run"', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule, ['-e', '/path/to/.env']);
        const argsBlock = plist.match(/<key>ProgramArguments<\/key>\s*<array>([\s\S]*?)<\/array>/);
        strict_1.default.ok(argsBlock, 'ProgramArguments missing');
        const strings = [...argsBlock[1].matchAll(/<string>([^<]*)<\/string>/g)].map((m) => m[1]);
        strict_1.default.deepEqual(strings, [nodeBin, aidevBin, 'run', '-e', '/path/to/.env']);
    });
    (0, node_test_1.it)('XML-escapes special characters in extra args', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, intervalSchedule, ['--x=a&b']);
        strict_1.default.ok(plist.includes('<string>--x=a&amp;b</string>'));
    });
});
(0, node_test_1.describe)('extractLaunchAgentArgs', () => {
    const label = 'com.aidev.run.abc123';
    const nodeBin = '/usr/local/bin/node';
    const aidevBin = '/usr/local/bin/aidev';
    const cwd = '/Users/dev/myproject';
    const schedule = { key: 'StartInterval', seconds: 900 };
    (0, node_test_1.it)('returns [] when no extra args were embedded', () => {
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, schedule);
        strict_1.default.deepEqual((0, schedule_1.extractLaunchAgentArgs)(plist), []);
    });
    (0, node_test_1.it)('round-trips extra args', () => {
        const args = ['-e', '/path/to/.env.aidev'];
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, schedule, args);
        strict_1.default.deepEqual((0, schedule_1.extractLaunchAgentArgs)(plist), args);
    });
    (0, node_test_1.it)('round-trips XML-escaped args', () => {
        const args = ['--x=a&b'];
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, schedule, args);
        strict_1.default.deepEqual((0, schedule_1.extractLaunchAgentArgs)(plist), args);
    });
    (0, node_test_1.it)('returns [] for plist without ProgramArguments', () => {
        strict_1.default.deepEqual((0, schedule_1.extractLaunchAgentArgs)('<plist><dict></dict></plist>'), []);
    });
});
// ─── extractLaunchdSchedule ───────────────────────────────────────────────────
(0, node_test_1.describe)('extractLaunchdSchedule', () => {
    const label = 'com.aidev.run.abc123';
    const nodeBin = '/usr/local/bin/node';
    const aidevBin = '/usr/local/bin/aidev';
    const cwd = '/Users/dev/myproject';
    (0, node_test_1.it)('extracts StartInterval from a generated plist', () => {
        const schedule = { key: 'StartInterval', seconds: 900 };
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, schedule);
        strict_1.default.deepEqual((0, schedule_1.extractLaunchdSchedule)(plist), schedule);
    });
    (0, node_test_1.it)('extracts StartCalendarInterval from a generated plist', () => {
        const schedule = { key: 'StartCalendarInterval', hour: 8, minute: 0 };
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, schedule);
        strict_1.default.deepEqual((0, schedule_1.extractLaunchdSchedule)(plist), schedule);
    });
    (0, node_test_1.it)('round-trips: extract then rebuild produces identical plist', () => {
        const schedule = { key: 'StartInterval', seconds: 1800 };
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, schedule);
        const extracted = (0, schedule_1.extractLaunchdSchedule)(plist);
        const rebuilt = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, extracted);
        strict_1.default.equal(rebuilt, plist);
    });
    (0, node_test_1.it)('round-trips calendar schedule: extract then rebuild produces identical plist', () => {
        const schedule = { key: 'StartCalendarInterval', hour: 8, minute: 0 };
        const plist = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, schedule);
        const extracted = (0, schedule_1.extractLaunchdSchedule)(plist);
        const rebuilt = (0, schedule_1.buildLaunchAgentPlist)(label, nodeBin, aidevBin, cwd, extracted);
        strict_1.default.equal(rebuilt, plist);
    });
    (0, node_test_1.it)('returns null for plist with no schedule keys', () => {
        strict_1.default.equal((0, schedule_1.extractLaunchdSchedule)('<plist><dict></dict></plist>'), null);
    });
});
// ─── schedule fix: Unix cron round-trip ───────────────────────────────────────
(0, node_test_1.describe)('buildUnixCronLine idempotency (schedule fix basis)', () => {
    const cwd = '/home/user/myproject';
    const node = '/usr/local/bin/node';
    const aidev = '/usr/local/bin/aidev';
    (0, node_test_1.it)('rebuilding with same args produces identical line (already up to date)', () => {
        const line = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        const rebuilt = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        strict_1.default.equal(line, rebuilt);
    });
    (0, node_test_1.it)('rebuilding with different node path produces a different line (needs fix)', () => {
        const original = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, '/old/bin/node', aidev);
        const updated = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        strict_1.default.notEqual(original, updated);
        strict_1.default.ok(updated.includes(node));
        strict_1.default.ok(!updated.includes('/old/bin/node'));
    });
    (0, node_test_1.it)('rebuilding with different aidev path produces a different line (needs fix)', () => {
        const original = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, '/old/bin/aidev');
        const updated = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev);
        strict_1.default.notEqual(original, updated);
        strict_1.default.ok(updated.includes(aidev));
    });
    (0, node_test_1.it)('preserves extra args round-tripped through extract+rebuild (schedule fix)', () => {
        const args = ['-e', '/path/to/.env.aidev'];
        const original = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, args);
        const extracted = (0, schedule_1.extractUnixCronArgs)(original);
        const rebuilt = (0, schedule_1.buildUnixCronLine)('*/15 * * * *', cwd, node, aidev, extracted);
        strict_1.default.equal(original, rebuilt);
    });
});
//# sourceMappingURL=schedule.test.js.map