intercomm-aimfp 0.4.0
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 +353 -0
- package/dist/claude-tui.d.ts +7 -0
- package/dist/claude-tui.d.ts.map +1 -0
- package/dist/claude-tui.js +55 -0
- package/dist/claude-tui.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +144 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +44 -0
- package/dist/config.js.map +1 -0
- package/dist/db.d.ts +9 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +117 -0
- package/dist/db.js.map +1 -0
- package/dist/fs-wrapper.d.ts +3 -0
- package/dist/fs-wrapper.d.ts.map +1 -0
- package/dist/fs-wrapper.js +9 -0
- package/dist/fs-wrapper.js.map +1 -0
- package/dist/git-wrapper.d.ts +11 -0
- package/dist/git-wrapper.d.ts.map +1 -0
- package/dist/git-wrapper.js +44 -0
- package/dist/git-wrapper.js.map +1 -0
- package/dist/mcp-entry.d.ts +3 -0
- package/dist/mcp-entry.d.ts.map +1 -0
- package/dist/mcp-entry.js +8 -0
- package/dist/mcp-entry.js.map +1 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +557 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/orchestrate.d.ts +52 -0
- package/dist/orchestrate.d.ts.map +1 -0
- package/dist/orchestrate.js +226 -0
- package/dist/orchestrate.js.map +1 -0
- package/dist/protocol.d.ts +3 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +33 -0
- package/dist/protocol.js.map +1 -0
- package/dist/store.d.ts +26 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +186 -0
- package/dist/store.js.map +1 -0
- package/dist/task-contract.d.ts +4 -0
- package/dist/task-contract.d.ts.map +1 -0
- package/dist/task-contract.js +111 -0
- package/dist/task-contract.js.map +1 -0
- package/dist/tmux-wrapper.d.ts +17 -0
- package/dist/tmux-wrapper.d.ts.map +1 -0
- package/dist/tmux-wrapper.js +66 -0
- package/dist/tmux-wrapper.js.map +1 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +56 -0
- package/dist/types.js.map +1 -0
- package/package.json +35 -0
- package/system-prompt.md +245 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,aAAa,GAAG,kBAAkB,CAAC;AACzC,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAU,EAAE,CAC7C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;AAErC,8EAA8E;AAC9E,gFAAgF;AAChF,0EAA0E;AAC1E,8EAA8E;AAC9E,iFAAiF;AACjF,wDAAwD;AACxD,oDAAoD;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAI7B,EAAU,EAAE;IACX,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;IACjC,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,IAAI,IAAI,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC,GAAG,CAAC;AAClB,CAAC,CAAC;AAEF,+EAA+E;AAC/E,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE,CACnD,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAU,EAAE,CACrE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AAErC,mFAAmF;AACnF,uFAAuF;AACvF,qFAAqF;AACrF,wFAAwF;AACxF,wFAAwF;AACxF,kFAAkF;AAClF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,YAAoB,EACpB,GAAW,EACI,EAAE;IACjB,IAAI,OAAO,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACxD,OAAO,CACL,gCAAgC,YAAY,wCAAwC,GAAG,KAAK;QAC5F,iHAAiH;QACjH,wHAAwH,CACzH,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/db.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Database as DatabaseType } from "better-sqlite3";
|
|
2
|
+
export declare const initDb: (root: string) => DatabaseType;
|
|
3
|
+
export declare const getDb: () => DatabaseType;
|
|
4
|
+
export declare const closeDb: () => void;
|
|
5
|
+
export declare const execute: (sql: string, ...params: unknown[]) => void;
|
|
6
|
+
export declare const queryOne: <T>(sql: string, ...params: unknown[]) => T | undefined;
|
|
7
|
+
export declare const queryAll: <T>(sql: string, ...params: unknown[]) => T[];
|
|
8
|
+
export declare const resolveRoot: (cwd: string) => string;
|
|
9
|
+
//# sourceMappingURL=db.d.ts.map
|
package/dist/db.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAsF/D,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,KAAG,YAWrC,CAAC;AAEF,eAAO,MAAM,KAAK,QAAO,YAGxB,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,IAK1B,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,GAAG,QAAQ,OAAO,EAAE,KAAG,IAE3D,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,QAAQ,OAAO,EAAE,KAAG,CAAC,GAAG,SACd,CAAC;AAEvD,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,QAAQ,OAAO,EAAE,KAAG,CAAC,EACrB,CAAC;AAM7C,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAKtC,CAAC"}
|
package/dist/db.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// SQLite wrapper — thin IO layer over better-sqlite3
|
|
2
|
+
import Database from "better-sqlite3";
|
|
3
|
+
import { basePath, dbFile, resolveDbRoot, ENV_DB_ROOT } from "./config.js";
|
|
4
|
+
import { ensureDir } from "./fs-wrapper.js";
|
|
5
|
+
import { gitCommonDir } from "./git-wrapper.js";
|
|
6
|
+
import { WORKTREE_STATUSES } from "./types.js";
|
|
7
|
+
let db = null;
|
|
8
|
+
// Build the CHECK clause from the single source of truth in types.ts so the
|
|
9
|
+
// schema can never drift from the WorktreeStatus union.
|
|
10
|
+
const WORKTREE_STATUS_CHECK = WORKTREE_STATUSES.map((s) => `'${s}'`).join(", ");
|
|
11
|
+
const SCHEMA = `
|
|
12
|
+
CREATE TABLE IF NOT EXISTS instances (
|
|
13
|
+
id TEXT PRIMARY KEY,
|
|
14
|
+
role TEXT NOT NULL CHECK(role IN ('master', 'worker')),
|
|
15
|
+
active INTEGER NOT NULL DEFAULT 1,
|
|
16
|
+
last_active INTEGER NOT NULL,
|
|
17
|
+
registered_at INTEGER NOT NULL,
|
|
18
|
+
session_id TEXT NOT NULL DEFAULT '',
|
|
19
|
+
tmux_target TEXT NOT NULL DEFAULT ''
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE IF NOT EXISTS messages (
|
|
23
|
+
id TEXT PRIMARY KEY,
|
|
24
|
+
from_id TEXT NOT NULL,
|
|
25
|
+
to_id TEXT NOT NULL,
|
|
26
|
+
type TEXT NOT NULL CHECK(type IN (
|
|
27
|
+
'task', 'status', 'question', 'answer', 'announce', 'done'
|
|
28
|
+
)),
|
|
29
|
+
content TEXT NOT NULL,
|
|
30
|
+
ts INTEGER NOT NULL
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
CREATE TABLE IF NOT EXISTS read_cursors (
|
|
34
|
+
instance_id TEXT NOT NULL,
|
|
35
|
+
last_read_seq INTEGER NOT NULL DEFAULT 0,
|
|
36
|
+
PRIMARY KEY (instance_id)
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
CREATE TABLE IF NOT EXISTS worktrees (
|
|
40
|
+
worker_id TEXT PRIMARY KEY,
|
|
41
|
+
branch TEXT NOT NULL DEFAULT '',
|
|
42
|
+
path TEXT NOT NULL,
|
|
43
|
+
base TEXT NOT NULL DEFAULT 'main',
|
|
44
|
+
status TEXT NOT NULL DEFAULT 'active'
|
|
45
|
+
CHECK(status IN (${WORKTREE_STATUS_CHECK})),
|
|
46
|
+
created_at INTEGER NOT NULL,
|
|
47
|
+
updated_at INTEGER NOT NULL
|
|
48
|
+
);
|
|
49
|
+
`;
|
|
50
|
+
// Migration for existing DBs that lack session_id column
|
|
51
|
+
const migrateSchema = (database) => {
|
|
52
|
+
const columns = database.prepare("PRAGMA table_info(instances)").all();
|
|
53
|
+
const hasSessionId = columns.some((col) => col.name === "session_id");
|
|
54
|
+
if (!hasSessionId) {
|
|
55
|
+
database.exec("ALTER TABLE instances ADD COLUMN session_id TEXT NOT NULL DEFAULT ''");
|
|
56
|
+
}
|
|
57
|
+
// tmux_target: '<session>:<window>.<pane>' captured at register, so the master
|
|
58
|
+
// can wake/scan/approve a worker's pane (and, later, M5 escalation can wake the
|
|
59
|
+
// master). '' when the instance is not running inside tmux.
|
|
60
|
+
const hasTmuxTarget = columns.some((col) => col.name === "tmux_target");
|
|
61
|
+
if (!hasTmuxTarget) {
|
|
62
|
+
database.exec("ALTER TABLE instances ADD COLUMN tmux_target TEXT NOT NULL DEFAULT ''");
|
|
63
|
+
}
|
|
64
|
+
// read_cursors: millisecond-ts cursor -> monotonic rowid cursor (P0 fix).
|
|
65
|
+
// The old `ts >` comparison silently dropped same-millisecond messages that
|
|
66
|
+
// straddled a read boundary; rowid is strictly increasing per insert.
|
|
67
|
+
const cursorCols = database.prepare("PRAGMA table_info(read_cursors)").all();
|
|
68
|
+
const hasSeq = cursorCols.some((col) => col.name === "last_read_seq");
|
|
69
|
+
const hasTs = cursorCols.some((col) => col.name === "last_read_ts");
|
|
70
|
+
if (!hasSeq && hasTs) {
|
|
71
|
+
database.exec("ALTER TABLE read_cursors ADD COLUMN last_read_seq INTEGER NOT NULL DEFAULT 0");
|
|
72
|
+
// Translate each ms cursor to the highest rowid it already covered, so
|
|
73
|
+
// previously-read messages stay read (no re-delivery, no loss).
|
|
74
|
+
database.exec(`UPDATE read_cursors
|
|
75
|
+
SET last_read_seq = COALESCE(
|
|
76
|
+
(SELECT MAX(rowid) FROM messages WHERE messages.ts <= read_cursors.last_read_ts), 0)`);
|
|
77
|
+
database.exec("ALTER TABLE read_cursors DROP COLUMN last_read_ts");
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const initDb = (root) => {
|
|
81
|
+
if (db)
|
|
82
|
+
return db;
|
|
83
|
+
ensureDir(basePath(root));
|
|
84
|
+
const path = dbFile(root);
|
|
85
|
+
db = new Database(path);
|
|
86
|
+
db.pragma("journal_mode = WAL");
|
|
87
|
+
db.pragma("busy_timeout = 5000");
|
|
88
|
+
db.exec(SCHEMA);
|
|
89
|
+
migrateSchema(db);
|
|
90
|
+
return db;
|
|
91
|
+
};
|
|
92
|
+
export const getDb = () => {
|
|
93
|
+
if (!db)
|
|
94
|
+
throw new Error("Database not initialized. Call initDb() first.");
|
|
95
|
+
return db;
|
|
96
|
+
};
|
|
97
|
+
export const closeDb = () => {
|
|
98
|
+
if (db) {
|
|
99
|
+
db.close();
|
|
100
|
+
db = null;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export const execute = (sql, ...params) => {
|
|
104
|
+
getDb().prepare(sql).run(...params);
|
|
105
|
+
};
|
|
106
|
+
export const queryOne = (sql, ...params) => getDb().prepare(sql).get(...params);
|
|
107
|
+
export const queryAll = (sql, ...params) => getDb().prepare(sql).all(...params);
|
|
108
|
+
// IO composition: gather the env override + git common dir, then defer to the
|
|
109
|
+
// pure resolveDbRoot. Both entry points (mcp-entry, cli) call this so every
|
|
110
|
+
// instance — including workers launched inside isolated worktrees — attaches to
|
|
111
|
+
// the one shared intercomm.db at the repo root.
|
|
112
|
+
export const resolveRoot = (cwd) => resolveDbRoot({
|
|
113
|
+
cwd,
|
|
114
|
+
envRoot: process.env[ENV_DB_ROOT],
|
|
115
|
+
gitCommonDir: gitCommonDir(cwd),
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=db.js.map
|
package/dist/db.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM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EAAE;IAChC,IAAI,EAAE,EAAE,CAAC;QACP,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,EAAE,GAAG,IAAI,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,GAAG,MAAiB,EAAQ,EAAE;IACjE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,GAAW,EAAE,GAAG,MAAiB,EAAiB,EAAE,CAC9E,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAkB,CAAC;AAEvD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,GAAW,EAAE,GAAG,MAAiB,EAAO,EAAE,CACpE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAQ,CAAC;AAE7C,8EAA8E;AAC9E,4EAA4E;AAC5E,gFAAgF;AAChF,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE,CACjD,aAAa,CAAC;IACZ,GAAG;IACH,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IACjC,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-wrapper.d.ts","sourceRoot":"","sources":["../src/fs-wrapper.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,KAAG,IAE3C,CAAC;AAIF,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,KAAG,MAChB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Thin IO wrappers — only what's needed for directory creation + file reads
|
|
2
|
+
import { mkdirSync, readFileSync } from "node:fs";
|
|
3
|
+
export const ensureDir = (dirPath) => {
|
|
4
|
+
mkdirSync(dirPath, { recursive: true });
|
|
5
|
+
};
|
|
6
|
+
// Read a UTF-8 text file synchronously. Throws if the path is unreadable —
|
|
7
|
+
// callers that must degrade gracefully wrap this in their own try/catch.
|
|
8
|
+
export const readTextFile = (filePath) => readFileSync(filePath, "utf8");
|
|
9
|
+
//# sourceMappingURL=fs-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-wrapper.js","sourceRoot":"","sources":["../src/fs-wrapper.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAQ,EAAE;IACjD,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,2EAA2E;AAC3E,yEAAyE;AACzE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAU,EAAE,CACvD,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type GitResult = {
|
|
2
|
+
readonly ok: true;
|
|
3
|
+
readonly stdout: string;
|
|
4
|
+
} | {
|
|
5
|
+
readonly ok: false;
|
|
6
|
+
readonly error: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const gitCommonDir: (cwd: string) => string | null;
|
|
9
|
+
export declare const addWorktree: (repoRoot: string, worktreePath: string, base: string) => GitResult;
|
|
10
|
+
export declare const removeWorktree: (repoRoot: string, worktreePath: string, force?: boolean) => GitResult;
|
|
11
|
+
//# sourceMappingURL=git-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-wrapper.d.ts","sourceRoot":"","sources":["../src/git-wrapper.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAwBnD,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAInD,CAAC;AAKF,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,EAChB,cAAc,MAAM,EACpB,MAAM,MAAM,KACX,SACoE,CAAC;AAGxE,eAAO,MAAM,cAAc,GACzB,UAAU,MAAM,EAChB,cAAc,MAAM,EACpB,QAAO,OAAe,KACrB,SAMA,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Thin IO wrappers around the git CLI.
|
|
2
|
+
//
|
|
3
|
+
// Every function here shells out (side effect) and returns data — no logic.
|
|
4
|
+
// InterComm's only git responsibility is filesystem ISOLATION: create and
|
|
5
|
+
// remove worktrees. Branch creation and all merge semantics belong to AIMFP's
|
|
6
|
+
// git directives, run by the agents — InterComm never branches or merges.
|
|
7
|
+
import { execFileSync } from "node:child_process";
|
|
8
|
+
import { isAbsolute, resolve } from "node:path";
|
|
9
|
+
const runGit = (cwd, args) => {
|
|
10
|
+
try {
|
|
11
|
+
const stdout = execFileSync("git", [...args], {
|
|
12
|
+
cwd,
|
|
13
|
+
encoding: "utf8",
|
|
14
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
15
|
+
}).trim();
|
|
16
|
+
return { ok: true, stdout };
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
const msg = err && typeof err === "object" && "stderr" in err && err.stderr
|
|
20
|
+
? String(err.stderr).trim()
|
|
21
|
+
: err instanceof Error
|
|
22
|
+
? err.message
|
|
23
|
+
: String(err);
|
|
24
|
+
return { ok: false, error: msg };
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
// Absolute path to the repo's COMMON git dir (shared by all linked worktrees),
|
|
28
|
+
// or null if cwd is not inside a git repo. `--git-common-dir` can return a path
|
|
29
|
+
// relative to cwd, so normalize it to absolute.
|
|
30
|
+
export const gitCommonDir = (cwd) => {
|
|
31
|
+
const res = runGit(cwd, ["rev-parse", "--git-common-dir"]);
|
|
32
|
+
if (!res.ok)
|
|
33
|
+
return null;
|
|
34
|
+
return isAbsolute(res.stdout) ? res.stdout : resolve(cwd, res.stdout);
|
|
35
|
+
};
|
|
36
|
+
// `git worktree add --detach <path> <base>` — detached HEAD at base's commit.
|
|
37
|
+
// Detached because git refuses to check out a branch (e.g. main) in two
|
|
38
|
+
// worktrees at once; the worker then runs AIMFP git_create_branch inside it.
|
|
39
|
+
export const addWorktree = (repoRoot, worktreePath, base) => runGit(repoRoot, ["worktree", "add", "--detach", worktreePath, base]);
|
|
40
|
+
// `git worktree remove [--force] <path>`.
|
|
41
|
+
export const removeWorktree = (repoRoot, worktreePath, force = false) => runGit(repoRoot, force
|
|
42
|
+
? ["worktree", "remove", "--force", worktreePath]
|
|
43
|
+
: ["worktree", "remove", worktreePath]);
|
|
44
|
+
//# sourceMappingURL=git-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-wrapper.js","sourceRoot":"","sources":["../src/git-wrapper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,EAAE;AACF,4EAA4E;AAC5E,0EAA0E;AAC1E,8EAA8E;AAC9E,0EAA0E;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMhD,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,IAAuB,EAAa,EAAE;IACjE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAA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D,EAAE,CACb,MAAM,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AAExE,0CAA0C;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,QAAgB,EAChB,YAAoB,EACpB,QAAiB,KAAK,EACX,EAAE,CACb,MAAM,CACJ,QAAQ,EACR,KAAK;IACH,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC;IACjD,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,CACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-entry.d.ts","sourceRoot":"","sources":["../src/mcp-entry.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createAndRunServer } from "./mcp-server.js";
|
|
3
|
+
import { resolveRoot } from "./db.js";
|
|
4
|
+
createAndRunServer(resolveRoot(process.cwd())).catch((err) => {
|
|
5
|
+
process.stderr.write(`InterComm AIMFP MCP server error: ${String(err)}\n`);
|
|
6
|
+
process.exit(1);
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=mcp-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-entry.js","sourceRoot":"","sources":["../src/mcp-entry.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,kBAAkB,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IACpE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAkrBA,eAAO,MAAM,kBAAkB,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CAkCnE,CAAC"}
|