slopwaresystems 0.4.1 → 0.4.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/dist/index.js +69 -100
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3385,7 +3385,7 @@ var slop_cli_default = "---\nname: slop-cli\ndescription: How an agent works the
|
|
|
3385
3385
|
var slop_planning_default = '---\nname: slop-planning\ndescription: How to break long or multi-session work into a plan on its task, keep each item\'s note current, and pick up where you left off. Load when a task will take more than one sitting, or when asked to plan, continue, or report progress.\n---\n\n# Planning long work on a task\n\nA task\'s **plan** is an ordered list of items, each with a **note**: the latest true statement about that item. The plan plus the task\'s timeline is your memory between sessions. Write to it as you work, not at the end.\n\n## Starting\n\n1. Read the task: `task` `show`. If it has a plan, read the notes; they are what the last session knew.\n2. If there is no plan, write one. Items are concrete, checkable, and ordered by what unlocks what. Eight to fifteen is typical; more means the task should be split.\n\n```\nplan(action: "add", task, items: [\n "Inventory every Intercom object we rely on (conversations, users, tags)",\n "Decide the target schema for the support agent",\n "Write and test the export script against a sample",\n "Run the full export; record counts",\n "Import into the support agent; verify counts match",\n "Switch inbound routing; keep Intercom read-only for a week",\n "Remove the Intercom SDK and env vars",\n])\n```\n\n\n## Working\n\n- Before an item: `plan` `note` with `item: n` and the note ("Starting. Approach: \u2026")\n- As facts arrive, replace the note. Notes are state, not a log: "Exported 1,204 conversations; 3 failed (attachments over 10 MB), ids in scripts/export/failed.json".\n- When an item is done: `plan` `done` with `item: n`. If it turned out to be two things, add the second with `plan` `add`.\n- Blocked? Put the blocker in the note, then move on to an item that is not blocked. Do not mark blocked items done.\n- Decisions go in the description (edit it) so the next reader does not have to reconstruct them.\n\n## Follow-ups and later\n\n- Work discovered but out of scope becomes its own task: `task` `create` in backlog, with "Found while doing <KEY>: \u2026" in the description.\n- Something to check later on this task is an item: `plan` `add` with one more title.\n\n## Finishing\n\n`task` `show` should show every item done or removed. Put what changed and where at the end of the description (`task` `update`), link the PR (`task` `link`), then `task` `finish`.\n\n## Picking up a task you did not start\n\n`task` `show`, then `task` `history`. The notes tell you the present; the history tells you how it got there. Then continue from the first item that is not done.\n';
|
|
3386
3386
|
|
|
3387
3387
|
// skills/slop-sessions.md
|
|
3388
|
-
var slop_sessions_default = "---\nname: slop-sessions\ndescription: How an agent claims a task, stays reachable on it (a live session), sees who else is live, and talks to other agents and people through the project's message board. Load when starting work on a task, when asked to check on other agents, when a `slop session wait` background task finishes, or when asked to leave a message for someone.\n---\n\n# Sessions and the board\n\nA **session** is you, live. With the MCP server it exists from your first slop tool call until your harness exits: first as presence in the project (no task), then on the task you claim. Being live means messages find you. Sessions are visible to everyone (`slop sessions`, the board's live badges) and are advisory: they say who is working, they do not lock anything.\n\n**Threads** are how agents and people talk across sessions. A thread has a subject, a scope (one task, or general) and messages; it is stored, so nothing is lost when a session ends. **The task is the address:** to reach the agent on ST-3, you write in a thread about ST-3. General threads are for people and for context; nobody claims them and you never have to answer one.\n\n## What wakes you, and what waits\n\n- A message in a thread **about the task you are live on**, or in **a thread you have written in** (that is how answers find you, even from a general thread or another ticket), reaches you at once. Nothing else does.\n- **Everything else waits.** `slop session start <KEY>` prints the unread threads about that task and the unread general ones (read those for context). `slop threads` lists them any time; `slop thread show <id>` reads one.\n- Your own messages never wake your own waiter.\n\n## The loop (MCP: the way that works)\n\nYour harness has the `slop` MCP server (`slop mcp install` set it up). Use its tools; nothing runs in the background and nothing has to be restarted.\n\n1. **Claim:** `session` `claim` with the task. Assigns the task to you, moves it to in progress, and returns what is unread about it. Read that first.\n2. **Work.** Keep the plan's notes current with `plan` `note`, tick with `plan` `done`.\n3. **You are live from your first call.** The server holds presence in the project as soon as you use any tool, and `session` `claim` upgrades it to the task; `task` `finish` or `session` `release` drops back to presence. Either way, for as long as the harness runs the server A message in a thread about your task, or in any thread you have written in, reaches you on its own: right after your next tool call (any tool; a hook on Claude Code and on Codex hands it to you), and in every slop tool's result besides. There is nothing to poll and nothing to restart. When one arrives, act or answer with `say` `reply` and carry on.\n4. **Nothing to do but wait?** `session` `wait` blocks until the next message. Optional; most of the time you just keep working.\n5. **Finish:** `task` `finish` (it also releases the session), or `session` `release` to step off without finishing.\n\
|
|
3388
|
+
var slop_sessions_default = "---\nname: slop-sessions\ndescription: How an agent claims a task, stays reachable on it (a live session), sees who else is live, and talks to other agents and people through the project's message board. Load when starting work on a task, when asked to check on other agents, when a `slop session wait` background task finishes, or when asked to leave a message for someone.\n---\n\n# Sessions and the board\n\nA **session** is you, live. With the MCP server it exists from your first slop tool call until your harness exits: first as presence in the project (no task), then on the task you claim. Being live means messages find you. Sessions are visible to everyone (`slop sessions`, the board's live badges) and are advisory: they say who is working, they do not lock anything.\n\n**Threads** are how agents and people talk across sessions. A thread has a subject, a scope (one task, or general) and messages; it is stored, so nothing is lost when a session ends. **The task is the address:** to reach the agent on ST-3, you write in a thread about ST-3. General threads are for people and for context; nobody claims them and you never have to answer one.\n\n## What wakes you, and what waits\n\n- A message in a thread **about the task you are live on**, or in **a thread you have written in** (that is how answers find you, even from a general thread or another ticket), reaches you at once. Nothing else does.\n- **Everything else waits.** `slop session start <KEY>` prints the unread threads about that task and the unread general ones (read those for context). `slop threads` lists them any time; `slop thread show <id>` reads one.\n- Your own messages never wake your own waiter.\n\n## The loop (MCP: the way that works)\n\nYour harness has the `slop` MCP server (`slop mcp install` set it up). Use its tools; nothing runs in the background and nothing has to be restarted.\n\n1. **Claim:** `session` `claim` with the task. Assigns the task to you, moves it to in progress, and returns what is unread about it. Read that first.\n2. **Work.** Keep the plan's notes current with `plan` `note`, tick with `plan` `done`.\n3. **You are live from your first call.** The server holds presence in the project as soon as you use any tool, and `session` `claim` upgrades it to the task; `task` `finish` or `session` `release` drops back to presence. Either way, for as long as the harness runs the server A message in a thread about your task, or in any thread you have written in, reaches you on its own: right after your next tool call (any tool; a hook on Claude Code and on Codex hands it to you), and in every slop tool's result besides. There is nothing to poll and nothing to restart. When one arrives, act or answer with `say` `reply` and carry on.\n4. **Nothing to do but wait?** `session` `wait` blocks until the next message. Optional; most of the time you just keep working.\n5. **Finish:** `task` `finish` (it also releases the session), or `session` `release` to step off without finishing.\n\nNothing is lost at the end of a turn: what arrived while you worked is handed to you with your next tool result.\n\n## Without MCP (scripts, people at a shell)\n\n`slop session start <KEY>` then `slop session wait <KEY>` in the background: it prints the first message and exits, and you run it again. Only for setups with no MCP. The tools above are the way.\n\n## Talking\n\n```\nsession who every live agent: name, task, person, machine, where it runs; you are marked\nthreads list (task?, unread?) list; threads read (id) reads one (marks it read)\nsay reply (thread, body) reaches the agents that wrote in the thread, the task's live agents, and its addressee\nsay post (body, task: \"WEB-12\") a new thread about a task: whoever is live on it\nsay post (body, to: \"Albert\") a new thread to one live agent, by the name session who shows\nsay post (body) a general thread: for people, and for context\n (subject is optional: without one, the first line of the body)\n```\n\nAgents have names. Yours is told to you at session start and is the same every time this conversation comes back; `session who` shows everyone's. A thread to an agent by name reaches it wherever it is, on a task or not, and its answers come back to you. If two live agents share a name, use the session id from `session who`.\n\n**Messages find you.** Anything for you (about your task, in a thread you are in, addressed to you) arrives on its own. On Claude Code it arrives as a turn of yours, even while you are idle. On Codex it waits for you: it is handed to you with your next tool result, so check `session check` when you start a turn if you expect something.\n\nYour session survives a bad network and a deploy: the server keeps it for two minutes and you reconnect as the same agent; anything said in the gap is handed to you after your next tool call.\n\nPick the scope by who should be interrupted: a question for the agent on a ticket goes in a thread about that ticket; a note for people or for whoever comes next is general. Keep it to what the other side needs; state goes in the plan's notes, decisions in the description.\n\n## Etiquette\n\n- One live session per agent, and one agent per working directory: run each agent in its own checkout or git worktree, so its inbox is its own.\n- Do not claim a task that has someone else's live session (`session` `who`); write in a thread about it first.\n- Answer messages about your task promptly: the other agent is blocked on you.\n- Report progress in the plan's notes, not in threads. Threads are for talking to someone.\n- If you stop working on a task, end the session so nobody waits on you.\n";
|
|
3389
3389
|
|
|
3390
3390
|
// skills/slop-working.md
|
|
3391
3391
|
var slop_working_default = "---\nname: slop-working\ndescription: The working loop for tasks on the board (claim, do, report, finish) and what to record where. Load at the start of any coding session in a repository linked with slop.\n---\n\n# The loop\n\n1. **What is there:** `board` `list` with `mine`, or plain `list`. If nothing is assigned to you, take the top item of the first \"to do\" column.\n2. **Claim it:** `session` `claim`. It assigns you, moves the task to in progress, makes you reachable, and returns what is unread (see `slop-sessions`). Then `task` `show` and read all of it, plan and notes included.\n3. **Do it.** Long work: follow `slop-planning`. Short work: just do it.\n4. **Report as you go**: the item's note is the present state of that piece of work; the description holds what you decided and why. Write in sentences a teammate can act on.\n5. **Finish:** `task` `link` the PR, put what changed and where at the end of the description (`task` `update`), then `task` `finish`.\n\n# Where things go\n\n| This | Goes here |\n|---|---|\n| The current truth about a piece of the work | the item's note (`plan` `note`) |\n| A decision and its reason | the description (`task` `update`) |\n| A question for the agent on a ticket | `say` `post` with `task` (a thread about that ticket) |\n| A note for people, or for whoever comes next | `say` `post` without `task` (a general thread) |\n| A discovery, a hand-off | the description, or a new task if it is work |\n| A pull request, a design, a log | `task` `link` |\n| Loose working notes nobody needs to act on | the task's notes (`task` `update` with `notes`) |\n| Work you found but will not do now | `task` `create` in backlog |\n\n# Etiquette\n\n- One task in progress at a time per agent. `session` `who` shows who is live; do not take a task with someone else's live session without asking (`say` `post` on that ticket).\n- Never delete a task or someone else's items; archive and remove are for the owner.\n- Severity is the impact if nothing is done: `critical` is data loss or money, `high` is users blocked, `medium` is friction, `low` is polish.\n";
|
|
@@ -3398,11 +3398,11 @@ function installSkills({ force = false } = {}) {
|
|
|
3398
3398
|
const written = [];
|
|
3399
3399
|
for (const home of SKILL_HOMES) {
|
|
3400
3400
|
for (const [name, markdown] of Object.entries(SKILLS)) {
|
|
3401
|
-
const
|
|
3402
|
-
if (!force && existsSync(
|
|
3401
|
+
const file2 = join(home, name, "SKILL.md");
|
|
3402
|
+
if (!force && existsSync(file2) && readFileSync(file2, "utf8") === markdown) continue;
|
|
3403
3403
|
mkdirSync(join(home, name), { recursive: true });
|
|
3404
|
-
writeFileSync(
|
|
3405
|
-
written.push(
|
|
3404
|
+
writeFileSync(file2, markdown);
|
|
3405
|
+
written.push(file2);
|
|
3406
3406
|
}
|
|
3407
3407
|
}
|
|
3408
3408
|
return written;
|
|
@@ -24147,14 +24147,15 @@ linked to ${link.projectKey} ${link.projectName} (${link.baseUrl})`
|
|
|
24147
24147
|
|
|
24148
24148
|
// src/commands/mcp.ts
|
|
24149
24149
|
import { execFileSync as execFileSync5, spawn as spawn3 } from "child_process";
|
|
24150
|
-
import { existsSync as
|
|
24150
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync13, writeFileSync as writeFileSync7 } from "fs";
|
|
24151
24151
|
import "path";
|
|
24152
24152
|
import { homedir as homedir4 } from "os";
|
|
24153
|
-
import { join as
|
|
24153
|
+
import { join as join11 } from "path";
|
|
24154
24154
|
|
|
24155
24155
|
// src/platform/live.ts
|
|
24156
24156
|
var PING_EVERY_MS = 25e3;
|
|
24157
24157
|
var PONG_WITHIN_MS = 1e4;
|
|
24158
|
+
var STANDBY_POLL_MS = 2e4;
|
|
24158
24159
|
async function waitForMessage(api, projectId, taskKey, options = {}) {
|
|
24159
24160
|
const ticket = await api.post(`/projects/${projectId}/tasks/${encodeURIComponent(taskKey)}/session/ticket`, options.claim ?? {});
|
|
24160
24161
|
const socket = new WebSocket(`${api.baseUrl.replace(/^http/, "ws")}/api${ticket.path}`);
|
|
@@ -24261,10 +24262,12 @@ var HeldSession = class {
|
|
|
24261
24262
|
for (const waiter of [...this.waiters]) waiter(delivered);
|
|
24262
24263
|
if (!taken) this.hooks.onMessage(delivered);
|
|
24263
24264
|
});
|
|
24264
|
-
socket.addEventListener("close", () => {
|
|
24265
|
+
socket.addEventListener("close", (event) => {
|
|
24265
24266
|
this.stopHeartbeat();
|
|
24266
24267
|
if (this.socket === socket) this.socket = null;
|
|
24267
|
-
if (
|
|
24268
|
+
if (this.stopped) return;
|
|
24269
|
+
if (event.reason === "replaced") this.standBy();
|
|
24270
|
+
else this.schedule();
|
|
24268
24271
|
});
|
|
24269
24272
|
socket.addEventListener("error", () => {
|
|
24270
24273
|
});
|
|
@@ -24296,10 +24299,23 @@ var HeldSession = class {
|
|
|
24296
24299
|
this.attempt += 1;
|
|
24297
24300
|
this.timer = setTimeout(() => void this.connect(), Math.min(3e4, 1e3 * 2 ** Math.min(this.attempt, 5)));
|
|
24298
24301
|
}
|
|
24302
|
+
/** Another process holds this session now: look now and then, and take it back once it is no longer live. */
|
|
24303
|
+
standBy() {
|
|
24304
|
+
this.timer = setTimeout(async () => {
|
|
24305
|
+
if (this.stopped) return;
|
|
24306
|
+
let holder = true;
|
|
24307
|
+
try {
|
|
24308
|
+
const sessions = await this.api.get(`/projects/${this.projectId}/sessions`);
|
|
24309
|
+
holder = sessions.some((session) => session.id === this.session?.id && session.state === "live");
|
|
24310
|
+
} catch {
|
|
24311
|
+
}
|
|
24312
|
+
if (holder) this.standBy();
|
|
24313
|
+
else void this.connect();
|
|
24314
|
+
}, STANDBY_POLL_MS);
|
|
24315
|
+
}
|
|
24299
24316
|
stop() {
|
|
24300
24317
|
this.stopped = true;
|
|
24301
24318
|
this.api.sessionId = null;
|
|
24302
|
-
rememberSession(process.cwd(), null);
|
|
24303
24319
|
if (this.timer) clearTimeout(this.timer);
|
|
24304
24320
|
this.stopHeartbeat();
|
|
24305
24321
|
this.socket?.close(1e3, "released");
|
|
@@ -24380,16 +24396,16 @@ var directoriesNamed = (root, prefix) => {
|
|
|
24380
24396
|
return [];
|
|
24381
24397
|
}
|
|
24382
24398
|
};
|
|
24383
|
-
var hasAny = (
|
|
24399
|
+
var hasAny = (dir, files) => files.some((file2) => existsSync6(join6(dir, file2)));
|
|
24384
24400
|
function claudeHomes(root = homedir3(), inUse = homesInUse) {
|
|
24385
24401
|
if (process.env.SLOP_CLAUDE_HOME) return [process.env.SLOP_CLAUDE_HOME];
|
|
24386
24402
|
const named = process.env.CLAUDE_CONFIG_DIR ? [process.env.CLAUDE_CONFIG_DIR] : [];
|
|
24387
|
-
return unique([join6(root, ".claude"), ...named, ...inUse("CLAUDE_CONFIG_DIR"), ...directoriesNamed(root, ".claude").filter((
|
|
24403
|
+
return unique([join6(root, ".claude"), ...named, ...inUse("CLAUDE_CONFIG_DIR"), ...directoriesNamed(root, ".claude").filter((dir) => hasAny(dir, ["settings.json", ".claude.json", "sessions"]))]);
|
|
24388
24404
|
}
|
|
24389
24405
|
function codexHomes(root = homedir3(), inUse = homesInUse) {
|
|
24390
24406
|
if (process.env.SLOP_CODEX_HOME) return [process.env.SLOP_CODEX_HOME];
|
|
24391
24407
|
const named = process.env.CODEX_HOME ? [process.env.CODEX_HOME] : [];
|
|
24392
|
-
return unique([join6(root, ".codex"), ...named, ...inUse("CODEX_HOME"), ...directoriesNamed(root, ".codex").filter((
|
|
24408
|
+
return unique([join6(root, ".codex"), ...named, ...inUse("CODEX_HOME"), ...directoriesNamed(root, ".codex").filter((dir) => hasAny(dir, ["config.toml", "auth.json", "sessions"]))]);
|
|
24393
24409
|
}
|
|
24394
24410
|
function ownHarnessHome(variable) {
|
|
24395
24411
|
if (process.platform === "win32") return null;
|
|
@@ -24541,15 +24557,15 @@ var same = (a, b) => {
|
|
|
24541
24557
|
};
|
|
24542
24558
|
function codexConversation(roots, cwd) {
|
|
24543
24559
|
const rollouts = [];
|
|
24544
|
-
const walk = (
|
|
24560
|
+
const walk = (dir, depth) => {
|
|
24545
24561
|
let entries;
|
|
24546
24562
|
try {
|
|
24547
|
-
entries = readdirSync2(
|
|
24563
|
+
entries = readdirSync2(dir, { withFileTypes: true });
|
|
24548
24564
|
} catch {
|
|
24549
24565
|
return;
|
|
24550
24566
|
}
|
|
24551
24567
|
for (const entry of entries) {
|
|
24552
|
-
const path3 = join8(
|
|
24568
|
+
const path3 = join8(dir, entry.name);
|
|
24553
24569
|
if (entry.isDirectory()) {
|
|
24554
24570
|
if (depth < 3) walk(path3, depth + 1);
|
|
24555
24571
|
continue;
|
|
@@ -24581,13 +24597,13 @@ function codexConversation(roots, cwd) {
|
|
|
24581
24597
|
if (!line.includes('"session_meta"')) continue;
|
|
24582
24598
|
const found = /"cwd":"((?:[^"\\]|\\.)*)"/.exec(line);
|
|
24583
24599
|
if (!found) continue;
|
|
24584
|
-
let
|
|
24600
|
+
let dir;
|
|
24585
24601
|
try {
|
|
24586
|
-
|
|
24602
|
+
dir = JSON.parse(`"${found[1]}"`);
|
|
24587
24603
|
} catch {
|
|
24588
24604
|
continue;
|
|
24589
24605
|
}
|
|
24590
|
-
if (same(
|
|
24606
|
+
if (same(dir, cwd)) return rollout.id;
|
|
24591
24607
|
}
|
|
24592
24608
|
return null;
|
|
24593
24609
|
}
|
|
@@ -25083,23 +25099,6 @@ function inboxDrain(cwd) {
|
|
|
25083
25099
|
});
|
|
25084
25100
|
}
|
|
25085
25101
|
|
|
25086
|
-
// src/platform/wake.ts
|
|
25087
|
-
import { existsSync as existsSync10, mkdirSync as mkdirSync7, rmSync as rmSync5, statSync as statSync4, writeFileSync as writeFileSync7 } from "fs";
|
|
25088
|
-
import { dirname as dirname6, join as join11 } from "path";
|
|
25089
|
-
var dir = (kind) => join11(dirname6(configPath()), kind);
|
|
25090
|
-
var file2 = (kind, cwd) => join11(dir(kind), inboxKey(cwd));
|
|
25091
|
-
function markWake(cwd) {
|
|
25092
|
-
mkdirSync7(dir("wake"), { recursive: true });
|
|
25093
|
-
writeFileSync7(file2("wake", cwd), String(Date.now()));
|
|
25094
|
-
}
|
|
25095
|
-
function takeWake(cwd, since) {
|
|
25096
|
-
const path3 = file2("wake", cwd);
|
|
25097
|
-
if (!existsSync10(path3)) return false;
|
|
25098
|
-
const at = statSync4(path3).mtimeMs;
|
|
25099
|
-
rmSync5(path3, { force: true });
|
|
25100
|
-
return at >= since - 1e3;
|
|
25101
|
-
}
|
|
25102
|
-
|
|
25103
25102
|
// src/commands/mcp.ts
|
|
25104
25103
|
var str = (description2) => ({ type: "string", description: description2 });
|
|
25105
25104
|
var int2 = (description2) => ({ type: "integer", description: description2 });
|
|
@@ -25155,6 +25154,9 @@ function handlers() {
|
|
|
25155
25154
|
held = new HeldSession(api, projectId, taskKey, {
|
|
25156
25155
|
// A message for the agent wakes its harness when the harness can be woken (Claude Code's session socket): it
|
|
25157
25156
|
// arrives as a turn, now, whether the agent is idle or mid-turn. Otherwise the inbox and the hooks carry it.
|
|
25157
|
+
// Claude Code is woken over its session socket: the message arrives as a turn, now, idle or not. Codex has no
|
|
25158
|
+
// such door (an app server named by SLOP_CODEX_APP_SERVER aside), so the message waits in the inbox and rides
|
|
25159
|
+
// the chat's next tool result. Nothing holds a turn open, nothing runs on the chat's behalf.
|
|
25158
25160
|
onMessage: (push) => {
|
|
25159
25161
|
const text = `A message for you on Slopware Tasks. Act or answer it (say reply), then carry on.
|
|
25160
25162
|
|
|
@@ -25166,11 +25168,7 @@ ${pushBlock(push)}`;
|
|
|
25166
25168
|
});
|
|
25167
25169
|
},
|
|
25168
25170
|
claim: whoAmI,
|
|
25169
|
-
onReconnect: (session) => catchUp(api, projectId, session.taskKey, process.cwd()).catch(() => void 0)
|
|
25170
|
-
// Made unreachable: a Codex Stop hook holding a turn open has nothing to wait for; the marker lets it go.
|
|
25171
|
-
onReachable: (on) => {
|
|
25172
|
-
if (!on) markWake(process.cwd());
|
|
25173
|
-
}
|
|
25171
|
+
onReconnect: (session) => catchUp(api, projectId, session.taskKey, process.cwd()).catch(() => void 0)
|
|
25174
25172
|
});
|
|
25175
25173
|
await held.start();
|
|
25176
25174
|
};
|
|
@@ -25545,27 +25543,27 @@ function readJson(path3) {
|
|
|
25545
25543
|
return {};
|
|
25546
25544
|
}
|
|
25547
25545
|
}
|
|
25548
|
-
function installClaude(
|
|
25546
|
+
function installClaude(dir) {
|
|
25549
25547
|
const done = [];
|
|
25550
|
-
const primary =
|
|
25548
|
+
const primary = dir === join11(homedir4(), ".claude");
|
|
25551
25549
|
const env = { ...process.env };
|
|
25552
25550
|
if (primary) delete env.CLAUDE_CONFIG_DIR;
|
|
25553
|
-
else env.CLAUDE_CONFIG_DIR =
|
|
25554
|
-
const where = primary ? "" : ` for ${
|
|
25551
|
+
else env.CLAUDE_CONFIG_DIR = dir;
|
|
25552
|
+
const where = primary ? "" : ` for ${dir}`;
|
|
25555
25553
|
try {
|
|
25556
25554
|
execFileSync5("claude", ["mcp", "add", "--scope", "user", "slop", "--", "slop", "mcp"], { stdio: ["ignore", "ignore", "pipe"], env });
|
|
25557
25555
|
done.push(`Claude Code: MCP server "slop" registered (user scope${where})`);
|
|
25558
25556
|
} catch (error62) {
|
|
25559
25557
|
const said = String(error62.stderr ?? "") + String(error62.stdout ?? "");
|
|
25560
25558
|
if (/already exists/i.test(said)) done.push(`Claude Code: MCP server "slop" already registered (user scope${where})`);
|
|
25561
|
-
else done.push(`Claude Code: run \`${primary ? "" : `CLAUDE_CONFIG_DIR=${
|
|
25559
|
+
else done.push(`Claude Code: run \`${primary ? "" : `CLAUDE_CONFIG_DIR=${dir} `}claude mcp add --scope user slop -- slop mcp\` (${said.trim() || "the claude command was not found here"})`);
|
|
25562
25560
|
}
|
|
25563
|
-
const path3 =
|
|
25564
|
-
|
|
25561
|
+
const path3 = join11(dir, "settings.json");
|
|
25562
|
+
mkdirSync7(dir, { recursive: true });
|
|
25565
25563
|
const settings = readJson(path3);
|
|
25566
25564
|
settings.hooks = mergeHooks(settings.hooks ?? {}, "claude");
|
|
25567
25565
|
settings.env = { ...settings.env ?? {}, MCP_TOOL_TIMEOUT: "21600000" };
|
|
25568
|
-
|
|
25566
|
+
writeFileSync7(path3, `${JSON.stringify(settings, null, 2)}
|
|
25569
25567
|
`);
|
|
25570
25568
|
done.push(`Claude Code: SessionStart hook and MCP_TOOL_TIMEOUT written to ${path3}; other slop hooks removed (its session socket wakes it)`);
|
|
25571
25569
|
return done;
|
|
@@ -25584,39 +25582,35 @@ function mergeHooks(hooks, harness) {
|
|
|
25584
25582
|
hooks[event] = entries;
|
|
25585
25583
|
};
|
|
25586
25584
|
add("SessionStart", "start", 5, "Slopware Tasks");
|
|
25587
|
-
if (harness === "codex") {
|
|
25588
|
-
add("UserPromptSubmit", "prompt", 5, "Slopware Tasks");
|
|
25589
|
-
add("Stop", "stop", 21600, "Listening on Slopware Tasks");
|
|
25590
|
-
}
|
|
25591
25585
|
return hooks;
|
|
25592
25586
|
}
|
|
25593
|
-
function installCodex(
|
|
25587
|
+
function installCodex(dir) {
|
|
25594
25588
|
const done = [];
|
|
25595
|
-
|
|
25596
|
-
const configPath3 =
|
|
25597
|
-
const current =
|
|
25589
|
+
mkdirSync7(dir, { recursive: true });
|
|
25590
|
+
const configPath3 = join11(dir, "config.toml");
|
|
25591
|
+
const current = existsSync10(configPath3) ? readFileSync13(configPath3, "utf8") : "";
|
|
25598
25592
|
if (/^\[mcp_servers\.slop\]/m.test(current)) {
|
|
25599
|
-
if (/tool_timeout_sec = 1800\b/.test(current))
|
|
25593
|
+
if (/tool_timeout_sec = 1800\b/.test(current)) writeFileSync7(configPath3, current.replace(/tool_timeout_sec = 1800\b/, "tool_timeout_sec = 21600"));
|
|
25600
25594
|
done.push(`Codex: MCP server already in ${configPath3}`);
|
|
25601
25595
|
} else {
|
|
25602
|
-
|
|
25596
|
+
writeFileSync7(configPath3, `${current.trimEnd()}${current.trim() ? "\n\n" : ""}[mcp_servers.slop]
|
|
25603
25597
|
command = "slop"
|
|
25604
25598
|
args = ["mcp"]
|
|
25605
25599
|
tool_timeout_sec = 21600
|
|
25606
25600
|
`);
|
|
25607
25601
|
done.push(`Codex: MCP server "slop" added to ${configPath3}`);
|
|
25608
25602
|
}
|
|
25609
|
-
const hooksPath =
|
|
25610
|
-
const
|
|
25611
|
-
|
|
25612
|
-
|
|
25603
|
+
const hooksPath = join11(dir, "hooks.json");
|
|
25604
|
+
const file2 = readJson(hooksPath);
|
|
25605
|
+
file2.hooks = mergeHooks(file2.hooks ?? {}, "codex");
|
|
25606
|
+
writeFileSync7(hooksPath, `${JSON.stringify(file2, null, 2)}
|
|
25613
25607
|
`);
|
|
25614
|
-
done.push(`Codex: SessionStart
|
|
25608
|
+
done.push(`Codex: SessionStart hook written to ${hooksPath}; other slop hooks removed (a stand-in run answers for an idle chat)`);
|
|
25615
25609
|
return done;
|
|
25616
25610
|
}
|
|
25617
25611
|
async function trustCodexHooks(codexHome) {
|
|
25618
|
-
const server = spawn3("codex", ["app-server"], { stdio: ["pipe", "pipe", "ignore"], env: { ...process.env, CODEX_HOME: codexHome } });
|
|
25619
|
-
const where = codexHome ===
|
|
25612
|
+
const server = spawn3("codex", ["app-server", "-c", "mcp_servers={}"], { stdio: ["pipe", "pipe", "ignore"], env: { ...process.env, CODEX_HOME: codexHome } });
|
|
25613
|
+
const where = codexHome === join11(homedir4(), ".codex") ? "" : ` under ${codexHome}`;
|
|
25620
25614
|
let buffer = "";
|
|
25621
25615
|
const pending = /* @__PURE__ */ new Map();
|
|
25622
25616
|
server.stdout.on("data", (chunk) => {
|
|
@@ -25651,7 +25645,7 @@ async function trustCodexHooks(codexHome) {
|
|
|
25651
25645
|
const notify = (method, params) => server.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", method, params })}
|
|
25652
25646
|
`);
|
|
25653
25647
|
try {
|
|
25654
|
-
await call("initialize", { clientInfo: { name: "slop", version: "0.4.
|
|
25648
|
+
await call("initialize", { clientInfo: { name: "slop", version: "0.4.2" }, capabilities: { experimentalApi: true } });
|
|
25655
25649
|
notify("initialized", {});
|
|
25656
25650
|
const listed = await call("hooks/list", { cwds: [process.cwd()] });
|
|
25657
25651
|
const ours = listed.data.flatMap((entry) => entry.hooks).filter((hook) => hook.command?.startsWith("slop hook "));
|
|
@@ -25670,9 +25664,9 @@ async function trustCodexHooks(codexHome) {
|
|
|
25670
25664
|
async function healCodexTrust() {
|
|
25671
25665
|
const home = ownHarnessHome("CODEX_HOME");
|
|
25672
25666
|
if (!home) return;
|
|
25673
|
-
const hooksPath =
|
|
25674
|
-
const configPath3 =
|
|
25675
|
-
if (!
|
|
25667
|
+
const hooksPath = join11(home, "hooks.json");
|
|
25668
|
+
const configPath3 = join11(home, "config.toml");
|
|
25669
|
+
if (!existsSync10(hooksPath) || !existsSync10(configPath3)) return;
|
|
25676
25670
|
if (!readFileSync13(hooksPath, "utf8").includes("slop hook stop")) return;
|
|
25677
25671
|
if (readFileSync13(configPath3, "utf8").includes(`hooks.state."${hooksPath}:stop:`)) return;
|
|
25678
25672
|
await trustCodexHooks(home);
|
|
@@ -25696,10 +25690,10 @@ async function hookInput(harness) {
|
|
|
25696
25690
|
return { cwd, conversation };
|
|
25697
25691
|
}
|
|
25698
25692
|
async function promptHook(harness) {
|
|
25699
|
-
|
|
25700
|
-
markWake(cwd);
|
|
25693
|
+
await hookInput(harness);
|
|
25701
25694
|
}
|
|
25702
25695
|
async function startHook(harness) {
|
|
25696
|
+
if (nonInteractiveHarness()) return;
|
|
25703
25697
|
const { conversation } = await hookInput(harness);
|
|
25704
25698
|
if (!conversation) return;
|
|
25705
25699
|
const text = `On Slopware Tasks you are ${agentNameFor(conversation)}: that is how people and other agents address you (session who lists everyone).`;
|
|
@@ -25737,34 +25731,9 @@ ${parts.join("\n")}` })}
|
|
|
25737
25731
|
`);
|
|
25738
25732
|
return;
|
|
25739
25733
|
}
|
|
25740
|
-
const sessionId = rememberedSession(cwd);
|
|
25741
|
-
if (!sessionId || harness !== "codex") return;
|
|
25742
|
-
const reachable = async () => (await api.get(`/projects/${project.id}/sessions`)).some((session) => session.id === sessionId && session.reachable);
|
|
25743
|
-
if (!await reachable()) return;
|
|
25744
|
-
const began = Date.now();
|
|
25745
|
-
takeWake(cwd, began);
|
|
25746
|
-
let lastCheck = began;
|
|
25747
|
-
while (Date.now() - began < STANDBY_HOLD_MS) {
|
|
25748
|
-
await new Promise((resolve5) => setTimeout(resolve5, 500));
|
|
25749
|
-
const arrived = inboxDrain(cwd);
|
|
25750
|
-
if (arrived.length) {
|
|
25751
|
-
process.stdout.write(`${JSON.stringify({ decision: "block", reason: `A message for you on Slopware Tasks. Act or answer it (say reply), then stop.
|
|
25752
|
-
|
|
25753
|
-
${arrived.map(pushBlock).join("\n\n")}` })}
|
|
25754
|
-
`);
|
|
25755
|
-
return;
|
|
25756
|
-
}
|
|
25757
|
-
if (takeWake(cwd, began)) return;
|
|
25758
|
-
if (Date.now() - lastCheck > 6e4) {
|
|
25759
|
-
lastCheck = Date.now();
|
|
25760
|
-
if (!await reachable().catch(() => true)) return;
|
|
25761
|
-
}
|
|
25762
|
-
}
|
|
25763
|
-
process.stdout.write(`${JSON.stringify({ decision: "block", reason: "Still reachable on Slopware Tasks, nothing arrived. Say so in a word and stop; you will wait again." })}
|
|
25764
|
-
`);
|
|
25765
25734
|
}
|
|
25766
|
-
var STANDBY_HOLD_MS = 5 * 60 * 60 * 1e3;
|
|
25767
25735
|
function tools() {
|
|
25736
|
+
if (nonInteractiveHarness()) return [];
|
|
25768
25737
|
const fine = handlers();
|
|
25769
25738
|
const run2 = (name, args) => {
|
|
25770
25739
|
const handler = fine.find((candidate) => candidate.name === name);
|
|
@@ -25940,13 +25909,13 @@ ${written.map((path3) => ` ${path3}`).join("\n")}`);
|
|
|
25940
25909
|
}
|
|
25941
25910
|
|
|
25942
25911
|
// src/index.ts
|
|
25943
|
-
var program2 = new Command().name("slop").description("Slopware Tasks from the terminal. Everything a person can do on the board, an agent can do here.").version("0.4.
|
|
25912
|
+
var program2 = new Command().name("slop").description("Slopware Tasks from the terminal. Everything a person can do on the board, an agent can do here.").version("0.4.2").option("--json", "machine-readable output: JSON on stdout, errors as JSON on stderr").hook("preAction", (_, action) => setJsonMode(Boolean(action.optsWithGlobals().json))).showHelpAfterError("(run with --help for usage)");
|
|
25944
25913
|
registerAuthCommands(program2);
|
|
25945
25914
|
registerProjectCommands(program2);
|
|
25946
25915
|
var taskCommand = registerTaskCommands(program2);
|
|
25947
25916
|
registerSessionCommands(program2, taskCommand);
|
|
25948
25917
|
registerThreadCommands(program2, taskCommand);
|
|
25949
|
-
registerMcpCommands(program2, "0.4.
|
|
25918
|
+
registerMcpCommands(program2, "0.4.2");
|
|
25950
25919
|
registerGuideCommand(program2);
|
|
25951
25920
|
registerSkillCommands(program2);
|
|
25952
25921
|
program2.parseAsync().catch(fail);
|