@rarog/server 1.1.1 → 1.1.2-beta.1
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/node_modules/@rarog/shared/package.json +1 -1
- package/node_modules/@rarog/shared/src/decode.js +3 -0
- package/node_modules/@rarog/shared/src/notify-copy.js +1 -0
- package/node_modules/@rarog/shared/src/protocol/background.js +7 -0
- package/node_modules/@rarog/shared/src/sentences/dialogs.js +10 -0
- package/node_modules/@rarog/shared/src/sentences/push.js +3 -0
- package/package.json +2 -2
- package/server/src/bootstrap/pr-status.js +15 -7
- package/server/src/bootstrap/push.js +36 -5
- package/server/src/cli/doctor-pr-status.js +10 -6
- package/server/src/demo/control.js +4 -2
- package/server/src/demo/mock-herdr.js +2 -2
- package/server/src/demo/scenarios.js +31 -17
- package/server/src/demo/seeds.js +62 -38
- package/server/src/drivers/herdr/pull-request-poll.js +5 -5
- package/server/src/drivers/herdr/queue-take-back.js +4 -0
- package/server/src/drivers/herdr/start-dialog-gate.js +132 -0
- package/server/src/drivers/herdr-driver.js +75 -15
- package/server/src/herdr/background/cli-shapes.js +16 -15
- package/server/src/herdr/background/index.js +7 -7
- package/server/src/herdr/background/merge.js +17 -5
- package/server/src/herdr/background/notification.js +0 -4
- package/server/src/herdr/background/pull-request-files.js +53 -161
- package/server/src/herdr/background/pull-requests.js +54 -632
- package/server/src/herdr/background/work.js +84 -0
- package/server/src/herdr/dialogs/copy.js +7 -0
- package/server/src/herdr/dialogs/index.js +4 -1
- package/server/src/herdr/dialogs/screen/form.js +2 -1
- package/server/src/herdr/dialogs/screen/option-run.js +25 -3
- package/server/src/herdr/dialogs/screen/parse.js +3 -3
- package/server/src/herdr/dialogs/screen/signatures.js +55 -0
- package/server/src/herdr/dialogs/screen/start-dialog.js +72 -0
- package/server/src/herdr/dialogs/screen/trust-arrow.js +46 -9
- package/server/src/herdr/jsonl-follow.js +6 -2
- package/server/src/herdr/label-code.js +104 -0
- package/server/src/herdr/label-migration.js +142 -0
- package/server/src/herdr/launcher.js +30 -5
- package/server/src/herdr/provenance.js +80 -40
- package/server/src/herdr/start-dialog-wait.js +96 -0
- package/server/src/herdr/supervisor.js +33 -10
- package/server/src/herdr/workspace-resolver.js +5 -4
- package/server/src/index.js +8 -3
- package/server/src/notify/apns-payload.js +5 -3
- package/server/src/notify/content.js +37 -0
- package/server/src/notify/index.js +4 -0
- package/server/src/notify/live-activity-state.js +9 -5
- package/server/src/notify/live-activity.js +5 -2
- package/server/src/notify/policy.js +4 -2
- package/server/src/notify/stalled-wait.js +213 -0
- package/server/src/pr-status/facts.js +87 -0
- package/server/src/pr-status/gh.js +76 -9
- package/server/src/pr-status/index.js +1 -10
- package/server/src/pr-status/source.js +20 -6
- package/server/src/pr-status/tracker.js +32 -9
- package/server/src/sessions/conversation-lists.js +8 -2
- package/server/src/sessions/driver-events.js +7 -3
- package/server/src/sessions/interrupt-windows.js +28 -4
- package/server/src/sessions/manager.js +14 -5
- package/server/src/sessions/pr-status-link.js +64 -16
- package/server/src/sessions/session.js +10 -3
- package/server/src/sessions/state-machine.js +11 -0
- package/server/src/sessions/test-session.js +50 -0
- package/server/src/term/herdr-backend.js +15 -12
- package/server/src/term/lifecycle.js +4 -6
|
@@ -1,33 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
import { newestFirst } from '../herdr/background/pull-requests.js';
|
|
2
|
+
/** How many PRs at most stand on the session list; the list rides in every snapshot frame, like artifacts. */
|
|
3
|
+
export const PULL_REQUESTS_MAX = 20;
|
|
4
|
+
/**
|
|
5
|
+
* The PRs a card shows: the linked PRs whose author is `viewer` and that GitHub says were created at or after
|
|
6
|
+
* `windowStart`, with the GitHub title and the link time as `createdAt`, newest first, at most
|
|
7
|
+
* {@link PULL_REQUESTS_MAX} after the filter. No login, no window or no facts = not shown. Pure.
|
|
8
|
+
*/
|
|
9
|
+
export function visiblePullRequests(input) {
|
|
10
|
+
const { linked, windowStart, viewer, factsOf } = input;
|
|
11
|
+
if (viewer === null || windowStart === null || windowStart === undefined)
|
|
12
|
+
return [];
|
|
13
|
+
const from = Date.parse(windowStart);
|
|
14
|
+
if (Number.isNaN(from))
|
|
15
|
+
return [];
|
|
16
|
+
const visible = [];
|
|
17
|
+
for (const { url, repo, number, createdAt } of linked) {
|
|
18
|
+
const facts = factsOf(url);
|
|
19
|
+
if (facts === undefined || facts.author !== viewer || !(facts.createdAtMs >= from))
|
|
20
|
+
continue;
|
|
21
|
+
const { title } = facts;
|
|
22
|
+
visible.push(title === undefined ? { url, repo, number, createdAt } : { url, repo, number, createdAt, title });
|
|
23
|
+
}
|
|
24
|
+
return visible.sort(newestFirst).slice(0, PULL_REQUESTS_MAX);
|
|
25
|
+
}
|
|
26
|
+
const urlsOf = (list) => (list ?? []).map((pr) => pr.url);
|
|
2
27
|
export class SessionPrStatus {
|
|
3
28
|
#port;
|
|
4
29
|
#deps;
|
|
5
30
|
constructor(port, deps) {
|
|
6
31
|
this.#port = port;
|
|
7
32
|
this.#deps = deps;
|
|
8
|
-
port?.listen((
|
|
33
|
+
port?.listen((change) => { this.#changed(change); });
|
|
9
34
|
}
|
|
10
35
|
/**
|
|
11
|
-
* The `pull-requests` driver event: a card's metadata without a state
|
|
12
|
-
*
|
|
13
|
-
* attach).
|
|
36
|
+
* The `pull-requests` driver event: the conversation's linked set and window, a card's metadata without a state
|
|
37
|
+
* transition, `seen` or push. An empty set clears the fields; a card frame goes out only when the shown list
|
|
38
|
+
* changed (the driver pays the set out at every attach).
|
|
14
39
|
*/
|
|
15
|
-
applyList(session,
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
40
|
+
applyList(session, linked, windowStart) {
|
|
41
|
+
const links = linked.length > 0 ? linked : undefined;
|
|
42
|
+
if (links === undefined && session.pullRequestLinks === undefined && session.pullRequests === undefined)
|
|
18
43
|
return;
|
|
19
|
-
session.
|
|
20
|
-
|
|
21
|
-
this
|
|
44
|
+
session.pullRequestLinks = links;
|
|
45
|
+
session.pullRequestWindowStart = links === undefined ? undefined : windowStart;
|
|
46
|
+
if (this.sync(session))
|
|
47
|
+
this.#deps.emitSessionChanged(session);
|
|
22
48
|
}
|
|
23
|
-
/** Drops the list (another conversation or out of scope) and tells the tracker. */
|
|
49
|
+
/** Drops the list and the links (another conversation or out of scope) and tells the tracker. */
|
|
24
50
|
clear(session) {
|
|
25
51
|
session.pullRequests = undefined;
|
|
52
|
+
session.pullRequestLinks = undefined;
|
|
53
|
+
session.pullRequestWindowStart = undefined;
|
|
26
54
|
this.sync(session);
|
|
27
55
|
}
|
|
28
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The shown list again from the session's links and window, and the tracker told both (the linked set to verify,
|
|
58
|
+
* the shown URLs to keep fresh); call after anything that set the PR fields. `true` = the shown list changed.
|
|
59
|
+
*/
|
|
29
60
|
sync(session) {
|
|
30
|
-
|
|
61
|
+
const before = session.pullRequests;
|
|
62
|
+
const shown = this.#port === undefined ? [] : visiblePullRequests({
|
|
63
|
+
linked: session.pullRequestLinks ?? [], windowStart: session.pullRequestWindowStart,
|
|
64
|
+
viewer: this.#port.viewerLogin(), factsOf: (url) => this.#port?.factsOf(url),
|
|
65
|
+
});
|
|
66
|
+
session.pullRequests = shown.length > 0 ? shown : undefined;
|
|
67
|
+
this.#port?.setSessionLinks(session.id, urlsOf(session.pullRequestLinks));
|
|
68
|
+
this.#port?.setSessionUrls(session.id, urlsOf(session.pullRequests));
|
|
69
|
+
return JSON.stringify(before ?? []) !== JSON.stringify(shown);
|
|
31
70
|
}
|
|
32
71
|
forget(sessionId) {
|
|
33
72
|
this.#port?.dropSession(sessionId);
|
|
@@ -41,9 +80,18 @@ export class SessionPrStatus {
|
|
|
41
80
|
return state === undefined ? pr : { ...pr, state };
|
|
42
81
|
});
|
|
43
82
|
}
|
|
44
|
-
|
|
83
|
+
/**
|
|
84
|
+
* A tracker answer: the sessions that link a changed URL (every session with links when the `gh` login changed)
|
|
85
|
+
* get their list again; a frame goes to those whose shown list changed or that show a URL whose state changed.
|
|
86
|
+
*/
|
|
87
|
+
#changed({ urls, viewerChanged }) {
|
|
45
88
|
for (const session of this.#deps.sessions.values()) {
|
|
46
|
-
|
|
89
|
+
const links = session.pullRequestLinks ?? [];
|
|
90
|
+
if (links.length === 0 || (!viewerChanged && !links.some((pr) => urls.has(pr.url))))
|
|
91
|
+
continue;
|
|
92
|
+
const listChanged = this.sync(session);
|
|
93
|
+
const shownChanged = urlsOf(session.pullRequests).some((url) => urls.has(url));
|
|
94
|
+
if (listChanged || shownChanged)
|
|
47
95
|
this.#deps.emitSessionChanged(session);
|
|
48
96
|
}
|
|
49
97
|
}
|
|
@@ -336,11 +336,18 @@ export class Session {
|
|
|
336
336
|
*/
|
|
337
337
|
artifacts;
|
|
338
338
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
339
|
+
* The PRs the card shows (`docs/pull-requests.md`): the owner's PRs among `pullRequestLinks`, recomputed by
|
|
340
|
+
* `pr-status-link.ts` from the links, the window and the facts from GitHub. VOLATILE like `artifacts`. `undefined`
|
|
341
|
+
* = none shown; an empty array is never kept here.
|
|
342
342
|
*/
|
|
343
343
|
pullRequests;
|
|
344
|
+
/**
|
|
345
|
+
* Pull requests linked to the current conversation (the driver's `pull-requests` event, newest first, at most 100)
|
|
346
|
+
* and the time of the conversation's first entry. VOLATILE like `pullRequests` and cleared with it when the
|
|
347
|
+
* conversation changes; `pullRequests` is what the card shows from them. `undefined` = no links or no read.
|
|
348
|
+
*/
|
|
349
|
+
pullRequestLinks;
|
|
350
|
+
pullRequestWindowStart;
|
|
344
351
|
/**
|
|
345
352
|
* Scheduled tasks of the current conversation (`docs/scheduled-tasks.md`), VOLATILE like `pullRequests`: the driver
|
|
346
353
|
* reads them from the conversation file and pays the list out at every attach. `undefined` = none or no read.
|
|
@@ -72,6 +72,17 @@ export const MAX_TURNS_DETAIL = say('state.max-turns');
|
|
|
72
72
|
export function isTerminal(state) {
|
|
73
73
|
return state === TERMINAL_STATE;
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* The zero turn of a session started without a prompt: `init` and a successful `result`, so the card waits for the
|
|
77
|
+
* first message. A card that already stands on a decision (a start dialog whose card came before the launch result)
|
|
78
|
+
* keeps it: the synthetic `result` would take it to a sendable `waiting-input` while the dialog stands in the terminal.
|
|
79
|
+
* The pane's `idle` after the answer ends that dialog like any other.
|
|
80
|
+
*/
|
|
81
|
+
export function zeroTurnEvents(state) {
|
|
82
|
+
if (state === 'waiting-permission' || state === 'waiting-question')
|
|
83
|
+
return [];
|
|
84
|
+
return [{ type: 'driver-init' }, { type: 'result', subtype: 'success' }];
|
|
85
|
+
}
|
|
75
86
|
/**
|
|
76
87
|
* Czysta funkcja przejścia.
|
|
77
88
|
*
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test session rule: a session whose working directory lies in a temporary directory. Agents that run tests and
|
|
3
|
+
* measurements start helper sessions in the Claude Code scratchpad (`/tmp/claude-<uid>/`, on macOS also written
|
|
4
|
+
* `/private/tmp/claude-<uid>/`) or in the temporary directory of this process (`os.tmpdir()`, `$TMPDIR`; on macOS
|
|
5
|
+
* also its on-disk form under `/private`). One function over a path, without state;
|
|
6
|
+
* the manager passes the fact to the notification scheduler, which keeps the rule for "done".
|
|
7
|
+
*/
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { DIRECT_DISK } from '../folder-gate/disk.js';
|
|
11
|
+
/** The server process: `process.getuid()`, `os.tmpdir()` and `realpath` through the work-area disk port. */
|
|
12
|
+
export function systemTempDirEnv() {
|
|
13
|
+
return {
|
|
14
|
+
uid: typeof process.getuid === 'function' ? process.getuid() : undefined,
|
|
15
|
+
tmpdir: os.tmpdir(),
|
|
16
|
+
realpath: (file) => DIRECT_DISK.sync('realpath', { path: file }),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The path as written and, when it resolves, on disk; both normalized without a trailing slash. */
|
|
20
|
+
function spellings(file, realpath) {
|
|
21
|
+
const written = path.resolve(file);
|
|
22
|
+
try {
|
|
23
|
+
const real = path.resolve(realpath(written));
|
|
24
|
+
return real === written ? [written] : [written, real];
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return [written];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether `cwd` is the scratchpad root of Claude Code for this user, the temporary directory of the server, or lies
|
|
32
|
+
* below one of them. A prefix matches on a directory boundary only: `/tmp/claude-501-other/` is not under
|
|
33
|
+
* `/tmp/claude-501/`. Never throws: it runs on every state transition of every session.
|
|
34
|
+
*/
|
|
35
|
+
export function inTemporaryDirectory(cwd, env = systemTempDirEnv()) {
|
|
36
|
+
if (cwd === '')
|
|
37
|
+
return false;
|
|
38
|
+
try {
|
|
39
|
+
const scratchpad = env.uid === undefined ? undefined : `claude-${String(env.uid)}`;
|
|
40
|
+
const written = scratchpad === undefined ? [] : [`/tmp/${scratchpad}`, `/private/tmp/${scratchpad}`];
|
|
41
|
+
if (env.tmpdir !== '')
|
|
42
|
+
written.push(env.tmpdir);
|
|
43
|
+
// The filesystem root would make every path temporary.
|
|
44
|
+
const roots = written.flatMap((root) => spellings(root, env.realpath)).filter((root) => root !== path.sep);
|
|
45
|
+
return spellings(cwd, env.realpath).some((candidate) => roots.some((root) => candidate === root || candidate.startsWith(root + path.sep)));
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* 3. **Zero logowania treści.** Bajty ekranu przechodzą przez ten moduł do gniazd WS i nie
|
|
22
22
|
* trafiają ani do logu, ani do pliku stanu. Na dysku zostaje jeden plik z samymi
|
|
23
23
|
* identyfikatorami paneli, ich katalogami i znacznikiem czasu (`term-herdr.json`).
|
|
24
|
-
* 4. **Pochodzenie panelu = jego ETYKIETA `
|
|
24
|
+
* 4. **Pochodzenie panelu = jego ETYKIETA `rt:<id>`, władza = token.** Token
|
|
25
25
|
* `rarog-term` ginie przy restarcie serwera herdr, etykieta panelu (`pane.rename`) — nie, bo
|
|
26
26
|
* herdr trzyma ją w snapshotcie. `reconcile()` przywraca token panelom z etykietą (jeden
|
|
27
27
|
* przebieg naraz, wspólny mutex z zakładaniem), niczego przy tym nie zamyka, a niepewny wynik
|
|
28
28
|
* znaczy odmowę zamiast drugiego taba obok. The label leads with the tab label
|
|
29
|
-
* (`<tab label> ·
|
|
29
|
+
* (`<tab label> · rt:<id>`), so herdr's Go-to names the pane like its tab.
|
|
30
30
|
* 5. **Etykieta TABA to slot albo rola plus katalog** (`rarog 1 · rarog`) — przy
|
|
31
31
|
* zakładaniu i, dla tabów w starym formacie, przy migracji w `reconcile`. Tylko tab jednopanelowy
|
|
32
32
|
* z naszym panelem i etykietą „1” z `workspace.create`; nazwa nadana ręcznie zostaje
|
|
@@ -39,8 +39,9 @@ import { TERM_ID_RE, TERM_PROC_MAX_LENGTH } from '@rarog/shared';
|
|
|
39
39
|
import { say } from '@rarog/shared/sentences';
|
|
40
40
|
import { redact } from '../auth/index.js';
|
|
41
41
|
import { RAROG_TERM_PANE_TOKEN, termPaneTokenOf } from '../config.js';
|
|
42
|
+
import { isLegacyPaneLabel } from '../herdr/label-migration.js';
|
|
42
43
|
import { decideProjectWorkspace, sharedProjectPlacement } from '../herdr/project-workspace.js';
|
|
43
|
-
import {
|
|
44
|
+
import { paneLabelTermId, realProjectPath, termPaneLabel, terminalTabLabel, } from '../herdr/provenance.js';
|
|
44
45
|
import { HerdrUnavailableError } from '../herdr/socket.js';
|
|
45
46
|
import { HerdrReadOnlyError, isBareShellForeground } from '../herdr/types.js';
|
|
46
47
|
import { matchTermId } from './lifecycle.js';
|
|
@@ -478,10 +479,9 @@ export function createHerdrBackend(options) {
|
|
|
478
479
|
paneId, source: RAROG_TERM_METADATA_SOURCE, tokens: { [RAROG_TERM_TOKEN]: id },
|
|
479
480
|
});
|
|
480
481
|
}
|
|
481
|
-
/** Tożsamość z etykiety `
|
|
482
|
+
/** Tożsamość z etykiety `rt:<id>` panelu albo `null` (brak, cudza, panel Claude). */
|
|
482
483
|
function labelIdOf(pane) {
|
|
483
|
-
|
|
484
|
-
return provenance?.kind === 'term' ? provenance.value : null;
|
|
484
|
+
return paneLabelTermId(pane.label);
|
|
485
485
|
}
|
|
486
486
|
/**
|
|
487
487
|
* Tożsamość z tokenu `rarog-term` albo `null`. Wartość spoza kształtu `TERM_ID_RE` nie jest
|
|
@@ -542,8 +542,8 @@ export function createHerdrBackend(options) {
|
|
|
542
542
|
* JEDEN przebieg odzyskiwania. Kroki:
|
|
543
543
|
*
|
|
544
544
|
* 1. Świeży `pane.list` (pełny wiersz z etykietą) i `listPaneIds` (pełny inwentarz obecności).
|
|
545
|
-
* 2. Etykieta `
|
|
546
|
-
* (panel w starym formacie) → `pane.rename` na `
|
|
545
|
+
* 2. Etykieta `rt:<id>` bez tokenu → token wraca (bez TTL). Token bez etykiety
|
|
546
|
+
* (panel w starym formacie) → `pane.rename` na `rt:<token>`. Tożsamość obecna na więcej niż
|
|
547
547
|
* jednym panelu albo panel z etykietą i INNYM tokenem → konflikt: nie ruszamy żadnego.
|
|
548
548
|
* 3. Prune `term-herdr.json` wyłącznie po `listPaneIds`.
|
|
549
549
|
* 4. Wynik: potwierdzone, przywrócone, zmigrowane, nieznane (timeout mutacji) i konflikty.
|
|
@@ -760,7 +760,7 @@ export function createHerdrBackend(options) {
|
|
|
760
760
|
/**
|
|
761
761
|
* MIGRACJA etykiet tabów terminala w starym formacie — krok `reconcile`, pod jego mutexem.
|
|
762
762
|
*
|
|
763
|
-
* Panel z potwierdzoną tożsamością (token) i NASZĄ etykietą panelu `
|
|
763
|
+
* Panel z potwierdzoną tożsamością (token) i NASZĄ etykietą panelu `rt:<id>` (także
|
|
764
764
|
* nadaną w tym samym przebiegu), tab jednopanelowy z etykietą z {@link LEGACY_TERM_TAB_LABELS}
|
|
765
765
|
* → `tab.rename` na nowy format. Inna etykieta taba = ręczna, nietknięta; split (więcej niż jeden panel) — nietknięty, bo tab nie jest wtedy „terminala". Katalog i slot bierzemy
|
|
766
766
|
* z pliku stanu (katalog powstania), a gdy ten nie pasuje — z bieżącego `cwd` panelu; żadna
|
|
@@ -768,7 +768,7 @@ export function createHerdrBackend(options) {
|
|
|
768
768
|
* potwierdzeniem stanu. Etykieta jest deterministyczna, więc śladu nie potrzebuje.
|
|
769
769
|
* `RAROG_HERDR_TAB_LABELS=0` gasi ten krok w całości.
|
|
770
770
|
*
|
|
771
|
-
* The same step gives a bare pane label `
|
|
771
|
+
* The same step gives a bare pane label `rt:<id>` its description: the terminal tab
|
|
772
772
|
* label from the same identity and directory, so a pane without a match keeps its old label.
|
|
773
773
|
* Single-pane tabs only, each write behind its own fresh confirmation.
|
|
774
774
|
*
|
|
@@ -788,6 +788,9 @@ export function createHerdrBackend(options) {
|
|
|
788
788
|
// jego tab też zostaje jego.
|
|
789
789
|
if (labelIdOf(pane) !== id && !labelledNow.has(pane.paneId))
|
|
790
790
|
continue;
|
|
791
|
+
// An old-format label is rewritten by the label migration first; its description comes on a later pass.
|
|
792
|
+
if (isLegacyPaneLabel(pane.label))
|
|
793
|
+
continue;
|
|
791
794
|
const checkKey = `${pane.paneId}|${id}|${pane.tabId}`;
|
|
792
795
|
if (tabLabelChecked.has(checkKey))
|
|
793
796
|
continue;
|
|
@@ -847,7 +850,7 @@ export function createHerdrBackend(options) {
|
|
|
847
850
|
}
|
|
848
851
|
}
|
|
849
852
|
/*
|
|
850
|
-
* The pane label: a bare `
|
|
853
|
+
* The pane label: a bare `rt:<id>` gets the terminal tab label in front, so herdr's
|
|
851
854
|
* Go-to names the pane like its tab. A label that already has a description stays (Rarog
|
|
852
855
|
* wrote it, or a human chose it within the pattern), which makes the step idempotent.
|
|
853
856
|
*/
|
|
@@ -959,7 +962,7 @@ export function createHerdrBackend(options) {
|
|
|
959
962
|
* (etykieta Raroga tej ścieżki albo `cwd` panelu w projekcie); bez dowodu nowy workspace.
|
|
960
963
|
* Samo `pane.cwd` nie wystarcza: dryfuje z każdym `cd`, więc tab projektu A wchodziłby do
|
|
961
964
|
* workspace'u projektu B. Sloty jednego projektu trzymają się razem dzięki etykiecie
|
|
962
|
-
* `
|
|
965
|
+
* `rt:<id>` pierwszego slotu (dowód mocny).
|
|
963
966
|
*/
|
|
964
967
|
/*
|
|
965
968
|
* Pisownie dla rozpoznania etykiet: `cwd` z rejestru i katalogi powstania
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { createHash } from 'node:crypto';
|
|
11
11
|
import { isPopupRole, TERM_ID_LENGTH, TERM_ROLES, TERM_SLOTS_MAX } from '@rarog/shared';
|
|
12
|
-
import {
|
|
12
|
+
import { paneLabelTermId } from '../herdr/provenance.js';
|
|
13
13
|
/**
|
|
14
14
|
* Tożsamość terminala: `sha256(realpath(cwd))` (slot 1) albo `sha256(realpath(cwd) + NUL + N)`
|
|
15
15
|
* (slot N ≥ 2), skrócony do 16 hex.
|
|
@@ -72,17 +72,15 @@ export function matchTermId(id, realCwd) {
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* Etykieta PANELU (`
|
|
75
|
+
* Etykieta PANELU (`rt:<id>`) → tożsamość terminala TEGO katalogu albo `null`.
|
|
76
76
|
*
|
|
77
77
|
* `null` dla etykiety spoza wzorca (`parsePaneLabel`), etykiety panelu Claude i identyfikatora,
|
|
78
78
|
* który nie jest hashem tej ścieżki przy żadnym slocie ani roli. Czysta: czyta tylko napis
|
|
79
79
|
* i ścieżkę, niczego nie rozwiązuje na dysku.
|
|
80
80
|
*/
|
|
81
81
|
export function matchTermLabel(label, realCwd) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
return null;
|
|
85
|
-
return matchTermId(provenance.value, realCwd);
|
|
82
|
+
const id = paneLabelTermId(label);
|
|
83
|
+
return id === null ? null : matchTermId(id, realCwd);
|
|
86
84
|
}
|
|
87
85
|
// ---------------------------------------------------------------------------
|
|
88
86
|
// Karencja i bezpiecznik respawnu
|