@staff0rd/assist 0.535.0 → 0.536.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 +390 -390
- package/dist/index.js +138 -96
- 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.536.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
|
|
@@ -27780,7 +27805,7 @@ function syncCodexHooks(sourcePath) {
|
|
|
27780
27805
|
fs39.mkdirSync(path62.dirname(configPath), { recursive: true });
|
|
27781
27806
|
fs39.writeFileSync(configPath, upsertManagedBlock(existing, body));
|
|
27782
27807
|
console.log(
|
|
27783
|
-
"Registered assist codex-hook in ~/.codex/config.toml (PreToolUse, PermissionRequest)"
|
|
27808
|
+
"Registered assist codex-hook in ~/.codex/config.toml (UserPromptSubmit, PreToolUse, PostToolUse, PermissionRequest, Stop)"
|
|
27784
27809
|
);
|
|
27785
27810
|
}
|
|
27786
27811
|
|
|
@@ -30403,42 +30428,20 @@ var ClientHub = class extends Set {
|
|
|
30403
30428
|
// src/commands/sessions/daemon/createSession.ts
|
|
30404
30429
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
30405
30430
|
|
|
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");
|
|
30431
|
+
// src/commands/sessions/daemon/sessionBase.ts
|
|
30432
|
+
function sessionBase(id, status3) {
|
|
30433
|
+
const startedAt = Date.now();
|
|
30434
|
+
return {
|
|
30435
|
+
id,
|
|
30436
|
+
status: status3,
|
|
30437
|
+
startedAt,
|
|
30438
|
+
runningMs: 0,
|
|
30439
|
+
/* why: runningMs counts only running stretches, so a session that starts
|
|
30440
|
+
* waiting (idle, awaiting first input) has no open stretch to stamp. */
|
|
30441
|
+
runningSince: status3 === "running" ? startedAt : null,
|
|
30442
|
+
waitingSince: status3 === "waiting" ? startedAt : null,
|
|
30443
|
+
scrollback: ""
|
|
30444
|
+
};
|
|
30442
30445
|
}
|
|
30443
30446
|
|
|
30444
30447
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
@@ -30448,14 +30451,14 @@ import * as pty from "node-pty";
|
|
|
30448
30451
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
30449
30452
|
import { chmodSync, existsSync as existsSync68, statSync as statSync11 } from "fs";
|
|
30450
30453
|
import { createRequire as createRequire3 } from "module";
|
|
30451
|
-
import
|
|
30454
|
+
import path69 from "path";
|
|
30452
30455
|
var require4 = createRequire3(import.meta.url);
|
|
30453
30456
|
var ensured = false;
|
|
30454
30457
|
function ensureSpawnHelperExecutable() {
|
|
30455
30458
|
if (ensured || process.platform !== "darwin") return;
|
|
30456
30459
|
ensured = true;
|
|
30457
|
-
const ptyRoot =
|
|
30458
|
-
const helper =
|
|
30460
|
+
const ptyRoot = path69.join(path69.dirname(require4.resolve("node-pty")), "..");
|
|
30461
|
+
const helper = path69.join(
|
|
30459
30462
|
ptyRoot,
|
|
30460
30463
|
"prebuilds",
|
|
30461
30464
|
`${process.platform}-${process.arch}`,
|
|
@@ -30507,6 +30510,84 @@ function shellEscape(s) {
|
|
|
30507
30510
|
return `'${s.replace(/'/g, String.raw`'\''`)}'`;
|
|
30508
30511
|
}
|
|
30509
30512
|
|
|
30513
|
+
// src/commands/sessions/daemon/spawnCodex.ts
|
|
30514
|
+
function spawnCodex2(opts = {}) {
|
|
30515
|
+
const args = ["codex"];
|
|
30516
|
+
if (opts.prompt) args.push(opts.prompt);
|
|
30517
|
+
return spawnPty(args, opts.cwd, opts.sessionId);
|
|
30518
|
+
}
|
|
30519
|
+
|
|
30520
|
+
// src/commands/sessions/daemon/spawnPi.ts
|
|
30521
|
+
function spawnPi2(opts = {}) {
|
|
30522
|
+
const args = ["pi"];
|
|
30523
|
+
if (opts.prompt) args.push(opts.prompt);
|
|
30524
|
+
return spawnPty(args, opts.cwd, opts.sessionId);
|
|
30525
|
+
}
|
|
30526
|
+
|
|
30527
|
+
// src/commands/sessions/daemon/startOrHoldPty.ts
|
|
30528
|
+
function startOrHoldPty(start3, hold) {
|
|
30529
|
+
if (hold) return { pty: null, pendingStart: start3 };
|
|
30530
|
+
return { pty: start3() };
|
|
30531
|
+
}
|
|
30532
|
+
|
|
30533
|
+
// src/commands/sessions/daemon/createHarnessSession.ts
|
|
30534
|
+
var spawners = {
|
|
30535
|
+
codex: spawnCodex2,
|
|
30536
|
+
pi: spawnPi2
|
|
30537
|
+
};
|
|
30538
|
+
function createHarnessSession(id, harness, prompt, cwd, holdPty) {
|
|
30539
|
+
return {
|
|
30540
|
+
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
30541
|
+
name: `Session ${id}`,
|
|
30542
|
+
commandType: "claude",
|
|
30543
|
+
harness,
|
|
30544
|
+
...startOrHoldPty(
|
|
30545
|
+
() => spawners[harness]({ prompt, cwd, sessionId: id }),
|
|
30546
|
+
holdPty
|
|
30547
|
+
),
|
|
30548
|
+
cwd,
|
|
30549
|
+
initialPrompt: prompt
|
|
30550
|
+
};
|
|
30551
|
+
}
|
|
30552
|
+
|
|
30553
|
+
// src/commands/sessions/daemon/resolveRunConfig.ts
|
|
30554
|
+
function resolveRunConfig(name, cwd) {
|
|
30555
|
+
try {
|
|
30556
|
+
const { run: run4 } = loadConfigFrom(cwd);
|
|
30557
|
+
const configs = resolveRunConfigs(run4, runConfigBaseDirFrom(cwd));
|
|
30558
|
+
const exact = configs.find((r) => r.name === name);
|
|
30559
|
+
if (exact) return exact;
|
|
30560
|
+
const suffixMatches = configs.filter((r) => r.name.endsWith(`:${name}`));
|
|
30561
|
+
return suffixMatches.length === 1 ? suffixMatches[0] : void 0;
|
|
30562
|
+
} catch {
|
|
30563
|
+
return void 0;
|
|
30564
|
+
}
|
|
30565
|
+
}
|
|
30566
|
+
|
|
30567
|
+
// src/commands/sessions/daemon/serverRunMeta.ts
|
|
30568
|
+
function serverRunMeta(runName, cwd) {
|
|
30569
|
+
const dir = cwd ?? process.cwd();
|
|
30570
|
+
const config = resolveRunConfig(runName, dir);
|
|
30571
|
+
if (!config?.server) return { server: false };
|
|
30572
|
+
return { server: true, port: config.port, origin: getCurrentOrigin(dir) };
|
|
30573
|
+
}
|
|
30574
|
+
|
|
30575
|
+
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
30576
|
+
import * as fs44 from "fs";
|
|
30577
|
+
import * as path70 from "path";
|
|
30578
|
+
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
30579
|
+
var __filename5 = fileURLToPath9(import.meta.url);
|
|
30580
|
+
var __dirname7 = path70.dirname(__filename5);
|
|
30581
|
+
function readDesignSystemPrompt() {
|
|
30582
|
+
const promptPath = path70.join(
|
|
30583
|
+
__dirname7,
|
|
30584
|
+
"..",
|
|
30585
|
+
"claude",
|
|
30586
|
+
"design-system-prompt.md"
|
|
30587
|
+
);
|
|
30588
|
+
return fs44.readFileSync(promptPath, "utf8");
|
|
30589
|
+
}
|
|
30590
|
+
|
|
30510
30591
|
// src/commands/sessions/daemon/spawnClaude.ts
|
|
30511
30592
|
function spawnClaude2(opts = {}) {
|
|
30512
30593
|
return spawnPty(buildArgs3(opts), opts.cwd, opts.sessionId);
|
|
@@ -30527,43 +30608,15 @@ function buildArgs3(opts) {
|
|
|
30527
30608
|
return base;
|
|
30528
30609
|
}
|
|
30529
30610
|
|
|
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
30611
|
// src/commands/sessions/daemon/spawnRun.ts
|
|
30538
30612
|
function spawnRun(opts) {
|
|
30539
30613
|
return spawnPty(["assist", "run", opts.name, ...opts.args ?? []], opts.cwd);
|
|
30540
30614
|
}
|
|
30541
30615
|
|
|
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
30616
|
// src/commands/sessions/daemon/createSession.ts
|
|
30565
30617
|
function createSession(id, prompt, cwd, design, harness, holdPty) {
|
|
30566
|
-
if (harness
|
|
30618
|
+
if (harness && harness !== "claude")
|
|
30619
|
+
return createHarnessSession(id, harness, prompt, cwd, holdPty);
|
|
30567
30620
|
const claudeSessionId = randomUUID9();
|
|
30568
30621
|
return {
|
|
30569
30622
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
@@ -30579,17 +30632,6 @@ function createSession(id, prompt, cwd, design, harness, holdPty) {
|
|
|
30579
30632
|
design
|
|
30580
30633
|
};
|
|
30581
30634
|
}
|
|
30582
|
-
function createPiSession(id, prompt, cwd, holdPty) {
|
|
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
30635
|
function createRunSession(id, { runName, runArgs, cwd, meta, launchedFrom }) {
|
|
30594
30636
|
const serverMeta = meta ?? serverRunMeta(runName, cwd);
|
|
30595
30637
|
return {
|