@moxxy/cli 0.14.4 → 0.14.5
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/bin.js +97 -21
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { z as z$1, createMutex, defineTunnelProvider, definePlugin, defineProvider, defineTool, MoxxyError, asTurnId, defineMode, asPluginId, defineCommand, defineChannel, defineWorkflowExecutor, toFriendlyError, estimateTextTokens, classifyHttpStatus, createStuckLoopDetector, runCompactionIfNeeded, runElisionIfNeeded, collectProviderStream, usageEventFields, isContextOverflowError, emitRequestsAndDetectStuck, executeToolUses, buildSystemPromptWithSkills, projectMessages, defineCompactor, defineCacheStrategy, denyByDefaultResolver, createAllowListResolver, zodToJsonSchema, fileDiffSummary, runSingleShotTurn, defineSurface, runManualCompaction, isFileDiffDisplay, renderFrontmatter, defineEmbedder, migrateModeName, skillFrontmatterSchema, asSkillId, startChannelWith, parseFrontmatterFile, createDeferredPermissionResolver, getInstallHint, defineTranscriber, summarizeTokensByModel, countNodes, moxxyPackageSchema, encodeLoginPrompt, classifyNetworkError, addModelTotals, createJsonFileStore, ISOLATION_RANK, MOXXY_PCM16_24KHZ_MIME, fileDiffVerb, parseFrontmatter, createCallbackResolver, autoAllowResolver, asSessionId, asToolCallId, defineViewRenderer, DEFAULT_VIEW_TAGS, isSafeViewUrl, evaluateToolRule, summarizeSessionTokensFromEvents, toDiffRows, diffGutterNo, computeElisionState, toolResultStubbed, toolResultStub, toolResultBytes, conversationalStubbed, conversationalStub, asEventId } from '@moxxy/sdk';
|
|
4
4
|
import * as fs32 from 'fs';
|
|
5
|
-
import fs32__default, { existsSync, promises, ReadStream, mkdirSync, rmSync, statSync, readdirSync,
|
|
5
|
+
import fs32__default, { existsSync, promises, ReadStream, mkdirSync, writeFileSync, rmSync, statSync, readdirSync, readFileSync, unlinkSync, chmodSync, watch, createReadStream } from 'fs';
|
|
6
6
|
import * as path3 from 'path';
|
|
7
7
|
import path3__default, { join, dirname, resolve, relative, isAbsolute, basename } from 'path';
|
|
8
8
|
import { isCliTunnelAvailable, writeFileAtomic, spawnCliTunnel, moxxyPath, moxxyHome, bearerTokenMatches, resolveChannelToken, rotateChannelToken, readRequestBody, MOXXY_WS_SUBPROTOCOL, bearerGuard, tokenFromWsProtocolHeader, writeFileAtomicSync } from '@moxxy/sdk/server';
|
|
@@ -81553,10 +81553,10 @@ var init_output = __esm({
|
|
|
81553
81553
|
transformers
|
|
81554
81554
|
});
|
|
81555
81555
|
}
|
|
81556
|
-
clip(
|
|
81556
|
+
clip(clip2) {
|
|
81557
81557
|
this.operations.push({
|
|
81558
81558
|
type: "clip",
|
|
81559
|
-
clip
|
|
81559
|
+
clip: clip2
|
|
81560
81560
|
});
|
|
81561
81561
|
}
|
|
81562
81562
|
unclip() {
|
|
@@ -81590,40 +81590,40 @@ var init_output = __esm({
|
|
|
81590
81590
|
const { text, transformers } = operation;
|
|
81591
81591
|
let { x: x4, y: y2 } = operation;
|
|
81592
81592
|
let lines = text.split("\n");
|
|
81593
|
-
const
|
|
81594
|
-
if (
|
|
81595
|
-
const clipHorizontally = typeof
|
|
81596
|
-
const clipVertically = typeof
|
|
81593
|
+
const clip2 = clips.at(-1);
|
|
81594
|
+
if (clip2) {
|
|
81595
|
+
const clipHorizontally = typeof clip2?.x1 === "number" && typeof clip2?.x2 === "number";
|
|
81596
|
+
const clipVertically = typeof clip2?.y1 === "number" && typeof clip2?.y2 === "number";
|
|
81597
81597
|
if (clipHorizontally) {
|
|
81598
81598
|
const width = widestLine(text);
|
|
81599
|
-
if (x4 + width <
|
|
81599
|
+
if (x4 + width < clip2.x1 || x4 > clip2.x2) {
|
|
81600
81600
|
continue;
|
|
81601
81601
|
}
|
|
81602
81602
|
}
|
|
81603
81603
|
if (clipVertically) {
|
|
81604
81604
|
const height = lines.length;
|
|
81605
|
-
if (y2 + height <
|
|
81605
|
+
if (y2 + height < clip2.y1 || y2 > clip2.y2) {
|
|
81606
81606
|
continue;
|
|
81607
81607
|
}
|
|
81608
81608
|
}
|
|
81609
81609
|
if (clipHorizontally) {
|
|
81610
81610
|
lines = lines.map((line) => {
|
|
81611
|
-
const from = x4 <
|
|
81611
|
+
const from = x4 < clip2.x1 ? clip2.x1 - x4 : 0;
|
|
81612
81612
|
const width = stringWidth(line);
|
|
81613
|
-
const to = x4 + width >
|
|
81613
|
+
const to = x4 + width > clip2.x2 ? clip2.x2 - x4 : width;
|
|
81614
81614
|
return sliceAnsi2(line, from, to);
|
|
81615
81615
|
});
|
|
81616
|
-
if (x4 <
|
|
81617
|
-
x4 =
|
|
81616
|
+
if (x4 < clip2.x1) {
|
|
81617
|
+
x4 = clip2.x1;
|
|
81618
81618
|
}
|
|
81619
81619
|
}
|
|
81620
81620
|
if (clipVertically) {
|
|
81621
|
-
const from = y2 <
|
|
81621
|
+
const from = y2 < clip2.y1 ? clip2.y1 - y2 : 0;
|
|
81622
81622
|
const height = lines.length;
|
|
81623
|
-
const to = y2 + height >
|
|
81623
|
+
const to = y2 + height > clip2.y2 ? clip2.y2 - y2 : height;
|
|
81624
81624
|
lines = lines.slice(from, to);
|
|
81625
|
-
if (y2 <
|
|
81626
|
-
y2 =
|
|
81625
|
+
if (y2 < clip2.y1) {
|
|
81626
|
+
y2 = clip2.y1;
|
|
81627
81627
|
}
|
|
81628
81628
|
}
|
|
81629
81629
|
}
|
|
@@ -136051,6 +136051,7 @@ var ARCHITECT_AGENT_ID = "architect";
|
|
|
136051
136051
|
var COLLAB_SCAFFOLD_DIR = ".moxxy-collab";
|
|
136052
136052
|
var CONTRACTS_FILENAME = "CONTRACTS.md";
|
|
136053
136053
|
var ROSTER_FILENAME = "roster.json";
|
|
136054
|
+
var BRIEF_FILENAME = "BRIEF.md";
|
|
136054
136055
|
function collabRunId(sessionId, turnId) {
|
|
136055
136056
|
const tail = (s2) => s2.replace(/[^a-zA-Z0-9]/g, "").slice(-6) || "x";
|
|
136056
136057
|
return `${tail(sessionId)}-${tail(turnId)}`;
|
|
@@ -139100,6 +139101,53 @@ function resolveCollabConfig(persisted, overrides) {
|
|
|
139100
139101
|
function stripUndefined(obj) {
|
|
139101
139102
|
return Object.fromEntries(Object.entries(obj).filter(([, v3]) => v3 !== void 0));
|
|
139102
139103
|
}
|
|
139104
|
+
var MAX_MSG_CHARS = 600;
|
|
139105
|
+
var MAX_TOTAL_CHARS = 6e3;
|
|
139106
|
+
function clip(s2, n2) {
|
|
139107
|
+
const t2 = s2.trim().replace(/\s+/g, " ");
|
|
139108
|
+
return t2.length > n2 ? `${t2.slice(0, n2 - 1)}\u2026` : t2;
|
|
139109
|
+
}
|
|
139110
|
+
function digestTurns(events) {
|
|
139111
|
+
const out = [];
|
|
139112
|
+
for (const raw of events) {
|
|
139113
|
+
const e3 = raw;
|
|
139114
|
+
if (e3.type === "user_prompt" && typeof e3.text === "string" && e3.text.trim()) {
|
|
139115
|
+
out.push({ role: "user", text: e3.text });
|
|
139116
|
+
} else if (e3.type === "assistant_message" && e3.source === "model" && typeof e3.content === "string" && e3.content.trim()) {
|
|
139117
|
+
out.push({ role: "assistant", text: e3.content });
|
|
139118
|
+
}
|
|
139119
|
+
}
|
|
139120
|
+
return out;
|
|
139121
|
+
}
|
|
139122
|
+
function buildBrief(task, events) {
|
|
139123
|
+
const turns = digestTurns(events);
|
|
139124
|
+
const trimmed = turns.length > 0 && turns[turns.length - 1].role === "user" && turns[turns.length - 1].text.trim() === task.trim() ? turns.slice(0, -1) : turns;
|
|
139125
|
+
const recent = trimmed.slice(-12);
|
|
139126
|
+
const lines = [
|
|
139127
|
+
"# Collaboration brief",
|
|
139128
|
+
"",
|
|
139129
|
+
"This is the shared context for the whole team. It is the user's goal and the",
|
|
139130
|
+
"conversation that led to it \u2014 read it before planning so your work fits the",
|
|
139131
|
+
"real intent, not just your narrow sub-task.",
|
|
139132
|
+
"",
|
|
139133
|
+
"## Goal",
|
|
139134
|
+
"",
|
|
139135
|
+
clip(task, 1500) || "(no goal text)"
|
|
139136
|
+
];
|
|
139137
|
+
if (recent.length > 0) {
|
|
139138
|
+
lines.push("", "## Conversation so far", "");
|
|
139139
|
+
for (const t2 of recent) {
|
|
139140
|
+
const who = t2.role === "user" ? "User" : "Assistant";
|
|
139141
|
+
lines.push(`- **${who}:** ${clip(t2.text, MAX_MSG_CHARS)}`);
|
|
139142
|
+
}
|
|
139143
|
+
}
|
|
139144
|
+
let brief = lines.join("\n");
|
|
139145
|
+
if (brief.length > MAX_TOTAL_CHARS) {
|
|
139146
|
+
brief = `${brief.slice(0, MAX_TOTAL_CHARS - 1)}\u2026`;
|
|
139147
|
+
}
|
|
139148
|
+
return `${brief}
|
|
139149
|
+
`;
|
|
139150
|
+
}
|
|
139103
139151
|
var IDENTITY = ["-c", "user.name=moxxy-collab", "-c", "user.email=collab@moxxy.local"];
|
|
139104
139152
|
function git(cwd2, args) {
|
|
139105
139153
|
return new Promise((resolve13) => {
|
|
@@ -139522,6 +139570,12 @@ async function* runCollaborative(ctx, deps) {
|
|
|
139522
139570
|
};
|
|
139523
139571
|
supervisor = (deps.createSupervisor ?? ((o2) => new PeerSupervisor(o2)))(supervisorOpts, hub);
|
|
139524
139572
|
yield await ctx.emit(plugin4(ctx, "collab_started", { task, parallel, gitInstalled: gitInstalled2, gitRepo }));
|
|
139573
|
+
try {
|
|
139574
|
+
mkdirSync(join(cwd2, COLLAB_SCAFFOLD_DIR), { recursive: true });
|
|
139575
|
+
writeFileSync(join(cwd2, COLLAB_SCAFFOLD_DIR, BRIEF_FILENAME), buildBrief(task, ctx.log.slice()));
|
|
139576
|
+
yield await ctx.emit(plugin4(ctx, "collab_brief_written", { path: join(COLLAB_SCAFFOLD_DIR, BRIEF_FILENAME) }));
|
|
139577
|
+
} catch {
|
|
139578
|
+
}
|
|
139525
139579
|
supervisor.spawn({ entry: architectEntry, cwd: cwd2, mode: COLLAB_ARCHITECT_MODE_NAME });
|
|
139526
139580
|
yield await ctx.emit(plugin4(ctx, "collab_agent_spawned", { id: ARCHITECT_AGENT_ID, role: "architect" }));
|
|
139527
139581
|
const architectOk = await waitForAgent(hub, supervisor, ARCHITECT_AGENT_ID, ctx.signal, cfg.wallClockMs);
|
|
@@ -139813,7 +139867,11 @@ function emitAbort(ctx, reason) {
|
|
|
139813
139867
|
}
|
|
139814
139868
|
|
|
139815
139869
|
// ../mode-collaborative/dist/prompts.js
|
|
139816
|
-
var COLLAB_COMMON = `You are one agent on a TEAM of separate agents collaborating on one task in a shared
|
|
139870
|
+
var COLLAB_COMMON = `You are one agent on a TEAM of separate agents collaborating on one task in a shared workspace. You are a peer, not in charge \u2014 you cooperate.
|
|
139871
|
+
|
|
139872
|
+
Know the WHOLE picture before you act:
|
|
139873
|
+
- ${COLLAB_SCAFFOLD_DIR}/${BRIEF_FILENAME} is the shared brief \u2014 the user's overall goal and the conversation/intent behind it. Read it FIRST so your work serves the real goal, not just the literal words of your sub-task.
|
|
139874
|
+
- Before planning, recall() any relevant prior knowledge about this workspace/task. When you discover a durable fact (a decision, a gotcha, an interface, a convention), memory_save it so the team \u2014 and future work \u2014 keeps it.
|
|
139817
139875
|
|
|
139818
139876
|
The team coordinates through a shared hub (use these tools):
|
|
139819
139877
|
- collab_roster \u2014 who is on the team, their roles, sub-tasks, and status.
|
|
@@ -139832,11 +139890,12 @@ Cooperation rules:
|
|
|
139832
139890
|
- When YOUR sub-task is fully complete and verified, call collab_done with a short summary. The run finishes when everyone is done.`;
|
|
139833
139891
|
var COLLAB_PEER_PROMPT = `${COLLAB_COMMON}
|
|
139834
139892
|
|
|
139835
|
-
You are an IMPLEMENTER. Your sub-task is provided. Start by reading ${COLLAB_SCAFFOLD_DIR}/${CONTRACTS_FILENAME} and calling collab_contracts, collab_roster, and collab_board so you know the plan and who owns what. Claim your files, implement against the contracts, coordinate on intersections, then call collab_done.`;
|
|
139893
|
+
You are an IMPLEMENTER. Your sub-task is provided. Start by reading ${COLLAB_SCAFFOLD_DIR}/${BRIEF_FILENAME} (the goal + intent) and ${COLLAB_SCAFFOLD_DIR}/${CONTRACTS_FILENAME}, and calling collab_contracts, collab_roster, and collab_board so you know the plan and who owns what. Claim your files, implement against the contracts, coordinate on intersections, then call collab_done.`;
|
|
139836
139894
|
var COLLAB_ARCHITECT_PROMPT = `${COLLAB_COMMON}
|
|
139837
139895
|
|
|
139838
139896
|
You are the ARCHITECT \u2014 you run FIRST and set the team up for success. Your job, in order:
|
|
139839
|
-
|
|
139897
|
+
0. Read ${COLLAB_SCAFFOLD_DIR}/${BRIEF_FILENAME} \u2014 the user's goal and the conversation behind it \u2014 so you decompose toward what they actually want.
|
|
139898
|
+
1. Explore the workspace to understand the task and its boundaries.
|
|
139840
139899
|
2. Decompose the task into INDEPENDENT sub-tasks with DISJOINT file ownership (minimize overlap so agents rarely touch the same files).
|
|
139841
139900
|
3. Define the shared CONTRACTS \u2014 the interfaces, types, API shapes, and module boundaries where the implementers' work meets. Publish each with collab_contract_publish (give an owner + consumers).
|
|
139842
139901
|
4. Write two files into the repo:
|
|
@@ -155948,7 +156007,10 @@ async function runAgentCommand(argv) {
|
|
|
155948
156007
|
const sessionId = process.env.MOXXY_SESSION_ID?.trim();
|
|
155949
156008
|
const mode = process.env.MOXXY_MODE?.trim() || "collab-peer";
|
|
155950
156009
|
const subtask = process.env.MOXXY_COLLAB_SUBTASK ?? "";
|
|
156010
|
+
const parentTask = process.env.MOXXY_COLLAB_PARENT_TASK?.trim() ?? "";
|
|
156011
|
+
const role = process.env.MOXXY_COLLAB_ROLE?.trim() ?? "";
|
|
155951
156012
|
const model = process.env.MOXXY_MODEL?.trim();
|
|
156013
|
+
const seededTurn = buildSeedTurn({ role, parentTask, subtask });
|
|
155952
156014
|
const setup = await bootSessionWithConfig(argv, {
|
|
155953
156015
|
skipKeyPrompt: true,
|
|
155954
156016
|
tolerateNoProvider: true,
|
|
@@ -155970,7 +156032,7 @@ async function runAgentCommand(argv) {
|
|
|
155970
156032
|
const runnerServer = await startRunnerServer(session);
|
|
155971
156033
|
const turnDone = (async () => {
|
|
155972
156034
|
try {
|
|
155973
|
-
for await (const _2 of session.runTurn(
|
|
156035
|
+
for await (const _2 of session.runTurn(seededTurn)) void _2;
|
|
155974
156036
|
} catch {
|
|
155975
156037
|
}
|
|
155976
156038
|
try {
|
|
@@ -155987,6 +156049,20 @@ async function runAgentCommand(argv) {
|
|
|
155987
156049
|
await runUntilSignal2(runnerServer, session, turnDone);
|
|
155988
156050
|
return 0;
|
|
155989
156051
|
}
|
|
156052
|
+
function buildSeedTurn(args) {
|
|
156053
|
+
const { role, parentTask, subtask } = args;
|
|
156054
|
+
const pointer = "Shared team context is in `.moxxy-collab/BRIEF.md` (the user's overall goal + the conversation/intent) and `.moxxy-collab/CONTRACTS.md` (the agreed interfaces). Read them before you start so your work fits the real goal.";
|
|
156055
|
+
if (role === "architect" || !parentTask || parentTask === subtask) {
|
|
156056
|
+
return subtask ? `${subtask}
|
|
156057
|
+
|
|
156058
|
+
${pointer}` : pointer;
|
|
156059
|
+
}
|
|
156060
|
+
return `Overall team goal: ${parentTask}
|
|
156061
|
+
|
|
156062
|
+
Your sub-task: ${subtask}
|
|
156063
|
+
|
|
156064
|
+
${pointer}`;
|
|
156065
|
+
}
|
|
155990
156066
|
async function runUntilSignal2(runnerServer, session, turnDone) {
|
|
155991
156067
|
let stopping = false;
|
|
155992
156068
|
const shutdown = async (signal) => {
|