robisie 0.6.4 → 0.6.5

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Historia zmian klienta / Client changelog
2
2
 
3
+ ## [0.6.5](https://github.com/chuppa12/robisie-app/compare/client-v0.6.4...client-v0.6.5) (2026-11-18)
4
+
5
+
6
+ ### Factory Cards
7
+
8
+ * Komenda update odracza zamiast odmawiać przy żywym claimie Testera lub odbiorcy, nie liczy cudzych procesów za pracę fabryki, a alarm odroczenia nazywa powód ([84a2acb](https://github.com/chuppa12/robisie-app/commit/84a2acb959f1bb64ea11477bacfc5e225d0e2411))
9
+
3
10
  ## [0.6.4](https://github.com/chuppa12/robisie-app/compare/client-v0.6.3...client-v0.6.4) (2026-11-18)
4
11
 
5
12
 
@@ -1,6 +1,6 @@
1
1
  /** Package identity and the server contract it speaks. */
2
2
  export declare const PACKAGE_NAME = "robisie";
3
- export declare const PACKAGE_VERSION = "0.6.4";
3
+ export declare const PACKAGE_VERSION = "0.6.5";
4
4
  /**
5
5
  * MAJOR of the agent-API contract this package understands.
6
6
  * PARITY: src/lib/mcp/contract-version.ts (AGENT_API_CONTRACT_VERSION) on the server.
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Package identity and the server contract it speaks. */
2
2
  export const PACKAGE_NAME = "robisie";
3
- export const PACKAGE_VERSION = "0.6.4"; // x-release-please-version
3
+ export const PACKAGE_VERSION = "0.6.5"; // x-release-please-version
4
4
  /**
5
5
  * MAJOR of the agent-API contract this package understands.
6
6
  * PARITY: src/lib/mcp/contract-version.ts (AGENT_API_CONTRACT_VERSION) on the server.
@@ -1 +1 @@
1
- {"schema":1,"sha":"6c3b20e80a8be698452a2c6ccf9ad59d74ff87f8","dirty":false}
1
+ {"schema":1,"sha":"25690e7a07af6dcf3e0568258c096595883544c8","dirty":false}
@@ -1725,6 +1725,6 @@
1725
1725
  "status": 0,
1726
1726
  "signal": null,
1727
1727
  "stdout": "v24.3.0\n",
1728
- "stderr": "(node:24341) ExperimentalWarning: SQLite is an experimental feature and might change at any time\n(Use `node --trace-warnings ...` to show where the warning was created)\n"
1728
+ "stderr": "(node:24426) ExperimentalWarning: SQLite is an experimental feature and might change at any time\n(Use `node --trace-warnings ...` to show where the warning was created)\n"
1729
1729
  }
1730
1730
  }
@@ -37652,7 +37652,7 @@ var init_constants = __esm({
37652
37652
  "packages/client/src/constants.ts"() {
37653
37653
  "use strict";
37654
37654
  PACKAGE_NAME = "robisie";
37655
- PACKAGE_VERSION = "0.6.4";
37655
+ PACKAGE_VERSION = "0.6.5";
37656
37656
  SUPPORTED_CONTRACT_MAJOR = 1;
37657
37657
  DEFAULT_ORIGIN = "https://robisie.app";
37658
37658
  MCP_SERVER_NAME = "robisie";
@@ -1,7 +1,7 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { createHash } from 'node:crypto';
3
3
  import * as fs from 'node:fs';
4
- import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
4
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
5
5
  import { createInterface } from 'node:readline/promises';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { isDeepStrictEqual } from 'node:util';
@@ -410,7 +410,7 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
410
410
  notifyFailure = host ? () => alarm('Aktualizacja nieudana; sprawdź prywatny audyt i potwierdzenie powrotu.') : undefined;
411
411
  const legacyState = env.HU_STATE || join(hostHome, 'auto-update.state');
412
412
  let legacyAttempt;
413
- const defer = () => {
413
+ const defer = (reason) => {
414
414
  if (legacyAttempt) {
415
415
  if (!regular(legacyState).equals(legacyAttempt.saved))
416
416
  refuse('Rejestr starego agenta zmienił się przed odroczeniem.');
@@ -441,11 +441,12 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
441
441
  const alarmed = previous?.alarmed === true || runtime.now() - since >= 7_200_000;
442
442
  io.writeFileSync(path, JSON.stringify({ since, alarmed }), { mode: 0o600, flush: true });
443
443
  if (alarmed && previous?.alarmed !== true) {
444
- audit('deferred-alarm', { since });
445
- ctx.err('Alarm: aktualizacja odroczona od co najmniej 7200 sekund.');
446
- alarm('Aktualizacja odroczona od co najmniej 7200 sekund: Worker w toku.');
444
+ audit('deferred-alarm', { since, reason });
445
+ const message = `Aktualizacja odroczona od co najmniej 7200 sekund: ${reason}.`;
446
+ ctx.err(`Alarm: ${message}`);
447
+ alarm(message);
447
448
  }
448
- ctx.out('Aktualizacja odroczona: trwa praca fabryki.');
449
+ ctx.out(`Aktualizacja odroczona: ${reason}.`);
449
450
  return 0;
450
451
  };
451
452
  serialRelease = acquire(join(update, '.update.lock')) ?? undefined;
@@ -453,37 +454,152 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
453
454
  ctx.out('Aktualizacja odroczona: inny aktualizator już działa.');
454
455
  return 0;
455
456
  }
457
+ const hostPlist = host ? env.HU_PLIST || join(ctx.home, 'Library/LaunchAgents/com.robisie.maszynista.plist') : null;
458
+ let hostService;
459
+ const readHostService = () => {
460
+ if (!hostPlist || hostService)
461
+ return;
462
+ const original = regular(hostPlist);
463
+ const service = json(Buffer.from(command('plutil', ['-convert', 'json', '-o', '-', hostPlist])));
464
+ const args = service.ProgramArguments;
465
+ if (service.Label !== 'com.robisie.maszynista' || !Array.isArray(args) || args.length !== 7
466
+ || !args.every(arg => typeof arg === 'string') || !isAbsolute(args[0]) || !isAbsolute(args[1])
467
+ || !isDeepStrictEqual(args.slice(2, 6), ['factory', 'run', '--once', '--engine-config'])
468
+ || io.realpathSync(args[6]) !== configPath || !args[1].endsWith('/dist/cli.js')
469
+ || object(service.EnvironmentVariables) && service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG !== undefined
470
+ && io.realpathSync(String(service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG)) !== configPath)
471
+ refuse('Niepoprawna tożsamość hostowego plista, paczki lub konfiguracji.');
472
+ hostService = { original, current: original, prepared: Buffer.alloc(0), cli: args[1], originalCli: args[1] };
473
+ };
474
+ const processEntry = (path) => {
475
+ if (!isAbsolute(path))
476
+ return null;
477
+ try {
478
+ return io.realpathSync(path);
479
+ }
480
+ catch (error) {
481
+ if (code(error) === 'ENOENT' || code(error) === 'ENOTDIR')
482
+ return null;
483
+ refuse('Nieustalony stan procesów fabryki.');
484
+ }
485
+ };
486
+ const alive = (pid, name) => {
487
+ try {
488
+ runtime.kill(pid, 0);
489
+ return true;
490
+ }
491
+ catch (error) {
492
+ if (code(error) === 'ESRCH')
493
+ return false;
494
+ refuse(`Nieustalony stan procesu: ${name}; zachowaj stan.`);
495
+ }
496
+ };
456
497
  const processBusy = () => {
457
- const output = command('ps', ['-axo', 'pid=,command=']);
458
- for (const line of output.split('\n').filter(line => line.trim())) {
459
- const match = line.match(/^\s*([1-9]\d*)\s+(.+)$/);
460
- if (!match)
498
+ const result = runtime.exec('ps', ['-axo', 'pid=,command='], ctx.cwd, env);
499
+ if (result.status !== 0 || result.signal !== null)
500
+ refuse('Nieustalony stan procesów fabryki.');
501
+ let busy = null;
502
+ for (const line of result.stdout.split('\n').filter(line => line.trim())) {
503
+ const match = line.match(/^\s*([1-9]\d*)\s+(\S.*)$/);
504
+ if (!match || !Number.isSafeInteger(Number(match[1])))
461
505
  refuse('Nieustalony stan procesów fabryki.');
462
506
  if (Number(match[1]) === runtime.pid)
463
507
  continue;
464
- if (/\bfactory\s+run\b|(?:^|[\/\s])tick\.(?:cjs|ts|js)(?:\s|$)|\bcodex\b[^\n]*\bexec\b/.test(match[2]))
465
- return true;
508
+ const tokens = match[2].trim().split(/\s+/).slice(0, 8), name = basename(tokens[0]);
509
+ const entry = tokens[1] === '--import' && tokens[2] === 'tsx' ? 3 : 1;
510
+ const script = basename(tokens[entry] ?? '');
511
+ const job = /\.(?:cjs|mjs|js)$/.test(script) && tokens[entry + 1] === '--job'
512
+ && ['tester', 'receiver'].includes(tokens[entry + 2] ?? '') && Boolean(tokens[entry + 3]);
513
+ let factory = false;
514
+ if (name === 'node' && (/^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(script) || script === 'cli.js' || job)) {
515
+ readHostService();
516
+ const path = processEntry(tokens[entry]);
517
+ if (path) {
518
+ const dirs = [dirname(fileURLToPath(runtime.moduleUrl))];
519
+ if (hostService)
520
+ dirs.push(dirname(hostService.cli));
521
+ const current = join(update, 'current');
522
+ if (stat(current))
523
+ dirs.push(join(io.realpathSync(current), 'dist'));
524
+ const cli = dirs.some(dir => processEntry(join(dir, 'cli.js')) === path);
525
+ // build-engine.mjs emits tick.cjs; aliases must resolve to that entrypoint.
526
+ const bundle = dirs.some(dir => processEntry(join(dir, 'engine/tick.cjs')) === path);
527
+ const source = /^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(basename(path))
528
+ && dirname(path) === join(repo, 'maszynista');
529
+ factory = cli && tokens[entry + 1] === 'factory' && tokens[entry + 2] === 'run'
530
+ || bundle || source;
531
+ }
532
+ }
533
+ const active = name === 'node' && (factory
534
+ || script === 'codex-companion.mjs' && tokens[entry + 1] === 'task-worker')
535
+ || name === 'codex' && tokens.slice(1, 4).includes('exec')
536
+ || name === 'claude' && tokens.slice(1, 6).some(token => token === '-p' || token === '--print');
537
+ if (active)
538
+ busy ??= `proces ${/^[A-Za-z0-9._-]+$/.test(name) ? name : 'fabryki'} PID ${match[1]}`;
466
539
  }
467
- return false;
540
+ return busy;
468
541
  };
469
542
  const preflight = async () => {
470
543
  check();
471
- const busy = processBusy();
544
+ let busy = null;
472
545
  for (const claim of ['.tester-job.lock', '.tester-job.input.json', '.tester-job.result.json',
473
546
  ...['claim.json', 'started', 'wynik.json', 'stop.json', 'ack.json'].map(name => `receiver-jobs/local/${name}`)]) {
474
- for (const suffix of ['', '.pending'])
475
- if (stat(join(state, claim + suffix)))
476
- refuse('Nierozliczony claim testera lub odbiorcy; zachowaj stan.');
547
+ for (const suffix of ['', '.pending']) {
548
+ const name = claim + suffix, path = join(state, name);
549
+ let exists = false;
550
+ try {
551
+ const file = stat(path);
552
+ if (!file)
553
+ continue;
554
+ exists = true;
555
+ if (!['.tester-job.lock', 'receiver-jobs/local/claim.json'].includes(claim) || !file.isFile())
556
+ throw new Error('unsupported claim');
557
+ const value = json(regular(path)), pid = value.pid;
558
+ if (typeof pid !== 'number' || !Number.isSafeInteger(pid) || pid <= 0
559
+ || !(runtime.now() - file.mtimeMs <= 600_000))
560
+ throw new Error('unsafe claim');
561
+ if (!alive(pid, name))
562
+ throw new Error('dead claim');
563
+ busy ??= `claim ${name}`;
564
+ }
565
+ catch {
566
+ refuse(`${exists ? 'Nierozliczony' : 'Nieczytelny'} claim ${name}; zachowaj stan.`);
567
+ }
568
+ }
477
569
  }
570
+ for (const name of ['.tick.lock', '.factory-run.lock']) {
571
+ const path = join(state, name);
572
+ try {
573
+ const file = stat(path);
574
+ if (!file)
575
+ continue;
576
+ const bytes = regular(path), token = bytes.toString('utf8').trim();
577
+ const match = token.match(name === '.tick.lock' ? /^([1-9]\d*)$/ : /^([1-9]\d*) [0-9a-fA-F-]{36}$/);
578
+ if (!match || !Number.isSafeInteger(Number(match[1])))
579
+ throw new Error('invalid lock');
580
+ const live = Number(match[1]) !== runtime.pid && alive(Number(match[1]), name), fresh = stat(path);
581
+ if (!fresh || fresh.ino !== file.ino || fresh.dev !== file.dev || !regular(path).equals(bytes))
582
+ throw new Error('changed lock');
583
+ if (live)
584
+ busy ??= `blokada ${name}`;
585
+ }
586
+ catch {
587
+ refuse(`Nieustalony stan blokady ${name}; zachowaj stan.`);
588
+ }
589
+ }
590
+ const processReason = processBusy();
591
+ busy ??= processReason;
478
592
  if (host) {
479
593
  const report = stat(lastTick);
480
- let workerBusy = false;
481
594
  if (report && runtime.now() - report.mtimeMs <= 600_000) {
482
595
  const lines = regular(lastTick).toString('utf8').match(/^- detail: wykonania .+$/gm);
483
596
  const counter = lines?.length === 1 ? lines[0].match(/^- detail: wykonania (0|[1-9]\d*)\/([1-9]\d*)(?:[ ,;].*)?$/) : null;
484
- workerBusy = !counter || !Number.isSafeInteger(Number(counter[1])) || !Number.isSafeInteger(Number(counter[2])) || Number(counter[1]) !== 0;
597
+ if (!counter || !Number.isSafeInteger(Number(counter[1])) || !Number.isSafeInteger(Number(counter[2])))
598
+ busy ??= 'LAST-TICK: nieustalony licznik wykonań';
599
+ else if (Number(counter[1]) !== 0)
600
+ busy ??= `LAST-TICK: wykonania ${counter[1]}/${counter[2]}`;
485
601
  }
486
- return { busy: busy || workerBusy, own: [] };
602
+ return { busy, own: [] };
487
603
  }
488
604
  const rows = await board.listTasks({ projectId: config.project, statuses: ['in_progress'], detailsKeys: [] });
489
605
  if (!Array.isArray(rows))
@@ -503,23 +619,10 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
503
619
  }
504
620
  return { busy, own };
505
621
  };
506
- if ((await preflight()).busy)
507
- return defer();
508
- const hostPlist = host ? env.HU_PLIST || join(ctx.home, 'Library/LaunchAgents/com.robisie.maszynista.plist') : null;
509
- let hostService;
510
- if (hostPlist) {
511
- const original = regular(hostPlist);
512
- const service = json(Buffer.from(command('plutil', ['-convert', 'json', '-o', '-', hostPlist])));
513
- const args = service.ProgramArguments;
514
- if (service.Label !== 'com.robisie.maszynista' || !Array.isArray(args) || args.length !== 7
515
- || !args.every(arg => typeof arg === 'string') || !isAbsolute(args[0]) || !isAbsolute(args[1])
516
- || !isDeepStrictEqual(args.slice(2, 6), ['factory', 'run', '--once', '--engine-config'])
517
- || io.realpathSync(args[6]) !== configPath || !args[1].endsWith('/dist/cli.js')
518
- || object(service.EnvironmentVariables) && service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG !== undefined
519
- && io.realpathSync(String(service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG)) !== configPath)
520
- refuse('Niepoprawna tożsamość hostowego plista, paczki lub konfiguracji.');
521
- hostService = { original, current: original, prepared: Buffer.alloc(0), cli: args[1], originalCli: args[1] };
522
- }
622
+ const initial = await preflight();
623
+ if (initial.busy)
624
+ return defer(initial.busy);
625
+ readHostService();
523
626
  const pointer = join(update, 'current');
524
627
  if (stat(pointer) && !stat(pointer)?.isSymbolicLink())
525
628
  refuse('Żywy wskaźnik musi być dowiązaniem aktualizatora.');
@@ -564,14 +667,15 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
564
667
  // A second precheck under the same lock as tick precedes card writes and the release attempt.
565
668
  tickRelease = acquire(join(state, '.tick.lock')) ?? undefined;
566
669
  if (!tickRelease)
567
- return defer();
670
+ return defer('blokada .tick.lock');
568
671
  const second = await preflight();
569
672
  if (second.busy)
570
- return defer();
673
+ return defer(second.busy);
571
674
  for (const card of second.own) {
572
675
  check();
573
- if (processBusy())
574
- return defer();
676
+ const activity = await preflight();
677
+ if (activity.busy)
678
+ return defer(activity.busy);
575
679
  const echo = await board.updateTask({ id: card.id, status: 'blocked', expected: { status: 'in_progress', details: card.details } });
576
680
  if (echo.id !== card.id || echo.status !== 'blocked')
577
681
  refuse('Niepotwierdzony CAS blocked; nie ponowiono zapisu.');
@@ -618,9 +722,9 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
618
722
  regular(join(next, 'dist/engine/tick.cjs'));
619
723
  const prepared = await preflight();
620
724
  if (prepared.busy)
621
- return defer();
725
+ return defer(prepared.busy);
622
726
  if (prepared.own.length)
623
- return defer();
727
+ return defer('karta maszynisty in_progress');
624
728
  const launcher = join(update, 'launch.mjs');
625
729
  const launcherText = `// robisie:update-managed
626
730
  import {realpathSync} from 'node:fs';
@@ -964,7 +1068,7 @@ try {
964
1068
  const activating = await preflight();
965
1069
  if (activating.busy || activating.own.length) {
966
1070
  rollback = undefined;
967
- return defer();
1071
+ return defer(activating.busy ?? 'karta maszynisty in_progress');
968
1072
  }
969
1073
  rememberTick();
970
1074
  const switchedAt = runtime.now();
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.6.4 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
20
+ export declare const MANAGED_LINE = "<!-- robisie:managed 0.6.5 \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.6.4) <!-- x-release-please-version -->
1
+ # robisie — from account to accepted card (package 0.6.5) <!-- 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.6.4) <!-- x-release-please-version -->
1
+ # robisie — od konta do odebranej karty (paczka 0.6.5) <!-- 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robisie",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Instalator klienta robisie: łączy agenta (Claude Code, Codex CLI, OpenCode) z tablicą robisie i instaluje role klienta.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",