@nathanstephenson/flow 0.1.10-beta.6 → 0.1.10-beta.8
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 +5 -19
- package/dist/build-id +1 -1
- package/dist/cli/application.js +4 -37
- package/dist/cli/bootstrap.js +2 -2
- package/dist/cli/install-guard.js +1 -1
- package/dist/client/context-usage.js +2 -3
- package/dist/client/enquiry.js +0 -6
- package/dist/client/model-choices.js +1 -1
- package/dist/client/permission.js +1 -2
- package/dist/client/reduce.js +1 -0
- package/dist/client/relative-time.js +1 -1
- package/dist/client/scope-kind.js +2 -3
- package/dist/client/search.js +1 -1
- package/dist/client/status.js +1 -1
- package/dist/client/subagent-tree.js +1 -1
- package/dist/client/tool-chains.js +1 -1
- package/dist/client/tool-summary.js +2 -3
- package/dist/daemon/config-store.js +2 -0
- package/dist/daemon/config.js +32 -1
- package/dist/daemon/git.js +33 -2
- package/dist/daemon/host.js +27 -8
- package/dist/daemon/pull-request.js +3 -10
- package/dist/daemon/repository.js +11 -0
- package/dist/daemon/runtime.js +1 -1
- package/dist/daemon/server.js +2 -2
- package/dist/daemon/stack.js +37 -3
- package/dist/daemon/workflow-schedule-driver.js +5 -1
- package/dist/protocol/stack.js +14 -1
- package/dist/workflows/schedules.js +1 -0
- package/package.json +1 -1
- package/web/dist/assets/index-Cf28Ke0f.js +51 -0
- package/web/dist/assets/index-DBl7acBx.css +2 -0
- package/web/dist/assets/{switch-B00FEUA7.js → select-C-BND5Jn.js} +1 -1
- package/web/dist/assets/{settings-mcp-3cgqQB28.js → settings-mcp-DEU2AgQP.js} +1 -1
- package/web/dist/assets/{settings-secrets-BIO_hXZ1.js → settings-secrets-29ZG3w6p.js} +1 -1
- package/web/dist/assets/{settings-workflows-Cutm8isB.js → settings-workflows-CS_5CtP9.js} +2 -2
- package/web/dist/assets/workflow-api-DkUjAZ4w.js +6 -0
- package/web/dist/assets/{workflows-D6oEUUhj.js → workflows-DOxarXng.js} +14 -14
- package/web/dist/assets/{workflows-pane-KIdSDKJB.js → workflows-pane-DlaP2y8m.js} +1 -1
- package/web/dist/index.html +5 -5
- package/dist/tui/app.js +0 -612
- package/dist/tui/keys.js +0 -90
- package/dist/tui/render.js +0 -417
- package/web/dist/assets/index-BhfJhrVJ.js +0 -51
- package/web/dist/assets/index-BvkM2cWL.css +0 -2
- package/web/dist/assets/workflow-api-BfExddae.js +0 -6
|
@@ -104,3 +104,14 @@ export async function resolvePullRequest(scope, repository, branch, github = gh)
|
|
|
104
104
|
unresolvedThreads: pr.reviewThreads.nodes.filter(thread => !thread.isResolved).length, updatedAt: pr.updatedAt,
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
+
export const writers = ["ADMIN", "MAINTAIN", "WRITE"];
|
|
108
|
+
export const mergeSettingsFields = "isArchived viewerPermission mergeCommitAllowed squashMergeAllowed rebaseMergeAllowed";
|
|
109
|
+
export function mergeMethods(repository) {
|
|
110
|
+
if (repository.isArchived || !writers.includes(repository.viewerPermission ?? ""))
|
|
111
|
+
return [];
|
|
112
|
+
return [
|
|
113
|
+
...(repository.mergeCommitAllowed ? ["MERGE"] : []),
|
|
114
|
+
...(repository.squashMergeAllowed ? ["SQUASH"] : []),
|
|
115
|
+
...(repository.rebaseMergeAllowed ? ["REBASE"] : []),
|
|
116
|
+
];
|
|
117
|
+
}
|
package/dist/daemon/runtime.js
CHANGED
|
@@ -49,7 +49,7 @@ export async function startRuntime(options) {
|
|
|
49
49
|
store, resolveSecret: name => secrets.resolve(name), retention: config.retention,
|
|
50
50
|
mcpConnections: config.mcpConnections, mcpAuth,
|
|
51
51
|
filesystemIsolationMode: config.filesystemIsolationMode, sandboxSupport: config.sandboxSupport,
|
|
52
|
-
sandboxSharing: config.sandboxSharing, projectRoot: config.projectRoot,
|
|
52
|
+
sandboxSharing: config.sandboxSharing, updateSourceBranch: config.updateSourceBranch, projectRoot: config.projectRoot,
|
|
53
53
|
standingAuthorisations: config.standingAuthorisations, allowTool: config.allowTool,
|
|
54
54
|
defaultBackend: config.defaultBackend, defaultModel: config.defaultModel,
|
|
55
55
|
defaultEffort: config.defaultEffort, defaultPermissionMode: config.defaultPermissionMode, autoCompaction: config.autoCompaction, compactionModel: config.compactionModel, summaryModel: config.summaryModel, tourModel: config.tourModel,
|
package/dist/daemon/server.js
CHANGED
|
@@ -959,7 +959,7 @@ function streamEvents(response, host, sessionId, since, oidc, browserSessionId)
|
|
|
959
959
|
detachAuth?.();
|
|
960
960
|
});
|
|
961
961
|
}
|
|
962
|
-
/** Bearer access is deliberately independent of OIDC so remote CLI
|
|
962
|
+
/** Bearer access is deliberately independent of OIDC so remote CLI clients keep working. */
|
|
963
963
|
async function authenticateRequest(request, options) {
|
|
964
964
|
if (tokenMatches(options.token, presentedBearer(request)))
|
|
965
965
|
return { kind: "bearer" };
|
|
@@ -1021,7 +1021,7 @@ a{display:inline-flex;align-items:center;justify-content:center;width:100%;heigh
|
|
|
1021
1021
|
response.end(html);
|
|
1022
1022
|
}
|
|
1023
1023
|
/**
|
|
1024
|
-
* Same-origin only. A request with no Origin header is a non-browser client (the
|
|
1024
|
+
* Same-origin only. A request with no Origin header is a non-browser client (the CLI, curl), which
|
|
1025
1025
|
* a hostile page cannot forge on the user's behalf, so it is not what this check defends against.
|
|
1026
1026
|
*/
|
|
1027
1027
|
function originAllowed(request, publicAppUrl) {
|
package/dist/daemon/stack.js
CHANGED
|
@@ -2,9 +2,10 @@ import { commonGitPath, localStack, localStacks } from "./stack-metadata.js";
|
|
|
2
2
|
import { access } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
|
-
import { localRepository, resolveRepository } from "./repository.js";
|
|
5
|
+
import { localRepository, mergeMethods, mergeSettingsFields, resolveRepository } from "./repository.js";
|
|
6
6
|
import { api, gh } from "./github.js";
|
|
7
7
|
import { head, localBranches, run, GIT_READ_TIMEOUT_MS, GIT_WRITE_TIMEOUT_MS } from "./git.js";
|
|
8
|
+
import { stackMergeBlock } from "../protocol/stack.js";
|
|
8
9
|
async function git(scope, args, write = false) {
|
|
9
10
|
const result = await run(scope, args, write ? GIT_WRITE_TIMEOUT_MS : GIT_READ_TIMEOUT_MS);
|
|
10
11
|
if (!result.ok)
|
|
@@ -67,7 +68,7 @@ export async function stackStatus(scope, github = gh) {
|
|
|
67
68
|
if (stacks.some(stack => stack.trunk.branch === branch))
|
|
68
69
|
return { ...status, notice: trunkNotice };
|
|
69
70
|
try {
|
|
70
|
-
return { ...status, view: parseStack(await runStack(scope, ["view", "--json"], github)) };
|
|
71
|
+
return { ...status, view: await withTracking(scope, parseStack(await runStack(scope, ["view", "--json"], github))) };
|
|
71
72
|
}
|
|
72
73
|
catch (error) {
|
|
73
74
|
if (!notInStack.test(String(error)))
|
|
@@ -79,6 +80,33 @@ export async function stackStatus(scope, github = gh) {
|
|
|
79
80
|
const stacked = new Set(stacks.flatMap(stack => stack.branches.map(member => member.branch)));
|
|
80
81
|
return { ...status, create: { current: branch, ...(trunk ? { trunk } : {}), branches: listed.value, unstacked: listed.value.filter(name => !stacked.has(name)) } };
|
|
81
82
|
}
|
|
83
|
+
async function withTracking(scope, view) {
|
|
84
|
+
const tracking = new Map((await git(scope, ["for-each-ref", "--format=%(refname:short)%00%(upstream)%00%(upstream:track,nobracket)", "refs/heads"])).split("\n").map(line => line.split("\0")).map(([name, upstream, track]) => [name, upstream ? track ?? "" : undefined]));
|
|
85
|
+
for (const branch of view.branches) {
|
|
86
|
+
const track = tracking.get(branch.name);
|
|
87
|
+
if (track === undefined || track === "gone")
|
|
88
|
+
continue;
|
|
89
|
+
branch.ahead = Number(/ahead (\d+)/.exec(track)?.[1] ?? 0);
|
|
90
|
+
branch.behind = Number(/behind (\d+)/.exec(track)?.[1] ?? 0);
|
|
91
|
+
}
|
|
92
|
+
return view;
|
|
93
|
+
}
|
|
94
|
+
export async function stackMergeMethods(scope, view, github = gh) {
|
|
95
|
+
const [owner, name] = (await resolveRepository(scope, view.currentBranch, github)).base.repo.split("/");
|
|
96
|
+
const { repository } = await api(scope, github, `query($owner:String!,$name:String!){repository(owner:$owner,name:$name){${mergeSettingsFields}}}`, { owner: owner, name: name });
|
|
97
|
+
return mergeMethods(repository);
|
|
98
|
+
}
|
|
99
|
+
const mergeFlags = { MERGE: "--merge", SQUASH: "--squash", REBASE: "--rebase" };
|
|
100
|
+
export async function mergeableStack(scope, github = gh) {
|
|
101
|
+
const { view, notice } = await stackStatus(scope, github);
|
|
102
|
+
if (!view)
|
|
103
|
+
throw new Error(notice ?? "This branch is not in a stack.");
|
|
104
|
+
await stackTitles(scope, view, github);
|
|
105
|
+
const block = stackMergeBlock(view);
|
|
106
|
+
if (block)
|
|
107
|
+
throw new Error(block);
|
|
108
|
+
return view;
|
|
109
|
+
}
|
|
82
110
|
const titles = new Map();
|
|
83
111
|
async function readTitles(scope, branch, numbers, github) {
|
|
84
112
|
const [owner, name] = (await resolveRepository(scope, branch, github)).base.repo.split("/");
|
|
@@ -171,7 +199,7 @@ async function validateInit(scope, trunk, branches, github) {
|
|
|
171
199
|
}
|
|
172
200
|
export async function changeStack(scope, input, github = gh) {
|
|
173
201
|
const { action } = input;
|
|
174
|
-
if (!["init", "add", "checkout", "rebase", "continue", "abort", "submit", "sync"].includes(action))
|
|
202
|
+
if (!["init", "add", "checkout", "rebase", "continue", "abort", "submit", "sync", "merge"].includes(action))
|
|
175
203
|
throw new Error("Unknown Stack action.");
|
|
176
204
|
if (action === "continue" || action === "abort") {
|
|
177
205
|
const state = await stackStatus(scope, github);
|
|
@@ -209,6 +237,12 @@ export async function changeStack(scope, input, github = gh) {
|
|
|
209
237
|
args.splice(0, 1, "rebase", `--${action}`);
|
|
210
238
|
if (action === "submit")
|
|
211
239
|
args.push("--auto");
|
|
240
|
+
if (action === "merge") {
|
|
241
|
+
if (!input.method || !Object.hasOwn(mergeFlags, input.method))
|
|
242
|
+
throw new Error("Invalid merge method.");
|
|
243
|
+
await mergeableStack(scope, github);
|
|
244
|
+
args.push("--yes", mergeFlags[input.method]);
|
|
245
|
+
}
|
|
212
246
|
return runStack(scope, args, github);
|
|
213
247
|
}
|
|
214
248
|
export const stackConflictMessage = "Resolve the current gh stack rebase conflicts in this Scope. Inspect the Stack rebase state and conflict files first. Preserve the intended changes and stage only resolved files. Run gh stack rebase --continue only after git diff --name-only --diff-filter=U is empty and all conflicts are resolved. Repeat for further conflicts; stop and report if the intended resolution is unclear. This request permits local conflict repair and Stack rebase continuation only. Do not push, submit, sync, merge, or restructure the stack. Report the result so I can review it before any separate Sync confirmation.";
|
|
@@ -7,7 +7,7 @@ import { ScheduledExecutionStarted } from './workflow-schedules.js';
|
|
|
7
7
|
import { resolveWorkflowCalls } from '../workflows/calls.js';
|
|
8
8
|
import { ScheduleValidationError } from '../workflows/schedule-errors.js';
|
|
9
9
|
import { includedProjects } from './projects.js';
|
|
10
|
-
import { isClean, localBranches, planWorktree, removeMergedBranch, removeWorktree, run, GIT_WRITE_TIMEOUT_MS } from './git.js';
|
|
10
|
+
import { isClean, localBranches, planWorktree, removeMergedBranch, removeWorktree, run, updateSourceBranch, GIT_WRITE_TIMEOUT_MS } from './git.js';
|
|
11
11
|
export function scheduleDriver(options) {
|
|
12
12
|
const { host, config, workflows, executions, schedules, transcripts } = options;
|
|
13
13
|
const repositories = new Map();
|
|
@@ -164,6 +164,10 @@ export function scheduleDriver(options) {
|
|
|
164
164
|
const provision = previous.catch(() => { }).then(async () => {
|
|
165
165
|
signal?.throwIfAborted();
|
|
166
166
|
const from = occurrence.settings.worktree.from;
|
|
167
|
+
if (config.updateSourceBranch() && !(await updateSourceBranch(repo, from)).ok) {
|
|
168
|
+
occurrence = { ...occurrence, warning: 'Source Branch not updated; cut from the local branch.' };
|
|
169
|
+
}
|
|
170
|
+
signal?.throwIfAborted();
|
|
167
171
|
const planned = await planWorktree({ repo, from, branch: `flow/schedule-${occurrence.id}`, under: transcripts.worktreesRoot() });
|
|
168
172
|
if (!planned.ok)
|
|
169
173
|
throw new Error('Could not plan worktree');
|
package/dist/protocol/stack.js
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export function stackMergeBlock(view) {
|
|
2
|
+
const open = view.branches.filter(branch => !branch.isMerged);
|
|
3
|
+
if (!open.length)
|
|
4
|
+
return "All pull requests of this stack are merged.";
|
|
5
|
+
for (const { name, pr } of open) {
|
|
6
|
+
if (!pr)
|
|
7
|
+
return `${name} has no pull request. Submit the stack first.`;
|
|
8
|
+
if (pr.state !== "OPEN")
|
|
9
|
+
return `#${pr.number} is ${pr.state.toLowerCase()}.`;
|
|
10
|
+
if (pr.isDraft)
|
|
11
|
+
return `#${pr.number} is a draft. Mark it ready for review first.`;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
@@ -44,6 +44,7 @@ export const occurrenceValidator = z.object({
|
|
|
44
44
|
createdAt: timestamp, finishedAt: timestamp.optional(), sessionId: storageId.optional(), association: z.enum(['pending', 'attached', 'failed']).optional(), executionId: storageId.optional(),
|
|
45
45
|
scope: z.string().min(1).optional(), worktree: z.object({ path: z.string(), repo: z.string(), branch: z.string() }).strict().optional(),
|
|
46
46
|
outcome: z.string().max(2000).optional(),
|
|
47
|
+
warning: z.string().max(2000).optional(),
|
|
47
48
|
}).strict().superRefine((value, context) => {
|
|
48
49
|
if (value.id !== occurrenceId(value.scheduleId, value.activation, value.scheduledAt))
|
|
49
50
|
context.addIssue({ code: 'custom', message: 'Invalid occurrence identity' });
|