robisie 0.6.14 → 0.7.0
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/CHANGELOG.md +30 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine/build-id.json +1 -1
- package/dist/engine/bundle-report.json +17 -5
- package/dist/engine/tick.cjs +880 -729
- package/dist/installation-update.js +121 -37
- package/dist/roles.d.ts +1 -1
- package/docs/README.en.md +1 -1
- package/docs/README.md +1 -1
- package/package.json +1 -1
|
@@ -534,25 +534,30 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
534
534
|
}
|
|
535
535
|
};
|
|
536
536
|
const processBusy = () => {
|
|
537
|
-
|
|
538
|
-
|
|
537
|
+
// macOS ps needs a UTF-8 locale to preserve argv paths. Sonoma may lack C.UTF-8.
|
|
538
|
+
const psEnv = ctx.platform === 'darwin' ? { ...env, LC_ALL: 'en_US.UTF-8' } : env;
|
|
539
|
+
const result = runtime.exec('ps', ['-axo', 'pid=,command='], ctx.cwd, psEnv);
|
|
540
|
+
if (result.status !== 0 || result.signal !== null || result.errorCode !== undefined)
|
|
539
541
|
refuse('Nieustalony stan procesów fabryki.');
|
|
540
542
|
let busy = null;
|
|
543
|
+
const jobs = { tester: new Set(), receiver: new Set() };
|
|
541
544
|
for (const line of result.stdout.split('\n').filter(line => line.trim())) {
|
|
542
545
|
const match = line.match(/^\s*([1-9]\d*)\s+(\S.*)$/);
|
|
543
|
-
|
|
546
|
+
const pid = Number(match?.[1]);
|
|
547
|
+
if (!match || !Number.isSafeInteger(pid))
|
|
544
548
|
refuse('Nieustalony stan procesów fabryki.');
|
|
545
|
-
if (
|
|
549
|
+
if (pid === runtime.pid)
|
|
546
550
|
continue;
|
|
547
|
-
const
|
|
551
|
+
const argv = match[2];
|
|
552
|
+
const tokens = argv.trim().split(/\s+/).slice(0, 8), name = basename(tokens[0]);
|
|
548
553
|
const entry = tokens[1] === '--import' && tokens[2] === 'tsx' ? 3 : 1;
|
|
549
554
|
const script = basename(tokens[entry] ?? '');
|
|
550
|
-
|
|
551
|
-
|
|
555
|
+
// ps flattens argv. Keep both paths whole around the launcher's fixed --job argument.
|
|
556
|
+
const job = name === 'node' ? argv.match(/^\S+\s+(?:--import\s+tsx\s+)?(\/.*?\.(?:cjs|mjs|js))\s+--job\s+(tester|receiver)\s+(.+)$/) : null;
|
|
552
557
|
let factory = false;
|
|
553
558
|
if (name === 'node' && (/^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(script) || script === 'cli.js' || job)) {
|
|
554
559
|
readHostService();
|
|
555
|
-
const path = processEntry(tokens[entry]);
|
|
560
|
+
const path = processEntry(job?.[1] ?? tokens[entry]);
|
|
556
561
|
if (path) {
|
|
557
562
|
const dirs = [dirname(fileURLToPath(runtime.moduleUrl))];
|
|
558
563
|
if (hostService)
|
|
@@ -563,6 +568,12 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
563
568
|
const cli = dirs.some(dir => processEntry(join(dir, 'cli.js')) === path);
|
|
564
569
|
// build-engine.mjs emits tick.cjs; aliases must resolve to that entrypoint.
|
|
565
570
|
const bundle = dirs.some(dir => processEntry(join(dir, 'engine/tick.cjs')) === path);
|
|
571
|
+
const family = job?.[2], input = job?.[3];
|
|
572
|
+
if (bundle && (family === 'tester' || family === 'receiver')) {
|
|
573
|
+
const target = family === 'tester' ? '.tester-job.input.json' : 'receiver-jobs/local';
|
|
574
|
+
if (input === join(state, target) || input === join(config.stateDir, target))
|
|
575
|
+
jobs[family].add(pid);
|
|
576
|
+
}
|
|
566
577
|
const source = /^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(basename(path))
|
|
567
578
|
&& dirname(path) === join(repo, 'maszynista');
|
|
568
579
|
factory = cli && tokens[entry + 1] === 'factory' && tokens[entry + 2] === 'run'
|
|
@@ -576,41 +587,114 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
576
587
|
if (active)
|
|
577
588
|
busy ??= `proces ${/^[A-Za-z0-9._-]+$/.test(name) ? name : 'fabryki'} PID ${match[1]}`;
|
|
578
589
|
}
|
|
579
|
-
return busy;
|
|
590
|
+
return { busy, jobs };
|
|
591
|
+
};
|
|
592
|
+
const unsettledClaim = (name) => refuse(`Nierozliczony claim ${name}; zachowaj stan.`);
|
|
593
|
+
const readClaim = (name, lock, promotion) => {
|
|
594
|
+
const path = join(state, name);
|
|
595
|
+
let file = null;
|
|
596
|
+
try {
|
|
597
|
+
file = stat(path);
|
|
598
|
+
if (!file)
|
|
599
|
+
return null;
|
|
600
|
+
if (!file.isFile())
|
|
601
|
+
throw new Error('unsafe claim');
|
|
602
|
+
const original = file;
|
|
603
|
+
const sameInode = (current) => current?.isFile() && current.ino === original.ino && current.dev === original.dev;
|
|
604
|
+
const promoted = () => {
|
|
605
|
+
if (!promotion || !sameInode(stat(join(state, promotion.target))))
|
|
606
|
+
return false;
|
|
607
|
+
promotion.detected = true;
|
|
608
|
+
return true;
|
|
609
|
+
};
|
|
610
|
+
let fd;
|
|
611
|
+
try {
|
|
612
|
+
fd = io.openSync(path, io.constants.O_RDONLY | io.constants.O_NOFOLLOW | io.constants.O_NONBLOCK);
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
if (code(error) === 'ENOENT' && promoted())
|
|
616
|
+
return null;
|
|
617
|
+
throw error;
|
|
618
|
+
}
|
|
619
|
+
try {
|
|
620
|
+
if (!sameInode(io.fstatSync(fd)))
|
|
621
|
+
throw new Error('changed claim');
|
|
622
|
+
let pid;
|
|
623
|
+
if (lock) {
|
|
624
|
+
const bytes = io.readFileSync(fd);
|
|
625
|
+
try {
|
|
626
|
+
pid = json(bytes).pid;
|
|
627
|
+
}
|
|
628
|
+
catch { /* Successfully read bytes may not yet contain a usable PID. */ }
|
|
629
|
+
}
|
|
630
|
+
// process.kill accepts only signed 32-bit PIDs.
|
|
631
|
+
const livePid = typeof pid === 'number' && Number.isInteger(pid) && pid > 0 && pid <= 2_147_483_647
|
|
632
|
+
&& alive(pid, name) ? pid : null;
|
|
633
|
+
const current = stat(path);
|
|
634
|
+
if (!current && promoted())
|
|
635
|
+
return null;
|
|
636
|
+
if (!current || !sameInode(current) || current.mtimeMs !== original.mtimeMs
|
|
637
|
+
|| current.ctimeMs !== original.ctimeMs || current.size !== original.size)
|
|
638
|
+
throw new Error('changed claim');
|
|
639
|
+
return { mtimeMs: original.mtimeMs, livePid };
|
|
640
|
+
}
|
|
641
|
+
finally {
|
|
642
|
+
io.closeSync(fd);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
catch {
|
|
646
|
+
if (file)
|
|
647
|
+
unsettledClaim(name);
|
|
648
|
+
refuse(`Nieczytelny claim ${name}; zachowaj stan.`);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
const readClaimPair = (name, lock) => {
|
|
652
|
+
const pendingName = `${name}.pending`, promotion = { target: name, detected: false };
|
|
653
|
+
// The writer publishes pending to final. Read in that order to see a completed rename.
|
|
654
|
+
let pending = readClaim(pendingName, lock, promotion);
|
|
655
|
+
if (promotion.detected)
|
|
656
|
+
pending = readClaim(pendingName, lock);
|
|
657
|
+
const final = readClaim(name, lock);
|
|
658
|
+
if (promotion.detected && !final)
|
|
659
|
+
unsettledClaim(pendingName);
|
|
660
|
+
return [['', final], ['.pending', pending]];
|
|
580
661
|
};
|
|
581
662
|
const preflight = async () => {
|
|
582
663
|
check();
|
|
583
|
-
let
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
664
|
+
let processes;
|
|
665
|
+
const scan = () => processes ??= processBusy();
|
|
666
|
+
let busy = null, qualified = null;
|
|
667
|
+
for (const [family, lock, ...companions] of [
|
|
668
|
+
['tester', '.tester-job.lock', '.tester-job.input.json', '.tester-job.result.json'],
|
|
669
|
+
['receiver', 'receiver-jobs/local/claim.json',
|
|
670
|
+
...['started', 'wynik.json', 'stop.json', 'ack.json'].map(name => `receiver-jobs/local/${name}`)],
|
|
671
|
+
]) {
|
|
672
|
+
const confirmed = new Map();
|
|
673
|
+
for (const [suffix, file] of readClaimPair(lock, true)) {
|
|
674
|
+
const name = lock + suffix;
|
|
675
|
+
if (!file)
|
|
676
|
+
continue;
|
|
677
|
+
if (file.livePid !== null && scan().jobs[family].has(file.livePid)) {
|
|
678
|
+
confirmed.set(suffix, file.mtimeMs);
|
|
679
|
+
qualified ??= `claim ${name}`;
|
|
680
|
+
}
|
|
681
|
+
else if (!(runtime.now() - file.mtimeMs <= 600_000))
|
|
682
|
+
unsettledClaim(name);
|
|
683
|
+
busy ??= file.livePid !== null ? `claim ${name}` : `claim ${name} czeka na rozliczenie przez takt`;
|
|
684
|
+
}
|
|
685
|
+
for (const companion of companions)
|
|
686
|
+
for (const [suffix, file] of readClaimPair(companion, false)) {
|
|
687
|
+
const name = companion + suffix;
|
|
591
688
|
if (!file)
|
|
592
689
|
continue;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const bytes = regular(path);
|
|
599
|
-
let pid;
|
|
600
|
-
try {
|
|
601
|
-
pid = json(bytes).pid;
|
|
602
|
-
}
|
|
603
|
-
catch { /* Successfully read bytes may not yet contain a usable PID. */ }
|
|
604
|
-
// process.kill accepts only signed 32-bit PIDs.
|
|
605
|
-
live = typeof pid === 'number' && Number.isInteger(pid) && pid > 0 && pid <= 2_147_483_647 && alive(pid, name);
|
|
606
|
-
}
|
|
607
|
-
busy ??= live ? `claim ${name}` : `claim ${name} czeka na rozliczenie przez takt`;
|
|
608
|
-
}
|
|
609
|
-
catch {
|
|
610
|
-
refuse(`${exists ? 'Nierozliczony' : 'Nieczytelny'} claim ${name}; zachowaj stan.`);
|
|
690
|
+
const lockMtime = confirmed.get(suffix) ?? confirmed.get(suffix === '' ? '.pending' : '');
|
|
691
|
+
const minMtime = lockMtime === undefined ? runtime.now() - 600_000 : lockMtime - 60_000;
|
|
692
|
+
if (!(file.mtimeMs >= minMtime))
|
|
693
|
+
unsettledClaim(name);
|
|
694
|
+
busy ??= `claim ${name} czeka na rozliczenie przez takt`;
|
|
611
695
|
}
|
|
612
|
-
}
|
|
613
696
|
}
|
|
697
|
+
busy = qualified ?? busy;
|
|
614
698
|
for (const name of ['.tick.lock', '.factory-run.lock']) {
|
|
615
699
|
const path = join(state, name);
|
|
616
700
|
try {
|
|
@@ -631,7 +715,7 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
631
715
|
refuse(`Nieustalony stan blokady ${name}; zachowaj stan.`);
|
|
632
716
|
}
|
|
633
717
|
}
|
|
634
|
-
const processReason =
|
|
718
|
+
const processReason = scan().busy;
|
|
635
719
|
busy ??= processReason;
|
|
636
720
|
if (host) {
|
|
637
721
|
const report = stat(lastTick);
|
package/dist/roles.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface Role {
|
|
|
17
17
|
export declare function rolesDir(): string;
|
|
18
18
|
export declare function parseRole(file: Role["file"], text: string): Role;
|
|
19
19
|
export declare function loadRoles(dir?: string): Role[];
|
|
20
|
-
export declare const MANAGED_LINE = "<!-- robisie:managed 0.
|
|
20
|
+
export declare const MANAGED_LINE = "<!-- robisie:managed 0.7.0 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
|
|
21
21
|
export type AgentFlavor = "claude" | "codex" | "opencode";
|
|
22
22
|
/** How the operator starts the Builder for one card in its own session (the card id is not a secret). */
|
|
23
23
|
export declare function builderStartCommand(flavor: AgentFlavor, codexRolePath?: string): string;
|
package/docs/README.en.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# robisie — from account to accepted card (package 0.
|
|
1
|
+
# robisie — from account to accepted card (package 0.7.0) <!-- x-release-please-version -->
|
|
2
2
|
|
|
3
3
|
In the project directory with its engine configuration, run `npx robisie init`, then `npx robisie doctor`: init prepares the project goal and tester protection list, and doctor checks both inputs.
|
|
4
4
|
|
package/docs/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# robisie — od konta do odebranej karty (paczka 0.
|
|
1
|
+
# robisie — od konta do odebranej karty (paczka 0.7.0) <!-- x-release-please-version -->
|
|
2
2
|
|
|
3
3
|
W katalogu projektu z konfiguracją silnika uruchom `npx robisie init`, potem `npx robisie doctor`: init przygotuje cel projektu i listę ochrony testera, a doctor sprawdzi oba wejścia.
|
|
4
4
|
|
package/package.json
CHANGED