@rarog/server 1.1.1 → 1.1.2-beta.2
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 +46 -1
- package/node_modules/@rarog/shared/src/notify-copy.js +2 -0
- package/node_modules/@rarog/shared/src/protocol/background.js +7 -0
- package/node_modules/@rarog/shared/src/protocol/context.js +57 -0
- package/node_modules/@rarog/shared/src/protocol/coordination.js +42 -0
- package/node_modules/@rarog/shared/src/protocol/dialog-live.js +117 -0
- package/node_modules/@rarog/shared/src/protocol/files.js +1 -1
- package/node_modules/@rarog/shared/src/protocol/inbox.js +6 -0
- package/node_modules/@rarog/shared/src/protocol/presence.js +47 -0
- package/node_modules/@rarog/shared/src/protocol.js +14 -146
- package/node_modules/@rarog/shared/src/rest.js +16 -1
- package/node_modules/@rarog/shared/src/sentences/dialogs.js +10 -0
- package/node_modules/@rarog/shared/src/sentences/push.js +9 -0
- package/node_modules/@rarog/shared/src/sentences/rest.js +9 -0
- package/node_modules/@rarog/shared/src/sentences/restart.js +1 -0
- package/node_modules/@rarog/shared/src/sentences/session.js +24 -0
- package/package.json +2 -2
- package/plugin/rarog/.claude-plugin/plugin.json +4 -0
- package/plugin/rarog/bin/rarog-coordinator +7 -0
- package/plugin/rarog/hooks/hooks.json +18 -0
- package/plugin/rarog/hooks/recipient.mjs +95 -0
- package/plugin/rarog/lib/coordinator.mjs +1340 -0
- package/plugin/rarog/lib/threads.mjs +350 -0
- package/plugin/rarog/skills/coordinator/SKILL.md +111 -0
- package/plugin/rarog/skills/coordinator/check-and-merge.md +46 -0
- package/plugin/rarog/skills/coordinator/close-thread.md +15 -0
- package/plugin/rarog/skills/coordinator/role.md +61 -0
- package/plugin/rarog/skills/coordinator/send-back.md +39 -0
- package/plugin/rarog/skills/coordinator/start-thread.md +43 -0
- package/server/src/bootstrap/coordination.js +49 -0
- package/server/src/bootstrap/coordinator-start.js +27 -0
- package/server/src/bootstrap/inbox.js +4 -0
- package/server/src/bootstrap/pr-status.js +15 -7
- package/server/src/bootstrap/push.js +59 -5
- package/server/src/cli/doctor-pr-status.js +10 -6
- package/server/src/companion/catalog.js +1 -1
- package/server/src/companion/index.js +2 -4
- package/server/src/config/flags.js +4 -0
- package/server/src/config-env.js +15 -0
- package/server/src/config.js +17 -3
- package/server/src/coordination/merge-events.js +86 -0
- package/server/src/coordination/merge-prompt.js +244 -0
- package/server/src/coordination/registry.js +289 -0
- package/server/src/coordination/state.js +94 -0
- package/server/src/coordination/summary.js +422 -0
- package/server/src/coordination/thread-file.js +245 -0
- package/server/src/coordination/thread-git.js +110 -0
- package/server/src/coordination/watch.js +237 -0
- package/server/src/demo/content/coordinator.js +89 -0
- package/server/src/demo/content/en.js +57 -1
- package/server/src/demo/content/pl.js +57 -1
- package/server/src/demo/control.js +4 -2
- package/server/src/demo/inbox.js +12 -0
- package/server/src/demo/mock-herdr.js +5 -4
- package/server/src/demo/review-routes.js +2 -2
- package/server/src/demo/scenarios.js +31 -17
- package/server/src/demo/seeds.js +82 -40
- package/server/src/drivers/herdr/live-dialog.js +412 -0
- package/server/src/drivers/herdr/live-step.js +261 -0
- package/server/src/drivers/herdr/pause-gate.js +60 -0
- 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/returned-prompt.js +4 -1
- package/server/src/drivers/herdr/screen-fallback.js +50 -0
- package/server/src/drivers/herdr/start-dialog-gate.js +136 -0
- package/server/src/drivers/herdr-driver.js +159 -77
- package/server/src/files/refusals.js +9 -2
- package/server/src/files/session-gate.js +5 -4
- package/server/src/git-branch-diff.js +194 -0
- package/server/src/herdr/argv.js +34 -3
- package/server/src/herdr/audit.js +32 -1
- package/server/src/herdr/background/cli-shapes.js +35 -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/queued-prompt.js +46 -0
- package/server/src/herdr/background/work.js +96 -0
- package/server/src/herdr/client.js +22 -46
- package/server/src/herdr/commands/catalog.js +11 -7
- package/server/src/herdr/commands/discover.js +33 -1
- package/server/src/herdr/commands/index.js +3 -2
- package/server/src/herdr/dialogs/copy.js +7 -0
- package/server/src/herdr/dialogs/index.js +13 -1
- package/server/src/herdr/dialogs/layer1/hook-list/hook-list.js +4 -56
- package/server/src/herdr/dialogs/live/model.js +220 -0
- package/server/src/herdr/dialogs/live/policy.js +108 -0
- package/server/src/herdr/dialogs/live/view.js +261 -0
- package/server/src/herdr/dialogs/screen/form.js +6 -4
- 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 +78 -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/engines.js +96 -0
- package/server/src/herdr/history-steps.js +9 -4
- package/server/src/herdr/identity.js +20 -5
- package/server/src/herdr/jsonl-follow.js +26 -3
- 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/plugin-copy.js +281 -0
- package/server/src/herdr/provenance.js +80 -40
- package/server/src/herdr/session-index.js +19 -0
- package/server/src/herdr/start-dialog-wait.js +96 -0
- package/server/src/herdr/supervisor.js +49 -23
- package/server/src/herdr/types.js +1 -0
- package/server/src/herdr/workspace-resolver.js +5 -4
- package/server/src/inbox/card.js +31 -8
- package/server/src/inbox/heads.js +1 -0
- package/server/src/inbox/inbox.js +21 -4
- package/server/src/inbox/removals.js +10 -1
- package/server/src/index.js +45 -8
- package/server/src/notify/apns-payload.js +5 -3
- package/server/src/notify/content.js +64 -0
- package/server/src/notify/index.js +11 -3
- package/server/src/notify/live-activity-state.js +19 -6
- package/server/src/notify/live-activity.js +5 -2
- package/server/src/notify/policy.js +53 -13
- package/server/src/notify/ready-to-merge.js +148 -0
- 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/project-root.js +233 -0
- package/server/src/routes/sessions.js +68 -2
- package/server/src/sessions/branch-diff.js +57 -0
- package/server/src/sessions/cli-registry.js +17 -3
- package/server/src/sessions/companion-scope.js +2 -1
- package/server/src/sessions/consent-cards.js +49 -2
- package/server/src/sessions/conversation-lists.js +11 -2
- package/server/src/sessions/coordinator-start.js +172 -0
- package/server/src/sessions/demo-modules.js +1 -0
- package/server/src/sessions/demo-seeds.js +100 -0
- package/server/src/sessions/driver-events.js +68 -14
- package/server/src/sessions/herdr-lifecycle.js +11 -4
- package/server/src/sessions/interrupt-windows.js +28 -4
- package/server/src/sessions/launch-gate.js +36 -11
- package/server/src/sessions/live-dialog.js +69 -0
- package/server/src/sessions/manager.js +138 -287
- package/server/src/sessions/owner-turn.js +36 -0
- package/server/src/sessions/pr-status-link.js +64 -16
- package/server/src/sessions/seen-marks.js +31 -12
- package/server/src/sessions/session-dialog.js +82 -0
- package/server/src/sessions/session-git.js +1 -0
- package/server/src/sessions/session-scope.js +6 -5
- package/server/src/sessions/session-take-back.js +5 -0
- package/server/src/sessions/session.js +82 -10
- package/server/src/sessions/state-machine.js +13 -0
- package/server/src/sessions/state-sentences.js +87 -30
- package/server/src/sessions/test-session.js +50 -0
- package/server/src/sessions/waiting-line.js +49 -0
- package/server/src/term/herdr-backend.js +15 -12
- package/server/src/term/lifecycle.js +4 -6
- package/server/src/transcript-import.js +20 -2
- package/server/src/version.js +4 -0
- /package/server/src/{companion/asks-owner.js → asks-owner.js} +0 -0
|
@@ -16,13 +16,15 @@
|
|
|
16
16
|
* wykryciu agenta, przy jego wyjściu, przy ręcznym uruchomieniu kolejnego i przy zmianie
|
|
17
17
|
* silnika; znika wyłącznie po jawnym `pane.rename` z `null`.
|
|
18
18
|
*
|
|
19
|
-
* The provenance suffix is CLOSED (anchored at the end,
|
|
20
|
-
* herdr can label a pane too, and anything
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* tab
|
|
25
|
-
*
|
|
19
|
+
* The provenance suffix is CLOSED (anchored at the end, `rt:` or `rc:` and a fixed number of
|
|
20
|
+
* base32 characters, `herdr/label-code.ts`): a human in herdr can label a pane too, and anything
|
|
21
|
+
* outside the patterns means "a foreign pane". In front of the suffix the label carries a
|
|
22
|
+
* description, ` · ` apart: the pane's tab label, cut to 40 code points
|
|
23
|
+
* ({@link paneLabelDescription}), so herdr's Go-to window and the pane frame name the pane like
|
|
24
|
+
* its tab. The suffix carries hashes, never a path; the description repeats what the tab label
|
|
25
|
+
* already shows (the card title, a name given by hand, the directory name of a terminal tab), so
|
|
26
|
+
* the label reveals nothing the herdr snapshot did not hold before. Every label is read through
|
|
27
|
+
* `legacyToCurrent` (`herdr/label-migration.ts`), so a label in the old format reads the same.
|
|
26
28
|
*
|
|
27
29
|
* Tu mieszka też etykieta TABA: czyszczenie wspólne dla Claude i terminala
|
|
28
30
|
* ({@link sanitizeTabLabel} — to samo co karta, bez znaków sterujących) i format taba terminala
|
|
@@ -34,7 +36,9 @@ import path from 'node:path';
|
|
|
34
36
|
import { TERM_ID_RE } from '@rarog/shared';
|
|
35
37
|
import { DIRECT_DISK } from '../folder-gate/disk.js';
|
|
36
38
|
import { normalizeSessionLabel } from '../session-label.js';
|
|
37
|
-
|
|
39
|
+
import { claudeLabelSuffix, joinLabel, keyCodeOf, readLabelSuffix, termLabelSuffix, } from './label-code.js';
|
|
40
|
+
import { legacyToCurrent } from './label-migration.js';
|
|
41
|
+
/** Prefix of Rarog names in herdr: the agent name and the terminal tab label. */
|
|
38
42
|
export const HERDR_NAME_PREFIX = 'rarog';
|
|
39
43
|
/** Nazwa agenta zakładanego przez Raroga. JEDNO źródło dla generatora i dla czytelnika. */
|
|
40
44
|
export const RAROG_AGENT_NAME_RE = new RegExp(`^${HERDR_NAME_PREFIX}-[0-9a-f]{6}$`);
|
|
@@ -44,18 +48,14 @@ export function newRarogAgentName() {
|
|
|
44
48
|
}
|
|
45
49
|
const PROJECT_KEY_RE = /^[0-9a-f]{16}$/;
|
|
46
50
|
const LABEL_TRACE_RE = /^[0-9a-f]{8}$/;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const CLAUDE_LABEL_RE = new RegExp(`^(?:(.+) · )?${HERDR_NAME_PREFIX}-claude ([0-9a-f]{16}) ([0-9a-f]{8})$`);
|
|
56
|
-
/** A captured description is valid when absent (bare format) or not blank. */
|
|
57
|
-
function descriptionOk(description) {
|
|
58
|
-
return description === undefined || /\S/u.test(description);
|
|
51
|
+
function opaque(raw) {
|
|
52
|
+
return raw;
|
|
53
|
+
}
|
|
54
|
+
function rawOf(provenance) {
|
|
55
|
+
return provenance;
|
|
56
|
+
}
|
|
57
|
+
function claudeRawOf(provenance) {
|
|
58
|
+
return provenance;
|
|
59
59
|
}
|
|
60
60
|
function sha256Hex(text) {
|
|
61
61
|
return createHash('sha256').update(text, 'utf8').digest('hex');
|
|
@@ -161,44 +161,84 @@ export function paneLabelDescription(tabLabel) {
|
|
|
161
161
|
return Array.from(normalizeSessionLabel(tabLabel))
|
|
162
162
|
.slice(0, PANE_LABEL_DESCRIPTION_MAX).join('').trim();
|
|
163
163
|
}
|
|
164
|
-
/** `<description> · <
|
|
165
|
-
function describedLabel(
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
/** `<description> · <suffix>`, or the bare suffix when the description is empty. */
|
|
165
|
+
function describedLabel(suffix, tabLabel) {
|
|
166
|
+
return joinLabel(paneLabelDescription(tabLabel), suffix);
|
|
167
|
+
}
|
|
168
|
+
/** Claude pane label from the project key CODE, so a rewrite keeps the key read from the label. */
|
|
169
|
+
function claudeLabelFromCode(keyCode, trace, tabLabel) {
|
|
170
|
+
if (!LABEL_TRACE_RE.test(trace))
|
|
171
|
+
throw new Error('Ślad etykiety taba spoza wzorca 8 hex.');
|
|
172
|
+
return describedLabel(claudeLabelSuffix(keyCode, trace), tabLabel);
|
|
168
173
|
}
|
|
169
174
|
/**
|
|
170
|
-
* Claude pane label: `<description> ·
|
|
171
|
-
* `tabLabel` is the pane's current tab label; omitted or blank =
|
|
175
|
+
* Claude pane label: `<description> · rc:<project key code><tab label trace code>` for a 16-hex
|
|
176
|
+
* project key and an 8-hex trace. `tabLabel` is the pane's current tab label; omitted or blank =
|
|
177
|
+
* the bare format.
|
|
172
178
|
*/
|
|
173
179
|
export function claudePaneLabel(key, trace, tabLabel = '') {
|
|
174
180
|
if (!PROJECT_KEY_RE.test(key))
|
|
175
181
|
throw new Error('Klucz projektu spoza wzorca 16 hex.');
|
|
176
|
-
|
|
177
|
-
throw new Error('Ślad etykiety taba spoza wzorca 8 hex.');
|
|
178
|
-
return describedLabel(`rarog-claude ${key} ${trace}`, tabLabel);
|
|
182
|
+
return claudeLabelFromCode(keyCodeOf(key), trace, tabLabel);
|
|
179
183
|
}
|
|
180
184
|
/**
|
|
181
|
-
* Terminal pane label: `<description> ·
|
|
185
|
+
* Terminal pane label: `<description> · rt:<terminal id code>` (id shaped like `TERM_ID_RE`).
|
|
182
186
|
* `tabLabel` is the terminal tab label (`terminalTabLabel`); omitted or blank = the bare format.
|
|
183
187
|
*/
|
|
184
188
|
export function termPaneLabel(id, tabLabel = '') {
|
|
185
189
|
if (!TERM_ID_RE.test(id))
|
|
186
190
|
throw new Error('Identyfikator terminala spoza wzorca 16 hex.');
|
|
187
|
-
return describedLabel(
|
|
191
|
+
return describedLabel(termLabelSuffix(id), tabLabel);
|
|
188
192
|
}
|
|
189
193
|
/**
|
|
190
194
|
* Pane label from `pane.list` → provenance, or `null` for any label outside the patterns.
|
|
191
|
-
* Reads both the bare format and the one with a leading description
|
|
195
|
+
* Reads both the bare format and the one with a leading description, and an old-format label
|
|
196
|
+
* through `legacyToCurrent`.
|
|
192
197
|
*/
|
|
193
198
|
export function parsePaneLabel(label) {
|
|
194
199
|
if (typeof label !== 'string')
|
|
195
200
|
return null;
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
const suffix = readLabelSuffix(legacyToCurrent(label));
|
|
202
|
+
return suffix === null ? null : opaque(suffix);
|
|
203
|
+
}
|
|
204
|
+
/** Full terminal id (`TERM_ID_RE` shape) of a terminal provenance; `null` for Claude or none. */
|
|
205
|
+
export function provenanceTermId(provenance) {
|
|
206
|
+
if (provenance === null)
|
|
207
|
+
return null;
|
|
208
|
+
const raw = rawOf(provenance);
|
|
209
|
+
return raw.kind === 'term' ? raw.id : null;
|
|
210
|
+
}
|
|
211
|
+
/** Full terminal id from a pane label, or `null` (no label, a foreign one, a Claude pane). */
|
|
212
|
+
export function paneLabelTermId(label) {
|
|
213
|
+
return provenanceTermId(parsePaneLabel(label));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* A Claude provenance whose project key code is the code of the key of `dir`, compared in the
|
|
217
|
+
* spelling given (the caller tries each candidate spelling); always `false` for a terminal
|
|
218
|
+
* provenance. 35 bits against the candidates of one path (about 60): a false match is about 2e-9.
|
|
219
|
+
*/
|
|
220
|
+
export function claudeKeyMatches(provenance, dir) {
|
|
221
|
+
const raw = rawOf(provenance);
|
|
222
|
+
return raw.kind === 'claude' && raw.keyCode === keyCodeOf(projectKey(dir));
|
|
223
|
+
}
|
|
224
|
+
/** The trace in a Claude provenance is the trace of `tabLabel` ("Rarog set this tab label"). */
|
|
225
|
+
export function claudeTraceMatches(provenance, tabLabel) {
|
|
226
|
+
return claudeRawOf(provenance).trace === labelTrace(tabLabel);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Provenance for a Claude pane that has none yet: the key of `realCwd` (after
|
|
230
|
+
* {@link realProjectPath}) and the trace of the tab label Rarog has just set.
|
|
231
|
+
*/
|
|
232
|
+
export function newClaudeProvenance(realCwd, tabLabel) {
|
|
233
|
+
const raw = { kind: 'claude', keyCode: keyCodeOf(projectKey(realCwd)), trace: labelTrace(tabLabel) };
|
|
234
|
+
return raw;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Claude pane label rebuilt from a provenance: the description from `tabLabel`, the project key
|
|
238
|
+
* from the provenance as it was read (never hashed again from a path), and the trace either kept
|
|
239
|
+
* (`'keep'`) or taken from `tabLabel` (`'fresh'`, the tab label is Rarog's own).
|
|
240
|
+
*/
|
|
241
|
+
export function claudePaneLabelFrom(provenance, tabLabel, trace) {
|
|
242
|
+
const raw = claudeRawOf(provenance);
|
|
243
|
+
return claudeLabelFromCode(raw.keyCode, trace === 'keep' ? raw.trace : labelTrace(tabLabel), tabLabel);
|
|
204
244
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The supervisor's index of entries by engine session ID. An entry without a session ID (a state-only engine whose
|
|
3
|
+
* session herdr does not report, `agentSessionId: ''`) never enters it and is never found by it: such entries are
|
|
4
|
+
* known by their pane alone, so two panes without a session ID stay two entries. No herdr calls, no other state.
|
|
5
|
+
*/
|
|
6
|
+
export class SessionIndex {
|
|
7
|
+
#keys = new Map();
|
|
8
|
+
/** The entry key of this engine session; `undefined` for `''`. */
|
|
9
|
+
get(agentSessionId) {
|
|
10
|
+
return agentSessionId === '' ? undefined : this.#keys.get(agentSessionId);
|
|
11
|
+
}
|
|
12
|
+
set(agentSessionId, key) {
|
|
13
|
+
if (agentSessionId !== '')
|
|
14
|
+
this.#keys.set(agentSessionId, key);
|
|
15
|
+
}
|
|
16
|
+
delete(agentSessionId) {
|
|
17
|
+
this.#keys.delete(agentSessionId);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start dialog wait of the launcher: a Claude Code start dialog herdr reads as ready (`idle`, `interactive_ready`,
|
|
3
|
+
* no session id), for example the dialog about external imports of the project's memory files, ends the readiness
|
|
4
|
+
* wait as `blocked`, like the trust dialog herdr reports itself. After any `blocked` start without a session id (also
|
|
5
|
+
* the trust dialog, which a start dialog herdr reads as ready can follow), a bounded poll notices the session id the
|
|
6
|
+
* answer brings: herdr pushes no status change for it.
|
|
7
|
+
*
|
|
8
|
+
* Two legs end the wait: the signature of a measured dialog on one read, or the same screen without the prompt field
|
|
9
|
+
* for {@link START_DIALOG_STABLE_MS}. The screen rule is `dialogs/screen/start-dialog.ts`; this module only keeps the
|
|
10
|
+
* time and the poll, sends no key and knows neither the supervisor nor the manager (they come in as functions).
|
|
11
|
+
*/
|
|
12
|
+
import { startDialogOf } from './dialogs/index.js';
|
|
13
|
+
import { HerdrGoneError } from './types.js';
|
|
14
|
+
/**
|
|
15
|
+
* How long one screen without the prompt field and without a known signature must stand unchanged before it counts
|
|
16
|
+
* as an unknown start dialog. A wrong hit costs one card for a few seconds, because the session id lifts it; a long
|
|
17
|
+
* wait leaves the phone without a word. A screen that changes (a render in progress) restarts the count.
|
|
18
|
+
*/
|
|
19
|
+
export const START_DIALOG_STABLE_MS = 8_000;
|
|
20
|
+
/**
|
|
21
|
+
* Poll period of `agent.get` after a start dialog. The pane is `idle` before and after the answer (herdr 0.9.5), so
|
|
22
|
+
* no status change has to be pushed; without this poll the full resync would be the first to notice the session id.
|
|
23
|
+
*/
|
|
24
|
+
export const START_DIALOG_SESSION_POLL_MS = 1_000;
|
|
25
|
+
/**
|
|
26
|
+
* Bound of that poll: it limits the `agent.get` calls on a pane nobody answers. An answer after it is still found by
|
|
27
|
+
* the full resync, only later.
|
|
28
|
+
*/
|
|
29
|
+
export const START_DIALOG_SESSION_WATCH_MS = 10 * 60_000;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a readiness sample is worth a screen read: herdr says ready, or has no readiness flag because the launch
|
|
32
|
+
* record is gone (`interactive_ready` absent without `launch_pending`), and knows no session id. A sample under
|
|
33
|
+
* `launch_pending` is not read: a cold start keeps the shell line on the screen for seconds, and that is no dialog.
|
|
34
|
+
*/
|
|
35
|
+
export function startDialogSample(sample) {
|
|
36
|
+
if (sample.agentSessionId !== '')
|
|
37
|
+
return false;
|
|
38
|
+
if (sample.interactiveReady === true)
|
|
39
|
+
return true;
|
|
40
|
+
return sample.interactiveReady === null && sample.launchPending !== true;
|
|
41
|
+
}
|
|
42
|
+
export function createStartDialogWatch(stableMs = START_DIALOG_STABLE_MS) {
|
|
43
|
+
let first = null;
|
|
44
|
+
return {
|
|
45
|
+
observe(screen, at) {
|
|
46
|
+
if (screen === null)
|
|
47
|
+
return null;
|
|
48
|
+
const dialog = startDialogOf(screen);
|
|
49
|
+
if (dialog === null) {
|
|
50
|
+
first = null;
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (dialog.id !== null)
|
|
54
|
+
return dialog;
|
|
55
|
+
if (first?.screen !== screen) {
|
|
56
|
+
first = { screen, at };
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return at - first.at >= stableMs ? dialog : null;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Polls `agent.get` until the session id appears, then asks the supervisor to refresh the pane once. Stops without a
|
|
65
|
+
* refresh when the agent is gone, when the supervisor no longer holds the launch, or after
|
|
66
|
+
* {@link START_DIALOG_SESSION_WATCH_MS}. Another read error keeps the poll. Never rejects.
|
|
67
|
+
*/
|
|
68
|
+
export async function watchStartDialogSession(watch) {
|
|
69
|
+
const deadline = watch.now() + START_DIALOG_SESSION_WATCH_MS;
|
|
70
|
+
try {
|
|
71
|
+
while (watch.now() < deadline) {
|
|
72
|
+
await watch.sleep(START_DIALOG_SESSION_POLL_MS);
|
|
73
|
+
if (!watch.held(watch.key))
|
|
74
|
+
return;
|
|
75
|
+
let sessionId;
|
|
76
|
+
try {
|
|
77
|
+
({ agentSessionId: sessionId } = await watch.probe(watch.paneId));
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
if (err instanceof HerdrGoneError)
|
|
81
|
+
return;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (sessionId !== '') {
|
|
85
|
+
watch.log(`herdr launcher: pane ${watch.paneId} reports its session after the start dialog; refreshing.`);
|
|
86
|
+
watch.appeared(watch.paneId);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
watch.log(`herdr launcher: no session on pane ${watch.paneId} within `
|
|
91
|
+
+ `${Math.round(START_DIALOG_SESSION_WATCH_MS / 60_000)} min of its start dialog; the resync takes over.`);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
watch.log(`herdr launcher: the session watch of pane ${watch.paneId} failed: ${err.message}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Model subskrypcji (zweryfikowany na żywym serwerze):
|
|
10
10
|
* - `events.subscribe` przyjmuje listę wpisów: globalne (`pane.created`, `pane.closed`,
|
|
11
|
-
* `pane.exited`, `pane.moved`, `pane.agent_detected`) i per panel
|
|
11
|
+
* `pane.exited`, `pane.moved`, `pane.agent_detected`, `tab.closed`, `workspace.closed`) i per panel
|
|
12
12
|
* (`pane.agent_status_changed` z `pane_id` — GLOBALNEJ wersji nie ma),
|
|
13
13
|
* - nie ma `events.unsubscribe` ani `events.update`, więc każda zmiana składu paneli to
|
|
14
14
|
* ZAMKNIĘCIE połączenia i ponowna subskrypcja pełną listą (debounce 500 ms — przy
|
|
@@ -29,9 +29,12 @@ import { AsyncEventQueue, systemScheduler } from '../drivers/runtime.js';
|
|
|
29
29
|
import { createAnswerRecheck } from './answer-recheck.js';
|
|
30
30
|
import { createHerdrAuditLog } from './audit.js';
|
|
31
31
|
import { createHerdrClient, createHerdrLaunchClient } from './client.js';
|
|
32
|
+
import { STATE_ONLY_REFUSALS, isStateOnlyEngine } from './engines.js';
|
|
33
|
+
import { SessionIndex } from './session-index.js';
|
|
32
34
|
import { createHiddenStore, sessionIdFor } from './identity.js';
|
|
35
|
+
import { createLabelMigration, isLegacyPaneLabel } from './label-migration.js';
|
|
33
36
|
import { createSendThrottle } from './commands/index.js';
|
|
34
|
-
import {
|
|
37
|
+
import { claudePaneLabelFrom, claudeTraceMatches, labelTrace, newClaudeProvenance, parsePaneLabel, realProjectPath, sanitizePaneTitle, sanitizeTabLabel, } from './provenance.js';
|
|
35
38
|
import { standingConsentDialog } from './dialogs/index.js';
|
|
36
39
|
import { collapseFooterMode, parseModeFooter } from './dialogs/screen/mode-footer.js';
|
|
37
40
|
import { HerdrUnavailableError, createHerdrSocket } from './socket.js';
|
|
@@ -42,12 +45,6 @@ import { HERDR_PANE_CAP_MESSAGE, sentenceOfError, HerdrGoneError, HerdrLaunchTim
|
|
|
42
45
|
* z `canLaunch` i tak nie powinien dopuścić tu żądania.
|
|
43
46
|
*/
|
|
44
47
|
const LAUNCH_NOT_WIRED = say('herdr.launch-off-panels');
|
|
45
|
-
/**
|
|
46
|
-
* Odmowa `closeTab` na panelu Codexa — bliźniaczka `HERDR_CODEX_CLOSE_MESSAGE`
|
|
47
|
-
* z managera: ten sam kod zdania z rejestru, bez importu z warstwy sesji (nadzorca importuje
|
|
48
|
-
* z niej wyłącznie typy i ta zależność miałaby iść w drugą stronę).
|
|
49
|
-
*/
|
|
50
|
-
const CODEX_CLOSE_MESSAGE = say('session.codex-close');
|
|
51
48
|
/** Odmowa operacji na kluczu, którego nadzorca nie zna (panel zniknął z herdr). */
|
|
52
49
|
const agentGone = (key) => new HerdrGoneError(say('herdr.agent-gone', { key }));
|
|
53
50
|
/**
|
|
@@ -90,10 +87,13 @@ const GLOBAL_SUBSCRIPTIONS = [
|
|
|
90
87
|
{ type: 'pane.exited' },
|
|
91
88
|
{ type: 'pane.moved' },
|
|
92
89
|
{ type: 'pane.agent_detected' },
|
|
90
|
+
// Closing a workspace sends no `pane.closed` for its panes (herdr 0.9.5); a closed tab refreshes the list too.
|
|
91
|
+
{ type: 'tab.closed' },
|
|
92
|
+
{ type: 'workspace.closed' },
|
|
93
93
|
];
|
|
94
94
|
/** Zdarzenia, po których pytamy o pełną listę (skład paneli mógł się zmienić). */
|
|
95
95
|
const COMPOSITION_EVENTS = new Set([
|
|
96
|
-
'pane_created', 'pane_closed', 'pane_exited', 'pane_moved', 'pane_agent_detected',
|
|
96
|
+
'pane_created', 'pane_closed', 'pane_exited', 'pane_moved', 'pane_agent_detected', 'tab_closed', 'workspace_closed',
|
|
97
97
|
]);
|
|
98
98
|
/** `pane.updated` (firehose ~10 ramek/s) świadomie NIE jest subskrybowane. */
|
|
99
99
|
const STATUS_EVENT = 'pane_agent_status_changed';
|
|
@@ -140,6 +140,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
140
140
|
const client = deps.client
|
|
141
141
|
?? createHerdrClient(requireSocket(socket), {
|
|
142
142
|
codexStatus: config.codexStatusEnabled === true,
|
|
143
|
+
agyStatus: config.agyStatusEnabled === true,
|
|
143
144
|
});
|
|
144
145
|
/*
|
|
145
146
|
* Kanał TWORZENIA powstaje tylko wtedy, gdy jest z czego: bez własnego gniazda i bez jawnie
|
|
@@ -184,6 +185,8 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
184
185
|
* na żywym panelu — oba źródła oddały ten sam ekran co do bajta.
|
|
185
186
|
*/
|
|
186
187
|
readScreen: async (paneId) => ((await client.readScreen(paneId, 'detection')).text),
|
|
188
|
+
sessionAppeared: (paneId) => { void refreshPane(paneId); },
|
|
189
|
+
launchHeld: (key) => !disposed && agents.get(key)?.seenInList === false,
|
|
187
190
|
logger: log,
|
|
188
191
|
})
|
|
189
192
|
: undefined);
|
|
@@ -193,7 +196,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
193
196
|
const lifecycle = new AsyncEventQueue();
|
|
194
197
|
const agents = new Map();
|
|
195
198
|
const byPane = new Map();
|
|
196
|
-
const bySession = new
|
|
199
|
+
const bySession = new SessionIndex();
|
|
197
200
|
/**
|
|
198
201
|
* Klucze agentów `claude` uruchomionych przez TEN proces Raroga.
|
|
199
202
|
*
|
|
@@ -226,6 +229,10 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
226
229
|
let refreshTimer = null;
|
|
227
230
|
let disposed = false;
|
|
228
231
|
let unavailable = false;
|
|
232
|
+
/** Old-format pane labels → the current format, over the whole `pane.list` whenever herdr answers. */
|
|
233
|
+
const labelMigration = launchClient === null ? null : createLabelMigration({
|
|
234
|
+
client: launchClient, writable: () => config.sendEnabled && !transport.status().readOnly, log,
|
|
235
|
+
});
|
|
229
236
|
/** Status recheck after a dialog answer, so a lost `idle` push does not leave the card standing until the resync. */
|
|
230
237
|
const answerRecheck = createAnswerRecheck({ scheduler, refresh: (paneId) => refreshPane(paneId), log });
|
|
231
238
|
/** The client every driver gets: the same as `client`, with the recheck after each accepted dialog answer. */
|
|
@@ -276,6 +283,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
276
283
|
if (!unavailable)
|
|
277
284
|
return;
|
|
278
285
|
unavailable = false;
|
|
286
|
+
labelMigration?.requestPass();
|
|
279
287
|
log('herdr: available again');
|
|
280
288
|
lifecycle.push({ type: 'available' });
|
|
281
289
|
};
|
|
@@ -420,12 +428,12 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
420
428
|
*
|
|
421
429
|
* Rarog nazywa tab WYŁĄCZNIE gdy: lokator to agent `claude` (Codex nigdy), tab jest
|
|
422
430
|
* jednopanelowy (`tab.get`, za każdym razem — panel mógł zostać przeniesiony albo tab
|
|
423
|
-
* podzielony), a panel nosi etykietę pochodzenia `
|
|
431
|
+
* podzielony), a panel nosi etykietę pochodzenia `rc:<klucz><ślad>`. Bieżąca etykieta
|
|
424
432
|
* taba jest „Raroga", gdy jej skrót równa się śladowi z etykiety panelu (trwałe — przeżywa
|
|
425
433
|
* restart Raroga i herdr) albo gdy ten proces sam ją tam zostawił (`written`, RAM). Każda inna
|
|
426
434
|
* = nadana ręcznie i NIETKNIĘTA — liczone przy każdym przebiegu od nowa, bez „ręcznej na zawsze".
|
|
427
435
|
*
|
|
428
|
-
* The pane label leads with the tab label (`<tab label> ·
|
|
436
|
+
* The pane label leads with the tab label (`<tab label> · rc:<key><trace>`): with
|
|
429
437
|
* Rarog's tab label it carries that label's trace, with a name given by hand it carries that
|
|
430
438
|
* name and the old trace. The pane label it already has = no write.
|
|
431
439
|
*
|
|
@@ -485,6 +493,9 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
485
493
|
// Panel terminala Raroga (ktoś odpalił `claude` w powłoce z Raroga): jego tab nazywa terminal.
|
|
486
494
|
if (provenance?.kind === 'term')
|
|
487
495
|
return 'done';
|
|
496
|
+
// An old-format label is rewritten by the label migration alone; the sync comes back after it.
|
|
497
|
+
if (isLegacyPaneLabel(pane.label))
|
|
498
|
+
return 'retry';
|
|
488
499
|
if (provenance === null) {
|
|
489
500
|
// Etykieta człowieka (niepusta, spoza wzorców Raroga) — panel cudzy, migracja też nie.
|
|
490
501
|
if (pane.label !== null && pane.label.trim() !== '')
|
|
@@ -508,7 +519,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
508
519
|
if (provenance === null) {
|
|
509
520
|
if (!isLegacyClaudeTabLabel(tab.label, [entry.agent.cwd, pane.cwd]))
|
|
510
521
|
return 'done';
|
|
511
|
-
const
|
|
522
|
+
const fresh = newClaudeProvenance(await realProjectPath(entry.agent.cwd), tab.label);
|
|
512
523
|
if (!(await confirmPane(client, paneId, tab.tabId, pane.label))) {
|
|
513
524
|
log(`herdr: pane ${paneId} changed before the label migration — skipping`);
|
|
514
525
|
return interrupted() ?? 'retry';
|
|
@@ -516,7 +527,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
516
527
|
const beforeMigration = interrupted();
|
|
517
528
|
if (beforeMigration !== null)
|
|
518
529
|
return beforeMigration;
|
|
519
|
-
const migrated =
|
|
530
|
+
const migrated = claudePaneLabelFrom(fresh, tab.label, 'keep');
|
|
520
531
|
try {
|
|
521
532
|
await client.renamePane(paneId, migrated);
|
|
522
533
|
}
|
|
@@ -524,7 +535,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
524
535
|
return writeFailed(err, `label migration of pane ${paneId} failed`);
|
|
525
536
|
}
|
|
526
537
|
log(`herdr: migration — pane ${paneId} got a provenance label (tab ${tab.tabId})`);
|
|
527
|
-
provenance =
|
|
538
|
+
provenance = fresh;
|
|
528
539
|
expectedLabel = migrated;
|
|
529
540
|
}
|
|
530
541
|
const owned = provenance;
|
|
@@ -551,7 +562,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
551
562
|
return null;
|
|
552
563
|
};
|
|
553
564
|
/** The pane label Rarog's own tab label calls for: the card label first, its trace last. */
|
|
554
|
-
const targetLabel =
|
|
565
|
+
const targetLabel = claudePaneLabelFrom(owned, target, 'fresh');
|
|
555
566
|
/** Nowy ślad po etykiecie, którą Rarog zostawił na tabie; `settled` tylko po udanym zapisie. */
|
|
556
567
|
const writeTrace = async () => {
|
|
557
568
|
const failed = await writePane(targetLabel, 'the tab label trace');
|
|
@@ -571,7 +582,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
571
582
|
}
|
|
572
583
|
return await writeTrace();
|
|
573
584
|
}
|
|
574
|
-
const ours =
|
|
585
|
+
const ours = claudeTraceMatches(owned, tab.label) || tab.label === state.written;
|
|
575
586
|
if (!ours) {
|
|
576
587
|
logTabLabelOnce(`manual|${key}|${tab.tabId}|${labelTrace(tab.label)}`, `herdr: tab ${tab.tabId} named by hand — the card label does not overwrite it`);
|
|
577
588
|
/*
|
|
@@ -579,7 +590,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
579
590
|
* shows it instead of hashes. The trace stays the old one: it proves Rarog's own tab
|
|
580
591
|
* label, and the name given by hand must not pass for Rarog's on the next card change.
|
|
581
592
|
*/
|
|
582
|
-
const manual =
|
|
593
|
+
const manual = claudePaneLabelFrom(owned, tab.label, 'keep');
|
|
583
594
|
if (ownLabel === manual)
|
|
584
595
|
return 'done';
|
|
585
596
|
return await writePane(manual, 'the hand-given tab name') ?? 'done';
|
|
@@ -775,7 +786,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
775
786
|
* A przede wszystkim: to jest ODCZYT TREŚCI cudzego panelu, którego wpis Codexa nie
|
|
776
787
|
* obiecuje. Tryb zostaje `unknown`, więc bramka wysyłki jest fail-closed z definicji.
|
|
777
788
|
*/
|
|
778
|
-
if (entry.agent.engine
|
|
789
|
+
if (isStateOnlyEngine(entry.agent.engine))
|
|
779
790
|
return 'unknown';
|
|
780
791
|
entry.lastModeReadAt = now();
|
|
781
792
|
let exact;
|
|
@@ -841,7 +852,9 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
841
852
|
* and on disk, so a link into such a folder or a root that is a symlink to home does not open it. Scope ignores
|
|
842
853
|
* the folder gate: a pane in a guarded folder a root opens stays in scope while the folder is closed.
|
|
843
854
|
*/
|
|
844
|
-
const scopeOf = (info) => (info.engine
|
|
855
|
+
const scopeOf = (info) => (isStateOnlyEngine(info.engine)
|
|
856
|
+
? false
|
|
857
|
+
: inWorkAreaOnDisk(info.cwd, config.roots, home, undefined, { gate: 'ignore' }));
|
|
845
858
|
/**
|
|
846
859
|
* Nowy wpis agenta w mapach supervisora.
|
|
847
860
|
*
|
|
@@ -874,6 +887,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
874
887
|
lastModeReadAt: 0,
|
|
875
888
|
sentAt: 0,
|
|
876
889
|
trustSeenAt: 0,
|
|
890
|
+
startDialog: null,
|
|
877
891
|
consentDialog: null,
|
|
878
892
|
// Wpis z `agent.list` zapala flagę od razu; rejestracja launchera zostaje na `false`,
|
|
879
893
|
// dopóki agent naprawdę nie pokaże się na liście.
|
|
@@ -913,7 +927,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
913
927
|
agentSessionId: reg.agentSessionId,
|
|
914
928
|
// Launcher zakłada WYŁĄCZNIE panele Claude (`agent.start(kind: 'claude')`) — Codex
|
|
915
929
|
// z klienta jest poza zakresem. Panel launchera nie jest terminalem Raroga (własny tab
|
|
916
|
-
// z etykietą `
|
|
930
|
+
// z etykietą `rc:`), więc tokenu terminala nie ma.
|
|
917
931
|
engine: 'claude',
|
|
918
932
|
termId: null,
|
|
919
933
|
cwd: reg.cwd,
|
|
@@ -1291,6 +1305,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
1291
1305
|
return;
|
|
1292
1306
|
}
|
|
1293
1307
|
markAvailable();
|
|
1308
|
+
void labelMigration?.run();
|
|
1294
1309
|
/*
|
|
1295
1310
|
* Skład map zmienił się W TRAKCIE odczytu (równoległy resync coś odkrył, `closeTab`
|
|
1296
1311
|
* coś zdjął): ta migawka `agent.list` jest starsza od rejestru, więc pętla `forget`
|
|
@@ -1625,6 +1640,14 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
1625
1640
|
entry.agent.agentSessionId = result.agentSessionId;
|
|
1626
1641
|
bySession.set(result.agentSessionId, key);
|
|
1627
1642
|
}
|
|
1643
|
+
/*
|
|
1644
|
+
* The launch result is one unordered `agent.get` read from before `ready` settled. An agent the supervisor
|
|
1645
|
+
* has seen on a list since then has fresher state in order: a start dialog read right before its answer would
|
|
1646
|
+
* put a ready pane back to `blocked` and hold the start prompt until the next resync.
|
|
1647
|
+
*/
|
|
1648
|
+
if (entry.seenInList)
|
|
1649
|
+
return { ...result, key };
|
|
1650
|
+
entry.startDialog = result.startDialog ?? null;
|
|
1628
1651
|
entry.agent.interactiveReady = result.interactiveReady;
|
|
1629
1652
|
/*
|
|
1630
1653
|
* Status ZAOBSERWOWANY przez launcher — jedyna droga, którą `blocked` dialogu
|
|
@@ -1688,8 +1711,9 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
1688
1711
|
* bramkę na ten scenariusz; ta jest drugą warstwą i stoi na prawdzie nadzorcy — bo to
|
|
1689
1712
|
* on, a nie karta, wie, jaki silnik naprawdę siedzi w panelu.
|
|
1690
1713
|
*/
|
|
1691
|
-
if (entry.agent.engine
|
|
1692
|
-
throw new HerdrNotOwnedError(
|
|
1714
|
+
if (isStateOnlyEngine(entry.agent.engine)) {
|
|
1715
|
+
throw new HerdrNotOwnedError(STATE_ONLY_REFUSALS[entry.agent.engine].close);
|
|
1716
|
+
}
|
|
1693
1717
|
if (entry.agent.tabId === '') {
|
|
1694
1718
|
throw new HerdrNotOwnedError(say('herdr.tab-unknown'));
|
|
1695
1719
|
}
|
|
@@ -1896,6 +1920,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
1896
1920
|
markTrustDialog: () => {
|
|
1897
1921
|
entry.trustSeenAt = now();
|
|
1898
1922
|
},
|
|
1923
|
+
startPhase: () => (entry.seenInList ? null : { startDialog: entry.startDialog }),
|
|
1899
1924
|
yoloRoots: config.yoloRoots,
|
|
1900
1925
|
sendEnabled: config.sendEnabled,
|
|
1901
1926
|
...(entry.knownContextLimit === undefined
|
|
@@ -1925,6 +1950,7 @@ export function createHerdrSupervisor(config, deps) {
|
|
|
1925
1950
|
if (refreshTimer !== null)
|
|
1926
1951
|
scheduler.clearTimeout(refreshTimer);
|
|
1927
1952
|
answerRecheck.dispose();
|
|
1953
|
+
labelMigration?.dispose();
|
|
1928
1954
|
for (const key of [...tabLabels.keys()])
|
|
1929
1955
|
dropTabLabel(key);
|
|
1930
1956
|
subscription?.close();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { arglessCodeOf, foreign, isServerSentence, say, textOf, } from '@rarog/shared/sentences';
|
|
2
|
+
export { STATE_ONLY_REFUSALS, isStateOnlyEngine } from './engines.js';
|
|
2
3
|
/**
|
|
3
4
|
* Powłoki, po których panel uchodzi za „gołą powłokę". Nazwa procesu wg jądra — bez `-`
|
|
4
5
|
* loginowego. Czytają ją dwa miejsca i oba ZAMYKAJĄ panel tylko po tym rozpoznaniu: sprzątanie
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
*/
|
|
42
42
|
import path from 'node:path';
|
|
43
43
|
import { matchTermId } from '../term/lifecycle.js';
|
|
44
|
-
import { parsePaneLabel,
|
|
44
|
+
import { claudeKeyMatches, parsePaneLabel, provenanceTermId, sanitizePaneTitle } from './provenance.js';
|
|
45
45
|
/** `child` to `parent` albo ścieżka w nim (po separatorze — `/a/apix` NIE leży w `/a/api`). */
|
|
46
46
|
export function isWithin(child, parent) {
|
|
47
47
|
if (child === parent)
|
|
@@ -51,9 +51,10 @@ export function isWithin(child, parent) {
|
|
|
51
51
|
}
|
|
52
52
|
/** Etykieta pochodzenia jest etykietą Raroga dla katalogu `dir` (hash z tej ścieżki). */
|
|
53
53
|
function labelBelongsTo(provenance, dir) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (provenance.kind === 'claude')
|
|
55
|
+
return claudeKeyMatches(provenance, dir);
|
|
56
|
+
const id = provenanceTermId(provenance);
|
|
57
|
+
return id !== null && matchTermId(id, dir) !== null;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Katalog, dla którego Rarog nadał tę etykietę, szukany od `cwd` panelu w górę — albo `null`.
|