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.
Files changed (59) hide show
  1. package/README.md +353 -0
  2. package/dist/claude-tui.d.ts +7 -0
  3. package/dist/claude-tui.d.ts.map +1 -0
  4. package/dist/claude-tui.js +55 -0
  5. package/dist/claude-tui.js.map +1 -0
  6. package/dist/cli.d.ts +3 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +144 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/config.d.ts +14 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +44 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/db.d.ts +9 -0
  15. package/dist/db.d.ts.map +1 -0
  16. package/dist/db.js +117 -0
  17. package/dist/db.js.map +1 -0
  18. package/dist/fs-wrapper.d.ts +3 -0
  19. package/dist/fs-wrapper.d.ts.map +1 -0
  20. package/dist/fs-wrapper.js +9 -0
  21. package/dist/fs-wrapper.js.map +1 -0
  22. package/dist/git-wrapper.d.ts +11 -0
  23. package/dist/git-wrapper.d.ts.map +1 -0
  24. package/dist/git-wrapper.js +44 -0
  25. package/dist/git-wrapper.js.map +1 -0
  26. package/dist/mcp-entry.d.ts +3 -0
  27. package/dist/mcp-entry.d.ts.map +1 -0
  28. package/dist/mcp-entry.js +8 -0
  29. package/dist/mcp-entry.js.map +1 -0
  30. package/dist/mcp-server.d.ts +2 -0
  31. package/dist/mcp-server.d.ts.map +1 -0
  32. package/dist/mcp-server.js +557 -0
  33. package/dist/mcp-server.js.map +1 -0
  34. package/dist/orchestrate.d.ts +52 -0
  35. package/dist/orchestrate.d.ts.map +1 -0
  36. package/dist/orchestrate.js +226 -0
  37. package/dist/orchestrate.js.map +1 -0
  38. package/dist/protocol.d.ts +3 -0
  39. package/dist/protocol.d.ts.map +1 -0
  40. package/dist/protocol.js +33 -0
  41. package/dist/protocol.js.map +1 -0
  42. package/dist/store.d.ts +26 -0
  43. package/dist/store.d.ts.map +1 -0
  44. package/dist/store.js +186 -0
  45. package/dist/store.js.map +1 -0
  46. package/dist/task-contract.d.ts +4 -0
  47. package/dist/task-contract.d.ts.map +1 -0
  48. package/dist/task-contract.js +111 -0
  49. package/dist/task-contract.js.map +1 -0
  50. package/dist/tmux-wrapper.d.ts +17 -0
  51. package/dist/tmux-wrapper.d.ts.map +1 -0
  52. package/dist/tmux-wrapper.js +66 -0
  53. package/dist/tmux-wrapper.js.map +1 -0
  54. package/dist/types.d.ts +92 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/types.js +56 -0
  57. package/dist/types.js.map +1 -0
  58. package/package.json +35 -0
  59. package/system-prompt.md +245 -0
