@saadnvd1/agent-os 0.3.605 → 0.3.608
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/app/api/busy/route.ts +2 -1
- package/app/api/updates/route.test.ts +3 -1
- package/components/Chat/ContextMeter.tsx +2 -2
- package/components/PrStageBadge.tsx +4 -4
- package/components/SessionList/LiveLine.tsx +0 -4
- package/components/Stacks/StatusChip.tsx +9 -33
- package/components/Stacks/status-chip.test.ts +40 -0
- package/components/Stacks/status-chip.ts +44 -0
- package/lib/busy.ts +9 -3
- package/lib/env-setup.ts +27 -12
- package/lib/project-config/agentos.schema.json +14 -0
- package/lib/project-config/schema.ts +10 -0
- package/lib/recipes/status-labels.ts +2 -2
- package/lib/resurrect/index.ts +2 -1
- package/lib/sidebar/live-status.ts +7 -14
- package/lib/simulator/index.ts +6 -1
- package/lib/tasks/brief.ts +16 -1
- package/lib/tasks/import.ts +6 -2
- package/lib/tasks/index.ts +2 -1
- package/lib/tasks/move.ts +2 -1
- package/lib/worktree-deps/caches.ts +250 -0
- package/lib/worktree-deps/clone.ts +94 -9
- package/lib/worktree-deps/fastcopy.ts +89 -0
- package/lib/worktree-deps/index.ts +14 -5
- package/lib/worktree-deps/paths.ts +20 -0
- package/lib/worktree-deps/spare.ts +26 -8
- package/package.json +1 -1
- package/scripts/autodeploy +28 -0
- package/scripts/autodeploy.test.ts +106 -0
- package/scripts/bench/worktree-setup.ts +101 -0
- package/scripts/wait-quiet +1 -1
package/app/api/busy/route.ts
CHANGED
|
@@ -8,5 +8,6 @@ export async function GET(request: NextRequest) {
|
|
|
8
8
|
const refused = requireLocalTrust(request);
|
|
9
9
|
if (refused) return refused;
|
|
10
10
|
const work = inFlight();
|
|
11
|
-
|
|
11
|
+
const busy = work.reviews + work.setups + work.simulatorStarts > 0;
|
|
12
|
+
return NextResponse.json({ ...work, busy });
|
|
12
13
|
}
|
|
@@ -15,7 +15,9 @@ vi.mock("@/lib/updates/check", async (orig) => ({
|
|
|
15
15
|
cachedCheck: () => check,
|
|
16
16
|
checkForUpdate: async () => ({ result: refreshed ?? check, throttled }),
|
|
17
17
|
}));
|
|
18
|
-
vi.mock("@/lib/busy", () => ({
|
|
18
|
+
vi.mock("@/lib/busy", () => ({
|
|
19
|
+
inFlight: () => ({ reviews: 0, setups: 0, simulatorStarts: 0 }),
|
|
20
|
+
}));
|
|
19
21
|
vi.mock("@/lib/status/collect", () => ({
|
|
20
22
|
collectStatuses: async () => ({
|
|
21
23
|
statuses: {
|
|
@@ -13,7 +13,7 @@ import { cn } from "@/lib/utils";
|
|
|
13
13
|
import { chatMeta, chatMetaActions } from "@/stores/chatMeta";
|
|
14
14
|
|
|
15
15
|
const LEVEL_COLOR = {
|
|
16
|
-
ok: "text-
|
|
16
|
+
ok: "text-foreground/40",
|
|
17
17
|
warn: "text-amber-500",
|
|
18
18
|
high: "text-destructive",
|
|
19
19
|
} as const;
|
|
@@ -94,7 +94,7 @@ export function ContextMeter({
|
|
|
94
94
|
className={cn(
|
|
95
95
|
"h-full rounded-full",
|
|
96
96
|
level === "ok"
|
|
97
|
-
? "bg-
|
|
97
|
+
? "bg-foreground/40"
|
|
98
98
|
: level === "warn"
|
|
99
99
|
? "bg-amber-500"
|
|
100
100
|
: "bg-destructive"
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
import { cn } from "@/lib/utils";
|
|
14
14
|
|
|
15
15
|
const TONE: Record<PrStageName, string> = {
|
|
16
|
-
merged: "bg-
|
|
16
|
+
merged: "bg-green-500/15 text-green-700 dark:text-green-400",
|
|
17
17
|
conflicts: "bg-amber-500/15 text-amber-700 dark:text-amber-400",
|
|
18
18
|
"ci-failed": "bg-red-500/15 text-red-700 dark:text-red-400",
|
|
19
|
-
"ci-running": "bg-
|
|
20
|
-
"ci-settling": "bg-
|
|
21
|
-
"review-running": "bg-
|
|
19
|
+
"ci-running": "bg-foreground/[0.06] text-muted-foreground",
|
|
20
|
+
"ci-settling": "bg-foreground/[0.06] text-muted-foreground",
|
|
21
|
+
"review-running": "bg-foreground/[0.06] text-muted-foreground",
|
|
22
22
|
"review-blocked": "bg-red-500/15 text-red-700 dark:text-red-400",
|
|
23
23
|
waiting: "bg-amber-500/15 text-amber-700 dark:text-amber-400",
|
|
24
24
|
armed: "bg-green-500/15 text-green-700 dark:text-green-400",
|
|
@@ -15,21 +15,17 @@ export interface LiveInput {
|
|
|
15
15
|
|
|
16
16
|
// A status badge's pill; the failed need is red text alone.
|
|
17
17
|
const PILL: Record<LiveTone, string> = {
|
|
18
|
-
blue: "bg-blue-500/15",
|
|
19
18
|
amber: "bg-amber-500/15",
|
|
20
19
|
red: "bg-red-500/15",
|
|
21
20
|
green: "bg-green-500/15",
|
|
22
|
-
purple: "bg-purple-500/15",
|
|
23
21
|
primary: "bg-primary/15",
|
|
24
22
|
muted: "bg-muted",
|
|
25
23
|
};
|
|
26
24
|
|
|
27
25
|
const TONE: Record<LiveTone, string> = {
|
|
28
|
-
blue: "text-blue-700 dark:text-blue-400",
|
|
29
26
|
amber: "text-amber-700 dark:text-amber-400",
|
|
30
27
|
red: "text-red-700 dark:text-red-400",
|
|
31
28
|
green: "text-green-700 dark:text-green-400",
|
|
32
|
-
purple: "text-purple-700 dark:text-purple-400",
|
|
33
29
|
primary: "text-primary",
|
|
34
30
|
muted: "text-muted-foreground",
|
|
35
31
|
};
|
|
@@ -1,52 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GitPullRequest, Loader2 } from "lucide-react";
|
|
2
2
|
import { cn } from "@/lib/utils";
|
|
3
|
-
|
|
4
|
-
type Status = StackItemView["status"] | StackStatus;
|
|
5
|
-
|
|
6
|
-
const amber = "bg-amber-500/15 text-amber-700 dark:text-amber-300";
|
|
7
|
-
const green = "bg-emerald-500/15 text-emerald-700 dark:text-emerald-300";
|
|
8
|
-
const muted = "bg-foreground/[0.06] text-muted-foreground";
|
|
9
|
-
const purple = "bg-primary/15 text-primary";
|
|
10
|
-
const red = "bg-destructive/15 text-destructive";
|
|
11
|
-
|
|
12
|
-
const CHIP: Record<Status, { label: string; tone: string }> = {
|
|
13
|
-
planned: { label: "Planned", tone: muted },
|
|
14
|
-
held: { label: "Held", tone: amber },
|
|
15
|
-
starting: { label: "Starting", tone: purple },
|
|
16
|
-
running: { label: "Working", tone: purple },
|
|
17
|
-
pr: { label: "PR open", tone: purple },
|
|
18
|
-
merged: { label: "Merged", tone: green },
|
|
19
|
-
failed: { label: "Failed", tone: red },
|
|
20
|
-
dropped: { label: "Dropped", tone: muted },
|
|
21
|
-
done: { label: "Done", tone: green },
|
|
22
|
-
excluded: { label: "Left out", tone: muted },
|
|
23
|
-
paused: { label: "Paused", tone: amber },
|
|
24
|
-
landing: { label: "Landing", tone: purple },
|
|
25
|
-
landed: { label: "Landed", tone: green },
|
|
26
|
-
};
|
|
3
|
+
import { chipFor, type ChipStatus } from "./status-chip";
|
|
27
4
|
|
|
28
5
|
export function StatusChip({
|
|
29
6
|
status,
|
|
30
7
|
attention,
|
|
31
8
|
stack,
|
|
32
9
|
}: {
|
|
33
|
-
status:
|
|
10
|
+
status: ChipStatus;
|
|
34
11
|
attention?: boolean;
|
|
35
|
-
// A whole stack: "running" reads as Running, not Working.
|
|
36
12
|
stack?: boolean;
|
|
37
13
|
}) {
|
|
38
|
-
const chip = attention
|
|
39
|
-
? { label: "Needs you", tone: amber }
|
|
40
|
-
: stack && status === "running"
|
|
41
|
-
? { label: "Running", tone: purple }
|
|
42
|
-
: CHIP[status];
|
|
14
|
+
const chip = chipFor(status, { attention, stack });
|
|
43
15
|
return (
|
|
44
16
|
<span
|
|
45
17
|
className={cn(
|
|
46
|
-
"inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[11px] font-medium",
|
|
18
|
+
"inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium",
|
|
47
19
|
chip.tone
|
|
48
20
|
)}
|
|
49
21
|
>
|
|
22
|
+
{chip.icon === "spinner" && (
|
|
23
|
+
<Loader2 className="h-3 w-3 animate-spin" aria-hidden />
|
|
24
|
+
)}
|
|
25
|
+
{chip.icon === "pr" && <GitPullRequest className="h-3 w-3" aria-hidden />}
|
|
50
26
|
{chip.label}
|
|
51
27
|
</span>
|
|
52
28
|
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { CHIP, chipFor, type ChipStatus } from "./status-chip";
|
|
3
|
+
|
|
4
|
+
const coloured = (tone: string) => /amber|emerald|destructive/.test(tone);
|
|
5
|
+
|
|
6
|
+
describe("status chip colour", () => {
|
|
7
|
+
it.each(["starting", "running", "pr", "landing"] as ChipStatus[])(
|
|
8
|
+
"%s is neutral with an icon",
|
|
9
|
+
(s) => {
|
|
10
|
+
expect(coloured(CHIP[s].tone)).toBe(false);
|
|
11
|
+
expect(CHIP[s].tone).not.toContain("primary");
|
|
12
|
+
expect(CHIP[s].icon).not.toBeNull();
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
it.each(["merged", "done", "landed"] as ChipStatus[])("%s is green", (s) =>
|
|
17
|
+
expect(CHIP[s].tone).toContain("emerald")
|
|
18
|
+
);
|
|
19
|
+
it("failed is red", () => expect(CHIP.failed.tone).toContain("destructive"));
|
|
20
|
+
it.each(["held", "paused"] as ChipStatus[])("%s is amber", (s) =>
|
|
21
|
+
expect(CHIP[s].tone).toContain("amber")
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
it("needs-you overrides status with amber", () => {
|
|
25
|
+
const c = chipFor("running", { attention: true });
|
|
26
|
+
expect(c.label).toBe("Needs you");
|
|
27
|
+
expect(c.tone).toContain("amber");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("a running stack reads Running, neutral", () => {
|
|
31
|
+
const c = chipFor("running", { stack: true });
|
|
32
|
+
expect(c.label).toBe("Running");
|
|
33
|
+
expect(coloured(c.tone)).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("no status uses the accent", () => {
|
|
37
|
+
for (const c of Object.values(CHIP))
|
|
38
|
+
expect(c.tone).not.toContain("primary");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { StackItemView, StackStatus } from "@/lib/stacks/types";
|
|
2
|
+
|
|
3
|
+
export type ChipStatus = StackItemView["status"] | StackStatus;
|
|
4
|
+
export type ChipIcon = "spinner" | "pr" | null;
|
|
5
|
+
|
|
6
|
+
// Colour means "look at this": amber needs you, red failed, green final.
|
|
7
|
+
// Everything still moving on its own is neutral, and an icon carries the meaning.
|
|
8
|
+
const amber = "bg-amber-500/15 text-amber-700 dark:text-amber-300";
|
|
9
|
+
const green = "bg-emerald-500/15 text-emerald-700 dark:text-emerald-300";
|
|
10
|
+
const muted = "bg-foreground/[0.06] text-muted-foreground";
|
|
11
|
+
const red = "bg-destructive/15 text-destructive";
|
|
12
|
+
|
|
13
|
+
interface Chip {
|
|
14
|
+
label: string;
|
|
15
|
+
tone: string;
|
|
16
|
+
icon: ChipIcon;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const CHIP: Record<ChipStatus, Chip> = {
|
|
20
|
+
planned: { label: "Planned", tone: muted, icon: null },
|
|
21
|
+
held: { label: "Held", tone: amber, icon: null },
|
|
22
|
+
starting: { label: "Starting", tone: muted, icon: "spinner" },
|
|
23
|
+
running: { label: "Working", tone: muted, icon: "spinner" },
|
|
24
|
+
pr: { label: "PR open", tone: muted, icon: "pr" },
|
|
25
|
+
merged: { label: "Merged", tone: green, icon: null },
|
|
26
|
+
failed: { label: "Failed", tone: red, icon: null },
|
|
27
|
+
dropped: { label: "Dropped", tone: muted, icon: null },
|
|
28
|
+
done: { label: "Done", tone: green, icon: null },
|
|
29
|
+
excluded: { label: "Left out", tone: muted, icon: null },
|
|
30
|
+
paused: { label: "Paused", tone: amber, icon: null },
|
|
31
|
+
landing: { label: "Landing", tone: muted, icon: "spinner" },
|
|
32
|
+
landed: { label: "Landed", tone: green, icon: null },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function chipFor(
|
|
36
|
+
status: ChipStatus,
|
|
37
|
+
opts: { attention?: boolean; stack?: boolean } = {}
|
|
38
|
+
): Chip {
|
|
39
|
+
if (opts.attention) return { label: "Needs you", tone: amber, icon: null };
|
|
40
|
+
// A whole stack: "running" reads as Running, not Working.
|
|
41
|
+
if (opts.stack && status === "running")
|
|
42
|
+
return { label: "Running", tone: muted, icon: "spinner" };
|
|
43
|
+
return CHIP[status];
|
|
44
|
+
}
|
package/lib/busy.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { db } from "./db";
|
|
2
|
+
import { runningStarts } from "./simulator";
|
|
2
3
|
|
|
3
|
-
// What a restart would cut off and have to start over: reviews
|
|
4
|
-
// setups run in the server. (Chat turns run in their own workers and
|
|
4
|
+
// What a restart would cut off and have to start over: reviews, task
|
|
5
|
+
// setups and simulator starts run in the server. (Chat turns run in their own workers and
|
|
5
6
|
// outlive it.) Older than half an hour is stuck, not in flight.
|
|
6
|
-
export function inFlight(): {
|
|
7
|
+
export function inFlight(): {
|
|
8
|
+
reviews: number;
|
|
9
|
+
setups: number;
|
|
10
|
+
simulatorStarts: number;
|
|
11
|
+
} {
|
|
7
12
|
const count = (sql: string) => (db.prepare(sql).get() as { n: number }).n;
|
|
8
13
|
return {
|
|
9
14
|
reviews: count(
|
|
@@ -16,5 +21,6 @@ export function inFlight(): { reviews: number; setups: number } {
|
|
|
16
21
|
WHERE setup_status = 'running' AND archived_at IS NULL
|
|
17
22
|
AND created_at > datetime('now', '-30 minutes')`
|
|
18
23
|
),
|
|
24
|
+
simulatorStarts: runningStarts(),
|
|
19
25
|
};
|
|
20
26
|
}
|
package/lib/env-setup.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import * as fs from "fs";
|
|
10
10
|
import * as path from "path";
|
|
11
11
|
import { bringDependencies, runCommand } from "./worktree-deps";
|
|
12
|
+
import { inside, realExisting } from "./worktree-deps/paths";
|
|
13
|
+
import { seedBuildCaches } from "./worktree-deps/caches";
|
|
12
14
|
import { loadProjectConfig, projectEnv, withPorts } from "./project-config";
|
|
13
15
|
import { recordPlaced } from "./worktree-placed";
|
|
14
16
|
import { databaseEnv, ensureSessionDatabase } from "./project-config/database";
|
|
@@ -79,18 +81,6 @@ export async function copyEnvFiles(
|
|
|
79
81
|
return copied;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
const inside = (root: string, p: string) =>
|
|
83
|
-
p === root || p.startsWith(root + path.sep);
|
|
84
|
-
|
|
85
|
-
// The real path of `p`'s deepest part that exists.
|
|
86
|
-
async function realExisting(p: string): Promise<string> {
|
|
87
|
-
for (let at = p; ; at = path.dirname(at)) {
|
|
88
|
-
const real = await fs.promises.realpath(at).catch(() => null);
|
|
89
|
-
if (real) return real;
|
|
90
|
-
if (path.dirname(at) === at) return at;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
84
|
/**
|
|
95
85
|
* agentos.json's `copy`: files or folders from the main checkout, each one
|
|
96
86
|
* resolved (symlinks included) to a place inside it, so a project can't
|
|
@@ -272,6 +262,31 @@ export async function setupWorktree(options: {
|
|
|
272
262
|
);
|
|
273
263
|
}
|
|
274
264
|
|
|
265
|
+
// Build caches, so the first typecheck, test or build is warm. An
|
|
266
|
+
// optimisation: it never fails a setup.
|
|
267
|
+
if (config.caches?.length !== 0 && sourcePath !== worktreePath) {
|
|
268
|
+
progress?.onStage?.("deps");
|
|
269
|
+
try {
|
|
270
|
+
const seeded = await seedBuildCaches({
|
|
271
|
+
sourcePath,
|
|
272
|
+
worktreePath,
|
|
273
|
+
paths: config.caches,
|
|
274
|
+
});
|
|
275
|
+
if (seeded.seeded.length || seeded.skipped.length)
|
|
276
|
+
result.steps.push({
|
|
277
|
+
name: "Seed build caches",
|
|
278
|
+
command: "cp (build caches)",
|
|
279
|
+
success: true,
|
|
280
|
+
output: [
|
|
281
|
+
...seeded.seeded.map((c) => `${c.rel} (${c.how})`),
|
|
282
|
+
...seeded.skipped.map((c) => `skipped ${c.rel}: ${c.why}`),
|
|
283
|
+
].join("\n"),
|
|
284
|
+
});
|
|
285
|
+
} catch (error) {
|
|
286
|
+
console.error("Seeding build caches failed:", error);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
275
290
|
// 4. The config's setup commands
|
|
276
291
|
if (config.setup && config.setup.length > 0) {
|
|
277
292
|
progress?.onStage?.("script");
|
|
@@ -48,6 +48,20 @@
|
|
|
48
48
|
"pattern": "^(?![/~\\\\])(?!(.*[/\\\\])?\\.\\.([/\\\\]|$)).+$"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
+
"caches": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"items": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"allOf": [
|
|
56
|
+
{
|
|
57
|
+
"pattern": "^(?![/~\\\\])(?!(.*[/\\\\])?\\.\\.([/\\\\]|$)).+$"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"pattern": "^([^*]*[/\\\\])?[^*/\\\\]*\\*?[^*/\\\\]*$"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
51
65
|
"dev": {
|
|
52
66
|
"type": "string",
|
|
53
67
|
"minLength": 1
|
|
@@ -28,6 +28,15 @@ const projectPath = z
|
|
|
28
28
|
"must be a path inside the project (relative, no '..')"
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
+
// Build caches to seed into a worktree: a path inside the project, with `*`
|
|
32
|
+
// allowed in the last segment (`*.tsbuildinfo`), never `.git`.
|
|
33
|
+
const cachePath = projectPath
|
|
34
|
+
.regex(
|
|
35
|
+
/^([^*]*[/\\])?[^*/\\]*\*?[^*/\\]*$/,
|
|
36
|
+
"`*` is allowed in the last segment only"
|
|
37
|
+
)
|
|
38
|
+
.refine((p) => !/(^|[/\\])\.git([/\\]|$)/.test(p), "not .git");
|
|
39
|
+
|
|
31
40
|
const port = z.number().int().min(1024).max(65000);
|
|
32
41
|
const notes = z.union([z.string(), z.array(z.string())]);
|
|
33
42
|
|
|
@@ -120,6 +129,7 @@ const shape = {
|
|
|
120
129
|
setup: z.array(z.string().min(1)).optional(),
|
|
121
130
|
copy: z.array(projectPath).optional(),
|
|
122
131
|
clone: z.array(projectPath).optional(),
|
|
132
|
+
caches: z.array(cachePath).optional(),
|
|
123
133
|
dev: z.string().min(1).optional(),
|
|
124
134
|
ready: ready.optional(),
|
|
125
135
|
deploy: deploy.optional(),
|
|
@@ -8,8 +8,8 @@ export const RUN_STATUS_LABELS: Record<
|
|
|
8
8
|
{ label: string; tone: Tone }
|
|
9
9
|
> = {
|
|
10
10
|
queued: { label: "Queued", tone: "muted" },
|
|
11
|
-
starting: { label: "Starting", tone: "
|
|
12
|
-
running: { label: "Running", tone: "
|
|
11
|
+
starting: { label: "Starting", tone: "muted" },
|
|
12
|
+
running: { label: "Running", tone: "muted" },
|
|
13
13
|
succeeded: { label: "Succeeded", tone: "success" },
|
|
14
14
|
failed: { label: "Failed", tone: "destructive" },
|
|
15
15
|
blocked: { label: "Needs you", tone: "warning" },
|
package/lib/resurrect/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
transcriptPath,
|
|
30
30
|
writeTranscript,
|
|
31
31
|
} from "../tasks/transcript";
|
|
32
|
-
import { buildTaskBrief } from "../tasks/brief";
|
|
32
|
+
import { buildTaskBrief, declaredTest } from "../tasks/brief";
|
|
33
33
|
import { syncTaskCardInBackground } from "../lumifyhub/task-cards";
|
|
34
34
|
import { allocatePorts } from "../ports";
|
|
35
35
|
import { loadProjectConfig, portBases } from "../project-config";
|
|
@@ -416,6 +416,7 @@ async function relaunch(s: Session, cwd: string): Promise<void> {
|
|
|
416
416
|
? buildTaskBrief({
|
|
417
417
|
branch: s.branch_name,
|
|
418
418
|
baseBranch: s.base_branch ?? "main",
|
|
419
|
+
test: declaredTest(cwd),
|
|
419
420
|
})
|
|
420
421
|
: undefined,
|
|
421
422
|
});
|
|
@@ -6,14 +6,7 @@ import {
|
|
|
6
6
|
} from "../tasks/pr-stage";
|
|
7
7
|
import type { StatusBadge } from "./row-badge";
|
|
8
8
|
|
|
9
|
-
export type LiveTone =
|
|
10
|
-
| "blue"
|
|
11
|
-
| "amber"
|
|
12
|
-
| "red"
|
|
13
|
-
| "green"
|
|
14
|
-
| "purple"
|
|
15
|
-
| "primary"
|
|
16
|
-
| "muted";
|
|
9
|
+
export type LiveTone = "amber" | "red" | "green" | "primary" | "muted";
|
|
17
10
|
|
|
18
11
|
export interface LivePart {
|
|
19
12
|
text: string;
|
|
@@ -31,17 +24,17 @@ export const BADGE_TONE: Record<StatusBadge["kind"], LiveTone> = {
|
|
|
31
24
|
failed: "red",
|
|
32
25
|
stalled: "amber",
|
|
33
26
|
starting: "muted",
|
|
34
|
-
planning: "
|
|
27
|
+
planning: "muted",
|
|
35
28
|
"plan-ready": "primary",
|
|
36
29
|
};
|
|
37
30
|
|
|
38
31
|
export const PR_STAGE_TONE: Record<PrStageName, LiveTone> = {
|
|
39
|
-
merged: "
|
|
32
|
+
merged: "green",
|
|
40
33
|
conflicts: "amber",
|
|
41
34
|
"ci-failed": "red",
|
|
42
|
-
"ci-running": "
|
|
43
|
-
"ci-settling": "
|
|
44
|
-
"review-running": "
|
|
35
|
+
"ci-running": "muted",
|
|
36
|
+
"ci-settling": "muted",
|
|
37
|
+
"review-running": "muted",
|
|
45
38
|
"review-blocked": "red",
|
|
46
39
|
waiting: "amber",
|
|
47
40
|
armed: "green",
|
|
@@ -58,7 +51,7 @@ export function liveParts(input: {
|
|
|
58
51
|
}): LivePart[] {
|
|
59
52
|
const parts: LivePart[] = [];
|
|
60
53
|
if (input.compacting)
|
|
61
|
-
parts.push({ text: "Compacting", tone: "
|
|
54
|
+
parts.push({ text: "Compacting", tone: "muted", busy: true });
|
|
62
55
|
const b = input.badge;
|
|
63
56
|
if (b)
|
|
64
57
|
parts.push({
|
package/lib/simulator/index.ts
CHANGED
|
@@ -144,6 +144,11 @@ const tail = (file: string, lines = 15) => {
|
|
|
144
144
|
// simulator can stop it.
|
|
145
145
|
const starts = new Map<string, ChildProcess>();
|
|
146
146
|
|
|
147
|
+
// Simulator starts running now, for lib/busy: a restart kills them.
|
|
148
|
+
export function runningStarts(): number {
|
|
149
|
+
return starts.size;
|
|
150
|
+
}
|
|
151
|
+
|
|
147
152
|
// The whole group: the project's build and Metro are children of the shell.
|
|
148
153
|
export function killGroup(child: ChildProcess, signal: NodeJS.Signals) {
|
|
149
154
|
try {
|
|
@@ -153,7 +158,7 @@ export function killGroup(child: ChildProcess, signal: NodeJS.Signals) {
|
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
|
|
156
|
-
function runStart(
|
|
161
|
+
export function runStart(
|
|
157
162
|
sessionId: string,
|
|
158
163
|
command: string,
|
|
159
164
|
cwd: string,
|
package/lib/tasks/brief.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { loadProjectConfig } from "../project-config";
|
|
2
|
+
|
|
1
3
|
// A task stacked on another task's unmerged branch.
|
|
2
4
|
export interface StackedOn {
|
|
3
5
|
// The parent's PR number, when it has one.
|
|
@@ -19,17 +21,30 @@ function stackedLines(baseBranch: string, stack: StackedOn): string {
|
|
|
19
21
|
- Never merge or rebase onto the default branch yourself. When the parent merges, AgentOS rebases your branch and retargets your PR, then tells you; re-run your checks when it does. AgentOS reviews your PR itself; a review of your head still counts for the head its restack left, and a push after that gets a new one.${also}`;
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
// The project's declared test command, read from the checkout the task runs in.
|
|
25
|
+
export function declaredTest(cwd: string): string | undefined {
|
|
26
|
+
return loadProjectConfig(cwd).config.test || undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function checksLine(test?: string): string {
|
|
30
|
+
return test
|
|
31
|
+
? `Run exactly this to check your work: \`${test}\`. CI runs the full suite on your pull request, so don't run it locally.`
|
|
32
|
+
: "Run the project's own checks (typecheck, tests, lint) when they exist and keep them passing.";
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
// The system brief every task agent runs under. It finishes by opening a PR
|
|
23
36
|
// and stopping: merging is the human's sign-off, never the agent's.
|
|
24
37
|
export function buildTaskBrief(opts: {
|
|
25
38
|
branch: string;
|
|
26
39
|
baseBranch: string;
|
|
27
40
|
stack?: StackedOn;
|
|
41
|
+
// The project's `test` from agentos.json, when it declares one.
|
|
42
|
+
test?: string;
|
|
28
43
|
}): string {
|
|
29
44
|
return `You are running as an AgentOS background task, alone, in an isolated git worktree.
|
|
30
45
|
|
|
31
46
|
- Branch: ${opts.branch} (based on ${opts.baseBranch}). Stay in this directory and on this branch.
|
|
32
|
-
- Do the task fully.
|
|
47
|
+
- Do the task fully. ${checksLine(opts.test)}
|
|
33
48
|
- When the work is done, commit with a conventional commit message, run \`git push -u origin ${opts.branch}\` and open a pull request against ${opts.baseBranch} with \`gh pr create\`, using a clear title and a short body that says what changed and how you verified it. Then stop and wait.
|
|
34
49
|
- You don't need to review it yourself: AgentOS runs an independent review of the PR's exact head commit before it can merge, and the orchestrator sends you any blocking findings to fix. For a risky change you may still run \`/do-code-review\` (or \`/code-review\`) before the PR.
|
|
35
50
|
- Never merge the pull request, never push to ${opts.baseBranch}, and never delete branches or worktrees. A human reviews and merges.${opts.stack ? stackedLines(opts.baseBranch, opts.stack) : ""}
|
package/lib/tasks/import.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { resolveModelForAgent } from "../model-catalog";
|
|
|
23
23
|
import { providerFor } from "../models/resolve";
|
|
24
24
|
import { preparePlanDir, PLAN_FILE } from "../models/plan-step";
|
|
25
25
|
import { carryTaskState } from "./move-carry";
|
|
26
|
-
import { buildTaskBrief } from "./brief";
|
|
26
|
+
import { buildTaskBrief, declaredTest } from "./brief";
|
|
27
27
|
import { expandHome } from "./session";
|
|
28
28
|
import { ensureProject } from "./project-ref";
|
|
29
29
|
import { checkoutBranchWorktree } from "./branch-worktree";
|
|
@@ -136,7 +136,11 @@ async function arrive(
|
|
|
136
136
|
? bundle.model
|
|
137
137
|
: resolveModelForAgent("claude", bundle.model || project.default_model);
|
|
138
138
|
const baseBranch = bundle.baseBranch ?? "main";
|
|
139
|
-
const brief = buildTaskBrief({
|
|
139
|
+
const brief = buildTaskBrief({
|
|
140
|
+
branch: bundle.branch,
|
|
141
|
+
baseBranch,
|
|
142
|
+
test: declaredTest(worktreePath),
|
|
143
|
+
});
|
|
140
144
|
// Checked and written with no await between, so two can't both pass.
|
|
141
145
|
db.transaction(() => {
|
|
142
146
|
refuseBusyBranch(project.id, bundle.branch);
|
package/lib/tasks/index.ts
CHANGED
|
@@ -33,7 +33,7 @@ import { agentLabel } from "../agent-options";
|
|
|
33
33
|
import { supportsChat } from "../chat/capabilities";
|
|
34
34
|
import { AGENT_DEFAULT_MODEL } from "../providers/registry";
|
|
35
35
|
import { statusDetector } from "../status-detector";
|
|
36
|
-
import { buildTaskBrief, type StackedOn } from "./brief";
|
|
36
|
+
import { buildTaskBrief, declaredTest, type StackedOn } from "./brief";
|
|
37
37
|
import {
|
|
38
38
|
attachTaskCard,
|
|
39
39
|
inBackground,
|
|
@@ -354,6 +354,7 @@ async function startTask(
|
|
|
354
354
|
branch: wt.branchName,
|
|
355
355
|
baseBranch,
|
|
356
356
|
stack: opts.base?.stack,
|
|
357
|
+
test: declaredTest(wt.worktreePath),
|
|
357
358
|
}),
|
|
358
359
|
naming.source,
|
|
359
360
|
view,
|
package/lib/tasks/move.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { db, type Session } from "../db";
|
|
|
13
13
|
import { getProject } from "../projects";
|
|
14
14
|
import { endTmuxSession } from "../tmux/end";
|
|
15
15
|
import { launchClaude } from "../agents/launch";
|
|
16
|
-
import { buildTaskBrief } from "./brief";
|
|
16
|
+
import { buildTaskBrief, declaredTest } from "./brief";
|
|
17
17
|
import { git as runGit } from "../git-exec";
|
|
18
18
|
import { getTaskSession, isoUTC } from "./session";
|
|
19
19
|
import { projectRef } from "./project-ref";
|
|
@@ -308,6 +308,7 @@ async function relaunch(session: Session, note?: string): Promise<void> {
|
|
|
308
308
|
? buildTaskBrief({
|
|
309
309
|
branch: session.branch_name,
|
|
310
310
|
baseBranch: session.base_branch ?? "main",
|
|
311
|
+
test: declaredTest(session.working_directory),
|
|
311
312
|
})
|
|
312
313
|
: undefined,
|
|
313
314
|
});
|