crewbee 0.1.8 → 0.1.9
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/dist/opencode-plugin.mjs +159 -18
- package/dist/src/agent-teams/filesystem.d.ts +11 -1
- package/dist/src/agent-teams/filesystem.d.ts.map +1 -1
- package/dist/src/agent-teams/filesystem.js +135 -10
- package/dist/src/agent-teams/filesystem.js.map +1 -1
- package/dist/src/agent-teams/library.d.ts.map +1 -1
- package/dist/src/agent-teams/library.js +32 -1
- package/dist/src/agent-teams/library.js.map +1 -1
- package/package.json +2 -1
- package/templates/crewbee.json +24 -0
- package/templates/teams/general-team/README.md +27 -0
- package/templates/teams/general-team/TEAM.md +37 -0
- package/templates/teams/general-team/general-analyst.agent.md +107 -0
- package/templates/teams/general-team/general-editor.agent.md +107 -0
- package/templates/teams/general-team/general-leader.agent.md +138 -0
- package/templates/teams/general-team/general-operator.agent.md +123 -0
- package/templates/teams/general-team/general-researcher.agent.md +116 -0
- package/templates/teams/general-team/general-writer.agent.md +122 -0
- package/templates/teams/general-team/team.manifest.yaml +119 -0
- package/templates/teams/general-team/team.policy.yaml +40 -0
- package/templates/teams/template-team/TEAM.md +71 -0
- package/templates/teams/template-team/executor.agent.md +294 -0
- package/templates/teams/template-team/leader.agent.md +336 -0
- package/templates/teams/template-team/researcher.agent.md +287 -0
- package/templates/teams/template-team/team.manifest.yaml +132 -0
- package/templates/teams/template-team/team.policy.yaml +49 -0
- package/templates/teams/wukong-team/README.md +26 -0
- package/templates/teams/wukong-team/TEAM.md +36 -0
- package/templates/teams/wukong-team/team.manifest.yaml +110 -0
- package/templates/teams/wukong-team/team.policy.yaml +40 -0
- package/templates/teams/wukong-team/wukong-bajie.agent.md +107 -0
- package/templates/teams/wukong-team/wukong-dragon.agent.md +123 -0
- package/templates/teams/wukong-team/wukong-leader.agent.md +133 -0
- package/templates/teams/wukong-team/wukong-monk.agent.md +107 -0
- package/templates/teams/wukong-team/wukong-wujing.agent.md +123 -0
package/dist/opencode-plugin.mjs
CHANGED
|
@@ -7325,6 +7325,7 @@ var require_dist = __commonJS({
|
|
|
7325
7325
|
});
|
|
7326
7326
|
|
|
7327
7327
|
// src/agent-teams/constants.ts
|
|
7328
|
+
var TEAM_CONFIG_ROOT = "teams";
|
|
7328
7329
|
var CREWBEE_CONFIG_FILE = "crewbee.json";
|
|
7329
7330
|
var BUILTIN_CODING_TEAM_ID = "coding-team";
|
|
7330
7331
|
var DEFAULT_EMBEDDED_TEAM_PRIORITY = 0;
|
|
@@ -9631,7 +9632,7 @@ function createEmbeddedCodingTeam() {
|
|
|
9631
9632
|
}
|
|
9632
9633
|
|
|
9633
9634
|
// src/agent-teams/filesystem.ts
|
|
9634
|
-
import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, readdirSync as readdirSync2, writeFileSync } from "node:fs";
|
|
9635
|
+
import { cpSync, existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, readdirSync as readdirSync2, writeFileSync } from "node:fs";
|
|
9635
9636
|
import os2 from "node:os";
|
|
9636
9637
|
import path3 from "node:path";
|
|
9637
9638
|
|
|
@@ -10486,13 +10487,16 @@ function getOptionalPriority(value, fallback) {
|
|
|
10486
10487
|
function getOptionalString(value) {
|
|
10487
10488
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
10488
10489
|
}
|
|
10489
|
-
function createDefaultCodingTeamSource() {
|
|
10490
|
+
function createDefaultCodingTeamSource(input) {
|
|
10490
10491
|
return {
|
|
10491
10492
|
kind: "embedded",
|
|
10492
10493
|
teamId: BUILTIN_CODING_TEAM_ID,
|
|
10493
10494
|
enabled: true,
|
|
10494
10495
|
priority: DEFAULT_EMBEDDED_TEAM_PRIORITY,
|
|
10495
|
-
order: -1
|
|
10496
|
+
order: -1,
|
|
10497
|
+
sourceScope: input.sourceScope,
|
|
10498
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
10499
|
+
configPath: input.configPath
|
|
10496
10500
|
};
|
|
10497
10501
|
}
|
|
10498
10502
|
function createDefaultCodingTeamConfigEntry() {
|
|
@@ -10502,7 +10506,49 @@ function createDefaultCodingTeamConfigEntry() {
|
|
|
10502
10506
|
priority: DEFAULT_EMBEDDED_TEAM_PRIORITY
|
|
10503
10507
|
};
|
|
10504
10508
|
}
|
|
10509
|
+
function getPackagedTemplateRootPath() {
|
|
10510
|
+
const candidates = [
|
|
10511
|
+
// Runtime bundle: dist/opencode-plugin.mjs, with __dirname pointing at dist.
|
|
10512
|
+
path3.resolve(__dirname, "..", "templates"),
|
|
10513
|
+
// Compiled module tests / direct imports: dist/src/agent-teams/filesystem.js.
|
|
10514
|
+
path3.resolve(__dirname, "../../..", "templates")
|
|
10515
|
+
];
|
|
10516
|
+
return candidates.find((candidate) => existsSync3(candidate));
|
|
10517
|
+
}
|
|
10518
|
+
function getPackagedCrewBeeConfigTemplatePath() {
|
|
10519
|
+
const templateRoot = getPackagedTemplateRootPath();
|
|
10520
|
+
return templateRoot ? path3.join(templateRoot, CREWBEE_CONFIG_FILE) : void 0;
|
|
10521
|
+
}
|
|
10522
|
+
function ensurePackagedTeamTemplates(configRoot, dryRun) {
|
|
10523
|
+
const templateRoot = getPackagedTemplateRootPath();
|
|
10524
|
+
if (!templateRoot) {
|
|
10525
|
+
return;
|
|
10526
|
+
}
|
|
10527
|
+
const packagedTeamsRoot = path3.join(templateRoot, TEAM_CONFIG_ROOT);
|
|
10528
|
+
if (!existsSync3(packagedTeamsRoot) || dryRun) {
|
|
10529
|
+
return;
|
|
10530
|
+
}
|
|
10531
|
+
cpSync(packagedTeamsRoot, path3.join(configRoot, TEAM_CONFIG_ROOT), {
|
|
10532
|
+
errorOnExist: false,
|
|
10533
|
+
force: false,
|
|
10534
|
+
recursive: true
|
|
10535
|
+
});
|
|
10536
|
+
}
|
|
10537
|
+
function isCrewBeeConfigFile(value) {
|
|
10538
|
+
return isRecord3(value) && Array.isArray(value.teams);
|
|
10539
|
+
}
|
|
10505
10540
|
function createDefaultCrewBeeConfig() {
|
|
10541
|
+
const templatePath = getPackagedCrewBeeConfigTemplatePath();
|
|
10542
|
+
if (templatePath) {
|
|
10543
|
+
try {
|
|
10544
|
+
const parsed = JSON.parse(readFileSync2(templatePath, "utf8"));
|
|
10545
|
+
if (isCrewBeeConfigFile(parsed)) {
|
|
10546
|
+
return parsed;
|
|
10547
|
+
}
|
|
10548
|
+
} catch (error45) {
|
|
10549
|
+
void error45;
|
|
10550
|
+
}
|
|
10551
|
+
}
|
|
10506
10552
|
return {
|
|
10507
10553
|
teams: [createDefaultCodingTeamConfigEntry()]
|
|
10508
10554
|
};
|
|
@@ -10567,6 +10613,7 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10567
10613
|
const configPath = resolveCrewBeeConfigPath(configRoot);
|
|
10568
10614
|
if (!existsSync3(configPath)) {
|
|
10569
10615
|
if (!input.dryRun) {
|
|
10616
|
+
ensurePackagedTeamTemplates(configRoot);
|
|
10570
10617
|
writeCrewBeeConfig(configPath, createDefaultCrewBeeConfig());
|
|
10571
10618
|
}
|
|
10572
10619
|
return {
|
|
@@ -10579,6 +10626,7 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10579
10626
|
if (!parsed.valid || !parsed.config) {
|
|
10580
10627
|
const backupPath = !input.dryRun && parsed.rawText !== void 0 ? backupCrewBeeConfig(configPath, parsed.rawText) : void 0;
|
|
10581
10628
|
if (!input.dryRun) {
|
|
10629
|
+
ensurePackagedTeamTemplates(configRoot);
|
|
10582
10630
|
writeCrewBeeConfig(configPath, createDefaultCrewBeeConfig());
|
|
10583
10631
|
}
|
|
10584
10632
|
return {
|
|
@@ -10661,7 +10709,10 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
10661
10709
|
teamId,
|
|
10662
10710
|
enabled: getOptionalBoolean(raw.enabled, true),
|
|
10663
10711
|
priority: getOptionalPriority(raw.priority, DEFAULT_EMBEDDED_TEAM_PRIORITY),
|
|
10664
|
-
order: input.index
|
|
10712
|
+
order: input.index,
|
|
10713
|
+
sourceScope: input.sourceScope,
|
|
10714
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
10715
|
+
configPath: input.configPath
|
|
10665
10716
|
},
|
|
10666
10717
|
issues: []
|
|
10667
10718
|
};
|
|
@@ -10673,7 +10724,10 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
10673
10724
|
teamDir: resolveConfiguredTeamPath(teamPath, input.configRoot),
|
|
10674
10725
|
enabled: getOptionalBoolean(raw.enabled, true),
|
|
10675
10726
|
priority: getOptionalPriority(raw.priority, DEFAULT_FILE_TEAM_PRIORITY),
|
|
10676
|
-
order: input.index
|
|
10727
|
+
order: input.index,
|
|
10728
|
+
sourceScope: input.sourceScope,
|
|
10729
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
10730
|
+
configPath: input.configPath
|
|
10677
10731
|
},
|
|
10678
10732
|
issues: []
|
|
10679
10733
|
};
|
|
@@ -10701,12 +10755,42 @@ function dedupeConfiguredTeamSources(input) {
|
|
|
10701
10755
|
function resolveCrewBeeConfigPath(configRoot = resolveOpenCodeConfigRoot()) {
|
|
10702
10756
|
return path3.join(configRoot, CREWBEE_CONFIG_FILE);
|
|
10703
10757
|
}
|
|
10704
|
-
function
|
|
10705
|
-
|
|
10758
|
+
function resolveProjectCrewBeeConfigRoot(worktree) {
|
|
10759
|
+
return path3.join(worktree, ".crewbee");
|
|
10760
|
+
}
|
|
10761
|
+
function createConfiguredTeamSourceDescriptors(input) {
|
|
10762
|
+
const sources = [];
|
|
10763
|
+
if (input.projectWorktree) {
|
|
10764
|
+
const projectConfigRoot = resolveProjectCrewBeeConfigRoot(input.projectWorktree);
|
|
10765
|
+
sources.push({
|
|
10766
|
+
scope: "project",
|
|
10767
|
+
configRoot: projectConfigRoot,
|
|
10768
|
+
configPath: resolveCrewBeeConfigPath(projectConfigRoot),
|
|
10769
|
+
precedence: 0,
|
|
10770
|
+
addDefaultCodingTeam: false,
|
|
10771
|
+
missingIsWarning: false
|
|
10772
|
+
});
|
|
10773
|
+
}
|
|
10774
|
+
sources.push({
|
|
10775
|
+
scope: "global",
|
|
10776
|
+
configRoot: input.globalConfigRoot,
|
|
10777
|
+
configPath: resolveCrewBeeConfigPath(input.globalConfigRoot),
|
|
10778
|
+
precedence: 1,
|
|
10779
|
+
addDefaultCodingTeam: true,
|
|
10780
|
+
missingIsWarning: false
|
|
10781
|
+
});
|
|
10782
|
+
return sources;
|
|
10783
|
+
}
|
|
10784
|
+
function listConfiguredTeamSourcesFromDescriptor(descriptor) {
|
|
10785
|
+
const configPath = descriptor.configPath;
|
|
10706
10786
|
if (!existsSync3(configPath)) {
|
|
10707
10787
|
return {
|
|
10708
|
-
sources: [createDefaultCodingTeamSource(
|
|
10709
|
-
|
|
10788
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10789
|
+
sourceScope: descriptor.scope,
|
|
10790
|
+
sourcePrecedence: descriptor.precedence,
|
|
10791
|
+
configPath
|
|
10792
|
+
})] : [],
|
|
10793
|
+
issues: descriptor.missingIsWarning ? [createConfigIssue(configPath, `crewbee.json source '${descriptor.scope}' does not exist.`)] : []
|
|
10710
10794
|
};
|
|
10711
10795
|
}
|
|
10712
10796
|
let parsed;
|
|
@@ -10715,7 +10799,11 @@ function listConfiguredTeamSources(configRoot = resolveOpenCodeConfigRoot()) {
|
|
|
10715
10799
|
const value = JSON.parse(rawConfig);
|
|
10716
10800
|
if (!isRecord3(value)) {
|
|
10717
10801
|
return {
|
|
10718
|
-
sources: [createDefaultCodingTeamSource(
|
|
10802
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10803
|
+
sourceScope: descriptor.scope,
|
|
10804
|
+
sourcePrecedence: descriptor.precedence,
|
|
10805
|
+
configPath
|
|
10806
|
+
})] : [],
|
|
10719
10807
|
issues: [createConfigIssue(configPath, "crewbee.json must contain a top-level object.")]
|
|
10720
10808
|
};
|
|
10721
10809
|
}
|
|
@@ -10723,27 +10811,41 @@ function listConfiguredTeamSources(configRoot = resolveOpenCodeConfigRoot()) {
|
|
|
10723
10811
|
} catch (error45) {
|
|
10724
10812
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
10725
10813
|
return {
|
|
10726
|
-
sources: [createDefaultCodingTeamSource(
|
|
10814
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10815
|
+
sourceScope: descriptor.scope,
|
|
10816
|
+
sourcePrecedence: descriptor.precedence,
|
|
10817
|
+
configPath
|
|
10818
|
+
})] : [],
|
|
10727
10819
|
issues: [createConfigIssue(configPath, `Failed to parse crewbee.json: ${message}`)]
|
|
10728
10820
|
};
|
|
10729
10821
|
}
|
|
10730
10822
|
if (parsed.teams !== void 0 && !Array.isArray(parsed.teams)) {
|
|
10731
10823
|
return {
|
|
10732
|
-
sources: [createDefaultCodingTeamSource(
|
|
10824
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10825
|
+
sourceScope: descriptor.scope,
|
|
10826
|
+
sourcePrecedence: descriptor.precedence,
|
|
10827
|
+
configPath
|
|
10828
|
+
})] : [],
|
|
10733
10829
|
issues: [createConfigIssue(configPath, "crewbee.json teams must be an array when provided.")]
|
|
10734
10830
|
};
|
|
10735
10831
|
}
|
|
10736
10832
|
const resolved = (parsed.teams ?? []).map((value, index) => normalizeConfiguredTeamEntry({
|
|
10737
10833
|
value,
|
|
10738
10834
|
index,
|
|
10739
|
-
configRoot,
|
|
10740
|
-
configPath
|
|
10835
|
+
configRoot: descriptor.configRoot,
|
|
10836
|
+
configPath,
|
|
10837
|
+
sourceScope: descriptor.scope,
|
|
10838
|
+
sourcePrecedence: descriptor.precedence
|
|
10741
10839
|
}));
|
|
10742
10840
|
const configuredSources = resolved.flatMap((entry) => entry.source ? [entry.source] : []);
|
|
10743
10841
|
const issues = resolved.flatMap((entry) => entry.issues);
|
|
10744
10842
|
const withDefaultCodingTeam = configuredSources.some(
|
|
10745
10843
|
(source) => source.kind === "embedded" && source.teamId === BUILTIN_CODING_TEAM_ID
|
|
10746
|
-
) ? configuredSources : [createDefaultCodingTeamSource(
|
|
10844
|
+
) || !descriptor.addDefaultCodingTeam ? configuredSources : [createDefaultCodingTeamSource({
|
|
10845
|
+
sourceScope: descriptor.scope,
|
|
10846
|
+
sourcePrecedence: descriptor.precedence,
|
|
10847
|
+
configPath
|
|
10848
|
+
}), ...configuredSources];
|
|
10747
10849
|
const deduped = dedupeConfiguredTeamSources({
|
|
10748
10850
|
sources: withDefaultCodingTeam,
|
|
10749
10851
|
configPath
|
|
@@ -10753,6 +10855,16 @@ function listConfiguredTeamSources(configRoot = resolveOpenCodeConfigRoot()) {
|
|
|
10753
10855
|
issues: [...issues, ...deduped.issues]
|
|
10754
10856
|
};
|
|
10755
10857
|
}
|
|
10858
|
+
function listConfiguredTeamSources(input) {
|
|
10859
|
+
const globalConfigRoot = typeof input === "string" ? input : input?.globalConfigRoot ?? resolveOpenCodeConfigRoot();
|
|
10860
|
+
const projectWorktree = typeof input === "string" ? void 0 : input?.projectWorktree;
|
|
10861
|
+
const descriptors = createConfiguredTeamSourceDescriptors({ globalConfigRoot, projectWorktree });
|
|
10862
|
+
const resolved = descriptors.map((descriptor) => listConfiguredTeamSourcesFromDescriptor(descriptor));
|
|
10863
|
+
return {
|
|
10864
|
+
sources: resolved.flatMap((entry) => entry.sources),
|
|
10865
|
+
issues: resolved.flatMap((entry) => entry.issues)
|
|
10866
|
+
};
|
|
10867
|
+
}
|
|
10756
10868
|
function loadTeamDefinitionFromDirectory(teamDir, workspaceRoot = process.cwd()) {
|
|
10757
10869
|
const manifest = mapTeamManifest(path3.join(teamDir, TEAM_MANIFEST_FILE));
|
|
10758
10870
|
const policyPath = path3.join(teamDir, TEAM_POLICY_FILE);
|
|
@@ -11016,7 +11128,7 @@ function createSkippedTeamIssue(teamDir, message) {
|
|
|
11016
11128
|
};
|
|
11017
11129
|
}
|
|
11018
11130
|
function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
11019
|
-
const configured = listConfiguredTeamSources();
|
|
11131
|
+
const configured = listConfiguredTeamSources({ projectWorktree: baseDir });
|
|
11020
11132
|
const pendingTeams = [];
|
|
11021
11133
|
for (const source of configured.sources) {
|
|
11022
11134
|
if (!source.enabled) {
|
|
@@ -11031,7 +11143,10 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11031
11143
|
pendingTeams.push({
|
|
11032
11144
|
loader: () => ({ team: embeddedTeam.team, issues: [] }),
|
|
11033
11145
|
priority: source.priority,
|
|
11034
|
-
order: source.order
|
|
11146
|
+
order: source.order,
|
|
11147
|
+
sourcePrecedence: source.sourcePrecedence,
|
|
11148
|
+
sourceScope: source.sourceScope,
|
|
11149
|
+
configPath: source.configPath
|
|
11035
11150
|
});
|
|
11036
11151
|
continue;
|
|
11037
11152
|
}
|
|
@@ -11050,10 +11165,17 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11050
11165
|
}
|
|
11051
11166
|
},
|
|
11052
11167
|
priority: source.priority,
|
|
11053
|
-
order: source.order
|
|
11168
|
+
order: source.order,
|
|
11169
|
+
sourcePrecedence: source.sourcePrecedence,
|
|
11170
|
+
sourceScope: source.sourceScope,
|
|
11171
|
+
configPath: source.configPath
|
|
11054
11172
|
});
|
|
11055
11173
|
}
|
|
11056
11174
|
pendingTeams.sort((left, right) => {
|
|
11175
|
+
const sourceOrder = left.sourcePrecedence - right.sourcePrecedence;
|
|
11176
|
+
if (sourceOrder !== 0) {
|
|
11177
|
+
return sourceOrder;
|
|
11178
|
+
}
|
|
11057
11179
|
const priorityOrder = left.priority - right.priority;
|
|
11058
11180
|
if (priorityOrder !== 0) {
|
|
11059
11181
|
return priorityOrder;
|
|
@@ -11061,11 +11183,22 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11061
11183
|
return left.order - right.order;
|
|
11062
11184
|
});
|
|
11063
11185
|
const usedCanonicalIds = /* @__PURE__ */ new Set();
|
|
11186
|
+
const usedTeamIds = /* @__PURE__ */ new Map();
|
|
11064
11187
|
const orderedTeams = [];
|
|
11065
11188
|
for (const entry of pendingTeams) {
|
|
11066
11189
|
const loaded = entry.loader();
|
|
11067
11190
|
configured.issues.push(...loaded.issues);
|
|
11068
11191
|
if (loaded.team) {
|
|
11192
|
+
const existing = usedTeamIds.get(loaded.team.manifest.id);
|
|
11193
|
+
if (existing) {
|
|
11194
|
+
configured.issues.push({
|
|
11195
|
+
level: "warning",
|
|
11196
|
+
filePath: entry.configPath,
|
|
11197
|
+
message: entry.sourceScope === "global" && existing.sourceScope === "project" ? `Project Team '${loaded.team.manifest.id}' shadows global Team '${loaded.team.manifest.id}'.` : `Skipped Team '${loaded.team.manifest.id}': duplicate Team id already loaded from ${existing.sourceScope} source.`
|
|
11198
|
+
});
|
|
11199
|
+
continue;
|
|
11200
|
+
}
|
|
11201
|
+
const usedCanonicalIdsBeforeNormalize = new Set(usedCanonicalIds);
|
|
11069
11202
|
const normalized = normalizeTeamAgentIds({
|
|
11070
11203
|
team: loaded.team,
|
|
11071
11204
|
usedCanonicalIds
|
|
@@ -11075,6 +11208,10 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11075
11208
|
const validationIssues = validateTeamDefinition(normalized.team);
|
|
11076
11209
|
const errors = validationIssues.filter((issue2) => issue2.level === "error");
|
|
11077
11210
|
if (errors.length > 0) {
|
|
11211
|
+
usedCanonicalIds.clear();
|
|
11212
|
+
for (const usedId of usedCanonicalIdsBeforeNormalize) {
|
|
11213
|
+
usedCanonicalIds.add(usedId);
|
|
11214
|
+
}
|
|
11078
11215
|
configured.issues.push(...errors.map((issue2) => ({
|
|
11079
11216
|
level: "warning",
|
|
11080
11217
|
filePath: issue2.filePath,
|
|
@@ -11084,6 +11221,10 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11084
11221
|
}
|
|
11085
11222
|
configured.issues.push(...validationIssues.filter((issue2) => issue2.level === "warning"));
|
|
11086
11223
|
orderedTeams.push(normalized.team);
|
|
11224
|
+
usedTeamIds.set(normalized.team.manifest.id, {
|
|
11225
|
+
sourceScope: entry.sourceScope,
|
|
11226
|
+
configPath: entry.configPath
|
|
11227
|
+
});
|
|
11087
11228
|
}
|
|
11088
11229
|
}
|
|
11089
11230
|
}
|
|
@@ -6,6 +6,9 @@ export interface ConfiguredEmbeddedTeamSource {
|
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
priority: number;
|
|
8
8
|
order: number;
|
|
9
|
+
sourceScope: TeamConfigSourceScope;
|
|
10
|
+
sourcePrecedence: number;
|
|
11
|
+
configPath: string;
|
|
9
12
|
}
|
|
10
13
|
export interface ConfiguredFilesystemTeamSource {
|
|
11
14
|
kind: "filesystem";
|
|
@@ -13,8 +16,12 @@ export interface ConfiguredFilesystemTeamSource {
|
|
|
13
16
|
enabled: boolean;
|
|
14
17
|
priority: number;
|
|
15
18
|
order: number;
|
|
19
|
+
sourceScope: TeamConfigSourceScope;
|
|
20
|
+
sourcePrecedence: number;
|
|
21
|
+
configPath: string;
|
|
16
22
|
}
|
|
17
23
|
export type ConfiguredTeamSource = ConfiguredEmbeddedTeamSource | ConfiguredFilesystemTeamSource;
|
|
24
|
+
export type TeamConfigSourceScope = "project" | "global";
|
|
18
25
|
export interface CrewBeeConfigFile {
|
|
19
26
|
teams: Array<Record<string, unknown>>;
|
|
20
27
|
}
|
|
@@ -32,7 +39,10 @@ export declare function ensureCrewBeeConfigFile(input: {
|
|
|
32
39
|
mode: "install" | "startup";
|
|
33
40
|
}): CrewBeeConfigEnsureResult;
|
|
34
41
|
export declare function resolveCrewBeeConfigPath(configRoot?: string): string;
|
|
35
|
-
export declare function listConfiguredTeamSources(
|
|
42
|
+
export declare function listConfiguredTeamSources(input?: string | {
|
|
43
|
+
globalConfigRoot?: string;
|
|
44
|
+
projectWorktree?: string;
|
|
45
|
+
}): {
|
|
36
46
|
sources: ConfiguredTeamSource[];
|
|
37
47
|
issues: TeamValidationIssue[];
|
|
38
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../../src/agent-teams/filesystem.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAyBnD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../../src/agent-teams/filesystem.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAGnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAyBnD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,qBAAqB,CAAC;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,qBAAqB,CAAC;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG,4BAA4B,GAAG,8BAA8B,CAAC;AAEjG,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAWzD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC;AAED,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,2BAA2B,GAAG,WAAW,CAAC;AAE3H,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,yBAAyB,CAAC;CACnC;AAyFD,wBAAgB,0BAA0B,IAAI,iBAAiB,CAmB9D;AA4ED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;CAC7B,GAAG,yBAAyB,CA8D5B;AA2HD,wBAAgB,wBAAwB,CAAC,UAAU,GAAE,MAAoC,GAAG,MAAM,CAEjG;AAqID,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG;IACF,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B,CAYA;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,MAAsB,GAAG,MAAM,CAE7E;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,GAAE,MAAgC,GAAG,MAAM,EAAE,CAUxF;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,aAAa,GAAE,MAAsB,GACpC,mBAAmB,CAuBrB"}
|
|
@@ -38,13 +38,16 @@ function getOptionalPriority(value, fallback) {
|
|
|
38
38
|
function getOptionalString(value) {
|
|
39
39
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
40
40
|
}
|
|
41
|
-
function createDefaultCodingTeamSource() {
|
|
41
|
+
function createDefaultCodingTeamSource(input) {
|
|
42
42
|
return {
|
|
43
43
|
kind: "embedded",
|
|
44
44
|
teamId: constants_1.BUILTIN_CODING_TEAM_ID,
|
|
45
45
|
enabled: true,
|
|
46
46
|
priority: constants_1.DEFAULT_EMBEDDED_TEAM_PRIORITY,
|
|
47
47
|
order: -1,
|
|
48
|
+
sourceScope: input.sourceScope,
|
|
49
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
50
|
+
configPath: input.configPath,
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
53
|
function createDefaultCodingTeamConfigEntry() {
|
|
@@ -54,7 +57,52 @@ function createDefaultCodingTeamConfigEntry() {
|
|
|
54
57
|
priority: constants_1.DEFAULT_EMBEDDED_TEAM_PRIORITY,
|
|
55
58
|
};
|
|
56
59
|
}
|
|
60
|
+
function getPackagedTemplateRootPath() {
|
|
61
|
+
const candidates = [
|
|
62
|
+
// Runtime bundle: dist/opencode-plugin.mjs, with __dirname pointing at dist.
|
|
63
|
+
node_path_1.default.resolve(__dirname, "..", "templates"),
|
|
64
|
+
// Compiled module tests / direct imports: dist/src/agent-teams/filesystem.js.
|
|
65
|
+
node_path_1.default.resolve(__dirname, "../../..", "templates"),
|
|
66
|
+
];
|
|
67
|
+
return candidates.find((candidate) => (0, node_fs_1.existsSync)(candidate));
|
|
68
|
+
}
|
|
69
|
+
function getPackagedCrewBeeConfigTemplatePath() {
|
|
70
|
+
const templateRoot = getPackagedTemplateRootPath();
|
|
71
|
+
return templateRoot ? node_path_1.default.join(templateRoot, constants_1.CREWBEE_CONFIG_FILE) : undefined;
|
|
72
|
+
}
|
|
73
|
+
function ensurePackagedTeamTemplates(configRoot, dryRun) {
|
|
74
|
+
const templateRoot = getPackagedTemplateRootPath();
|
|
75
|
+
if (!templateRoot) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const packagedTeamsRoot = node_path_1.default.join(templateRoot, constants_1.TEAM_CONFIG_ROOT);
|
|
79
|
+
if (!(0, node_fs_1.existsSync)(packagedTeamsRoot) || dryRun) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
(0, node_fs_1.cpSync)(packagedTeamsRoot, node_path_1.default.join(configRoot, constants_1.TEAM_CONFIG_ROOT), {
|
|
83
|
+
errorOnExist: false,
|
|
84
|
+
force: false,
|
|
85
|
+
recursive: true,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function isCrewBeeConfigFile(value) {
|
|
89
|
+
return isRecord(value) && Array.isArray(value.teams);
|
|
90
|
+
}
|
|
57
91
|
function createDefaultCrewBeeConfig() {
|
|
92
|
+
const templatePath = getPackagedCrewBeeConfigTemplatePath();
|
|
93
|
+
if (templatePath) {
|
|
94
|
+
try {
|
|
95
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(templatePath, "utf8"));
|
|
96
|
+
if (isCrewBeeConfigFile(parsed)) {
|
|
97
|
+
return parsed;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
// Fall back to the built-in minimal config below. Invalid package templates
|
|
102
|
+
// should not block installation or startup self-repair.
|
|
103
|
+
void error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
58
106
|
return {
|
|
59
107
|
teams: [createDefaultCodingTeamConfigEntry()],
|
|
60
108
|
};
|
|
@@ -121,6 +169,7 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
121
169
|
const configPath = resolveCrewBeeConfigPath(configRoot);
|
|
122
170
|
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
123
171
|
if (!input.dryRun) {
|
|
172
|
+
ensurePackagedTeamTemplates(configRoot);
|
|
124
173
|
writeCrewBeeConfig(configPath, createDefaultCrewBeeConfig());
|
|
125
174
|
}
|
|
126
175
|
return {
|
|
@@ -135,6 +184,7 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
135
184
|
? backupCrewBeeConfig(configPath, parsed.rawText)
|
|
136
185
|
: undefined;
|
|
137
186
|
if (!input.dryRun) {
|
|
187
|
+
ensurePackagedTeamTemplates(configRoot);
|
|
138
188
|
writeCrewBeeConfig(configPath, createDefaultCrewBeeConfig());
|
|
139
189
|
}
|
|
140
190
|
return {
|
|
@@ -218,6 +268,9 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
218
268
|
enabled: getOptionalBoolean(raw.enabled, true),
|
|
219
269
|
priority: getOptionalPriority(raw.priority, constants_1.DEFAULT_EMBEDDED_TEAM_PRIORITY),
|
|
220
270
|
order: input.index,
|
|
271
|
+
sourceScope: input.sourceScope,
|
|
272
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
273
|
+
configPath: input.configPath,
|
|
221
274
|
},
|
|
222
275
|
issues: [],
|
|
223
276
|
};
|
|
@@ -230,6 +283,9 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
230
283
|
enabled: getOptionalBoolean(raw.enabled, true),
|
|
231
284
|
priority: getOptionalPriority(raw.priority, constants_1.DEFAULT_FILE_TEAM_PRIORITY),
|
|
232
285
|
order: input.index,
|
|
286
|
+
sourceScope: input.sourceScope,
|
|
287
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
288
|
+
configPath: input.configPath,
|
|
233
289
|
},
|
|
234
290
|
issues: [],
|
|
235
291
|
};
|
|
@@ -260,12 +316,44 @@ function dedupeConfiguredTeamSources(input) {
|
|
|
260
316
|
function resolveCrewBeeConfigPath(configRoot = (0, install_root_1.resolveOpenCodeConfigRoot)()) {
|
|
261
317
|
return node_path_1.default.join(configRoot, constants_1.CREWBEE_CONFIG_FILE);
|
|
262
318
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
319
|
+
function resolveProjectCrewBeeConfigRoot(worktree) {
|
|
320
|
+
return node_path_1.default.join(worktree, ".crewbee");
|
|
321
|
+
}
|
|
322
|
+
function createConfiguredTeamSourceDescriptors(input) {
|
|
323
|
+
const sources = [];
|
|
324
|
+
if (input.projectWorktree) {
|
|
325
|
+
const projectConfigRoot = resolveProjectCrewBeeConfigRoot(input.projectWorktree);
|
|
326
|
+
sources.push({
|
|
327
|
+
scope: "project",
|
|
328
|
+
configRoot: projectConfigRoot,
|
|
329
|
+
configPath: resolveCrewBeeConfigPath(projectConfigRoot),
|
|
330
|
+
precedence: 0,
|
|
331
|
+
addDefaultCodingTeam: false,
|
|
332
|
+
missingIsWarning: false,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
sources.push({
|
|
336
|
+
scope: "global",
|
|
337
|
+
configRoot: input.globalConfigRoot,
|
|
338
|
+
configPath: resolveCrewBeeConfigPath(input.globalConfigRoot),
|
|
339
|
+
precedence: 1,
|
|
340
|
+
addDefaultCodingTeam: true,
|
|
341
|
+
missingIsWarning: false,
|
|
342
|
+
});
|
|
343
|
+
return sources;
|
|
344
|
+
}
|
|
345
|
+
function listConfiguredTeamSourcesFromDescriptor(descriptor) {
|
|
346
|
+
const configPath = descriptor.configPath;
|
|
265
347
|
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
266
348
|
return {
|
|
267
|
-
sources:
|
|
268
|
-
|
|
349
|
+
sources: descriptor.addDefaultCodingTeam
|
|
350
|
+
? [createDefaultCodingTeamSource({
|
|
351
|
+
sourceScope: descriptor.scope,
|
|
352
|
+
sourcePrecedence: descriptor.precedence,
|
|
353
|
+
configPath,
|
|
354
|
+
})]
|
|
355
|
+
: [],
|
|
356
|
+
issues: descriptor.missingIsWarning ? [createConfigIssue(configPath, `crewbee.json source '${descriptor.scope}' does not exist.`)] : [],
|
|
269
357
|
};
|
|
270
358
|
}
|
|
271
359
|
let parsed;
|
|
@@ -274,7 +362,13 @@ function listConfiguredTeamSources(configRoot = (0, install_root_1.resolveOpenCo
|
|
|
274
362
|
const value = JSON.parse(rawConfig);
|
|
275
363
|
if (!isRecord(value)) {
|
|
276
364
|
return {
|
|
277
|
-
sources:
|
|
365
|
+
sources: descriptor.addDefaultCodingTeam
|
|
366
|
+
? [createDefaultCodingTeamSource({
|
|
367
|
+
sourceScope: descriptor.scope,
|
|
368
|
+
sourcePrecedence: descriptor.precedence,
|
|
369
|
+
configPath,
|
|
370
|
+
})]
|
|
371
|
+
: [],
|
|
278
372
|
issues: [createConfigIssue(configPath, "crewbee.json must contain a top-level object.")],
|
|
279
373
|
};
|
|
280
374
|
}
|
|
@@ -283,27 +377,46 @@ function listConfiguredTeamSources(configRoot = (0, install_root_1.resolveOpenCo
|
|
|
283
377
|
catch (error) {
|
|
284
378
|
const message = error instanceof Error ? error.message : String(error);
|
|
285
379
|
return {
|
|
286
|
-
sources:
|
|
380
|
+
sources: descriptor.addDefaultCodingTeam
|
|
381
|
+
? [createDefaultCodingTeamSource({
|
|
382
|
+
sourceScope: descriptor.scope,
|
|
383
|
+
sourcePrecedence: descriptor.precedence,
|
|
384
|
+
configPath,
|
|
385
|
+
})]
|
|
386
|
+
: [],
|
|
287
387
|
issues: [createConfigIssue(configPath, `Failed to parse crewbee.json: ${message}`)],
|
|
288
388
|
};
|
|
289
389
|
}
|
|
290
390
|
if (parsed.teams !== undefined && !Array.isArray(parsed.teams)) {
|
|
291
391
|
return {
|
|
292
|
-
sources:
|
|
392
|
+
sources: descriptor.addDefaultCodingTeam
|
|
393
|
+
? [createDefaultCodingTeamSource({
|
|
394
|
+
sourceScope: descriptor.scope,
|
|
395
|
+
sourcePrecedence: descriptor.precedence,
|
|
396
|
+
configPath,
|
|
397
|
+
})]
|
|
398
|
+
: [],
|
|
293
399
|
issues: [createConfigIssue(configPath, "crewbee.json teams must be an array when provided.")],
|
|
294
400
|
};
|
|
295
401
|
}
|
|
296
402
|
const resolved = (parsed.teams ?? []).map((value, index) => normalizeConfiguredTeamEntry({
|
|
297
403
|
value,
|
|
298
404
|
index,
|
|
299
|
-
configRoot,
|
|
405
|
+
configRoot: descriptor.configRoot,
|
|
300
406
|
configPath,
|
|
407
|
+
sourceScope: descriptor.scope,
|
|
408
|
+
sourcePrecedence: descriptor.precedence,
|
|
301
409
|
}));
|
|
302
410
|
const configuredSources = resolved.flatMap((entry) => (entry.source ? [entry.source] : []));
|
|
303
411
|
const issues = resolved.flatMap((entry) => entry.issues);
|
|
304
412
|
const withDefaultCodingTeam = configuredSources.some((source) => source.kind === "embedded" && source.teamId === constants_1.BUILTIN_CODING_TEAM_ID)
|
|
413
|
+
|| !descriptor.addDefaultCodingTeam
|
|
305
414
|
? configuredSources
|
|
306
|
-
: [createDefaultCodingTeamSource(
|
|
415
|
+
: [createDefaultCodingTeamSource({
|
|
416
|
+
sourceScope: descriptor.scope,
|
|
417
|
+
sourcePrecedence: descriptor.precedence,
|
|
418
|
+
configPath,
|
|
419
|
+
}), ...configuredSources];
|
|
307
420
|
const deduped = dedupeConfiguredTeamSources({
|
|
308
421
|
sources: withDefaultCodingTeam,
|
|
309
422
|
configPath,
|
|
@@ -313,6 +426,18 @@ function listConfiguredTeamSources(configRoot = (0, install_root_1.resolveOpenCo
|
|
|
313
426
|
issues: [...issues, ...deduped.issues],
|
|
314
427
|
};
|
|
315
428
|
}
|
|
429
|
+
function listConfiguredTeamSources(input) {
|
|
430
|
+
const globalConfigRoot = typeof input === "string"
|
|
431
|
+
? input
|
|
432
|
+
: (input?.globalConfigRoot ?? (0, install_root_1.resolveOpenCodeConfigRoot)());
|
|
433
|
+
const projectWorktree = typeof input === "string" ? undefined : input?.projectWorktree;
|
|
434
|
+
const descriptors = createConfiguredTeamSourceDescriptors({ globalConfigRoot, projectWorktree });
|
|
435
|
+
const resolved = descriptors.map((descriptor) => listConfiguredTeamSourcesFromDescriptor(descriptor));
|
|
436
|
+
return {
|
|
437
|
+
sources: resolved.flatMap((entry) => entry.sources),
|
|
438
|
+
issues: resolved.flatMap((entry) => entry.issues),
|
|
439
|
+
};
|
|
440
|
+
}
|
|
316
441
|
function resolveTeamConfigRoot(baseDir = process.cwd()) {
|
|
317
442
|
return node_path_1.default.resolve(baseDir, constants_1.TEAM_CONFIG_ROOT);
|
|
318
443
|
}
|