synabun 2.4.4 → 2.4.6
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/CHANGELOG.md +42 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +5 -4
- package/docs/whatsapp.md +19 -3
- package/hooks/claude-code/session-start.mjs +21 -18
- package/lib/claude-global-config.js +214 -0
- package/lib/client-config-repair.js +17 -3
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +6 -1
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +1 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +1 -0
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +1 -1
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +18 -3
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +85 -16
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +24 -5
- package/mcp-server/dist/tools/skill-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/skill-tools.js +88 -8
- package/mcp-server/dist/tools/skill-tools.js.map +1 -1
- package/mcp-server/dist/tools/tool-groups.d.ts.map +1 -1
- package/mcp-server/dist/tools/tool-groups.js +19 -4
- package/mcp-server/dist/tools/tool-groups.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/index.ts +6 -1
- package/mcp-server/src/services/neural-interface.ts +2 -1
- package/mcp-server/src/services/tool-catalog.ts +1 -1
- package/mcp-server/src/tools/agents.ts +78 -16
- package/mcp-server/src/tools/skill-tools.ts +82 -9
- package/mcp-server/src/tools/tool-groups.ts +19 -4
- package/neural-interface/i18n/en.json +484 -19
- package/neural-interface/i18n/pt-BR.json +484 -19
- package/neural-interface/lib/agents-studio-api.js +7 -2
- package/neural-interface/lib/antigravity/home.js +43 -8
- package/neural-interface/lib/antigravity/panel-bridge.js +7 -3
- package/neural-interface/lib/antigravity/tool-call.js +14 -0
- package/neural-interface/lib/assistant-brains/antigravity.js +4 -2
- package/neural-interface/lib/assistant-dispatch.js +15 -1
- package/neural-interface/lib/assistant-persona.js +8 -3
- package/neural-interface/lib/assistant-route-gate.js +11 -2
- package/neural-interface/lib/assistant-runtime.js +95 -13
- package/neural-interface/lib/assistant-spilled-output.js +53 -0
- package/neural-interface/lib/assistant-user-context.js +7 -3
- package/neural-interface/lib/browser-default.js +22 -2
- package/neural-interface/lib/browser-extension-bridge.js +50 -3
- package/neural-interface/lib/browser-extension-pin.json +7 -7
- package/neural-interface/lib/browser-extension-protocol.js +30 -1
- package/neural-interface/lib/browser-extension-setup.js +204 -36
- package/neural-interface/lib/claude-agent-bridge.js +13 -2
- package/neural-interface/lib/codex-thread-history.js +144 -7
- package/neural-interface/lib/codex-worker-app-server.js +84 -30
- package/neural-interface/lib/db.js +26 -0
- package/neural-interface/lib/greeting/sources.js +7 -3
- package/neural-interface/lib/jsonl-lines.js +10 -11
- package/neural-interface/lib/line-buffer.js +88 -0
- package/neural-interface/lib/loop-stall.js +15 -1
- package/neural-interface/lib/memory-list-read.js +105 -0
- package/neural-interface/lib/memory-timers.js +4 -1
- package/neural-interface/lib/native-loop-runtime.js +7 -3
- package/neural-interface/lib/provider-panel-api-key-auth.js +33 -6
- package/neural-interface/lib/remote-policy.js +24 -7
- package/neural-interface/lib/skills/api-v2.js +18 -3
- package/neural-interface/lib/skills/bundle.js +2 -2
- package/neural-interface/lib/skills/deploy.js +169 -34
- package/neural-interface/lib/skills/digest.js +57 -3
- package/neural-interface/lib/skills/health.js +55 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +12 -0
- package/neural-interface/lib/skills/runtime-checks.js +7 -4
- package/neural-interface/lib/skills/scan-shell.js +56 -7
- package/neural-interface/lib/skills/scan.js +13 -12
- package/neural-interface/lib/skills/service.js +7 -2
- package/neural-interface/lib/skills/telemetry.js +2 -2
- package/neural-interface/lib/teams/README.md +34 -6
- package/neural-interface/lib/teams/api.js +94 -10
- package/neural-interface/lib/teams/index.js +4 -0
- package/neural-interface/lib/teams/landing.js +195 -75
- package/neural-interface/lib/teams/recovery.js +68 -0
- package/neural-interface/lib/teams/scheduler.js +380 -61
- package/neural-interface/lib/teams/worktrees.js +123 -30
- package/neural-interface/lib/terminal-token-redaction.js +228 -58
- package/neural-interface/lib/terminal-tokens.js +18 -0
- package/neural-interface/lib/whatsapp/brain.js +21 -0
- package/neural-interface/lib/whatsapp/bridge.js +40 -4
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +6 -2
- package/neural-interface/public/index.html +117 -37
- package/neural-interface/public/shared/agents/studio/ax-api.js +27 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +1 -1
- package/neural-interface/public/shared/agents/studio/ax-icons.js +1 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-main.js +127 -41
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +436 -33
- package/neural-interface/public/shared/agents/studio/ax-teams.js +357 -10
- package/neural-interface/public/shared/agents/studio/ax-ui.js +31 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +67 -69
- package/neural-interface/public/shared/agents/studio/ax-work-answer.js +86 -0
- package/neural-interface/public/shared/agents/studio/ax-work-view.js +305 -0
- package/neural-interface/public/shared/agents/studio/ax-work.css +74 -0
- package/neural-interface/public/shared/agents/studio/ax-work.js +300 -0
- package/neural-interface/public/shared/browser-extension-updates.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-deferred.js +90 -0
- package/neural-interface/public/shared/cdx/cdx-render.js +18 -7
- package/neural-interface/public/shared/cdx/cdx-tabs.js +2 -1
- package/neural-interface/public/shared/extension-setup/es-page.js +23 -4
- package/neural-interface/public/shared/extension-setup/es-view.js +51 -11
- package/neural-interface/public/shared/extension-update-view.js +1 -1
- package/neural-interface/public/shared/loading-diagnostic-entry.js +16 -1
- package/neural-interface/public/shared/settings/settings-ai-browser.js +23 -3
- package/neural-interface/public/shared/settings/settings-browser-extension.js +575 -197
- package/neural-interface/public/shared/settings/settings-extension-diagrams.js +116 -0
- package/neural-interface/public/shared/settings/settings-extension-guide.js +222 -0
- package/neural-interface/public/shared/settings/settings-ia.js +2 -2
- package/neural-interface/public/shared/settings/settings-shell.js +5 -0
- package/neural-interface/public/shared/skills/studio/sx-operations-view.js +5 -0
- package/neural-interface/public/shared/skills/studio/sx-plan.js +42 -3
- package/neural-interface/public/shared/skills/studio/sx-publish-view.js +20 -4
- package/neural-interface/public/shared/styles.css +196 -13
- package/neural-interface/public/shared/ui-settings.js +48 -11
- package/neural-interface/server.js +336 -253
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/skills/skill-forge/SKILL.md +7 -3
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
// (lib/teams/api.js `teamDetail`) is read with its parts put back inside the team (ax-api.js `teamDetailOf`): claims
|
|
15
15
|
// by `glob`, the landing's `landed` / `refused` records, a slice's `lastReport`, an event's `event`, a message's
|
|
16
16
|
// `fromSlice`, the team's `attention`.
|
|
17
|
+
//
|
|
18
|
+
// A landing is bound to what the owner was shown. The server says what a landing sent now would move
|
|
19
|
+
// (`landing.preview`: the target branch and its tip, the integration head, whether the tests passed on that head,
|
|
20
|
+
// `canLand`, and the refusal's `code` / `reason` when it cannot); the page offers Land only while `canLand`, sends
|
|
21
|
+
// the three values it displayed with the request, and a LANDING_PREVIEW_STALE answer (the branch or the work changed
|
|
22
|
+
// meanwhile) lands nothing and is asked about again with the fresh preview (`landWithPreview`). Landing work no test
|
|
23
|
+
// verified is a second, separate question, and the only request that carries `allowUntested`. A server without the
|
|
24
|
+
// preview is the page as it was: Land for a ready team, an empty request.
|
|
17
25
|
// No DOM and no imports.
|
|
18
26
|
|
|
19
27
|
export const TEAM_STATES = Object.freeze(['creating', 'planned', 'running', 'integrating', 'ready', 'landing', 'merged', 'completed', 'failed', 'cancelled']);
|
|
@@ -24,6 +32,19 @@ export const SLICE_STATES = Object.freeze(['planned', 'pending', 'blocked', 'run
|
|
|
24
32
|
const TEAM_TONES = { creating: 'idle', planned: 'idle', running: 'active', integrating: 'active', ready: 'ok', landing: 'active', merged: 'done', completed: 'done', failed: 'err', cancelled: 'off', needs_attention: 'warn', landed: 'done', discarded: 'off' };
|
|
25
33
|
/** A team that reached the owner's branch, is on its way there, or was thrown away: nothing more to land or discard. */
|
|
26
34
|
const SETTLED_TEAM = new Set(['merged', 'landing', 'landed', 'discarded', 'completed']);
|
|
35
|
+
/**
|
|
36
|
+
* A team that is over (the scheduler's closed statuses, lib/teams/scheduler.js CLOSED_TEAM_STATUSES, and the
|
|
37
|
+
* journal's words for the same ends): the Finished list. Every other team, a state this page does not know
|
|
38
|
+
* included, is Open (never offered for removal), and the Open list is the rail's count.
|
|
39
|
+
*/
|
|
40
|
+
export const FINISHED_TEAM_STATUSES = Object.freeze(['landed', 'completed', 'discarded', 'failed', 'merged', 'cancelled']);
|
|
41
|
+
const FINISHED_TEAM = new Set(FINISHED_TEAM_STATUSES);
|
|
42
|
+
/** What the server says to do about a closed team that still has something on disk (lib/teams/scheduler.js removalOf). */
|
|
43
|
+
export const REMOVAL_NEXT = Object.freeze(['cleanup', 'force_discard', 'by_hand']);
|
|
44
|
+
/** Why a closed team's record cannot go yet, when it is not what is left on disk (`agentsStudio.teams.removalBlocked.*`). */
|
|
45
|
+
export const REMOVAL_BLOCKED = Object.freeze(['TEAM_RUNS_ACTIVE', 'DISPATCH_UNAVAILABLE', 'PROJECT_NOT_FOUND', 'NOT_A_REPOSITORY', 'GIT_UNAVAILABLE', 'TEAM_NEEDS_RECOVERY', 'TEAM_OPEN']);
|
|
46
|
+
/** Why a discard kept a worktree or a branch (lib/teams/worktrees.js `kept[].reason`; `agentsStudio.teams.keptReason.*`). */
|
|
47
|
+
export const KEPT_REASONS = Object.freeze(['uncommitted_changes', 'unintegrated_commits', 'folder_is_not_a_worktree', 'worktree_not_removed', 'branch_not_removed', 'worktree_not_verified', 'worker_commits']);
|
|
27
48
|
const SLICE_TONES = { planned: 'idle', pending: 'idle', blocked: 'warn', running: 'active', done: 'ok', rejected: 'err', integrating: 'active', integrated: 'done', completed: 'done', conflict: 'err', 'tests-failed': 'err', failed: 'err', cancelled: 'off' };
|
|
28
49
|
|
|
29
50
|
const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -35,34 +56,137 @@ const stateOf = (value) => text(first(value?.status, value?.state), 40).toLowerC
|
|
|
35
56
|
/** The tone of a team's or a slice's state: idle / active / ok / done / warn / err / off. */
|
|
36
57
|
export const teamTone = (state) => TEAM_TONES[state] || 'idle';
|
|
37
58
|
export const sliceTone = (state) => SLICE_TONES[state] || 'idle';
|
|
59
|
+
/** Is a team over (Finished)? */
|
|
60
|
+
export const isFinishedTeam = (status) => FINISHED_TEAM.has(String(status || '').toLowerCase());
|
|
61
|
+
|
|
62
|
+
/** The open statuses a card offers a quick action on: a team that waits on the owner. Never a running team. */
|
|
63
|
+
export const QUICK_TEAM_STATUSES = Object.freeze(['needs_attention', 'ready']);
|
|
64
|
+
/** The quick actions of a card: Clean up & remove, Discard & remove, Discard. */
|
|
65
|
+
export const QUICK_ACTIONS = Object.freeze(['cleanup-merged', 'discard-remove', 'discard']);
|
|
66
|
+
const count = (value) => (Number.isInteger(value) && value >= 0 ? value : null);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A ready team whose work is on its base branch already (lib/teams/scheduler.js `onTargetOf`), or null: where
|
|
70
|
+
* (`branch`), whether its worktrees and branches could go now (`clean`), and, in a team's detail, what keeps it from
|
|
71
|
+
* being clean (uncommitted files per worktree, branches with commits the base branch lacks, a live worker, other).
|
|
72
|
+
* Only for a ready team: any other status, or an answer without a branch, is null.
|
|
73
|
+
*/
|
|
74
|
+
export function onTargetOf(team) {
|
|
75
|
+
const o = isObject(team?.alreadyOnTarget) ? team.alreadyOnTarget : null;
|
|
76
|
+
if (!o || stateOf(team) !== 'ready' || team?.plan?.readOnly === true) return null;
|
|
77
|
+
const branch = text(o.branch, 300);
|
|
78
|
+
if (!branch) return null;
|
|
79
|
+
const list = (value) => (Array.isArray(value) ? value.filter(isObject) : []);
|
|
80
|
+
return {
|
|
81
|
+
branch,
|
|
82
|
+
head: text(o.head, 80),
|
|
83
|
+
clean: o.clean === true,
|
|
84
|
+
runs: count(o.runs),
|
|
85
|
+
dirty: list(o.dirty).map((item) => ({ sliceId: text(item.sliceId, 128) || null, path: text(item.path, 1024), files: (Array.isArray(item.files) ? item.files : []).filter((f) => typeof f === 'string').slice(0, 50) })).filter((item) => item.path).slice(0, 20),
|
|
86
|
+
unmerged: list(o.unmerged).map((item) => ({ sliceId: text(item.sliceId, 128) || null, branch: text(item.branch, 300), commits: (Array.isArray(item.commits) ? item.commits : []).filter((c) => typeof c === 'string').length })).filter((item) => item.branch).slice(0, 20),
|
|
87
|
+
other: (Array.isArray(o.other) ? o.other : []).filter((line) => typeof line === 'string' && line).map((line) => line.slice(0, 600)).slice(0, 10),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
38
90
|
|
|
39
91
|
/** A row of the teams list. */
|
|
40
92
|
export function teamRow(team) {
|
|
41
93
|
const t = isObject(team) ? team : {};
|
|
42
94
|
const slices = Array.isArray(t.slices) ? t.slices.length : isObject(t.slices) ? Object.keys(t.slices).length : number(first(t.slices, t.sliceCount, t.slicesCount));
|
|
43
95
|
const status = stateOf(t);
|
|
96
|
+
const onTarget = onTargetOf(t);
|
|
44
97
|
return {
|
|
45
98
|
id: text(first(t.id, t.teamId), 128),
|
|
46
99
|
title: text(first(t.title, t.plan?.title, t.name), 200),
|
|
47
100
|
project: text(first(t.project, t.projectPath, t.plan?.projectPath), 1024),
|
|
48
|
-
|
|
101
|
+
// A ready team whose work is on its base branch already says so instead of "Ready to land".
|
|
102
|
+
status, tone: onTarget ? (onTarget.clean ? 'done' : 'warn') : teamTone(status),
|
|
49
103
|
density: text(first(t.density, t.plan?.density), 40),
|
|
50
104
|
slices: slices ?? null,
|
|
51
105
|
createdAt: text(first(t.createdAt, t.created_at), 40),
|
|
52
106
|
updatedAt: text(first(t.updatedAt, t.updated_at), 40),
|
|
107
|
+
finished: isFinishedTeam(status),
|
|
108
|
+
// Only a finished team the server said can go now (nothing of it on disk or in git, no live worker).
|
|
109
|
+
removable: isFinishedTeam(status) && t.removable === true,
|
|
110
|
+
onTarget,
|
|
111
|
+
// An open team that waits on the owner: its live workers and what of it is on disk (null: not said).
|
|
112
|
+
liveRuns: count(t.liveRuns),
|
|
113
|
+
left: count(t.left),
|
|
53
114
|
};
|
|
54
115
|
}
|
|
55
116
|
|
|
117
|
+
/**
|
|
118
|
+
* The one quick action a card of the Open list offers, or null. Never on a running team, on a team with a live
|
|
119
|
+
* worker or on one whose workers the server did not count; never without the capability its route needs.
|
|
120
|
+
* cleanup-merged a ready team whose work is on its base branch already, clean (`teams-on-target`)
|
|
121
|
+
* discard-remove needs attention or ready, nothing of it on disk or in git (`teams-quick-discard`)
|
|
122
|
+
* discard needs attention or ready, with worktrees or branches (`teams-quick-discard`)
|
|
123
|
+
* A ready team on its base branch that is not clean gets none: discarding it would say its landed work was given up.
|
|
124
|
+
* @param {object} row a teamRow
|
|
125
|
+
* @param {{ has: (cap: string) => boolean }} caps
|
|
126
|
+
*/
|
|
127
|
+
export function quickActionOf(row, caps) {
|
|
128
|
+
const has = (cap) => typeof caps?.has === 'function' && caps.has(cap);
|
|
129
|
+
if (!row?.id || row.finished || !QUICK_TEAM_STATUSES.includes(row.status)) return null;
|
|
130
|
+
if (row.onTarget) return row.onTarget.clean && has('teams-on-target') ? 'cleanup-merged' : null;
|
|
131
|
+
if (!has('teams-quick-discard') || row.liveRuns !== 0 || row.left === null) return null;
|
|
132
|
+
return row.left === 0 ? 'discard-remove' : 'discard';
|
|
133
|
+
}
|
|
134
|
+
|
|
56
135
|
/** The list, newest first, a team without an id left out. */
|
|
57
136
|
export function teamRows(teams) {
|
|
58
137
|
return (Array.isArray(teams) ? teams : []).map(teamRow).filter((row) => row.id)
|
|
59
138
|
.sort((a, b) => String(b.createdAt).localeCompare(String(a.createdAt)));
|
|
60
139
|
}
|
|
61
140
|
|
|
62
|
-
/**
|
|
141
|
+
/** The list in two: the teams under way (Open) and the teams that are over (Finished), each newest first. */
|
|
142
|
+
export function splitTeams(rows) {
|
|
143
|
+
const list = Array.isArray(rows) ? rows : [];
|
|
144
|
+
return { open: list.filter((row) => !row.finished), finished: list.filter((row) => row.finished) };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** How many teams are under way (the rail's count): the Open list. A team that waits on the owner is under way. */
|
|
63
148
|
export function activeTeams(rows) {
|
|
64
|
-
|
|
65
|
-
|
|
149
|
+
return splitTeams(rows).open.length;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The finished teams Clear finished removes (the server checks each again) and how many it leaves. */
|
|
153
|
+
export function clearableTeams(rows) {
|
|
154
|
+
const { finished } = splitTeams(rows);
|
|
155
|
+
const removable = finished.filter((row) => row.removable);
|
|
156
|
+
return { removable, kept: finished.length - removable.length };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** A closed team's removal view (lib/teams/scheduler.js `removalView`), or null when the answer has none. */
|
|
160
|
+
export function removalOf(team) {
|
|
161
|
+
const r = isObject(team?.removal) ? team.removal : null;
|
|
162
|
+
if (!r) return null;
|
|
163
|
+
const left = (Array.isArray(r.left) ? r.left : []).filter(isObject).map((item) => ({
|
|
164
|
+
sliceId: text(item.sliceId, 128) || null,
|
|
165
|
+
path: text(item.path, 1024),
|
|
166
|
+
branch: text(item.branch, 300),
|
|
167
|
+
worktree: item.worktree === true,
|
|
168
|
+
branchExists: item.branchExists === true,
|
|
169
|
+
})).filter((item) => item.path || item.branch).slice(0, 200);
|
|
170
|
+
return {
|
|
171
|
+
removable: r.removable === true,
|
|
172
|
+
code: text(r.code, 80) || null,
|
|
173
|
+
next: REMOVAL_NEXT.includes(r.next) ? r.next : null,
|
|
174
|
+
message: text(r.message, 1200),
|
|
175
|
+
left,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** What a discard kept, and why (the scheduler's `cleanup.kept`, in the landing part of the answer). */
|
|
180
|
+
export function keptWork(team) {
|
|
181
|
+
const cleanup = isObject(team?.landing?.cleanup) ? team.landing.cleanup : isObject(team?.cleanup) ? team.cleanup : {};
|
|
182
|
+
return (Array.isArray(cleanup.kept) ? cleanup.kept : []).filter(isObject).map((item) => ({
|
|
183
|
+
sliceId: text(item.sliceId, 128) || null,
|
|
184
|
+
path: text(item.path, 1024),
|
|
185
|
+
branch: text(item.branch, 300),
|
|
186
|
+
reason: text(item.reason, 60),
|
|
187
|
+
files: (Array.isArray(item.files) ? item.files : []).filter((f) => typeof f === 'string').slice(0, 20),
|
|
188
|
+
commits: number(item.commits),
|
|
189
|
+
})).slice(0, 100);
|
|
66
190
|
}
|
|
67
191
|
|
|
68
192
|
function sliceOf(raw, plan) {
|
|
@@ -127,6 +251,200 @@ export function integrationOf(team) {
|
|
|
127
251
|
};
|
|
128
252
|
}
|
|
129
253
|
|
|
254
|
+
/** The answer of a landing whose bound values no longer hold: nothing moved, and `preview` is what holds now. */
|
|
255
|
+
export const LANDING_PREVIEW_STALE = 'LANDING_PREVIEW_STALE';
|
|
256
|
+
/**
|
|
257
|
+
* Why Land is not offered, as the page says it (`agentsStudio.teams.landWhy.*`): the refusal codes of a landing
|
|
258
|
+
* (lib/teams/landing.js), TESTS_NOT_PASSED in two (a team with a test command, and one without: NO_TEST_COMMAND), and
|
|
259
|
+
* `other` for a refusal that came without a sentence. Any other code is said with the server's own `reason`.
|
|
260
|
+
*/
|
|
261
|
+
export const LAND_WHY = Object.freeze(['TESTS_NOT_PASSED', 'NO_TEST_COMMAND', 'NOT_FAST_FORWARD', 'NOTHING_TO_LAND', 'TEAM_NOT_READY', 'TARGET_NOT_FOUND', 'other']);
|
|
262
|
+
const LAND_WHY_CODES = new Set(['NOT_FAST_FORWARD', 'NOTHING_TO_LAND', 'TEAM_NOT_READY', 'TARGET_NOT_FOUND']);
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The English of the landing's strings (`agentsStudio.teams.land*` in i18n/en.json must equal it; the contract test
|
|
266
|
+
* compares). The page says a string through its translator and falls back to this one, so the question that moves
|
|
267
|
+
* the owner's branch never shows a key: `public/` reloads at any time, a locale file an older build left does not.
|
|
268
|
+
*/
|
|
269
|
+
export const LAND_COPY = Object.freeze({
|
|
270
|
+
'agentsStudio.teams.landTip': 'Current tip',
|
|
271
|
+
'agentsStudio.teams.landTipMissing': 'Branch not found',
|
|
272
|
+
'agentsStudio.teams.landHead': 'Integration head',
|
|
273
|
+
'agentsStudio.teams.landTests': 'Tests on this head',
|
|
274
|
+
'agentsStudio.teams.landTestsNotPassed': 'Not passed',
|
|
275
|
+
'agentsStudio.teams.landNoTestCommand': 'No test command',
|
|
276
|
+
'agentsStudio.teams.landStale': 'The branch or the team\'s work changed since this dialog opened. Nothing was landed.',
|
|
277
|
+
'agentsStudio.teams.landStaleAgain': 'These are the values now. Confirm again to land them, or cancel.',
|
|
278
|
+
'agentsStudio.teams.landUntested': 'Land without tests',
|
|
279
|
+
'agentsStudio.teams.landUntestedHelp': 'Your own decision: land work that no test verified',
|
|
280
|
+
'agentsStudio.teams.landUntestedTitle': 'Land "{name}" without tests?',
|
|
281
|
+
'agentsStudio.teams.landUntestedAsk': '{branch} will be moved to the team\'s integrated result.',
|
|
282
|
+
'agentsStudio.teams.landUntestedWarn': 'This work was not verified by tests: no test run passed on this head. Landing it is your own decision.',
|
|
283
|
+
'agentsStudio.teams.landWhy.TESTS_NOT_PASSED': 'Land is not offered: the tests have not passed on the integration head.',
|
|
284
|
+
'agentsStudio.teams.landWhy.NO_TEST_COMMAND': 'Land is not offered: this team has no test command, so no test verified its work.',
|
|
285
|
+
'agentsStudio.teams.landWhy.NOT_FAST_FORWARD': 'Land is not offered: {branch} has commits the team\'s work lacks, so it cannot be moved forward to it.',
|
|
286
|
+
'agentsStudio.teams.landWhy.NOTHING_TO_LAND': 'Nothing to land: {branch} already has everything the team integrated.',
|
|
287
|
+
'agentsStudio.teams.landWhy.TEAM_NOT_READY': 'Land is not offered yet: not every slice is joined on the integration branch.',
|
|
288
|
+
'agentsStudio.teams.landWhy.TARGET_NOT_FOUND': 'Land is not offered: the branch {branch} is not in this project.',
|
|
289
|
+
'agentsStudio.teams.landWhy.other': 'Land is not offered for this team right now.',
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
/** A string of LAND_COPY with its values put in ('' for a key it does not have). */
|
|
293
|
+
export function landCopy(key, params = null) {
|
|
294
|
+
const said = typeof LAND_COPY[key] === 'string' ? LAND_COPY[key] : '';
|
|
295
|
+
return said.replace(/\{(\w+)\}/g, (whole, name) => (params && params[name] !== undefined && params[name] !== null ? String(params[name]) : whole));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** A commit id as the page shows it: its first nine characters. */
|
|
299
|
+
export const shortHash = (commit) => String(commit || '').slice(0, 9);
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* What a landing sent now would move (`landing.preview` of a team's answer, or the `preview` of a stale refusal), or
|
|
303
|
+
* null when the answer has none (a server from before it). A commit id is kept whole or not at all: it is sent back
|
|
304
|
+
* as it came. `canLand` holds only with a target branch and both heads, because those are what the request binds.
|
|
305
|
+
*/
|
|
306
|
+
export function landingPreviewOf(raw) {
|
|
307
|
+
if (!isObject(raw)) return null;
|
|
308
|
+
const whole = (value, max) => (typeof value === 'string' && value && value.length <= max ? value : null);
|
|
309
|
+
const targetBranch = whole(raw.targetBranch, 300);
|
|
310
|
+
const targetHead = whole(raw.targetHead, 80);
|
|
311
|
+
const integrationHead = whole(raw.integrationHead, 80);
|
|
312
|
+
return {
|
|
313
|
+
targetBranch: targetBranch || '',
|
|
314
|
+
targetHead,
|
|
315
|
+
integrationHead,
|
|
316
|
+
testCommand: (Array.isArray(raw.testCommand) ? raw.testCommand.filter((part) => typeof part === 'string').join(' ').slice(0, 600) : text(raw.testCommand, 600)) || null,
|
|
317
|
+
testsPassedOnHead: raw.testsPassedOnHead === true,
|
|
318
|
+
canLand: raw.canLand === true && !!targetBranch && !!targetHead && !!integrationHead,
|
|
319
|
+
code: text(raw.code, 80) || null,
|
|
320
|
+
reason: text(raw.reason, 600),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Why a landing with this preview is not offered, or null (no preview, or it can land): the refusal's `code`, the
|
|
326
|
+
* page's sentence for it (`key` with its `params`) or, for a code the page has no sentence for, the server's own
|
|
327
|
+
* (`text`).
|
|
328
|
+
*/
|
|
329
|
+
export function landWhyOf(preview) {
|
|
330
|
+
if (!preview || preview.canLand) return null;
|
|
331
|
+
const code = preview.code;
|
|
332
|
+
const word = code === 'TESTS_NOT_PASSED' ? (preview.testCommand ? 'TESTS_NOT_PASSED' : 'NO_TEST_COMMAND')
|
|
333
|
+
: LAND_WHY_CODES.has(code) ? code
|
|
334
|
+
: preview.reason ? null : 'other';
|
|
335
|
+
return {
|
|
336
|
+
code,
|
|
337
|
+
key: word ? `agentsStudio.teams.landWhy.${word}` : null,
|
|
338
|
+
params: { branch: preview.targetBranch },
|
|
339
|
+
text: word ? '' : preview.reason,
|
|
340
|
+
// A team still under way, or one with nothing left to land, is the usual course; the rest is in the owner's way.
|
|
341
|
+
tone: code === 'TEAM_NOT_READY' || code === 'NOTHING_TO_LAND' ? 'info' : 'warn',
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* What the owner may confirm with this preview: 'land' (it can land as it is), 'untested' (only when asked for:
|
|
347
|
+
* the one refusal is TESTS_NOT_PASSED and there is a branch and both heads to bind), or null (nothing).
|
|
348
|
+
*/
|
|
349
|
+
export function landOfferOf(preview, { untested = false } = {}) {
|
|
350
|
+
if (!preview) return null;
|
|
351
|
+
if (preview.canLand) return 'land';
|
|
352
|
+
if (untested && preview.code === 'TESTS_NOT_PASSED' && preview.targetBranch && preview.targetHead && preview.integrationHead) return 'untested';
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* The body of the land request for a preview: the branch and the two heads the owner was shown, and `allowUntested`
|
|
358
|
+
* only for the untested offer (never for a preview that can land as it is). null: nothing may be sent.
|
|
359
|
+
*/
|
|
360
|
+
export function landRequest(preview, { untested = false } = {}) {
|
|
361
|
+
const offer = landOfferOf(preview, { untested });
|
|
362
|
+
if (!offer) return null;
|
|
363
|
+
const body = { targetBranch: preview.targetBranch, expectedTargetHead: preview.targetHead, expectedIntegrationHead: preview.integrationHead };
|
|
364
|
+
if (offer === 'untested') body.allowUntested = true;
|
|
365
|
+
return body;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** Was this landing refused because what it was bound to no longer holds? */
|
|
369
|
+
export const isStaleLanding = (error) => error?.code === LANDING_PREVIEW_STALE;
|
|
370
|
+
/** The fresh preview a stale refusal carries (`preview` in the refusal's body), or null. */
|
|
371
|
+
export const stalePreviewOf = (error) => (isStaleLanding(error) ? landingPreviewOf(error?.body?.preview ?? error?.preview) : null);
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* The question of a landing, as the dialog draws it: its title, the lines before the facts, the facts (the target
|
|
375
|
+
* branch, its tip, the integration head, the tests on that head) and the lines after, and the button that confirms
|
|
376
|
+
* (none when nothing may be confirmed). The facts are the preview's own values: the same ones `landRequest` sends.
|
|
377
|
+
* @param {object} o
|
|
378
|
+
* @param {object|null} o.preview landingPreviewOf(...), or null on a server without one
|
|
379
|
+
* @param {'land'|'untested'|null} o.offer
|
|
380
|
+
* @param {boolean} [o.stale] a landing was just refused as stale: this preview is the fresh one
|
|
381
|
+
* @param {string} [o.name] the team's title
|
|
382
|
+
* @param {string} [o.branch] the branch to name when there is no preview
|
|
383
|
+
* @param {string} [o.failedOn] the commit the last test run failed on (the integration's record), if it failed
|
|
384
|
+
*/
|
|
385
|
+
export function landQuestionOf({ preview = null, offer = null, stale = false, name = '', branch = '', failedOn = '' } = {}) {
|
|
386
|
+
// Every key is written out whole: the contract test reads the keys the Studio says from its modules' text.
|
|
387
|
+
const untested = offer === 'untested';
|
|
388
|
+
const line = (id, key, { params = null, text: said = '', tone = null } = {}) => ({ id, key, params, text: said, tone });
|
|
389
|
+
const before = [];
|
|
390
|
+
if (stale) before.push(line('stale', 'agentsStudio.teams.landStale', { tone: 'warn' }));
|
|
391
|
+
if (stale && offer) before.push(line('again', 'agentsStudio.teams.landStaleAgain'));
|
|
392
|
+
if (offer) before.push(line('ask', untested ? 'agentsStudio.teams.landUntestedAsk' : 'agentsStudio.teams.landAsk', { params: { branch: preview?.targetBranch || branch } }));
|
|
393
|
+
const fact = (id, label, value, { shown = value, missing = null, chip = null } = {}) => ({ id, label, value, shown, missing, chip });
|
|
394
|
+
const facts = !preview ? [] : [
|
|
395
|
+
fact('target', 'agentsStudio.teams.target', preview.targetBranch),
|
|
396
|
+
fact('tip', 'agentsStudio.teams.landTip', preview.targetHead, { shown: shortHash(preview.targetHead), missing: 'agentsStudio.teams.landTipMissing' }),
|
|
397
|
+
fact('head', 'agentsStudio.teams.landHead', preview.integrationHead, { shown: shortHash(preview.integrationHead) }),
|
|
398
|
+
fact('tests', 'agentsStudio.teams.landTests', null, {
|
|
399
|
+
shown: '',
|
|
400
|
+
chip: preview.testsPassedOnHead ? { key: 'agentsStudio.teams.testsPassed', tone: 'ok' }
|
|
401
|
+
: !preview.testCommand ? { key: 'agentsStudio.teams.landNoTestCommand', tone: 'warn' }
|
|
402
|
+
: failedOn && failedOn === preview.integrationHead ? { key: 'agentsStudio.teams.testsFailed', tone: 'err' } : { key: 'agentsStudio.teams.landTestsNotPassed', tone: 'warn' },
|
|
403
|
+
}),
|
|
404
|
+
];
|
|
405
|
+
const after = [];
|
|
406
|
+
if (untested) after.push(line('untested', 'agentsStudio.teams.landUntestedWarn', { tone: 'warn' }));
|
|
407
|
+
else if (offer) after.push(line('refuses', 'agentsStudio.teams.landRefuses'));
|
|
408
|
+
else {
|
|
409
|
+
const why = landWhyOf(preview);
|
|
410
|
+
if (why) after.push(line('why', why.key, { params: why.params, text: why.text, tone: why.tone === 'warn' ? 'warn' : null }));
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
title: { key: untested ? 'agentsStudio.teams.landUntestedTitle' : 'agentsStudio.teams.landTitle', params: { name } },
|
|
414
|
+
before, facts, after,
|
|
415
|
+
confirm: untested ? { key: 'agentsStudio.teams.landUntested', kind: 'danger' } : offer ? { key: 'agentsStudio.teams.land', kind: 'primary' } : null,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* One landing, from its question to its answer. `ask({ preview, offer, stale })` puts the question to the owner and
|
|
421
|
+
* answers 'go' or anything else; `send(body)` posts the request. The request carries exactly the preview that was
|
|
422
|
+
* confirmed. A
|
|
423
|
+
* stale refusal lands nothing and is never sent again by itself: the question is asked again with the fresh preview
|
|
424
|
+
* (which may offer nothing any more: then it only says why). Any other refusal is thrown.
|
|
425
|
+
* @returns {Promise<{ outcome: 'landed'|'cancelled'|'blocked', preview: object|null, stale: boolean, body?: object, out?: object }>}
|
|
426
|
+
*/
|
|
427
|
+
export async function landWithPreview({ preview = null, untested = false, ask, send }) {
|
|
428
|
+
let shown = preview;
|
|
429
|
+
let stale = false;
|
|
430
|
+
for (;;) {
|
|
431
|
+
// A server without the preview: Land as it was (never the untested question, which needs values to bind).
|
|
432
|
+
const offer = shown ? landOfferOf(shown, { untested }) : (untested ? null : 'land');
|
|
433
|
+
const answer = await ask({ preview: shown, offer, stale });
|
|
434
|
+
if (!offer) return { outcome: 'blocked', preview: shown, stale };
|
|
435
|
+
if (answer !== 'go') return { outcome: 'cancelled', preview: shown, stale };
|
|
436
|
+
const body = shown ? landRequest(shown, { untested }) : {};
|
|
437
|
+
try {
|
|
438
|
+
return { outcome: 'landed', preview: shown, stale, body, out: await send(body) };
|
|
439
|
+
} catch (error) {
|
|
440
|
+
const fresh = stalePreviewOf(error);
|
|
441
|
+
if (!fresh) throw error;
|
|
442
|
+
shown = fresh;
|
|
443
|
+
stale = true;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
130
448
|
/** The landing: whether the team's result reached the owner's branch, and how. */
|
|
131
449
|
export function landingOf(team) {
|
|
132
450
|
const l = isObject(team?.landing) ? team.landing : {};
|
|
@@ -142,6 +460,8 @@ export function landingOf(team) {
|
|
|
142
460
|
commit: text(first(str(l.commit), str(l.head), str(landed.mergeCommit), str(landed.to)), 80),
|
|
143
461
|
at: text(first(str(l.at), str(l.landedAt), str(l.finishedAt), str(landed.at)), 40),
|
|
144
462
|
error: text(first(str(l.error), str(l.reason), str(refused.message)), 600),
|
|
463
|
+
// What a landing sent now would move (null: a server from before the preview).
|
|
464
|
+
preview: landingPreviewOf(l.preview),
|
|
145
465
|
};
|
|
146
466
|
}
|
|
147
467
|
|
|
@@ -182,19 +502,46 @@ export function teamView(team) {
|
|
|
182
502
|
const row = teamRow(team);
|
|
183
503
|
const slices = sliceRows(team);
|
|
184
504
|
const integration = integrationOf(team);
|
|
505
|
+
const readOnly = team?.plan?.readOnly === true;
|
|
506
|
+
// A finished team: the server's look at git and the disk (null from a server without it: nothing is offered).
|
|
507
|
+
const removal = row.finished ? removalOf(team) : null;
|
|
508
|
+
const leftWith = (next) => !!removal && !removal.removable && removal.next === next && removal.left.length > 0;
|
|
509
|
+
const landing = landingOf(team);
|
|
510
|
+
const preview = landing.preview;
|
|
511
|
+
// A team that can still be landed from here: not read-only, not over, not on its base branch already.
|
|
512
|
+
const landable = !readOnly && !row.finished && !SETTLED_TEAM.has(row.status) && !row.onTarget;
|
|
185
513
|
return {
|
|
186
514
|
...row,
|
|
187
515
|
slices,
|
|
188
|
-
readOnly
|
|
516
|
+
readOnly,
|
|
517
|
+
removal,
|
|
518
|
+
kept: keptWork(team),
|
|
519
|
+
// Landed, its worktrees and branches still there: the owner cleans them up (merged and clean, or nothing goes).
|
|
520
|
+
canCleanup: !readOnly && (row.status === 'landed' || row.status === 'merged') && leftWith('cleanup'),
|
|
521
|
+
// Discarded (or failed) with work kept: the owner deletes it with a forced discard.
|
|
522
|
+
canForceDiscard: !readOnly && ['discarded', 'cancelled', 'failed'].includes(row.status) && leftWith('force_discard'),
|
|
523
|
+
// Nothing of it is left and no worker lives: its record can go.
|
|
524
|
+
canRemove: row.finished && removal?.removable === true,
|
|
189
525
|
baseBranch: text(first(team?.baseBranch, team?.plan?.baseBranch), 300),
|
|
190
526
|
baseCommit: text(first(team?.baseCommit, team?.plan?.baseCommit), 80),
|
|
191
|
-
integration, landing
|
|
527
|
+
integration, landing, claims: claimRows(team), feed: feedItems(team),
|
|
192
528
|
// What the scheduler waits on the owner for (status `needs_attention`): its sentence, shown as text.
|
|
193
529
|
attention: text(isObject(team?.attention) ? first(team.attention.message, team.attention.code) : team?.attention, 600),
|
|
194
|
-
//
|
|
195
|
-
|
|
196
|
-
//
|
|
197
|
-
|
|
530
|
+
// Land follows the server's preview: offered exactly while a landing sent now would be accepted. Without a
|
|
531
|
+
// preview (an older server) it is offered once the team is ready, as before, and the server says why not. Never
|
|
532
|
+
// for a team whose work is on its base branch already: there is nothing left to land.
|
|
533
|
+
canLand: preview ? landable && preview.canLand : !readOnly && row.status === 'ready' && !row.onTarget,
|
|
534
|
+
// The preview of a team that can still be landed from here (null: none, or the team is over or on its branch).
|
|
535
|
+
landPreview: preview && landable ? preview : null,
|
|
536
|
+
// Why Land is not offered, in the page's words (null: it is offered, there is no preview, or the team is over).
|
|
537
|
+
landWhy: preview && landable ? landWhyOf(preview) : null,
|
|
538
|
+
// The tests are all that is in the way: landing untested work is offered apart, as the owner's own decision.
|
|
539
|
+
canLandUntested: !!preview && landable && landOfferOf(preview, { untested: true }) === 'untested',
|
|
540
|
+
// A team that reached the owner's branch, or is on its way there, is not thrown away from here; neither is one
|
|
541
|
+
// whose work is on its base branch already (a discard would record its landed work as given up).
|
|
542
|
+
canDiscard: !!row.id && !SETTLED_TEAM.has(row.status) && team?.removed !== true && !row.onTarget,
|
|
543
|
+
// Its work is on its base branch already and nothing would be lost: Clean up & remove.
|
|
544
|
+
canCleanupMerged: !!row.onTarget && row.onTarget.clean,
|
|
198
545
|
sliceCounts: slices.reduce((acc, slice) => { acc[slice.tone] = (acc[slice.tone] || 0) + 1; return acc; }, {}),
|
|
199
546
|
};
|
|
200
547
|
}
|
|
@@ -14,6 +14,7 @@ import { dropdownHTML } from '../../cc-dropdown.js';
|
|
|
14
14
|
import { agentIcon, toneOf, AX_ICONS } from './ax-icons.js';
|
|
15
15
|
import { standingOf, scopeLabel, authorKind } from './ax-library.js';
|
|
16
16
|
import { diffRows, hunksOf, privilegeChanges, privilegeSummary, diffSize } from './ax-diff.js';
|
|
17
|
+
import { WORK_COPY } from './ax-work.js';
|
|
17
18
|
|
|
18
19
|
/** The words the pure modules take (ax-diff.js valueText): the page's strings for values. */
|
|
19
20
|
export function wordsOf(t, { projects = [], profiles = [] } = {}) {
|
|
@@ -30,6 +31,36 @@ export function wordsOf(t, { projects = [], profiles = [] } = {}) {
|
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
/** Navigation within Agents. The Library and definition reviews share the same rail entry. */
|
|
35
|
+
export function agentSections(ctx) {
|
|
36
|
+
const sections = [['library', 'agentsStudio.rail.library', ctx.counts.total]];
|
|
37
|
+
if (ctx.caps.has('reviews')) sections.push(['review', 'agentsStudio.rail.review', ctx.counts.review]);
|
|
38
|
+
return html`<nav class="sx-place-head" aria-label="${ctx.t('agentsStudio.rail.agents')}"><span class="sx-seg">
|
|
39
|
+
${sections.map(([place, label, count]) => html`<button type="button" id="ax-section-${place}" data-act="agents-section" data-place="${place}" aria-pressed="${String(ctx.view.place === place)}">${ctx.t(label)} · ${count}</button>`)}
|
|
40
|
+
</span></nav>`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The shell's own English for the strings it added with the Work view (rail, Manage teams). A page loads its locale
|
|
45
|
+
* file once, when it opens; the Studio's code loads when the Studio opens. A page opened before an update therefore
|
|
46
|
+
* runs the new Studio with the old locale file, and these strings must not show their keys there.
|
|
47
|
+
*/
|
|
48
|
+
export const SHELL_COPY = Object.freeze({
|
|
49
|
+
'agentsStudio.rail.work': 'Work',
|
|
50
|
+
'agentsStudio.rail.agents': 'Agents',
|
|
51
|
+
'agentsStudio.rail.taskStatus': 'Task status',
|
|
52
|
+
'agentsStudio.teams.manage': 'Manage teams',
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/** A shell string: the translator's, else the module's own English (SHELL_COPY, then the Work list's), never a key. */
|
|
56
|
+
export function shellText(t, key, params) {
|
|
57
|
+
const said = t(key, params);
|
|
58
|
+
if (said !== key) return said;
|
|
59
|
+
const own = SHELL_COPY[key] ?? WORK_COPY[key];
|
|
60
|
+
if (typeof own !== 'string') return said;
|
|
61
|
+
return params ? own.replace(/\{(\w+)\}/g, (_, name) => String(params[name] ?? '')) : own;
|
|
62
|
+
}
|
|
63
|
+
|
|
33
64
|
/** A word of a family, or the value as written when the family has no word for it (a state from a newer server). */
|
|
34
65
|
export function wordOr(t, family, value) {
|
|
35
66
|
const key = `${family}.${value}`;
|