@@ -0,0 +1,111 @@
1
+ // Task contract serialize/parse (Phase 2: directive-driven tasking).
2
+ //
3
+ // Thin-pointer model: a master serializes a TaskContract into a message's
4
+ // content with buildTaskContract; a worker recovers it with parseTaskContract.
5
+ // The contract is a POINTER to an AIMFP work entity, not a prose instruction —
6
+ // the worker runs aimfp_run in its own clone and continues that entity normally.
7
+ // InterComm stays AIMFP-agnostic: it never resolves aimfp_target and never reads
8
+ // project.db; it only carries this string as opaque message content. Pure
9
+ // functions only, no IO.
10
+ // Discriminator + version embedded in the serialized JSON so parseTaskContract
11
+ // can distinguish a task contract from arbitrary message content and reject the
12
+ // superseded prose shape (v1) and any incompatible future shapes.
13
+ const CONTRACT_KIND = "task_contract";
14
+ const CONTRACT_VERSION = 2;
15
+ // The AIMFP tables a pointer may reference (mirrors AimfpTargetType).
16
+ const AIMFP_TARGET_TYPES = [
17
+ "task",
18
+ "milestone",
19
+ "subtask",
20
+ "sidequest",
21
+ "item",
22
+ ];
23
+ const isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
24
+ const isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
25
+ // Validate the pointer: a known type plus at least one of id (number) | slug
26
+ // (non-empty string). Returns the typed target or an error reason.
27
+ const parseAimfpTarget = (value) => {
28
+ if (typeof value !== "object" || value === null) {
29
+ return { ok: false, error: "aimfp_target must be an object" };
30
+ }
31
+ const obj = value;
32
+ if (!AIMFP_TARGET_TYPES.includes(obj.type)) {
33
+ return {
34
+ ok: false,
35
+ error: `aimfp_target.type must be one of ${AIMFP_TARGET_TYPES.join(", ")}`,
36
+ };
37
+ }
38
+ const hasId = typeof obj.id === "number" && Number.isInteger(obj.id);
39
+ const hasSlug = isNonEmptyString(obj.slug);
40
+ if (!hasId && !hasSlug) {
41
+ return {
42
+ ok: false,
43
+ error: "aimfp_target must have an integer id or a non-empty slug",
44
+ };
45
+ }
46
+ return {
47
+ ok: true,
48
+ target: {
49
+ type: obj.type,
50
+ ...(hasId ? { id: obj.id } : {}),
51
+ ...(hasSlug ? { slug: obj.slug } : {}),
52
+ },
53
+ };
54
+ };
55
+ // Master-side: serialize a thin-pointer contract into messages.content.
56
+ export const buildTaskContract = (contract) => JSON.stringify({
57
+ kind: CONTRACT_KIND,
58
+ v: CONTRACT_VERSION,
59
+ role: contract.role,
60
+ role_instructions: contract.role_instructions,
61
+ aimfp_target: contract.aimfp_target,
62
+ reportBack: contract.reportBack,
63
+ });
64
+ // Worker-side: parse + validate a content string into a TaskContract. Never
65
+ // throws — returns {ok:false, error} for any non-contract, malformed, or
66
+ // superseded (v1) input.
67
+ export const parseTaskContract = (content) => {
68
+ let raw;
69
+ try {
70
+ raw = JSON.parse(content);
71
+ }
72
+ catch {
73
+ return { ok: false, error: "content is not valid JSON" };
74
+ }
75
+ if (typeof raw !== "object" || raw === null) {
76
+ return { ok: false, error: "content is not a task contract object" };
77
+ }
78
+ const obj = raw;
79
+ if (obj.kind !== CONTRACT_KIND) {
80
+ return { ok: false, error: "content is not a task contract" };
81
+ }
82
+ if (obj.v !== CONTRACT_VERSION) {
83
+ return {
84
+ ok: false,
85
+ error: `unsupported task contract version: ${String(obj.v)}`,
86
+ };
87
+ }
88
+ if (!isNonEmptyString(obj.role)) {
89
+ return { ok: false, error: "role must be a non-empty string" };
90
+ }
91
+ if (!isNonEmptyString(obj.role_instructions)) {
92
+ return { ok: false, error: "role_instructions must be a non-empty string" };
93
+ }
94
+ if (!isStringArray(obj.reportBack)) {
95
+ return { ok: false, error: "reportBack must be an array of strings" };
96
+ }
97
+ const target = parseAimfpTarget(obj.aimfp_target);
98
+ if (!target.ok) {
99
+ return { ok: false, error: target.error };
100
+ }
101
+ return {
102
+ ok: true,
103
+ contract: {
104
+ role: obj.role,
105
+ role_instructions: obj.role_instructions,
106
+ aimfp_target: target.target,
107
+ reportBack: obj.reportBack,
108
+ },
109
+ };
110
+ };
111
+ //# sourceMappingURL=task-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-contract.js","sourceRoot":"","sources":["../src/task-contract.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,+EAA+E;AAC/E,iFAAiF;AACjF,iFAAiF;AACjF,0EAA0E;AAC1E,yBAAyB;AASzB,+EAA+E;AAC/E,gFAAgF;AAChF,kEAAkE;AAClE,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,sEAAsE;AACtE,MAAM,kBAAkB,GAA+B;IACrD,MAAM;IACN,WAAW;IACX,SAAS;IACT,WAAW;IACX,MAAM;CACP,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,KAAc,EAAqB,EAAE,CAC1D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AAE1E,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAmB,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAEvD,6EAA6E;AAC7E,mEAAmE;AACnE,MAAM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C;IACD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,8CAA8C,EAAE,CAAC;IAC9E,CAAC;IACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,wCAAwC,EAAE,CAAC;IACxE,CAAC;IAED,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,QAAQ,EAAE;YACR,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,YAAY,EAAE,MAAM,CAAC,MAAM;YAC3B,UAAU,EAAE,GAAG,CAAC,UAAU;SAC3B;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ export type TmuxResult = {
2
+ readonly ok: true;
3
+ readonly stdout: string;
4
+ } | {
5
+ readonly ok: false;
6
+ readonly error: string;
7
+ };
8
+ export declare const newSession: (name: string, cwd: string, width?: number, height?: number) => TmuxResult;
9
+ export declare const sendKeys: (target: string, keys: readonly string[], literal?: boolean) => TmuxResult;
10
+ export declare const capturePane: (target: string) => TmuxResult;
11
+ export declare const hasSession: (name: string) => TmuxResult;
12
+ export declare const listSessions: () => TmuxResult;
13
+ export declare const killSession: (name: string) => TmuxResult;
14
+ export declare const displayMessage: (target: string, format: string) => TmuxResult;
15
+ export declare const splitLines: (stdout: string) => readonly string[];
16
+ export declare const currentPaneTarget: () => string;
17
+ //# sourceMappingURL=tmux-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tmux-wrapper.d.ts","sourceRoot":"","sources":["../src/tmux-wrapper.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,UAAU,GAClB;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;AAsBnD,eAAO,MAAM,UAAU,GACrB,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,QAAO,MAAY,EACnB,SAAQ,MAAW,KAClB,UAOC,CAAC;AAKL,eAAO,MAAM,QAAQ,GACnB,QAAQ,MAAM,EACd,MAAM,SAAS,MAAM,EAAE,EACvB,UAAS,OAAe,KACvB,UAGwC,CAAC;AAG5C,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,KAAG,UACE,CAAC;AAIhD,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,UACE,CAAC;AAI7C,eAAO,MAAM,YAAY,QAAO,UACqB,CAAC;AAGtD,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,UACJ,CAAC;AAIxC,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,UACN,CAAC;AAG3D,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,SAAS,MAAM,EACU,CAAC;AAMtE,eAAO,MAAM,iBAAiB,QAAO,MAKpC,CAAC"}
@@ -0,0 +1,66 @@
1
+ // Thin IO wrappers around the tmux CLI.
2
+ //
3
+ // Every function shells out (side effect) and returns data — no logic. Mirrors
4
+ // git-wrapper.ts in shape: each call returns a TmuxResult discriminated union and
5
+ // never throws. The pure decisions about WHAT to send (which keys clear which
6
+ // dialog) live in claude-tui.ts; this module only carries them to tmux.
7
+ import { execFileSync } from "node:child_process";
8
+ const runTmux = (args) => {
9
+ try {
10
+ const stdout = execFileSync("tmux", [...args], {
11
+ encoding: "utf8",
12
+ stdio: ["ignore", "pipe", "pipe"],
13
+ }).trim();
14
+ return { ok: true, stdout };
15
+ }
16
+ catch (err) {
17
+ const msg = err && typeof err === "object" && "stderr" in err && err.stderr
18
+ ? String(err.stderr).trim()
19
+ : err instanceof Error
20
+ ? err.message
21
+ : String(err);
22
+ return { ok: false, error: msg };
23
+ }
24
+ };
25
+ // `tmux new-session -d -s <name> -x <w> -y <h> -c <cwd>` — detached session,
26
+ // fixed geometry so capture-pane output is stable for dialog detection.
27
+ export const newSession = (name, cwd, width = 220, height = 50) => runTmux([
28
+ "new-session", "-d",
29
+ "-s", name,
30
+ "-x", String(width),
31
+ "-y", String(height),
32
+ "-c", cwd,
33
+ ]);
34
+ // `tmux send-keys -t <target> [-l] <keys...>`. With literal=true the keys are
35
+ // sent as raw text (the `-l` flag, for prompt strings); otherwise each entry is
36
+ // a tmux key NAME (e.g. "Enter", "1"), so callers can mix characters and keys.
37
+ export const sendKeys = (target, keys, literal = false) => runTmux(literal
38
+ ? ["send-keys", "-t", target, "-l", ...keys]
39
+ : ["send-keys", "-t", target, ...keys]);
40
+ // `tmux capture-pane -t <target> -p` — dump the pane's visible text.
41
+ export const capturePane = (target) => runTmux(["capture-pane", "-t", target, "-p"]);
42
+ // `tmux has-session -t =<name>` — ok:true iff a session with exactly this name
43
+ // exists (the `=` forces an exact match, not a prefix match).
44
+ export const hasSession = (name) => runTmux(["has-session", "-t", `=${name}`]);
45
+ // `tmux list-sessions -F '#{session_name}'` — ok carries newline-joined names
46
+ // ("" when the server has no sessions). Use splitLines to get an array.
47
+ export const listSessions = () => runTmux(["list-sessions", "-F", "#{session_name}"]);
48
+ // `tmux kill-session -t <name>`.
49
+ export const killSession = (name) => runTmux(["kill-session", "-t", name]);
50
+ // `tmux display-message -p -t <target> <format>` — resolve a format string
51
+ // (e.g. '#S:#I.#P' -> 'worker-1:0.0') for the given pane/target.
52
+ export const displayMessage = (target, format) => runTmux(["display-message", "-p", "-t", target, format]);
53
+ // Pure: split list-sessions stdout into trimmed, non-empty session names.
54
+ export const splitLines = (stdout) => stdout.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
55
+ // IO: resolve THIS process's own pane target ('<session>:<window>.<pane>') from
56
+ // $TMUX_PANE, so an instance can record where it lives at register time. Returns
57
+ // '' when not running inside tmux (or the lookup fails) — a non-tmux instance
58
+ // simply has no wakeable target.
59
+ export const currentPaneTarget = () => {
60
+ const pane = process.env.TMUX_PANE;
61
+ if (!pane)
62
+ return "";
63
+ const res = displayMessage(pane, "#S:#I.#P");
64
+ return res.ok ? res.stdout : "";
65
+ };
66
+ //# sourceMappingURL=tmux-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tmux-wrapper.js","sourceRoot":"","sources":["../src/tmux-wrapper.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,+EAA+E;AAC/E,kFAAkF;AAClF,8EAA8E;AAC9E,wEAAwE;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlD,MAAM,OAAO,GAAG,CAAC,IAAuB,EAAc,EAAE;IACtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;YAC7C,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;SAClC,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GACP,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM;YAC7D,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,C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92 @@
1
+ export type Role = "master" | "worker";
2
+ export type MessageType = "task" | "status" | "question" | "answer" | "announce" | "done";
3
+ export type Instance = {
4
+ readonly id: string;
5
+ readonly role: Role;
6
+ readonly active: boolean;
7
+ readonly lastActive: number;
8
+ readonly registeredAt: number;
9
+ readonly sessionId: string;
10
+ readonly tmuxTarget: string;
11
+ };
12
+ export type Message = {
13
+ readonly id: string;
14
+ readonly fromId: string;
15
+ readonly toId: string;
16
+ readonly type: MessageType;
17
+ readonly content: string;
18
+ readonly ts: number;
19
+ };
20
+ export type ReadCursor = {
21
+ readonly instanceId: string;
22
+ readonly lastReadSeq: number;
23
+ };
24
+ export type InstanceRow = {
25
+ id: string;
26
+ role: string;
27
+ active: number;
28
+ last_active: number;
29
+ registered_at: number;
30
+ session_id: string;
31
+ tmux_target: string;
32
+ };
33
+ export type MessageRow = {
34
+ id: string;
35
+ from_id: string;
36
+ to_id: string;
37
+ type: string;
38
+ content: string;
39
+ ts: number;
40
+ };
41
+ export type CursorRow = {
42
+ instance_id: string;
43
+ last_read_seq: number;
44
+ };
45
+ export declare const instanceFromRow: (row: InstanceRow) => Instance;
46
+ export declare const messageFromRow: (row: MessageRow) => Message;
47
+ export type ParsedArgs = {
48
+ readonly command: string;
49
+ readonly positional: readonly string[];
50
+ readonly flags: Readonly<Record<string, string | boolean>>;
51
+ };
52
+ export type AimfpTargetType = "task" | "milestone" | "subtask" | "sidequest" | "item";
53
+ export type AimfpTarget = {
54
+ readonly type: AimfpTargetType;
55
+ readonly id?: number;
56
+ readonly slug?: string;
57
+ };
58
+ export type TaskContract = {
59
+ readonly role: string;
60
+ readonly role_instructions: string;
61
+ readonly aimfp_target: AimfpTarget;
62
+ readonly reportBack: readonly string[];
63
+ };
64
+ export type ParsedTaskContract = {
65
+ readonly ok: true;
66
+ readonly contract: TaskContract;
67
+ } | {
68
+ readonly ok: false;
69
+ readonly error: string;
70
+ };
71
+ export declare const WORKTREE_STATUSES: readonly ["active", "done", "queued", "merging", "verifying", "merged", "conflict", "failed", "removed"];
72
+ export type WorktreeStatus = (typeof WORKTREE_STATUSES)[number];
73
+ export type Worktree = {
74
+ readonly workerId: string;
75
+ readonly branch: string;
76
+ readonly path: string;
77
+ readonly base: string;
78
+ readonly status: WorktreeStatus;
79
+ readonly createdAt: number;
80
+ readonly updatedAt: number;
81
+ };
82
+ export type WorktreeRow = {
83
+ worker_id: string;
84
+ branch: string;
85
+ path: string;
86
+ base: string;
87
+ status: string;
88
+ created_at: number;
89
+ updated_at: number;
90
+ };
91
+ export declare const worktreeFromRow: (row: WorktreeRow) => Worktree;
92
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEvC,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,UAAU,GACV,MAAM,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;I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,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,KAAK,WAAW,KAAG,QAQjD,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,56 @@
1
+ // Data contracts for InterComm AIMFP
2
+ // Conversion helpers (pure)
3
+ export const instanceFromRow = (row) => ({
4
+ id: row.id,
5
+ role: row.role,
6
+ active: row.active === 1,
7
+ lastActive: row.last_active,
8
+ registeredAt: row.registered_at,
9
+ sessionId: row.session_id,
10
+ tmuxTarget: row.tmux_target,
11
+ });
12
+ export const messageFromRow = (row) => ({
13
+ id: row.id,
14
+ fromId: row.from_id,
15
+ toId: row.to_id,
16
+ type: row.type,
17
+ content: row.content,
18
+ ts: row.ts,
19
+ });
20
+ // --- Worktree registry (multi-agent parallelization addon) ---
21
+ //
22
+ // Single source of truth for the worktree lifecycle. The status set is a
23
+ // superset informed by ctx's agent merge queue (queued / verifying / conflict)
24
+ // layered onto the original design states. InterComm only TRACKS these — it
25
+ // never merges; AIMFP git directives own the actual branch/merge semantics.
26
+ //
27
+ // active — worker is editing inside its worktree
28
+ // done — worker reported its task complete (ready to submit)
29
+ // queued — submitted to the master's merge queue, awaiting its turn
30
+ // merging — master is merging the branch (AIMFP git_merge_branch)
31
+ // verifying — verification command running on the merged result (ctx gate)
32
+ // merged — applied + verified; target branch advanced
33
+ // conflict — could not apply cleanly on the latest target; back for revision
34
+ // failed — applied but verification failed (or an execution error)
35
+ // removed — worktree torn down
36
+ export const WORKTREE_STATUSES = [
37
+ "active",
38
+ "done",
39
+ "queued",
40
+ "merging",
41
+ "verifying",
42
+ "merged",
43
+ "conflict",
44
+ "failed",
45
+ "removed",
46
+ ];
47
+ export const worktreeFromRow = (row) => ({
48
+ workerId: row.worker_id,
49
+ branch: row.branch,
50
+ path: row.path,
51
+ base: row.base,
52
+ status: row.status,
53
+ createdAt: row.created_at,
54
+ updatedAt: row.updated_at,
55
+ });
56
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qCAAqC;AA6DrC,4BAA4B;AAC5B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAgB,EAAY,EAAE,CAAC,CAAC;IAC9D,EAAE,EAAE,GAAG,CAAC,EAAE;IACV,IAAI,EAAE,GAAG,CAAC,IAAY;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,CAAC;IACxB,UAAU,EAAE,GAAG,CAAC,WAAW;IAC3B,YAAY,EAAE,GAAG,CAAC,aAAa;IAC/B,SAAS,EAAE,GAAG,CAAC,UAAU;IACzB,UAAU,EAAE,GAAG,CAAC,WAAW;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAe,EAAW,EAAE,CAAC,CAAC;IAC3D,EAAE,EAAE,GAAG,CAAC,EAAE;IACV,MAAM,EAAE,GAAG,CAAC,OAAO;IACnB,IAAI,EAAE,GAAG,CAAC,KAAK;IACf,IAAI,EAAE,GAAG,CAAC,IAAmB;IAC7B,OAAO,EAAE,GAAG,CAAC,OAAO;IACpB,EAAE,EAAE,GAAG,CAAC,EAAE;CACX,CAAC,CAAC;AAqDH,gEAAgE;AAChE,EAAE;AACF,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,4EAA4E;AAC5E,EAAE;AACF,sDAAsD;AACtD,oEAAoE;AACpE,yEAAyE;AACzE,sEAAsE;AACtE,6EAA6E;AAC7E,2DAA2D;AAC3D,gFAAgF;AAChF,wEAAwE;AACxE,mCAAmC;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,SAAS;IACT,WAAW;IACX,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,SAAS;CACD,CAAC;AAwBX,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAgB,EAAY,EAAE,CAAC,CAAC;IAC9D,QAAQ,EAAE,GAAG,CAAC,SAAS;IACvB,MAAM,EAAE,GAAG,CAAC,MAAM;IAClB,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,MAAM,EAAE,GAAG,CAAC,MAAwB;IACpC,SAAS,EAAE,GAAG,CAAC,UAAU;IACzB,SAAS,EAAE,GAAG,CAAC,UAAU;CAC1B,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "intercomm-aimfp",
3
+ "version": "0.4.0",
4
+ "description": "Local intercommunication system for coordinating multiple Claude Code instances via SQLite",
5
+ "type": "module",
6
+ "main": "dist/cli.js",
7
+ "bin": {
8
+ "intercomm": "dist/cli.js",
9
+ "intercomm-mcp": "dist/mcp-entry.js"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "dev": "tsc --watch"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "system-prompt.md"
18
+ ],
19
+ "keywords": [
20
+ "claude",
21
+ "ipc",
22
+ "coordination"
23
+ ],
24
+ "license": "MIT",
25
+ "devDependencies": {
26
+ "@types/better-sqlite3": "^7.6.13",
27
+ "@types/node": "^25.3.3",
28
+ "typescript": "^5.9.3"
29
+ },
30
+ "dependencies": {
31
+ "@modelcontextprotocol/sdk": "^1.27.1",
32
+ "better-sqlite3": "^12.6.2",
33
+ "zod": "^4.3.6"
34
+ }
35
+ }