@linxiraos/pi-messenger 1.1.0 → 1.3.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/CHANGELOG.md +741 -676
- package/LICENSE +45 -0
- package/README.md +424 -424
- package/THIRD-PARTY-NOTICES.txt +22951 -0
- package/config-overlay.ts +175 -171
- package/config.ts +221 -209
- package/crew/agents/crew-plan-sync.md +66 -64
- package/crew/agents/crew-planner.md +173 -172
- package/crew/agents/crew-reviewer.md +58 -58
- package/crew/agents/crew-worker.md +130 -129
- package/crew/agents.ts +507 -434
- package/crew/handlers/coordination.ts +350 -332
- package/crew/handlers/plan.ts +988 -906
- package/crew/handlers/review.ts +354 -333
- package/crew/handlers/revise.ts +400 -376
- package/crew/handlers/status.ts +303 -295
- package/crew/handlers/sync.ts +237 -233
- package/crew/handlers/task.ts +820 -792
- package/crew/handlers/team.ts +294 -235
- package/crew/handlers/work.ts +467 -425
- package/crew/id-allocator.ts +30 -30
- package/crew/index.ts +297 -257
- package/crew/live-progress.ts +58 -58
- package/crew/lobby.ts +504 -473
- package/crew/prompt.ts +262 -252
- package/crew/registry.ts +114 -114
- package/crew/spawn.ts +135 -111
- package/crew/state-autonomous.ts +163 -164
- package/crew/state-planning.ts +264 -263
- package/crew/state.ts +20 -20
- package/crew/store.ts +646 -642
- package/crew/task-actions.ts +162 -131
- package/crew/team/store.ts +572 -479
- package/crew/team/subagent-roles.ts +105 -87
- package/crew/team/types.ts +50 -50
- package/crew/types.ts +194 -194
- package/crew/utils/artifacts.ts +57 -62
- package/crew/utils/config.ts +158 -156
- package/crew/utils/discover.ts +221 -219
- package/crew/utils/install.ts +94 -85
- package/crew/utils/migrations.ts +126 -0
- package/crew/utils/progress.ts +191 -187
- package/crew/utils/result.ts +16 -16
- package/crew/utils/risk-labels.ts +5 -7
- package/crew/utils/task-format.ts +14 -14
- package/crew/utils/team-roles.ts +44 -28
- package/crew/utils/truncate.ts +76 -79
- package/crew/utils/verdict.ts +55 -55
- package/editor-binary.ts +150 -0
- package/editor-command.ts +107 -0
- package/editor-target.ts +40 -0
- package/feed.ts +321 -268
- package/handlers.ts +1041 -1107
- package/index.ts +1314 -1206
- package/install.mjs +187 -189
- package/lib.ts +587 -467
- package/overlay-actions.ts +519 -511
- package/overlay-coordinator.ts +150 -150
- package/overlay-render.ts +770 -676
- package/overlay.ts +872 -830
- package/package.json +64 -60
- package/paths.ts +60 -0
- package/skills/pi-messenger-crew/SKILL.md +375 -347
- package/store.ts +1147 -1139
- package/teamagent-command.ts +321 -0
- package/vitest.config.ts +10 -10
|
@@ -1,87 +1,105 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export interface DiscoverSubagentRoleOptions {
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function listMarkdownFiles(dir: string): string[] {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function splitList(value: string): string[] {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { TeamRoleDefinition } from "./types.ts";
|
|
4
|
+
import { canonicalPackagedTeamRole, isValidTeamName } from "../utils/team-roles.ts";
|
|
5
|
+
import { getAgentDir } from "@linxiraos/pi-utils/dirs";
|
|
6
|
+
|
|
7
|
+
export interface DiscoverSubagentRoleOptions {
|
|
8
|
+
homeDir?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function listMarkdownFiles(dir: string): string[] {
|
|
12
|
+
if (!fs.existsSync(dir)) return [];
|
|
13
|
+
const out: string[] = [];
|
|
14
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
15
|
+
const full = path.join(dir, entry.name);
|
|
16
|
+
if (entry.isDirectory()) {
|
|
17
|
+
out.push(...listMarkdownFiles(full));
|
|
18
|
+
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
19
|
+
out.push(full);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return out.sort();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function splitList(value: string): string[] {
|
|
26
|
+
const trimmed = value.trim();
|
|
27
|
+
if (!trimmed) return [];
|
|
28
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
29
|
+
return trimmed
|
|
30
|
+
.slice(1, -1)
|
|
31
|
+
.split(",")
|
|
32
|
+
.map(v => v.trim().replace(/^['"]|['"]$/g, ""))
|
|
33
|
+
.filter(Boolean);
|
|
34
|
+
}
|
|
35
|
+
return trimmed
|
|
36
|
+
.split(",")
|
|
37
|
+
.map(v => v.trim())
|
|
38
|
+
.filter(Boolean);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function parseFrontmatter(content: string): { data: Record<string, string>; body: string } {
|
|
42
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
43
|
+
if (!normalized.startsWith("---\n")) return { data: {}, body: normalized };
|
|
44
|
+
const end = normalized.indexOf("\n---", 4);
|
|
45
|
+
if (end === -1) return { data: {}, body: content };
|
|
46
|
+
const raw = normalized.slice(4, end);
|
|
47
|
+
const data: Record<string, string> = {};
|
|
48
|
+
for (const line of raw.split("\n")) {
|
|
49
|
+
const idx = line.indexOf(":");
|
|
50
|
+
if (idx <= 0) continue;
|
|
51
|
+
const key = line.slice(0, idx).trim();
|
|
52
|
+
const value = line
|
|
53
|
+
.slice(idx + 1)
|
|
54
|
+
.trim()
|
|
55
|
+
.replace(/^['"]|['"]$/g, "");
|
|
56
|
+
if (key) data[key] = value;
|
|
57
|
+
}
|
|
58
|
+
const bodyStart = normalized.indexOf("\n", end + 4);
|
|
59
|
+
return { data, body: bodyStart === -1 ? "" : normalized.slice(bodyStart + 1).trim() };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function readRoleFile(filePath: string, sourceLabel: string): TeamRoleDefinition | null {
|
|
63
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
64
|
+
const { data, body } = parseFrontmatter(content);
|
|
65
|
+
const rawName = data.name || path.basename(filePath, ".md");
|
|
66
|
+
if (!isValidTeamName(rawName)) return null;
|
|
67
|
+
const name = canonicalPackagedTeamRole(rawName) ?? rawName;
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
name,
|
|
71
|
+
...(data.description ? { description: data.description } : {}),
|
|
72
|
+
...(data.model ? { model: data.model } : {}),
|
|
73
|
+
...(data.thinking ? { thinking: data.thinking } : {}),
|
|
74
|
+
...((data.skills ?? data.autoloadSkills) ? { skills: splitList(data.skills ?? data.autoloadSkills) } : {}),
|
|
75
|
+
...(body ? { prompt: body.slice(0, 4000) } : {}),
|
|
76
|
+
promptSource: `${sourceLabel}:${name}`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function discoverSubagentRoles(
|
|
81
|
+
cwd: string,
|
|
82
|
+
options?: DiscoverSubagentRoleOptions,
|
|
83
|
+
): Record<string, TeamRoleDefinition> {
|
|
84
|
+
// Under zeta, user agents live in ~/.zeta/agent/agents and project agents
|
|
85
|
+
// in <project>/.zeta/agents — the same directories runtime discovery
|
|
86
|
+
// reads. (.agents is the pre-zeta upstream layout, kept for compatibility.)
|
|
87
|
+
// An explicit homeDir is a test seam mirroring the default layout.
|
|
88
|
+
const userAgentsDir = options?.homeDir
|
|
89
|
+
? path.join(options.homeDir, ".zeta", "agent", "agents")
|
|
90
|
+
: path.join(getAgentDir(), "agents");
|
|
91
|
+
const sources = [
|
|
92
|
+
{ dir: userAgentsDir, label: "subagent:user" },
|
|
93
|
+
{ dir: path.join(cwd, ".zeta", "agents"), label: "subagent:project" },
|
|
94
|
+
{ dir: path.join(cwd, ".agents"), label: "subagent:legacy-project" },
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const roles: Record<string, TeamRoleDefinition> = {};
|
|
98
|
+
for (const source of sources) {
|
|
99
|
+
for (const file of listMarkdownFiles(source.dir)) {
|
|
100
|
+
const role = readRoleFile(file, source.label);
|
|
101
|
+
if (role) roles[role.name] = { ...roles[role.name], ...role };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return roles;
|
|
105
|
+
}
|
package/crew/team/types.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
export const TEAM_MEMORY_TYPES = ["decision", "interface", "risk", "handoff"] as const;
|
|
2
|
-
|
|
3
|
-
export type TeamMemoryType = typeof TEAM_MEMORY_TYPES[number];
|
|
4
|
-
|
|
5
|
-
export interface TeamState {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface TeamRoleDefinition {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface TeamProfile {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface TeamMemoryEntry {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface TeamPromptContext {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
1
|
+
export const TEAM_MEMORY_TYPES = ["decision", "interface", "risk", "handoff"] as const;
|
|
2
|
+
|
|
3
|
+
export type TeamMemoryType = (typeof TEAM_MEMORY_TYPES)[number];
|
|
4
|
+
|
|
5
|
+
export interface TeamState {
|
|
6
|
+
name: string;
|
|
7
|
+
profile?: string;
|
|
8
|
+
created_at: string;
|
|
9
|
+
updated_at: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TeamRoleDefinition {
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
model?: string;
|
|
16
|
+
thinking?: string;
|
|
17
|
+
skills?: string[];
|
|
18
|
+
prompt?: string;
|
|
19
|
+
promptSource?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TeamProfile {
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
roles?: Record<string, Partial<TeamRoleDefinition>>;
|
|
26
|
+
approval?: {
|
|
27
|
+
mode?: "off" | "risk-labels";
|
|
28
|
+
labels?: string[];
|
|
29
|
+
};
|
|
30
|
+
memory?: {
|
|
31
|
+
inject?: TeamMemoryType[];
|
|
32
|
+
maxCharsPerType?: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TeamMemoryEntry {
|
|
37
|
+
ts: string;
|
|
38
|
+
agent: string;
|
|
39
|
+
type: TeamMemoryType;
|
|
40
|
+
message: string;
|
|
41
|
+
taskId?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TeamPromptContext {
|
|
45
|
+
team?: TeamState;
|
|
46
|
+
profile?: TeamProfile;
|
|
47
|
+
role?: TeamRoleDefinition;
|
|
48
|
+
charter?: string;
|
|
49
|
+
memory: Partial<Record<TeamMemoryType, TeamMemoryEntry[]>>;
|
|
50
|
+
}
|