teamroom 0.1.1 → 0.2.1
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 +149 -70
- package/dist/cli/index.js +202 -106
- package/dist/cli/index.js.map +1 -1
- package/dist/client/agents-md.d.ts +14 -0
- package/dist/client/agents-md.js +53 -0
- package/dist/client/agents-md.js.map +1 -0
- package/dist/client/api-client.d.ts +4 -0
- package/dist/client/backend.d.ts +60 -0
- package/dist/client/backend.js +103 -0
- package/dist/client/backend.js.map +1 -0
- package/dist/client/claude-events.d.ts +18 -0
- package/dist/client/claude-events.js +172 -0
- package/dist/client/claude-events.js.map +1 -0
- package/dist/client/claude-hook.d.ts +19 -12
- package/dist/client/claude-hook.js +90 -48
- package/dist/client/claude-hook.js.map +1 -1
- package/dist/client/config.d.ts +13 -4
- package/dist/client/config.js +25 -6
- package/dist/client/config.js.map +1 -1
- package/dist/client/doctor.js +60 -7
- package/dist/client/doctor.js.map +1 -1
- package/dist/client/git.d.ts +0 -2
- package/dist/client/git.js +2 -6
- package/dist/client/git.js.map +1 -1
- package/dist/client/ignore.d.ts +12 -0
- package/dist/client/ignore.js +96 -0
- package/dist/client/ignore.js.map +1 -0
- package/dist/client/invite-link.d.ts +3 -1
- package/dist/client/invite-link.js +19 -4
- package/dist/client/invite-link.js.map +1 -1
- package/dist/client/mcp-config.d.ts +39 -6
- package/dist/client/mcp-config.js +81 -26
- package/dist/client/mcp-config.js.map +1 -1
- package/dist/client/workspace.d.ts +34 -7
- package/dist/client/workspace.js +81 -39
- package/dist/client/workspace.js.map +1 -1
- package/dist/core/agents.d.ts +6 -0
- package/dist/core/agents.js +7 -0
- package/dist/core/agents.js.map +1 -1
- package/dist/core/overlap.d.ts +12 -3
- package/dist/core/overlap.js +51 -8
- package/dist/core/overlap.js.map +1 -1
- package/dist/core/room.d.ts +3 -1
- package/dist/core/room.js +37 -1
- package/dist/core/room.js.map +1 -1
- package/dist/core/schemas.d.ts +9 -0
- package/dist/core/schemas.js +10 -2
- package/dist/core/schemas.js.map +1 -1
- package/dist/core/types.d.ts +7 -1
- package/dist/dashboard/Dashboard.d.ts +2 -1
- package/dist/dashboard/Dashboard.js +3 -3
- package/dist/dashboard/Dashboard.js.map +1 -1
- package/dist/dashboard/model.d.ts +10 -3
- package/dist/dashboard/model.js +38 -7
- package/dist/dashboard/model.js.map +1 -1
- package/dist/dashboard/run.js +2 -2
- package/dist/dashboard/run.js.map +1 -1
- package/dist/mcp/auto-report.d.ts +43 -0
- package/dist/mcp/auto-report.js +118 -0
- package/dist/mcp/auto-report.js.map +1 -0
- package/dist/mcp/server.d.ts +18 -4
- package/dist/mcp/server.js +44 -29
- package/dist/mcp/server.js.map +1 -1
- package/dist/server/app.js +7 -9
- package/dist/server/app.js.map +1 -1
- package/dist/store/file-store.js +1 -1
- package/dist/store/file-store.js.map +1 -1
- package/package.json +9 -2
|
@@ -2,51 +2,106 @@ import { promises as fs } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ConfigError } from "./errors.js";
|
|
5
|
-
/** Project-scoped MCP config read by Claude Code. Meant to be committed so the whole team gets it. */
|
|
6
|
-
export const MCP_CONFIG_FILE = ".mcp.json";
|
|
7
5
|
export const MCP_SERVER_NAME = "teamroom";
|
|
6
|
+
/** Claude Code's project MCP config. Meant to be committed so the whole team gets it. */
|
|
7
|
+
export const MCP_CONFIG_FILE = ".mcp.json";
|
|
8
8
|
const TEAMROOM_MCP_ENTRY = { command: "teamroom", args: ["mcp"] };
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
export const MCP_TARGETS = [
|
|
10
|
+
{ agent: "claude", label: "Claude Code", file: MCP_CONFIG_FILE, format: "json" },
|
|
11
|
+
{ agent: "cursor", label: "Cursor", file: path.join(".cursor", "mcp.json"), format: "json", marker: ".cursor" },
|
|
12
|
+
{
|
|
13
|
+
agent: "gemini",
|
|
14
|
+
label: "Gemini CLI",
|
|
15
|
+
file: path.join(".gemini", "settings.json"),
|
|
16
|
+
format: "json",
|
|
17
|
+
marker: ".gemini",
|
|
18
|
+
},
|
|
19
|
+
// Codex only loads a project config in trusted projects.
|
|
20
|
+
{ agent: "codex", label: "Codex", file: path.join(".codex", "config.toml"), format: "toml", marker: ".codex" },
|
|
21
|
+
];
|
|
12
22
|
export const CODEX_SNIPPET = `[mcp_servers.${MCP_SERVER_NAME}]
|
|
13
23
|
command = "teamroom"
|
|
14
24
|
args = ["mcp"]`;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Mistral Vibe's project config replaces parts of the user's, so teamroom
|
|
27
|
+
* never writes one. Add this to ~/.vibe/config.toml instead.
|
|
28
|
+
*/
|
|
29
|
+
export const VIBE_SNIPPET = `[[mcp_servers]]
|
|
30
|
+
name = "${MCP_SERVER_NAME}"
|
|
31
|
+
transport = "stdio"
|
|
32
|
+
command = "teamroom"
|
|
33
|
+
args = ["mcp"]`;
|
|
34
|
+
export const GENERIC_MCP_DESCRIPTION = 'Any other MCP client: a stdio server, command "teamroom", args ["mcp"].';
|
|
35
|
+
/** Writes the teamroom server into every agent config that applies to this repo, keeping everything else there. */
|
|
36
|
+
export async function installMcpConfigs(repoRoot, forced = []) {
|
|
37
|
+
const results = [];
|
|
38
|
+
for (const target of MCP_TARGETS) {
|
|
39
|
+
const applies = !target.marker || forced.includes(target.agent) || (await exists(path.join(repoRoot, target.marker)));
|
|
40
|
+
if (!applies)
|
|
41
|
+
continue;
|
|
42
|
+
const file = path.join(repoRoot, target.file);
|
|
43
|
+
const change = target.format === "json" ? await installJson(file) : await installToml(file);
|
|
44
|
+
results.push({ agent: target.agent, label: target.label, file, change });
|
|
45
|
+
}
|
|
46
|
+
return results;
|
|
29
47
|
}
|
|
48
|
+
/** Claude Code's config alone, for callers that only care whether agents in general are set up. */
|
|
30
49
|
export async function mcpConfigHasTeamroom(repoRoot) {
|
|
31
|
-
const config = await
|
|
50
|
+
const config = await readJsonConfig(path.join(repoRoot, MCP_CONFIG_FILE));
|
|
32
51
|
return config?.mcpServers?.[MCP_SERVER_NAME] !== undefined;
|
|
33
52
|
}
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
const jsonConfigSchema = z.looseObject({
|
|
54
|
+
mcpServers: z.record(z.string(), z.unknown()).optional(),
|
|
55
|
+
});
|
|
56
|
+
async function installJson(file) {
|
|
57
|
+
const existing = await readJsonConfig(file);
|
|
58
|
+
if (existing?.mcpServers?.[MCP_SERVER_NAME] !== undefined)
|
|
59
|
+
return "unchanged";
|
|
60
|
+
const next = { ...existing, mcpServers: { ...existing?.mcpServers, [MCP_SERVER_NAME]: TEAMROOM_MCP_ENTRY } };
|
|
61
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
62
|
+
await fs.writeFile(file, `${JSON.stringify(next, null, 2)}\n`, "utf8");
|
|
63
|
+
return existing ? "added" : "created";
|
|
64
|
+
}
|
|
65
|
+
/** TOML tables can come in any order, so appending one never disturbs what is already there. */
|
|
66
|
+
async function installToml(file) {
|
|
67
|
+
const existing = await readIfExists(file);
|
|
68
|
+
if (existing !== undefined && new RegExp(`^\\s*\\[mcp_servers\\.${MCP_SERVER_NAME}\\]`, "m").test(existing)) {
|
|
69
|
+
return "unchanged";
|
|
70
|
+
}
|
|
71
|
+
const base = existing?.trimEnd();
|
|
72
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
73
|
+
await fs.writeFile(file, base ? `${base}\n\n${CODEX_SNIPPET}\n` : `${CODEX_SNIPPET}\n`, "utf8");
|
|
74
|
+
return existing === undefined ? "created" : "added";
|
|
75
|
+
}
|
|
76
|
+
async function readJsonConfig(file) {
|
|
77
|
+
const raw = await readIfExists(file);
|
|
78
|
+
if (raw === undefined)
|
|
79
|
+
return undefined;
|
|
80
|
+
try {
|
|
81
|
+
return jsonConfigSchema.parse(JSON.parse(raw));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Never overwrite a config we cannot parse: it may hold other servers' settings.
|
|
85
|
+
throw new ConfigError(`${file} is not valid JSON. Fix it, then run \`teamroom init\` again.`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async function readIfExists(file) {
|
|
36
89
|
try {
|
|
37
|
-
|
|
90
|
+
return await fs.readFile(file, "utf8");
|
|
38
91
|
}
|
|
39
92
|
catch (error) {
|
|
40
93
|
if (error.code === "ENOENT")
|
|
41
94
|
return undefined;
|
|
42
95
|
throw new ConfigError(`Could not read ${file}.`);
|
|
43
96
|
}
|
|
97
|
+
}
|
|
98
|
+
async function exists(target) {
|
|
44
99
|
try {
|
|
45
|
-
|
|
100
|
+
await fs.access(target);
|
|
101
|
+
return true;
|
|
46
102
|
}
|
|
47
103
|
catch {
|
|
48
|
-
|
|
49
|
-
throw new ConfigError(`${file} is not valid JSON. Fix it, then run \`teamroom agents install\` again.`);
|
|
104
|
+
return false;
|
|
50
105
|
}
|
|
51
106
|
}
|
|
52
107
|
//# sourceMappingURL=mcp-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-config.js","sourceRoot":"","sources":["../../src/client/mcp-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"mcp-config.js","sourceRoot":"","sources":["../../src/client/mcp-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAA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ActivitySource, FileOverlap } from "../core/types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { type BackendMode, type RoomBackend } from "./backend.js";
|
|
3
3
|
import { type TeamroomConfig } from "./config.js";
|
|
4
|
-
import { Git } from "./git.js";
|
|
4
|
+
import { Git, type WorkingState } from "./git.js";
|
|
5
|
+
import { type IgnoreMatcher } from "./ignore.js";
|
|
5
6
|
export interface Workspace {
|
|
6
7
|
cwd: string;
|
|
7
8
|
repoRoot: string;
|
|
9
|
+
commonDir: string;
|
|
8
10
|
git: Git;
|
|
9
11
|
session: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
member: string;
|
|
13
|
+
mode: BackendMode;
|
|
14
|
+
backend: RoomBackend;
|
|
15
|
+
/** Set only in shared mode. */
|
|
16
|
+
config?: TeamroomConfig;
|
|
17
|
+
/** Files whose overlap is noise, such as lockfiles. */
|
|
18
|
+
isIgnored: IgnoreMatcher;
|
|
12
19
|
}
|
|
13
|
-
export
|
|
20
|
+
export interface OpenWorkspaceOptions {
|
|
21
|
+
env?: NodeJS.ProcessEnv;
|
|
22
|
+
/** Hooks that run inline with an agent keep this short, so a slow server never stalls an edit. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
maxAttempts?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Shared mode when the repo joined a room, local mode otherwise. Local mode needs no setup at all. */
|
|
27
|
+
export declare function openWorkspace(cwd: string, options?: OpenWorkspaceOptions): Promise<Workspace>;
|
|
28
|
+
/** Room admin only makes sense for a shared room. */
|
|
29
|
+
export declare function requireShared(workspace: Workspace): TeamroomConfig;
|
|
30
|
+
/** An explicit name, else git's user.name, else the OS user, cleaned up to be a valid member name. */
|
|
31
|
+
export declare function defaultMemberName(git: Git, explicit?: string): Promise<string>;
|
|
14
32
|
export interface ReportResult {
|
|
15
33
|
activity: Activity;
|
|
16
34
|
/** Files left out because the snapshot was over the per-entry limit. */
|
|
@@ -24,12 +42,15 @@ export declare function reportWork(workspace: Workspace, options: {
|
|
|
24
42
|
source: ActivitySource;
|
|
25
43
|
note?: string;
|
|
26
44
|
agent?: string;
|
|
45
|
+
instance?: string;
|
|
46
|
+
state?: WorkingState;
|
|
27
47
|
}): Promise<ReportResult>;
|
|
28
48
|
export declare function postNote(workspace: Workspace, options: {
|
|
29
49
|
text: string;
|
|
30
50
|
files?: string[];
|
|
31
51
|
source: ActivitySource;
|
|
32
52
|
agent?: string;
|
|
53
|
+
instance?: string;
|
|
33
54
|
}): Promise<Activity>;
|
|
34
55
|
/**
|
|
35
56
|
* Records that a coding agent edited one file. Returns null for files outside
|
|
@@ -39,20 +60,26 @@ export declare function reportEdit(workspace: Workspace, options: {
|
|
|
39
60
|
file: string;
|
|
40
61
|
agent: string;
|
|
41
62
|
}): Promise<Activity | null>;
|
|
63
|
+
/** Tells the room this agent is still running, so it counts even before it changes anything. */
|
|
64
|
+
export declare function reportPresence(workspace: Workspace, options: {
|
|
65
|
+
agent?: string;
|
|
66
|
+
instance: string;
|
|
67
|
+
}): Promise<Activity>;
|
|
42
68
|
export interface OverlapCheck {
|
|
43
69
|
files: string[];
|
|
44
70
|
overlaps: FileOverlap[];
|
|
45
71
|
}
|
|
46
72
|
/**
|
|
47
73
|
* Asks who else is touching `files` (default: everything this checkout has
|
|
48
|
-
* changed).
|
|
49
|
-
* since they can no longer conflict.
|
|
74
|
+
* changed). Ignored files, such as lockfiles, are left out of the question.
|
|
50
75
|
*/
|
|
51
76
|
export declare function checkOverlap(workspace: Workspace, options?: {
|
|
52
77
|
files?: string[];
|
|
53
78
|
sinceHours?: number;
|
|
79
|
+
state?: WorkingState;
|
|
54
80
|
}): Promise<OverlapCheck>;
|
|
55
81
|
/** Accepts absolute paths or paths relative to the cwd, returns a path relative to the repo root. */
|
|
56
82
|
export declare function toRepoPath(workspace: Pick<Workspace, "cwd" | "repoRoot">, file: string): string;
|
|
83
|
+
export declare function isOutsideRepo(repoPath: string): boolean;
|
|
57
84
|
export declare function formatOverlaps(overlaps: FileOverlap[]): string;
|
|
58
85
|
export declare function formatAge(isoTimestamp: string, now?: Date): string;
|
package/dist/client/workspace.js
CHANGED
|
@@ -1,35 +1,82 @@
|
|
|
1
|
+
import os from "node:os";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { agentLabel } from "../core/agents.js";
|
|
3
4
|
import { normalizePath } from "../core/overlap.js";
|
|
4
|
-
import { MAX_FILES_PER_ACTIVITY, MAX_TEXT_LENGTH } from "../core/schemas.js";
|
|
5
|
+
import { MAX_FILES_PER_ACTIVITY, MAX_NAME_LENGTH, MAX_TEXT_LENGTH, memberNameSchema } from "../core/schemas.js";
|
|
5
6
|
import { ApiClient } from "./api-client.js";
|
|
7
|
+
import { LocalBackend, SharedBackend } from "./backend.js";
|
|
6
8
|
import { ENV, loadConfig } from "./config.js";
|
|
9
|
+
import { ConfigError } from "./errors.js";
|
|
7
10
|
import { Git, sessionForRepoRoot } from "./git.js";
|
|
8
|
-
|
|
11
|
+
import { loadIgnore } from "./ignore.js";
|
|
12
|
+
const FALLBACK_MEMBER_NAME = "me";
|
|
13
|
+
/** Shared mode when the repo joined a room, local mode otherwise. Local mode needs no setup at all. */
|
|
14
|
+
export async function openWorkspace(cwd, options = {}) {
|
|
15
|
+
const env = options.env ?? process.env;
|
|
9
16
|
const git = new Git(cwd);
|
|
10
17
|
const [repoRoot, commonDir] = await Promise.all([git.repoRoot(), git.commonDir()]);
|
|
11
|
-
const config = await loadConfig(commonDir, env);
|
|
18
|
+
const [config, isIgnored] = await Promise.all([loadConfig(commonDir, env), loadIgnore(repoRoot)]);
|
|
19
|
+
const rootGit = new Git(repoRoot);
|
|
20
|
+
const member = config?.member ?? (await defaultMemberName(rootGit, env[ENV.member]));
|
|
21
|
+
const backend = config
|
|
22
|
+
? new SharedBackend(new ApiClient({
|
|
23
|
+
server: config.server,
|
|
24
|
+
token: config.token,
|
|
25
|
+
timeoutMs: options.timeoutMs,
|
|
26
|
+
maxAttempts: options.maxAttempts,
|
|
27
|
+
}), config.roomId)
|
|
28
|
+
: new LocalBackend(commonDir, member, path.basename(repoRoot));
|
|
12
29
|
return {
|
|
13
30
|
cwd,
|
|
14
31
|
repoRoot,
|
|
15
|
-
|
|
32
|
+
commonDir,
|
|
33
|
+
git: rootGit,
|
|
16
34
|
session: env[ENV.session] ?? sessionForRepoRoot(repoRoot),
|
|
35
|
+
member,
|
|
36
|
+
mode: backend.mode,
|
|
37
|
+
backend,
|
|
17
38
|
config,
|
|
18
|
-
|
|
39
|
+
isIgnored,
|
|
19
40
|
};
|
|
20
41
|
}
|
|
42
|
+
/** Room admin only makes sense for a shared room. */
|
|
43
|
+
export function requireShared(workspace) {
|
|
44
|
+
if (!workspace.config) {
|
|
45
|
+
throw new ConfigError("This repo is in local mode, which has no invites or members to manage. Share it with `teamroom create --server <url>` first.");
|
|
46
|
+
}
|
|
47
|
+
return workspace.config;
|
|
48
|
+
}
|
|
49
|
+
/** An explicit name, else git's user.name, else the OS user, cleaned up to be a valid member name. */
|
|
50
|
+
export async function defaultMemberName(git, explicit) {
|
|
51
|
+
const candidates = [explicit, await git.userName(), safeOsUserName()];
|
|
52
|
+
for (const candidate of candidates) {
|
|
53
|
+
const cleaned = candidate?.replace(/@/g, "").trim().slice(0, MAX_NAME_LENGTH);
|
|
54
|
+
if (cleaned && memberNameSchema.safeParse(cleaned).success)
|
|
55
|
+
return cleaned;
|
|
56
|
+
}
|
|
57
|
+
return FALLBACK_MEMBER_NAME;
|
|
58
|
+
}
|
|
59
|
+
function safeOsUserName() {
|
|
60
|
+
try {
|
|
61
|
+
return os.userInfo().username;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
21
67
|
/**
|
|
22
68
|
* Publishes this checkout's current changes as a `wip` snapshot. An empty
|
|
23
69
|
* snapshot is still sent: it clears what this session reported before.
|
|
24
70
|
*/
|
|
25
71
|
export async function reportWork(workspace, options) {
|
|
26
|
-
const state = await workspace.git.workingState();
|
|
72
|
+
const state = options.state ?? (await workspace.git.workingState());
|
|
27
73
|
const files = state.files.slice(0, MAX_FILES_PER_ACTIVITY);
|
|
28
74
|
const omittedFiles = state.files.length - files.length;
|
|
29
|
-
const activity = await workspace.
|
|
75
|
+
const activity = await workspace.backend.postActivity({
|
|
30
76
|
kind: "wip",
|
|
31
77
|
source: options.source,
|
|
32
78
|
agent: options.agent,
|
|
79
|
+
instance: options.instance,
|
|
33
80
|
session: workspace.session,
|
|
34
81
|
text: truncate(options.note?.trim() || describeSnapshot(state.files.length, state.branch)),
|
|
35
82
|
branch: state.branch,
|
|
@@ -40,10 +87,11 @@ export async function reportWork(workspace, options) {
|
|
|
40
87
|
}
|
|
41
88
|
export async function postNote(workspace, options) {
|
|
42
89
|
const [branch, commit] = await Promise.all([workspace.git.currentBranch(), workspace.git.headCommit()]);
|
|
43
|
-
return workspace.
|
|
90
|
+
return workspace.backend.postActivity({
|
|
44
91
|
kind: "note",
|
|
45
92
|
source: options.source,
|
|
46
93
|
agent: options.agent,
|
|
94
|
+
instance: options.instance,
|
|
47
95
|
session: workspace.session,
|
|
48
96
|
text: truncate(options.text.trim()),
|
|
49
97
|
branch,
|
|
@@ -57,10 +105,10 @@ export async function postNote(workspace, options) {
|
|
|
57
105
|
*/
|
|
58
106
|
export async function reportEdit(workspace, options) {
|
|
59
107
|
const file = toRepoPath(workspace, options.file);
|
|
60
|
-
if (
|
|
108
|
+
if (isOutsideRepo(file))
|
|
61
109
|
return null;
|
|
62
110
|
const [branch, commit] = await Promise.all([workspace.git.currentBranch(), workspace.git.headCommit()]);
|
|
63
|
-
return workspace.
|
|
111
|
+
return workspace.backend.postActivity({
|
|
64
112
|
kind: "edit",
|
|
65
113
|
source: "agent",
|
|
66
114
|
agent: options.agent,
|
|
@@ -71,48 +119,41 @@ export async function reportEdit(workspace, options) {
|
|
|
71
119
|
files: [file],
|
|
72
120
|
});
|
|
73
121
|
}
|
|
122
|
+
/** Tells the room this agent is still running, so it counts even before it changes anything. */
|
|
123
|
+
export async function reportPresence(workspace, options) {
|
|
124
|
+
return workspace.backend.postActivity({
|
|
125
|
+
kind: "presence",
|
|
126
|
+
source: "agent",
|
|
127
|
+
agent: options.agent,
|
|
128
|
+
instance: options.instance,
|
|
129
|
+
session: workspace.session,
|
|
130
|
+
text: `${agentLabel(options.agent)} is running`,
|
|
131
|
+
files: [],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
74
134
|
/**
|
|
75
135
|
* Asks who else is touching `files` (default: everything this checkout has
|
|
76
|
-
* changed).
|
|
77
|
-
* since they can no longer conflict.
|
|
136
|
+
* changed). Ignored files, such as lockfiles, are left out of the question.
|
|
78
137
|
*/
|
|
79
138
|
export async function checkOverlap(workspace, options = {}) {
|
|
80
|
-
const
|
|
139
|
+
const requested = options.files && options.files.length > 0
|
|
81
140
|
? [...new Set(options.files.map((file) => toRepoPath(workspace, file)))]
|
|
82
|
-
: (await workspace.git.workingState()).files;
|
|
141
|
+
: (options.state ?? (await workspace.git.workingState())).files;
|
|
142
|
+
const files = requested.filter((file) => !isOutsideRepo(file) && !workspace.isIgnored(file));
|
|
83
143
|
if (files.length === 0)
|
|
84
144
|
return { files, overlaps: [] };
|
|
85
145
|
const batches = chunk(files, MAX_FILES_PER_ACTIVITY);
|
|
86
|
-
const results = await Promise.all(batches.map((batch) => workspace.
|
|
87
|
-
|
|
88
|
-
session: workspace.session,
|
|
89
|
-
sinceHours: options.sinceHours,
|
|
90
|
-
})));
|
|
91
|
-
const overlaps = await dropMergedCommits(workspace.git, results.flat());
|
|
92
|
-
return { files, overlaps };
|
|
93
|
-
}
|
|
94
|
-
async function dropMergedCommits(git, overlaps) {
|
|
95
|
-
const baseRef = await git.defaultBranchRef();
|
|
96
|
-
if (!baseRef)
|
|
97
|
-
return overlaps;
|
|
98
|
-
const commits = new Set(overlaps.flatMap((overlap) => overlap.touchedBy.filter((touch) => touch.kind === "commit" && touch.commit).map((touch) => touch.commit ?? "")));
|
|
99
|
-
const merged = new Set();
|
|
100
|
-
await Promise.all([...commits].map(async (commit) => {
|
|
101
|
-
if (await git.isMergedInto(commit, baseRef))
|
|
102
|
-
merged.add(commit);
|
|
103
|
-
}));
|
|
104
|
-
return overlaps
|
|
105
|
-
.map((overlap) => ({
|
|
106
|
-
...overlap,
|
|
107
|
-
touchedBy: overlap.touchedBy.filter((touch) => !(touch.kind === "commit" && touch.commit && merged.has(touch.commit))),
|
|
108
|
-
}))
|
|
109
|
-
.filter((overlap) => overlap.touchedBy.length > 0);
|
|
146
|
+
const results = await Promise.all(batches.map((batch) => workspace.backend.findOverlaps({ files: batch, session: workspace.session, sinceHours: options.sinceHours })));
|
|
147
|
+
return { files, overlaps: results.flat() };
|
|
110
148
|
}
|
|
111
149
|
/** Accepts absolute paths or paths relative to the cwd, returns a path relative to the repo root. */
|
|
112
150
|
export function toRepoPath(workspace, file) {
|
|
113
151
|
const absolute = path.resolve(workspace.cwd, file);
|
|
114
152
|
return normalizePath(path.relative(workspace.repoRoot, absolute));
|
|
115
153
|
}
|
|
154
|
+
export function isOutsideRepo(repoPath) {
|
|
155
|
+
return repoPath === "" || repoPath === ".." || repoPath.startsWith("../") || path.isAbsolute(repoPath);
|
|
156
|
+
}
|
|
116
157
|
export function formatOverlaps(overlaps) {
|
|
117
158
|
if (overlaps.length === 0)
|
|
118
159
|
return "No one else is touching these files.";
|
|
@@ -121,7 +162,8 @@ export function formatOverlaps(overlaps) {
|
|
|
121
162
|
const touches = overlap.touchedBy.map((touch) => {
|
|
122
163
|
const where = [touch.session, touch.branch].filter(Boolean).join(" on ");
|
|
123
164
|
const via = touch.agent ? ` via ${agentLabel(touch.agent)}` : "";
|
|
124
|
-
|
|
165
|
+
const plan = touch.plan ? ` Plan: ${touch.plan}` : "";
|
|
166
|
+
return ` - ${touch.member}${via}${where ? ` (${where})` : ""}, ${touch.kind} ${formatAge(touch.at)}: ${touch.text}${plan}`;
|
|
125
167
|
});
|
|
126
168
|
return [overlap.file, ...touches].join("\n");
|
|
127
169
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/client/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/client/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEhH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAoB,YAAY,EAAoB,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAqB,MAAM,UAAU,CAAC;AACtE,OAAO,EAAsB,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAwBlC,uGAAuG;AACvG,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW,EAAE,OAAO,GAAyB,EAAE;IACjF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,C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C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,GAAG,CAAC;AAC5E,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,IAAI,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,GAAG,CAAC;AAC1F,CAAC;AAED,SAAS,KAAK,CAAO,KAAa,EAAE,IAAY;IAC9C,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IACvG,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/core/agents.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export declare const MAX_AGENT_ID_LENGTH = 40;
|
|
2
2
|
export declare const AGENT_ID_PATTERN: RegExp;
|
|
3
|
+
export declare const MAX_AGENT_INSTANCE_LENGTH = 64;
|
|
4
|
+
export declare const AGENT_INSTANCE_PATTERN: RegExp;
|
|
5
|
+
/** How often a running agent's MCP server says it is still there. */
|
|
6
|
+
export declare const AGENT_HEARTBEAT_INTERVAL_MS = 60000;
|
|
7
|
+
/** An agent whose last heartbeat is older than this has most likely quit. Allows for a couple of missed beats. */
|
|
8
|
+
export declare const AGENT_PRESENCE_TTL_MS: number;
|
|
3
9
|
/** Maps a raw MCP client name to the short id stored on activity. Returns undefined when nothing usable is left. */
|
|
4
10
|
export declare function normalizeAgentId(clientName: string | undefined): string | undefined;
|
|
5
11
|
/** Human name for an agent id, for the CLI and the dashboard. */
|
package/dist/core/agents.js
CHANGED
|
@@ -10,6 +10,13 @@ const KNOWN_CLIENTS = {
|
|
|
10
10
|
};
|
|
11
11
|
export const MAX_AGENT_ID_LENGTH = 40;
|
|
12
12
|
export const AGENT_ID_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
13
|
+
export const MAX_AGENT_INSTANCE_LENGTH = 64;
|
|
14
|
+
export const AGENT_INSTANCE_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
15
|
+
const MINUTE_MS = 60_000;
|
|
16
|
+
/** How often a running agent's MCP server says it is still there. */
|
|
17
|
+
export const AGENT_HEARTBEAT_INTERVAL_MS = MINUTE_MS;
|
|
18
|
+
/** An agent whose last heartbeat is older than this has most likely quit. Allows for a couple of missed beats. */
|
|
19
|
+
export const AGENT_PRESENCE_TTL_MS = 3 * MINUTE_MS;
|
|
13
20
|
/** Maps a raw MCP client name to the short id stored on activity. Returns undefined when nothing usable is left. */
|
|
14
21
|
export function normalizeAgentId(clientName) {
|
|
15
22
|
if (!clientName)
|
package/dist/core/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/core/agents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,aAAa,GAAkD;IACnE,aAAa,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;IAC1D,kBAAkB,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IACnD,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;CACvC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAEzD,oHAAoH;AACpH,MAAM,UAAU,gBAAgB,CAAC,UAA8B;IAC7D,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAClC,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,EAAE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M,SAAS,GAAG,MAAM,CAAC;AACzB,qEAAqE;AACrE,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC;AACrD,kHAAkH;AAClH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,SAAS,CAAC;AAEnD,oHAAoH;AACpH,MAAM,UAAU,gBAAgB,CAAC,UAA8B;IAC7D,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAClC,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,EAAE,CAAC;IAC3B,MAAM,SAAS,GAAG,GAAG;SAClB,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;SAC9B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;SAC1B,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACjC,OAAO,SAAS,IAAI,SAAS,CAAC;AAChC,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,UAAU,CAAC,OAA2B;IACpD,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC;IACnF,OAAO,KAAK,EAAE,KAAK,IAAI,OAAO,CAAC;AACjC,CAAC"}
|
package/dist/core/overlap.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Activity, FileOverlap } from "./types.js";
|
|
1
|
+
import type { Activity, FileOverlap, OverlapTouch } from "./types.js";
|
|
2
2
|
export declare const DEFAULT_OVERLAP_WINDOW_HOURS = 72;
|
|
3
3
|
interface FindOverlapsInput {
|
|
4
4
|
activity: Activity[];
|
|
@@ -13,9 +13,18 @@ interface FindOverlapsInput {
|
|
|
13
13
|
* For each requested file, lists the other sessions that touched it recently,
|
|
14
14
|
* keeping only each session's latest touch so the answer stays short.
|
|
15
15
|
*
|
|
16
|
-
* A `wip` snapshot replaces the earlier snapshots
|
|
17
|
-
* session has since merged or reverted stop showing up as
|
|
16
|
+
* A `wip` snapshot replaces the earlier snapshots and agent edits of its
|
|
17
|
+
* session, so files a session has since merged or reverted stop showing up as
|
|
18
|
+
* overlap. Edits newer than the snapshot still count: the agent is mid-task.
|
|
18
19
|
*/
|
|
19
20
|
export declare function findOverlaps({ activity, files, member, session, sinceHours, now, }: FindOverlapsInput): FileOverlap[];
|
|
21
|
+
/**
|
|
22
|
+
* Identifies an overlap for "already warned about this" checks: who is in the
|
|
23
|
+
* file and what they said they plan. Timestamps and snapshot text are left
|
|
24
|
+
* out, since they change on every edit of a session that keeps working, which
|
|
25
|
+
* is the overlap the reader already knows about.
|
|
26
|
+
*/
|
|
27
|
+
export declare function overlapSignature(touches: OverlapTouch[]): string;
|
|
20
28
|
export declare function normalizePath(file: string): string;
|
|
29
|
+
export declare function latestSnapshotBySession(activity: Activity[]): Map<string, Activity>;
|
|
21
30
|
export {};
|