@staff0rd/assist 0.535.1 → 0.537.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/README.md +1 -1
- package/codex/config.toml +17 -2
- package/dist/commands/sessions/web/bundle.js +369 -369
- package/dist/index.js +194 -133
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.537.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -16946,20 +16946,38 @@ function registerCodeComment(parent) {
|
|
|
16946
16946
|
codeComment.command("confirm").description("Confirm a pin to insert its comment and clear the pin state").argument("<pin>", "Pin issued by 'code-comment set'").action(codeCommentConfirm);
|
|
16947
16947
|
}
|
|
16948
16948
|
|
|
16949
|
+
// src/commands/codexHook/codexStatusFor.ts
|
|
16950
|
+
function codexStatusFor(event, autoDecided) {
|
|
16951
|
+
if (event === "UserPromptSubmit")
|
|
16952
|
+
return { status: "running", source: "prompt" };
|
|
16953
|
+
if (event === "PreToolUse") return { status: "running", source: "pretool" };
|
|
16954
|
+
if (event === "PostToolUse") return { status: "running", source: "posttool" };
|
|
16955
|
+
if (event === "Stop") return { status: "waiting", source: "stop", ack: true };
|
|
16956
|
+
if (event !== "PermissionRequest") return void 0;
|
|
16957
|
+
return autoDecided ? { status: "running", source: "permission" } : { status: "waiting", source: "permission", ack: true };
|
|
16958
|
+
}
|
|
16959
|
+
|
|
16960
|
+
// src/commands/codexHook/reportCodexStatus.ts
|
|
16961
|
+
async function reportCodexStatus(event, autoDecided) {
|
|
16962
|
+
const report2 = codexStatusFor(event, autoDecided);
|
|
16963
|
+
if (!report2) return;
|
|
16964
|
+
await setSessionStatus(report2.status, {
|
|
16965
|
+
source: report2.source,
|
|
16966
|
+
ack: report2.ack
|
|
16967
|
+
});
|
|
16968
|
+
}
|
|
16969
|
+
|
|
16949
16970
|
// src/commands/codexHook/index.ts
|
|
16950
16971
|
var SUPPORTED_TOOLS2 = /* @__PURE__ */ new Set(["Bash", "PowerShell"]);
|
|
16951
16972
|
function parseInput(raw) {
|
|
16952
16973
|
try {
|
|
16953
16974
|
const data = JSON.parse(raw);
|
|
16975
|
+
const event = data.hook_event_name ?? "PreToolUse";
|
|
16954
16976
|
const command = data.tool_input?.command;
|
|
16955
|
-
if (typeof command !== "string" || !command.trim()) return
|
|
16977
|
+
if (typeof command !== "string" || !command.trim()) return { event };
|
|
16956
16978
|
if (!data.tool_name || !SUPPORTED_TOOLS2.has(data.tool_name))
|
|
16957
|
-
return
|
|
16958
|
-
return {
|
|
16959
|
-
event: data.hook_event_name ?? "PreToolUse",
|
|
16960
|
-
toolName: data.tool_name,
|
|
16961
|
-
command: command.trim()
|
|
16962
|
-
};
|
|
16979
|
+
return { event };
|
|
16980
|
+
return { event, toolName: data.tool_name, command: command.trim() };
|
|
16963
16981
|
} catch {
|
|
16964
16982
|
return void 0;
|
|
16965
16983
|
}
|
|
@@ -16985,22 +17003,29 @@ function permissionRequestOutput(decision) {
|
|
|
16985
17003
|
}
|
|
16986
17004
|
};
|
|
16987
17005
|
}
|
|
17006
|
+
function decide(input) {
|
|
17007
|
+
if (!input.toolName || !input.command) return void 0;
|
|
17008
|
+
return decideCommand(input.toolName, input.command);
|
|
17009
|
+
}
|
|
17010
|
+
function outputFor(event, decision) {
|
|
17011
|
+
if (!decision) return void 0;
|
|
17012
|
+
if (event === "PermissionRequest") return permissionRequestOutput(decision);
|
|
17013
|
+
return preToolUseOutput(decision);
|
|
17014
|
+
}
|
|
16988
17015
|
async function codexHook() {
|
|
16989
17016
|
const input = parseInput(await readStdin());
|
|
16990
17017
|
if (!input) return;
|
|
16991
|
-
const decision =
|
|
16992
|
-
|
|
16993
|
-
const output = input.event === "PermissionRequest" ? permissionRequestOutput(decision) : preToolUseOutput(decision);
|
|
17018
|
+
const decision = decide(input);
|
|
17019
|
+
const output = outputFor(input.event, decision);
|
|
16994
17020
|
if (output) console.log(JSON.stringify(output));
|
|
17021
|
+
await reportCodexStatus(input.event, decision !== void 0);
|
|
16995
17022
|
}
|
|
16996
17023
|
|
|
16997
17024
|
// src/commands/registerCodexHook.ts
|
|
16998
17025
|
function registerCodexHook(program2) {
|
|
16999
17026
|
program2.command("codex-hook").description(
|
|
17000
|
-
"Codex
|
|
17001
|
-
).action(() =>
|
|
17002
|
-
codexHook();
|
|
17003
|
-
});
|
|
17027
|
+
"Codex hook: auto-approves read-only CLI commands (PreToolUse/PermissionRequest) and reports session status (running/waiting) to the sessions daemon"
|
|
17028
|
+
).action(() => codexHook());
|
|
17004
17029
|
}
|
|
17005
17030
|
|
|
17006
17031
|
// src/commands/complexity/analyze.ts
|
|
@@ -22576,7 +22601,8 @@ function requestClaudeSession(prompt, cwd, options2) {
|
|
|
22576
22601
|
type: "create",
|
|
22577
22602
|
prompt,
|
|
22578
22603
|
cwd,
|
|
22579
|
-
inPlace: options2?.inPlace === true
|
|
22604
|
+
inPlace: options2?.inPlace === true,
|
|
22605
|
+
launchedFrom: options2?.launchedFrom ?? process.env.ASSIST_SESSION_ID
|
|
22580
22606
|
});
|
|
22581
22607
|
}
|
|
22582
22608
|
|
|
@@ -27780,7 +27806,7 @@ function syncCodexHooks(sourcePath) {
|
|
|
27780
27806
|
fs39.mkdirSync(path62.dirname(configPath), { recursive: true });
|
|
27781
27807
|
fs39.writeFileSync(configPath, upsertManagedBlock(existing, body));
|
|
27782
27808
|
console.log(
|
|
27783
|
-
"Registered assist codex-hook in ~/.codex/config.toml (PreToolUse, PermissionRequest)"
|
|
27809
|
+
"Registered assist codex-hook in ~/.codex/config.toml (UserPromptSubmit, PreToolUse, PostToolUse, PermissionRequest, Stop)"
|
|
27784
27810
|
);
|
|
27785
27811
|
}
|
|
27786
27812
|
|
|
@@ -30403,42 +30429,20 @@ var ClientHub = class extends Set {
|
|
|
30403
30429
|
// src/commands/sessions/daemon/createSession.ts
|
|
30404
30430
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
30405
30431
|
|
|
30406
|
-
// src/commands/sessions/daemon/
|
|
30407
|
-
function
|
|
30408
|
-
|
|
30409
|
-
|
|
30410
|
-
|
|
30411
|
-
|
|
30412
|
-
|
|
30413
|
-
|
|
30414
|
-
|
|
30415
|
-
|
|
30416
|
-
|
|
30417
|
-
|
|
30418
|
-
|
|
30419
|
-
|
|
30420
|
-
// src/commands/sessions/daemon/serverRunMeta.ts
|
|
30421
|
-
function serverRunMeta(runName, cwd) {
|
|
30422
|
-
const dir = cwd ?? process.cwd();
|
|
30423
|
-
const config = resolveRunConfig(runName, dir);
|
|
30424
|
-
if (!config?.server) return { server: false };
|
|
30425
|
-
return { server: true, port: config.port, origin: getCurrentOrigin(dir) };
|
|
30426
|
-
}
|
|
30427
|
-
|
|
30428
|
-
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
30429
|
-
import * as fs44 from "fs";
|
|
30430
|
-
import * as path69 from "path";
|
|
30431
|
-
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
30432
|
-
var __filename5 = fileURLToPath9(import.meta.url);
|
|
30433
|
-
var __dirname7 = path69.dirname(__filename5);
|
|
30434
|
-
function readDesignSystemPrompt() {
|
|
30435
|
-
const promptPath = path69.join(
|
|
30436
|
-
__dirname7,
|
|
30437
|
-
"..",
|
|
30438
|
-
"claude",
|
|
30439
|
-
"design-system-prompt.md"
|
|
30440
|
-
);
|
|
30441
|
-
return fs44.readFileSync(promptPath, "utf8");
|
|
30432
|
+
// src/commands/sessions/daemon/sessionBase.ts
|
|
30433
|
+
function sessionBase(id, status3) {
|
|
30434
|
+
const startedAt = Date.now();
|
|
30435
|
+
return {
|
|
30436
|
+
id,
|
|
30437
|
+
status: status3,
|
|
30438
|
+
startedAt,
|
|
30439
|
+
runningMs: 0,
|
|
30440
|
+
/* why: runningMs counts only running stretches, so a session that starts
|
|
30441
|
+
* waiting (idle, awaiting first input) has no open stretch to stamp. */
|
|
30442
|
+
runningSince: status3 === "running" ? startedAt : null,
|
|
30443
|
+
waitingSince: status3 === "waiting" ? startedAt : null,
|
|
30444
|
+
scrollback: ""
|
|
30445
|
+
};
|
|
30442
30446
|
}
|
|
30443
30447
|
|
|
30444
30448
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
@@ -30448,14 +30452,14 @@ import * as pty from "node-pty";
|
|
|
30448
30452
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
30449
30453
|
import { chmodSync, existsSync as existsSync68, statSync as statSync11 } from "fs";
|
|
30450
30454
|
import { createRequire as createRequire3 } from "module";
|
|
30451
|
-
import
|
|
30455
|
+
import path69 from "path";
|
|
30452
30456
|
var require4 = createRequire3(import.meta.url);
|
|
30453
30457
|
var ensured = false;
|
|
30454
30458
|
function ensureSpawnHelperExecutable() {
|
|
30455
30459
|
if (ensured || process.platform !== "darwin") return;
|
|
30456
30460
|
ensured = true;
|
|
30457
|
-
const ptyRoot =
|
|
30458
|
-
const helper =
|
|
30461
|
+
const ptyRoot = path69.join(path69.dirname(require4.resolve("node-pty")), "..");
|
|
30462
|
+
const helper = path69.join(
|
|
30459
30463
|
ptyRoot,
|
|
30460
30464
|
"prebuilds",
|
|
30461
30465
|
`${process.platform}-${process.arch}`,
|
|
@@ -30507,6 +30511,84 @@ function shellEscape(s) {
|
|
|
30507
30511
|
return `'${s.replace(/'/g, String.raw`'\''`)}'`;
|
|
30508
30512
|
}
|
|
30509
30513
|
|
|
30514
|
+
// src/commands/sessions/daemon/spawnCodex.ts
|
|
30515
|
+
function spawnCodex2(opts = {}) {
|
|
30516
|
+
const args = ["codex"];
|
|
30517
|
+
if (opts.prompt) args.push(opts.prompt);
|
|
30518
|
+
return spawnPty(args, opts.cwd, opts.sessionId);
|
|
30519
|
+
}
|
|
30520
|
+
|
|
30521
|
+
// src/commands/sessions/daemon/spawnPi.ts
|
|
30522
|
+
function spawnPi2(opts = {}) {
|
|
30523
|
+
const args = ["pi"];
|
|
30524
|
+
if (opts.prompt) args.push(opts.prompt);
|
|
30525
|
+
return spawnPty(args, opts.cwd, opts.sessionId);
|
|
30526
|
+
}
|
|
30527
|
+
|
|
30528
|
+
// src/commands/sessions/daemon/startOrHoldPty.ts
|
|
30529
|
+
function startOrHoldPty(start3, hold) {
|
|
30530
|
+
if (hold) return { pty: null, pendingStart: start3 };
|
|
30531
|
+
return { pty: start3() };
|
|
30532
|
+
}
|
|
30533
|
+
|
|
30534
|
+
// src/commands/sessions/daemon/createHarnessSession.ts
|
|
30535
|
+
var spawners = {
|
|
30536
|
+
codex: spawnCodex2,
|
|
30537
|
+
pi: spawnPi2
|
|
30538
|
+
};
|
|
30539
|
+
function createHarnessSession(id, harness, prompt, cwd, holdPty) {
|
|
30540
|
+
return {
|
|
30541
|
+
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
30542
|
+
name: `Session ${id}`,
|
|
30543
|
+
commandType: "claude",
|
|
30544
|
+
harness,
|
|
30545
|
+
...startOrHoldPty(
|
|
30546
|
+
() => spawners[harness]({ prompt, cwd, sessionId: id }),
|
|
30547
|
+
holdPty
|
|
30548
|
+
),
|
|
30549
|
+
cwd,
|
|
30550
|
+
initialPrompt: prompt
|
|
30551
|
+
};
|
|
30552
|
+
}
|
|
30553
|
+
|
|
30554
|
+
// src/commands/sessions/daemon/resolveRunConfig.ts
|
|
30555
|
+
function resolveRunConfig(name, cwd) {
|
|
30556
|
+
try {
|
|
30557
|
+
const { run: run4 } = loadConfigFrom(cwd);
|
|
30558
|
+
const configs = resolveRunConfigs(run4, runConfigBaseDirFrom(cwd));
|
|
30559
|
+
const exact = configs.find((r) => r.name === name);
|
|
30560
|
+
if (exact) return exact;
|
|
30561
|
+
const suffixMatches = configs.filter((r) => r.name.endsWith(`:${name}`));
|
|
30562
|
+
return suffixMatches.length === 1 ? suffixMatches[0] : void 0;
|
|
30563
|
+
} catch {
|
|
30564
|
+
return void 0;
|
|
30565
|
+
}
|
|
30566
|
+
}
|
|
30567
|
+
|
|
30568
|
+
// src/commands/sessions/daemon/serverRunMeta.ts
|
|
30569
|
+
function serverRunMeta(runName, cwd) {
|
|
30570
|
+
const dir = cwd ?? process.cwd();
|
|
30571
|
+
const config = resolveRunConfig(runName, dir);
|
|
30572
|
+
if (!config?.server) return { server: false };
|
|
30573
|
+
return { server: true, port: config.port, origin: getCurrentOrigin(dir) };
|
|
30574
|
+
}
|
|
30575
|
+
|
|
30576
|
+
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
30577
|
+
import * as fs44 from "fs";
|
|
30578
|
+
import * as path70 from "path";
|
|
30579
|
+
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
30580
|
+
var __filename5 = fileURLToPath9(import.meta.url);
|
|
30581
|
+
var __dirname7 = path70.dirname(__filename5);
|
|
30582
|
+
function readDesignSystemPrompt() {
|
|
30583
|
+
const promptPath = path70.join(
|
|
30584
|
+
__dirname7,
|
|
30585
|
+
"..",
|
|
30586
|
+
"claude",
|
|
30587
|
+
"design-system-prompt.md"
|
|
30588
|
+
);
|
|
30589
|
+
return fs44.readFileSync(promptPath, "utf8");
|
|
30590
|
+
}
|
|
30591
|
+
|
|
30510
30592
|
// src/commands/sessions/daemon/spawnClaude.ts
|
|
30511
30593
|
function spawnClaude2(opts = {}) {
|
|
30512
30594
|
return spawnPty(buildArgs3(opts), opts.cwd, opts.sessionId);
|
|
@@ -30527,43 +30609,15 @@ function buildArgs3(opts) {
|
|
|
30527
30609
|
return base;
|
|
30528
30610
|
}
|
|
30529
30611
|
|
|
30530
|
-
// src/commands/sessions/daemon/spawnPi.ts
|
|
30531
|
-
function spawnPi2(opts = {}) {
|
|
30532
|
-
const args = ["pi"];
|
|
30533
|
-
if (opts.prompt) args.push(opts.prompt);
|
|
30534
|
-
return spawnPty(args, opts.cwd, opts.sessionId);
|
|
30535
|
-
}
|
|
30536
|
-
|
|
30537
30612
|
// src/commands/sessions/daemon/spawnRun.ts
|
|
30538
30613
|
function spawnRun(opts) {
|
|
30539
30614
|
return spawnPty(["assist", "run", opts.name, ...opts.args ?? []], opts.cwd);
|
|
30540
30615
|
}
|
|
30541
30616
|
|
|
30542
|
-
// src/commands/sessions/daemon/startOrHoldPty.ts
|
|
30543
|
-
function startOrHoldPty(start3, hold) {
|
|
30544
|
-
if (hold) return { pty: null, pendingStart: start3 };
|
|
30545
|
-
return { pty: start3() };
|
|
30546
|
-
}
|
|
30547
|
-
|
|
30548
|
-
// src/commands/sessions/daemon/sessionBase.ts
|
|
30549
|
-
function sessionBase(id, status3) {
|
|
30550
|
-
const startedAt = Date.now();
|
|
30551
|
-
return {
|
|
30552
|
-
id,
|
|
30553
|
-
status: status3,
|
|
30554
|
-
startedAt,
|
|
30555
|
-
runningMs: 0,
|
|
30556
|
-
/* why: runningMs counts only running stretches, so a session that starts
|
|
30557
|
-
* waiting (idle, awaiting first input) has no open stretch to stamp. */
|
|
30558
|
-
runningSince: status3 === "running" ? startedAt : null,
|
|
30559
|
-
waitingSince: status3 === "waiting" ? startedAt : null,
|
|
30560
|
-
scrollback: ""
|
|
30561
|
-
};
|
|
30562
|
-
}
|
|
30563
|
-
|
|
30564
30617
|
// src/commands/sessions/daemon/createSession.ts
|
|
30565
30618
|
function createSession(id, prompt, cwd, design, harness, holdPty) {
|
|
30566
|
-
if (harness
|
|
30619
|
+
if (harness && harness !== "claude")
|
|
30620
|
+
return createHarnessSession(id, harness, prompt, cwd, holdPty);
|
|
30567
30621
|
const claudeSessionId = randomUUID9();
|
|
30568
30622
|
return {
|
|
30569
30623
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
@@ -30579,18 +30633,7 @@ function createSession(id, prompt, cwd, design, harness, holdPty) {
|
|
|
30579
30633
|
design
|
|
30580
30634
|
};
|
|
30581
30635
|
}
|
|
30582
|
-
function
|
|
30583
|
-
return {
|
|
30584
|
-
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
30585
|
-
name: `Session ${id}`,
|
|
30586
|
-
commandType: "claude",
|
|
30587
|
-
harness: "pi",
|
|
30588
|
-
...startOrHoldPty(() => spawnPi2({ prompt, cwd, sessionId: id }), holdPty),
|
|
30589
|
-
cwd,
|
|
30590
|
-
initialPrompt: prompt
|
|
30591
|
-
};
|
|
30592
|
-
}
|
|
30593
|
-
function createRunSession(id, { runName, runArgs, cwd, meta, launchedFrom }) {
|
|
30636
|
+
function createRunSession(id, { runName, runArgs, cwd, meta }) {
|
|
30594
30637
|
const serverMeta = meta ?? serverRunMeta(runName, cwd);
|
|
30595
30638
|
return {
|
|
30596
30639
|
...sessionBase(id, "running"),
|
|
@@ -30600,7 +30643,6 @@ function createRunSession(id, { runName, runArgs, cwd, meta, launchedFrom }) {
|
|
|
30600
30643
|
runName,
|
|
30601
30644
|
runArgs,
|
|
30602
30645
|
cwd,
|
|
30603
|
-
launchedFrom,
|
|
30604
30646
|
server: serverMeta.server || void 0,
|
|
30605
30647
|
serverPort: serverMeta.port,
|
|
30606
30648
|
serverOrigin: serverMeta.origin
|
|
@@ -31991,7 +32033,8 @@ function wireSessionWatchers(session, notify2, onStatusChange) {
|
|
|
31991
32033
|
}
|
|
31992
32034
|
|
|
31993
32035
|
// src/commands/sessions/daemon/registerSpawnedSession.ts
|
|
31994
|
-
function registerSpawnedSession(session, sessions, clients, onStatusChange, notify2) {
|
|
32036
|
+
function registerSpawnedSession(session, sessions, clients, onStatusChange, notify2, context) {
|
|
32037
|
+
if (context?.launchedFrom) session.launchedFrom = context.launchedFrom;
|
|
31995
32038
|
sessions.set(session.id, session);
|
|
31996
32039
|
wirePtyEvents(session, clients, onStatusChange);
|
|
31997
32040
|
notify2();
|
|
@@ -32034,12 +32077,13 @@ var sessionLimits = {
|
|
|
32034
32077
|
|
|
32035
32078
|
// src/commands/sessions/daemon/makeSessionSpawner.ts
|
|
32036
32079
|
function makeSessionSpawner(sessions, clients, counter, onStatusChange, notify2) {
|
|
32037
|
-
const register = (allocateId) => (create) => registerSpawnedSession(
|
|
32080
|
+
const register = (allocateId) => (create, context) => registerSpawnedSession(
|
|
32038
32081
|
create(allocateId()),
|
|
32039
32082
|
sessions,
|
|
32040
32083
|
clients,
|
|
32041
32084
|
onStatusChange(),
|
|
32042
|
-
notify2
|
|
32085
|
+
notify2,
|
|
32086
|
+
context
|
|
32043
32087
|
);
|
|
32044
32088
|
return {
|
|
32045
32089
|
spawn: register(() => sessionLimits.nextId(sessions.size, counter)),
|
|
@@ -33199,6 +33243,7 @@ function resetCardForRun(session, assistArgs) {
|
|
|
33199
33243
|
session.usageSeeded = false;
|
|
33200
33244
|
setStatus2(session, "running");
|
|
33201
33245
|
session.restored = void 0;
|
|
33246
|
+
session.launchedFrom = void 0;
|
|
33202
33247
|
}
|
|
33203
33248
|
|
|
33204
33249
|
// src/commands/sessions/daemon/startReusedRunPty.ts
|
|
@@ -33279,16 +33324,19 @@ function releaseReason(durability, session) {
|
|
|
33279
33324
|
}
|
|
33280
33325
|
|
|
33281
33326
|
// src/commands/sessions/daemon/worktree/allocateAndBind.ts
|
|
33282
|
-
function allocateAndBind(ctx, cwd, create, options2 = {}) {
|
|
33327
|
+
function allocateAndBind(ctx, cwd, create, options2 = {}, context) {
|
|
33283
33328
|
const alloc = allocateTree(cwd, boundTreeRoots(ctx.sessions), options2);
|
|
33284
33329
|
const needsSeeding = alloc.kind === "worktree" && alloc.created === true;
|
|
33285
|
-
const id = ctx.spawnWith(
|
|
33330
|
+
const id = ctx.spawnWith(
|
|
33331
|
+
(sid) => create(sid, alloc.cwd, needsSeeding),
|
|
33332
|
+
context
|
|
33333
|
+
);
|
|
33286
33334
|
bindNewWorktree(ctx.sessions.get(id), alloc, ctx.notify, ctx.startHeld);
|
|
33287
33335
|
return id;
|
|
33288
33336
|
}
|
|
33289
33337
|
|
|
33290
33338
|
// src/commands/sessions/daemon/worktree/ensureWatcher.ts
|
|
33291
|
-
function ensureWatcher(ctx, cwd) {
|
|
33339
|
+
function ensureWatcher(ctx, cwd, launchedFrom) {
|
|
33292
33340
|
if (!cwd) return void 0;
|
|
33293
33341
|
const repoRoot2 = findRepoRoot(cwd) ?? cwd;
|
|
33294
33342
|
const cfg = worktreeConfigFor(repoRoot2);
|
|
@@ -33305,7 +33353,8 @@ function ensureWatcher(ctx, cwd) {
|
|
|
33305
33353
|
ctx,
|
|
33306
33354
|
clone,
|
|
33307
33355
|
(sid, resolvedCwd) => createWatcherSession(sid, resolvedCwd ?? clone),
|
|
33308
|
-
{ inPlace: true }
|
|
33356
|
+
{ inPlace: true },
|
|
33357
|
+
{ launchedFrom }
|
|
33309
33358
|
);
|
|
33310
33359
|
daemonLog(
|
|
33311
33360
|
`spawned watcher session ${id} running /watch in the clone ${clone}`
|
|
@@ -33399,7 +33448,7 @@ function reuseSessionForRun(session, itemId2, clients, onStatusChange, tree) {
|
|
|
33399
33448
|
onStatusChange
|
|
33400
33449
|
);
|
|
33401
33450
|
if (!started) return;
|
|
33402
|
-
if (tree) ensureWatcher(tree, originCwd);
|
|
33451
|
+
if (tree) ensureWatcher(tree, originCwd, session.id);
|
|
33403
33452
|
attachReusedRun(session, alloc, clients, onStatusChange, tree);
|
|
33404
33453
|
daemonLog(
|
|
33405
33454
|
`session ${session.id} reused for backlog run ${itemId2}: ${session.name}`
|
|
@@ -33722,7 +33771,7 @@ async function forwardWindowsCreate(conn, state, client, data) {
|
|
|
33722
33771
|
}
|
|
33723
33772
|
function stripOutboundSessionId(data) {
|
|
33724
33773
|
const stripped = { ...data };
|
|
33725
|
-
for (const key of ["sessionId", "joinSessionId"])
|
|
33774
|
+
for (const key of ["sessionId", "joinSessionId", "launchedFrom"])
|
|
33726
33775
|
if (typeof stripped[key] === "string")
|
|
33727
33776
|
stripped[key] = stripWindowsSessionId(stripped[key]);
|
|
33728
33777
|
return stripped;
|
|
@@ -34195,7 +34244,8 @@ function joinableStream(sessions, targetId) {
|
|
|
34195
34244
|
function spawnIntoStream(ctx, target, prompt, harness) {
|
|
34196
34245
|
const holdUntilSeeded = target.pendingStart !== void 0;
|
|
34197
34246
|
const id = ctx.spawnWith(
|
|
34198
|
-
(sid) => createSession(sid, prompt, target.cwd, false, harness, holdUntilSeeded)
|
|
34247
|
+
(sid) => createSession(sid, prompt, target.cwd, false, harness, holdUntilSeeded),
|
|
34248
|
+
{ launchedFrom: target.id }
|
|
34199
34249
|
);
|
|
34200
34250
|
const joined = ctx.sessions.get(id);
|
|
34201
34251
|
if (joined && target.worktree) joined.worktree = { ...target.worktree };
|
|
@@ -34241,8 +34291,7 @@ function createAssistSession(id, assistArgs, cwd, meta, holdPty) {
|
|
|
34241
34291
|
),
|
|
34242
34292
|
scrollback: "",
|
|
34243
34293
|
assistArgs,
|
|
34244
|
-
cwd
|
|
34245
|
-
launchedFrom: meta?.launchedFrom
|
|
34294
|
+
cwd
|
|
34246
34295
|
};
|
|
34247
34296
|
}
|
|
34248
34297
|
|
|
@@ -34338,15 +34387,16 @@ function cloneForReapedTree(missingCwd) {
|
|
|
34338
34387
|
}
|
|
34339
34388
|
|
|
34340
34389
|
// src/commands/sessions/daemon/worktree/spawnInTree.ts
|
|
34341
|
-
function spawnInTree(ctx, prompt, cwd, design, harness, inPlace) {
|
|
34390
|
+
function spawnInTree(ctx, { prompt, cwd, design, harness, inPlace }, context) {
|
|
34342
34391
|
return allocateAndBind(
|
|
34343
34392
|
ctx,
|
|
34344
34393
|
cwd,
|
|
34345
34394
|
(sid, resolvedCwd, holdUntilSeeded) => createSession(sid, prompt, resolvedCwd, design, harness, holdUntilSeeded),
|
|
34346
|
-
{ inPlace }
|
|
34395
|
+
{ inPlace },
|
|
34396
|
+
context
|
|
34347
34397
|
);
|
|
34348
34398
|
}
|
|
34349
|
-
function spawnAssistInTree(ctx, assistArgs, cwd, meta) {
|
|
34399
|
+
function spawnAssistInTree(ctx, assistArgs, cwd, meta, context) {
|
|
34350
34400
|
const id = allocateAndBind(
|
|
34351
34401
|
ctx,
|
|
34352
34402
|
cwd,
|
|
@@ -34356,9 +34406,10 @@ function spawnAssistInTree(ctx, assistArgs, cwd, meta) {
|
|
|
34356
34406
|
commits: isCommittingArgs(assistArgs),
|
|
34357
34407
|
draftLike: isDraftCommand(assistArgs[0]),
|
|
34358
34408
|
inPlace: meta?.inPlace
|
|
34359
|
-
}
|
|
34409
|
+
},
|
|
34410
|
+
context
|
|
34360
34411
|
);
|
|
34361
|
-
if (isBacklogRunArgs(assistArgs)) ensureWatcher(ctx, cwd);
|
|
34412
|
+
if (isBacklogRunArgs(assistArgs)) ensureWatcher(ctx, cwd, id);
|
|
34362
34413
|
return id;
|
|
34363
34414
|
}
|
|
34364
34415
|
function resumeInTree(ctx, sessionId, cwd, name) {
|
|
@@ -34488,20 +34539,20 @@ var SessionManager = class {
|
|
|
34488
34539
|
this.onStatusChange
|
|
34489
34540
|
);
|
|
34490
34541
|
}
|
|
34491
|
-
spawn(
|
|
34492
|
-
return spawnInTree(this.treeCtx(),
|
|
34542
|
+
spawn(request = {}, context) {
|
|
34543
|
+
return spawnInTree(this.treeCtx(), request, context);
|
|
34493
34544
|
}
|
|
34494
34545
|
addAgent(targetId, prompt, harness) {
|
|
34495
34546
|
return addAgentToStream(this.treeCtx(), targetId, prompt, harness);
|
|
34496
34547
|
}
|
|
34497
|
-
spawnRun(request) {
|
|
34498
|
-
return this.spawnWith((id) => createRunSession(id, request));
|
|
34548
|
+
spawnRun(request, context) {
|
|
34549
|
+
return this.spawnWith((id) => createRunSession(id, request), context);
|
|
34499
34550
|
}
|
|
34500
34551
|
liveServerRun(origin, excludeId) {
|
|
34501
34552
|
return liveServerRun(this.sessions, origin, excludeId);
|
|
34502
34553
|
}
|
|
34503
|
-
spawnAssist(assistArgs, cwd, meta) {
|
|
34504
|
-
return spawnAssistInTree(this.treeCtx(), assistArgs, cwd, meta);
|
|
34554
|
+
spawnAssist(assistArgs, cwd, meta, context) {
|
|
34555
|
+
return spawnAssistInTree(this.treeCtx(), assistArgs, cwd, meta, context);
|
|
34505
34556
|
}
|
|
34506
34557
|
resume(sessionId, cwd, name) {
|
|
34507
34558
|
return resumeInTree(this.treeCtx(), sessionId, cwd, name);
|
|
@@ -34602,13 +34653,20 @@ function creator(isNew, spawn13) {
|
|
|
34602
34653
|
};
|
|
34603
34654
|
}
|
|
34604
34655
|
|
|
34656
|
+
// src/commands/sessions/daemon/spawnContextFrom.ts
|
|
34657
|
+
function spawnContextFrom(d) {
|
|
34658
|
+
return {
|
|
34659
|
+
launchedFrom: d.launchedFrom ?? d.joinSessionId
|
|
34660
|
+
};
|
|
34661
|
+
}
|
|
34662
|
+
|
|
34605
34663
|
// src/commands/sessions/daemon/handleCreateRun.ts
|
|
34606
34664
|
function handleCreateRun(client, m, d) {
|
|
34607
34665
|
if (m.windowsProxy.route(client, d)) return;
|
|
34608
34666
|
const runName = d.runName;
|
|
34609
34667
|
const cwd = d.cwd;
|
|
34610
34668
|
const runArgs = d.runArgs ?? [];
|
|
34611
|
-
const
|
|
34669
|
+
const context = spawnContextFrom(d);
|
|
34612
34670
|
const meta = serverRunMeta(runName, cwd);
|
|
34613
34671
|
if (meta.server && meta.origin) {
|
|
34614
34672
|
const existing = m.liveServerRun(meta.origin);
|
|
@@ -34620,7 +34678,7 @@ function handleCreateRun(client, m, d) {
|
|
|
34620
34678
|
type: "run-conflict",
|
|
34621
34679
|
runName,
|
|
34622
34680
|
cwd,
|
|
34623
|
-
launchedFrom,
|
|
34681
|
+
launchedFrom: context.launchedFrom,
|
|
34624
34682
|
existing: serverConflictInfo(existing)
|
|
34625
34683
|
});
|
|
34626
34684
|
return;
|
|
@@ -34634,7 +34692,7 @@ function handleCreateRun(client, m, d) {
|
|
|
34634
34692
|
}
|
|
34635
34693
|
sendTo(client, {
|
|
34636
34694
|
type: "created",
|
|
34637
|
-
sessionId: m.spawnRun({ runName, runArgs, cwd, meta,
|
|
34695
|
+
sessionId: m.spawnRun({ runName, runArgs, cwd, meta }, context),
|
|
34638
34696
|
isNew: true
|
|
34639
34697
|
});
|
|
34640
34698
|
}
|
|
@@ -34753,11 +34811,14 @@ function spawnCreate(m, d) {
|
|
|
34753
34811
|
);
|
|
34754
34812
|
}
|
|
34755
34813
|
return m.spawn(
|
|
34756
|
-
|
|
34757
|
-
|
|
34758
|
-
|
|
34759
|
-
|
|
34760
|
-
|
|
34814
|
+
{
|
|
34815
|
+
prompt,
|
|
34816
|
+
cwd: d.cwd,
|
|
34817
|
+
design,
|
|
34818
|
+
harness,
|
|
34819
|
+
inPlace: d.inPlace === true
|
|
34820
|
+
},
|
|
34821
|
+
spawnContextFrom(d)
|
|
34761
34822
|
);
|
|
34762
34823
|
}
|
|
34763
34824
|
|
|
@@ -34781,9 +34842,9 @@ var messageHandlers = {
|
|
|
34781
34842
|
{
|
|
34782
34843
|
title: d.title,
|
|
34783
34844
|
subtitle: d.subtitle,
|
|
34784
|
-
inPlace: d.inPlace === true
|
|
34785
|
-
|
|
34786
|
-
|
|
34845
|
+
inPlace: d.inPlace === true
|
|
34846
|
+
},
|
|
34847
|
+
spawnContextFrom(d)
|
|
34787
34848
|
)
|
|
34788
34849
|
),
|
|
34789
34850
|
resume: creator(
|