crewbee 0.1.8 → 0.1.10
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 +19 -3
- package/README.zh-CN.md +24 -8
- package/dist/opencode-plugin.mjs +403 -70
- package/dist/src/adapters/opencode/config-hook.d.ts.map +1 -1
- package/dist/src/adapters/opencode/config-hook.js +9 -2
- package/dist/src/adapters/opencode/config-hook.js.map +1 -1
- package/dist/src/adapters/opencode/plugin.d.ts.map +1 -1
- package/dist/src/adapters/opencode/plugin.js +1 -1
- package/dist/src/adapters/opencode/plugin.js.map +1 -1
- package/dist/src/adapters/opencode/system-transform-hook.d.ts +2 -1
- package/dist/src/adapters/opencode/system-transform-hook.d.ts.map +1 -1
- package/dist/src/adapters/opencode/system-transform-hook.js +17 -3
- package/dist/src/adapters/opencode/system-transform-hook.js.map +1 -1
- package/dist/src/agent-teams/canonical-agent-id.d.ts.map +1 -1
- package/dist/src/agent-teams/canonical-agent-id.js +3 -0
- package/dist/src/agent-teams/canonical-agent-id.js.map +1 -1
- package/dist/src/agent-teams/diagnostics.d.ts +10 -0
- package/dist/src/agent-teams/diagnostics.d.ts.map +1 -0
- package/dist/src/agent-teams/diagnostics.js +29 -0
- package/dist/src/agent-teams/diagnostics.js.map +1 -0
- package/dist/src/agent-teams/filesystem.d.ts +15 -1
- package/dist/src/agent-teams/filesystem.d.ts.map +1 -1
- package/dist/src/agent-teams/filesystem.js +268 -30
- package/dist/src/agent-teams/filesystem.js.map +1 -1
- package/dist/src/agent-teams/index.d.ts +1 -0
- package/dist/src/agent-teams/index.d.ts.map +1 -1
- package/dist/src/agent-teams/index.js +5 -1
- package/dist/src/agent-teams/index.js.map +1 -1
- package/dist/src/agent-teams/library.d.ts +5 -1
- package/dist/src/agent-teams/library.d.ts.map +1 -1
- package/dist/src/agent-teams/library.js +62 -8
- package/dist/src/agent-teams/library.js.map +1 -1
- package/dist/src/agent-teams/parsers.js +3 -3
- package/dist/src/agent-teams/parsers.js.map +1 -1
- package/dist/src/agent-teams/types.d.ts +6 -0
- package/dist/src/agent-teams/types.d.ts.map +1 -1
- package/dist/src/agent-teams/validation.d.ts.map +1 -1
- package/dist/src/agent-teams/validation.js +50 -3
- package/dist/src/agent-teams/validation.js.map +1 -1
- package/dist/src/cli/doctor.d.ts.map +1 -1
- package/dist/src/cli/doctor.js +36 -1
- package/dist/src/cli/doctor.js.map +1 -1
- package/dist/src/cli/render-help.d.ts.map +1 -1
- package/dist/src/cli/render-help.js +2 -1
- package/dist/src/cli/render-help.js.map +1 -1
- package/dist/src/cli/run-cli.d.ts.map +1 -1
- package/dist/src/cli/run-cli.js +7 -0
- package/dist/src/cli/run-cli.js.map +1 -1
- package/dist/src/cli/validate.d.ts +6 -0
- package/dist/src/cli/validate.d.ts.map +1 -0
- package/dist/src/cli/validate.js +90 -0
- package/dist/src/cli/validate.js.map +1 -0
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/install/doctor.d.ts.map +1 -1
- package/dist/src/install/doctor.js +15 -1
- package/dist/src/install/doctor.js.map +1 -1
- package/dist/src/install/types.d.ts +7 -0
- package/dist/src/install/types.d.ts.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
|
|
|
@@ -10128,8 +10129,8 @@ function mapCollaboration(raw) {
|
|
|
10128
10129
|
return value.map(mapCollaborationBinding);
|
|
10129
10130
|
};
|
|
10130
10131
|
return {
|
|
10131
|
-
defaultConsults: mapList(raw
|
|
10132
|
-
defaultHandoffs: mapList(raw
|
|
10132
|
+
defaultConsults: mapList(raw?.default_consults ?? raw?.defaultConsults ?? [], "default_consults"),
|
|
10133
|
+
defaultHandoffs: mapList(raw?.default_handoffs ?? raw?.defaultHandoffs ?? [], "default_handoffs")
|
|
10133
10134
|
};
|
|
10134
10135
|
}
|
|
10135
10136
|
function mapMinimalOperations(raw, body) {
|
|
@@ -10296,7 +10297,7 @@ function mapAgentProfile(filePath) {
|
|
|
10296
10297
|
rejectRemovedAgentProfileFields(data, filePath);
|
|
10297
10298
|
const personaCore = asRecord(data.persona_core, "persona_core");
|
|
10298
10299
|
const responsibilityCore = asRecord(data.responsibility_core, "responsibility_core");
|
|
10299
|
-
const collaboration =
|
|
10300
|
+
const collaboration = asOptionalRecord(data.collaboration);
|
|
10300
10301
|
const runtimeConfig = asRecord(data.runtime_config, "runtime_config");
|
|
10301
10302
|
const extraContent = omitKeys(data, KNOWN_AGENT_TOP_LEVEL_KEYS);
|
|
10302
10303
|
const reservedAgentKeys = new Set(KNOWN_AGENT_TOP_LEVEL_KEYS);
|
|
@@ -10467,11 +10468,16 @@ function mapTeamPolicy(filePath) {
|
|
|
10467
10468
|
// src/agent-teams/filesystem.ts
|
|
10468
10469
|
var TEAM_MANIFEST_FILE = "team.manifest.yaml";
|
|
10469
10470
|
var TEAM_POLICY_FILE = "team.policy.yaml";
|
|
10470
|
-
function createConfigIssue(
|
|
10471
|
+
function createConfigIssue(input) {
|
|
10471
10472
|
return {
|
|
10472
10473
|
level: "warning",
|
|
10473
|
-
filePath: configPath,
|
|
10474
|
-
message
|
|
10474
|
+
filePath: input.configPath,
|
|
10475
|
+
message: input.message,
|
|
10476
|
+
code: input.code,
|
|
10477
|
+
path: input.path,
|
|
10478
|
+
suggestion: input.suggestion,
|
|
10479
|
+
sourceScope: input.sourceScope,
|
|
10480
|
+
fixable: input.fixable
|
|
10475
10481
|
};
|
|
10476
10482
|
}
|
|
10477
10483
|
function isRecord3(value) {
|
|
@@ -10486,13 +10492,16 @@ function getOptionalPriority(value, fallback) {
|
|
|
10486
10492
|
function getOptionalString(value) {
|
|
10487
10493
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
10488
10494
|
}
|
|
10489
|
-
function createDefaultCodingTeamSource() {
|
|
10495
|
+
function createDefaultCodingTeamSource(input) {
|
|
10490
10496
|
return {
|
|
10491
10497
|
kind: "embedded",
|
|
10492
10498
|
teamId: BUILTIN_CODING_TEAM_ID,
|
|
10493
10499
|
enabled: true,
|
|
10494
10500
|
priority: DEFAULT_EMBEDDED_TEAM_PRIORITY,
|
|
10495
|
-
order: -1
|
|
10501
|
+
order: -1,
|
|
10502
|
+
sourceScope: input.sourceScope,
|
|
10503
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
10504
|
+
configPath: input.configPath
|
|
10496
10505
|
};
|
|
10497
10506
|
}
|
|
10498
10507
|
function createDefaultCodingTeamConfigEntry() {
|
|
@@ -10502,7 +10511,49 @@ function createDefaultCodingTeamConfigEntry() {
|
|
|
10502
10511
|
priority: DEFAULT_EMBEDDED_TEAM_PRIORITY
|
|
10503
10512
|
};
|
|
10504
10513
|
}
|
|
10514
|
+
function getPackagedTemplateRootPath() {
|
|
10515
|
+
const candidates = [
|
|
10516
|
+
// Runtime bundle: dist/opencode-plugin.mjs, with __dirname pointing at dist.
|
|
10517
|
+
path3.resolve(__dirname, "..", "templates"),
|
|
10518
|
+
// Compiled module tests / direct imports: dist/src/agent-teams/filesystem.js.
|
|
10519
|
+
path3.resolve(__dirname, "../../..", "templates")
|
|
10520
|
+
];
|
|
10521
|
+
return candidates.find((candidate) => existsSync3(candidate));
|
|
10522
|
+
}
|
|
10523
|
+
function getPackagedCrewBeeConfigTemplatePath() {
|
|
10524
|
+
const templateRoot = getPackagedTemplateRootPath();
|
|
10525
|
+
return templateRoot ? path3.join(templateRoot, CREWBEE_CONFIG_FILE) : void 0;
|
|
10526
|
+
}
|
|
10527
|
+
function ensurePackagedTeamTemplates(configRoot, dryRun) {
|
|
10528
|
+
const templateRoot = getPackagedTemplateRootPath();
|
|
10529
|
+
if (!templateRoot) {
|
|
10530
|
+
return;
|
|
10531
|
+
}
|
|
10532
|
+
const packagedTeamsRoot = path3.join(templateRoot, TEAM_CONFIG_ROOT);
|
|
10533
|
+
if (!existsSync3(packagedTeamsRoot) || dryRun) {
|
|
10534
|
+
return;
|
|
10535
|
+
}
|
|
10536
|
+
cpSync(packagedTeamsRoot, path3.join(configRoot, TEAM_CONFIG_ROOT), {
|
|
10537
|
+
errorOnExist: false,
|
|
10538
|
+
force: false,
|
|
10539
|
+
recursive: true
|
|
10540
|
+
});
|
|
10541
|
+
}
|
|
10542
|
+
function isCrewBeeConfigFile(value) {
|
|
10543
|
+
return isRecord3(value) && Array.isArray(value.teams);
|
|
10544
|
+
}
|
|
10505
10545
|
function createDefaultCrewBeeConfig() {
|
|
10546
|
+
const templatePath = getPackagedCrewBeeConfigTemplatePath();
|
|
10547
|
+
if (templatePath) {
|
|
10548
|
+
try {
|
|
10549
|
+
const parsed = JSON.parse(readFileSync2(templatePath, "utf8"));
|
|
10550
|
+
if (isCrewBeeConfigFile(parsed)) {
|
|
10551
|
+
return parsed;
|
|
10552
|
+
}
|
|
10553
|
+
} catch (error45) {
|
|
10554
|
+
void error45;
|
|
10555
|
+
}
|
|
10556
|
+
}
|
|
10506
10557
|
return {
|
|
10507
10558
|
teams: [createDefaultCodingTeamConfigEntry()]
|
|
10508
10559
|
};
|
|
@@ -10567,6 +10618,7 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10567
10618
|
const configPath = resolveCrewBeeConfigPath(configRoot);
|
|
10568
10619
|
if (!existsSync3(configPath)) {
|
|
10569
10620
|
if (!input.dryRun) {
|
|
10621
|
+
ensurePackagedTeamTemplates(configRoot);
|
|
10570
10622
|
writeCrewBeeConfig(configPath, createDefaultCrewBeeConfig());
|
|
10571
10623
|
}
|
|
10572
10624
|
return {
|
|
@@ -10579,6 +10631,7 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10579
10631
|
if (!parsed.valid || !parsed.config) {
|
|
10580
10632
|
const backupPath = !input.dryRun && parsed.rawText !== void 0 ? backupCrewBeeConfig(configPath, parsed.rawText) : void 0;
|
|
10581
10633
|
if (!input.dryRun) {
|
|
10634
|
+
ensurePackagedTeamTemplates(configRoot);
|
|
10582
10635
|
writeCrewBeeConfig(configPath, createDefaultCrewBeeConfig());
|
|
10583
10636
|
}
|
|
10584
10637
|
return {
|
|
@@ -10628,7 +10681,14 @@ function resolveConfiguredTeamPath(teamPath, configRoot) {
|
|
|
10628
10681
|
function normalizeConfiguredTeamEntry(input) {
|
|
10629
10682
|
if (!isRecord3(input.value)) {
|
|
10630
10683
|
return {
|
|
10631
|
-
issues: [createConfigIssue(
|
|
10684
|
+
issues: [createConfigIssue({
|
|
10685
|
+
configPath: input.configPath,
|
|
10686
|
+
message: `crewbee.json teams[${input.index}] must be an object.`,
|
|
10687
|
+
code: "crewbee_config_team_entry_invalid",
|
|
10688
|
+
path: `teams[${input.index}]`,
|
|
10689
|
+
sourceScope: input.sourceScope,
|
|
10690
|
+
suggestion: "Replace this entry with an object containing either id or path."
|
|
10691
|
+
})]
|
|
10632
10692
|
};
|
|
10633
10693
|
}
|
|
10634
10694
|
const raw = input.value;
|
|
@@ -10636,22 +10696,50 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
10636
10696
|
const teamPath = getOptionalString(raw.path);
|
|
10637
10697
|
if (teamId && teamPath) {
|
|
10638
10698
|
return {
|
|
10639
|
-
issues: [createConfigIssue(
|
|
10699
|
+
issues: [createConfigIssue({
|
|
10700
|
+
configPath: input.configPath,
|
|
10701
|
+
message: `crewbee.json teams[${input.index}] cannot declare both id and path.`,
|
|
10702
|
+
code: "crewbee_config_team_entry_conflict",
|
|
10703
|
+
path: `teams[${input.index}]`,
|
|
10704
|
+
sourceScope: input.sourceScope,
|
|
10705
|
+
suggestion: "Keep id for embedded Teams or path for filesystem Teams, not both."
|
|
10706
|
+
})]
|
|
10640
10707
|
};
|
|
10641
10708
|
}
|
|
10642
10709
|
if (!teamId && !teamPath) {
|
|
10643
10710
|
return {
|
|
10644
|
-
issues: [createConfigIssue(
|
|
10711
|
+
issues: [createConfigIssue({
|
|
10712
|
+
configPath: input.configPath,
|
|
10713
|
+
message: `crewbee.json teams[${input.index}] must declare either id or path.`,
|
|
10714
|
+
code: "crewbee_config_team_entry_missing_source",
|
|
10715
|
+
path: `teams[${input.index}]`,
|
|
10716
|
+
sourceScope: input.sourceScope,
|
|
10717
|
+
suggestion: "Add an embedded Team id or a filesystem Team path."
|
|
10718
|
+
})]
|
|
10645
10719
|
};
|
|
10646
10720
|
}
|
|
10647
10721
|
if (raw.enabled !== void 0 && typeof raw.enabled !== "boolean") {
|
|
10648
10722
|
return {
|
|
10649
|
-
issues: [createConfigIssue(
|
|
10723
|
+
issues: [createConfigIssue({
|
|
10724
|
+
configPath: input.configPath,
|
|
10725
|
+
message: `crewbee.json teams[${input.index}].enabled must be a boolean when provided.`,
|
|
10726
|
+
code: "crewbee_config_team_entry_enabled_invalid",
|
|
10727
|
+
path: `teams[${input.index}].enabled`,
|
|
10728
|
+
sourceScope: input.sourceScope,
|
|
10729
|
+
suggestion: "Use true or false for enabled."
|
|
10730
|
+
})]
|
|
10650
10731
|
};
|
|
10651
10732
|
}
|
|
10652
10733
|
if (raw.priority !== void 0 && (typeof raw.priority !== "number" || !Number.isFinite(raw.priority))) {
|
|
10653
10734
|
return {
|
|
10654
|
-
issues: [createConfigIssue(
|
|
10735
|
+
issues: [createConfigIssue({
|
|
10736
|
+
configPath: input.configPath,
|
|
10737
|
+
message: `crewbee.json teams[${input.index}].priority must be a finite number when provided.`,
|
|
10738
|
+
code: "crewbee_config_team_entry_priority_invalid",
|
|
10739
|
+
path: `teams[${input.index}].priority`,
|
|
10740
|
+
sourceScope: input.sourceScope,
|
|
10741
|
+
suggestion: "Use a finite numeric priority; lower values load first."
|
|
10742
|
+
})]
|
|
10655
10743
|
};
|
|
10656
10744
|
}
|
|
10657
10745
|
if (teamId) {
|
|
@@ -10661,7 +10749,10 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
10661
10749
|
teamId,
|
|
10662
10750
|
enabled: getOptionalBoolean(raw.enabled, true),
|
|
10663
10751
|
priority: getOptionalPriority(raw.priority, DEFAULT_EMBEDDED_TEAM_PRIORITY),
|
|
10664
|
-
order: input.index
|
|
10752
|
+
order: input.index,
|
|
10753
|
+
sourceScope: input.sourceScope,
|
|
10754
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
10755
|
+
configPath: input.configPath
|
|
10665
10756
|
},
|
|
10666
10757
|
issues: []
|
|
10667
10758
|
};
|
|
@@ -10673,14 +10764,24 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
10673
10764
|
teamDir: resolveConfiguredTeamPath(teamPath, input.configRoot),
|
|
10674
10765
|
enabled: getOptionalBoolean(raw.enabled, true),
|
|
10675
10766
|
priority: getOptionalPriority(raw.priority, DEFAULT_FILE_TEAM_PRIORITY),
|
|
10676
|
-
order: input.index
|
|
10767
|
+
order: input.index,
|
|
10768
|
+
sourceScope: input.sourceScope,
|
|
10769
|
+
sourcePrecedence: input.sourcePrecedence,
|
|
10770
|
+
configPath: input.configPath
|
|
10677
10771
|
},
|
|
10678
10772
|
issues: []
|
|
10679
10773
|
};
|
|
10680
10774
|
} catch (error45) {
|
|
10681
10775
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
10682
10776
|
return {
|
|
10683
|
-
issues: [createConfigIssue(
|
|
10777
|
+
issues: [createConfigIssue({
|
|
10778
|
+
configPath: input.configPath,
|
|
10779
|
+
message: `crewbee.json teams[${input.index}].path is invalid: ${message}`,
|
|
10780
|
+
code: "crewbee_config_team_entry_path_invalid",
|
|
10781
|
+
path: `teams[${input.index}].path`,
|
|
10782
|
+
sourceScope: input.sourceScope,
|
|
10783
|
+
suggestion: "Use an absolute path, ~/path, or @path relative to the crewbee.json directory."
|
|
10784
|
+
})]
|
|
10684
10785
|
};
|
|
10685
10786
|
}
|
|
10686
10787
|
}
|
|
@@ -10690,7 +10791,12 @@ function dedupeConfiguredTeamSources(input) {
|
|
|
10690
10791
|
const sources = input.sources.filter((source) => {
|
|
10691
10792
|
const key = source.kind === "embedded" ? `embedded:${source.teamId}` : `filesystem:${source.teamDir.toLowerCase()}`;
|
|
10692
10793
|
if (seen.has(key)) {
|
|
10693
|
-
issues.push(createConfigIssue(
|
|
10794
|
+
issues.push(createConfigIssue({
|
|
10795
|
+
configPath: input.configPath,
|
|
10796
|
+
message: `crewbee.json contains a duplicate Team entry for '${key}'.`,
|
|
10797
|
+
code: "crewbee_config_duplicate_team_entry",
|
|
10798
|
+
suggestion: "Remove the duplicate Team entry; the first matching entry is used."
|
|
10799
|
+
}));
|
|
10694
10800
|
return false;
|
|
10695
10801
|
}
|
|
10696
10802
|
seen.add(key);
|
|
@@ -10701,12 +10807,47 @@ function dedupeConfiguredTeamSources(input) {
|
|
|
10701
10807
|
function resolveCrewBeeConfigPath(configRoot = resolveOpenCodeConfigRoot()) {
|
|
10702
10808
|
return path3.join(configRoot, CREWBEE_CONFIG_FILE);
|
|
10703
10809
|
}
|
|
10704
|
-
function
|
|
10705
|
-
|
|
10810
|
+
function resolveProjectCrewBeeConfigRoot(worktree) {
|
|
10811
|
+
return path3.join(worktree, ".crewbee");
|
|
10812
|
+
}
|
|
10813
|
+
function createConfiguredTeamSourceDescriptors(input) {
|
|
10814
|
+
const sources = [];
|
|
10815
|
+
if (input.projectWorktree) {
|
|
10816
|
+
const projectConfigRoot = resolveProjectCrewBeeConfigRoot(input.projectWorktree);
|
|
10817
|
+
sources.push({
|
|
10818
|
+
scope: "project",
|
|
10819
|
+
configRoot: projectConfigRoot,
|
|
10820
|
+
configPath: resolveCrewBeeConfigPath(projectConfigRoot),
|
|
10821
|
+
precedence: 0,
|
|
10822
|
+
addDefaultCodingTeam: false,
|
|
10823
|
+
missingIsWarning: false
|
|
10824
|
+
});
|
|
10825
|
+
}
|
|
10826
|
+
sources.push({
|
|
10827
|
+
scope: "global",
|
|
10828
|
+
configRoot: input.globalConfigRoot,
|
|
10829
|
+
configPath: resolveCrewBeeConfigPath(input.globalConfigRoot),
|
|
10830
|
+
precedence: 1,
|
|
10831
|
+
addDefaultCodingTeam: true,
|
|
10832
|
+
missingIsWarning: false
|
|
10833
|
+
});
|
|
10834
|
+
return sources;
|
|
10835
|
+
}
|
|
10836
|
+
function listConfiguredTeamSourcesFromDescriptor(descriptor) {
|
|
10837
|
+
const configPath = descriptor.configPath;
|
|
10706
10838
|
if (!existsSync3(configPath)) {
|
|
10707
10839
|
return {
|
|
10708
|
-
sources: [createDefaultCodingTeamSource(
|
|
10709
|
-
|
|
10840
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10841
|
+
sourceScope: descriptor.scope,
|
|
10842
|
+
sourcePrecedence: descriptor.precedence,
|
|
10843
|
+
configPath
|
|
10844
|
+
})] : [],
|
|
10845
|
+
issues: descriptor.missingIsWarning ? [createConfigIssue({
|
|
10846
|
+
configPath,
|
|
10847
|
+
message: `crewbee.json source '${descriptor.scope}' does not exist.`,
|
|
10848
|
+
code: "crewbee_config_missing",
|
|
10849
|
+
sourceScope: descriptor.scope
|
|
10850
|
+
})] : []
|
|
10710
10851
|
};
|
|
10711
10852
|
}
|
|
10712
10853
|
let parsed;
|
|
@@ -10715,35 +10856,75 @@ function listConfiguredTeamSources(configRoot = resolveOpenCodeConfigRoot()) {
|
|
|
10715
10856
|
const value = JSON.parse(rawConfig);
|
|
10716
10857
|
if (!isRecord3(value)) {
|
|
10717
10858
|
return {
|
|
10718
|
-
sources: [createDefaultCodingTeamSource(
|
|
10719
|
-
|
|
10859
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10860
|
+
sourceScope: descriptor.scope,
|
|
10861
|
+
sourcePrecedence: descriptor.precedence,
|
|
10862
|
+
configPath
|
|
10863
|
+
})] : [],
|
|
10864
|
+
issues: [createConfigIssue({
|
|
10865
|
+
configPath,
|
|
10866
|
+
message: "crewbee.json must contain a top-level object.",
|
|
10867
|
+
code: "crewbee_config_root_invalid",
|
|
10868
|
+
sourceScope: descriptor.scope,
|
|
10869
|
+
fixable: descriptor.addDefaultCodingTeam,
|
|
10870
|
+
suggestion: descriptor.addDefaultCodingTeam ? "Run crewbee install to rewrite the global crewbee.json from the packaged template." : "Replace project crewbee.json with an object containing a teams array."
|
|
10871
|
+
})]
|
|
10720
10872
|
};
|
|
10721
10873
|
}
|
|
10722
10874
|
parsed = value;
|
|
10723
10875
|
} catch (error45) {
|
|
10724
10876
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
10725
10877
|
return {
|
|
10726
|
-
sources: [createDefaultCodingTeamSource(
|
|
10727
|
-
|
|
10878
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10879
|
+
sourceScope: descriptor.scope,
|
|
10880
|
+
sourcePrecedence: descriptor.precedence,
|
|
10881
|
+
configPath
|
|
10882
|
+
})] : [],
|
|
10883
|
+
issues: [createConfigIssue({
|
|
10884
|
+
configPath,
|
|
10885
|
+
message: `Failed to parse crewbee.json: ${message}`,
|
|
10886
|
+
code: "crewbee_config_parse_failed",
|
|
10887
|
+
sourceScope: descriptor.scope,
|
|
10888
|
+
fixable: descriptor.addDefaultCodingTeam,
|
|
10889
|
+
suggestion: descriptor.addDefaultCodingTeam ? "The global config can be safely repaired from the packaged template on install or plugin startup." : "Fix the JSON syntax; project configs are reported but not auto-rewritten."
|
|
10890
|
+
})]
|
|
10728
10891
|
};
|
|
10729
10892
|
}
|
|
10730
10893
|
if (parsed.teams !== void 0 && !Array.isArray(parsed.teams)) {
|
|
10731
10894
|
return {
|
|
10732
|
-
sources: [createDefaultCodingTeamSource(
|
|
10733
|
-
|
|
10895
|
+
sources: descriptor.addDefaultCodingTeam ? [createDefaultCodingTeamSource({
|
|
10896
|
+
sourceScope: descriptor.scope,
|
|
10897
|
+
sourcePrecedence: descriptor.precedence,
|
|
10898
|
+
configPath
|
|
10899
|
+
})] : [],
|
|
10900
|
+
issues: [createConfigIssue({
|
|
10901
|
+
configPath,
|
|
10902
|
+
message: "crewbee.json teams must be an array when provided.",
|
|
10903
|
+
code: "crewbee_config_teams_invalid",
|
|
10904
|
+
path: "teams",
|
|
10905
|
+
sourceScope: descriptor.scope,
|
|
10906
|
+
fixable: descriptor.addDefaultCodingTeam,
|
|
10907
|
+
suggestion: descriptor.addDefaultCodingTeam ? "The global config can be safely repaired from the packaged template on install or plugin startup." : "Use teams: [] or a list of Team entries in project crewbee.json."
|
|
10908
|
+
})]
|
|
10734
10909
|
};
|
|
10735
10910
|
}
|
|
10736
10911
|
const resolved = (parsed.teams ?? []).map((value, index) => normalizeConfiguredTeamEntry({
|
|
10737
10912
|
value,
|
|
10738
10913
|
index,
|
|
10739
|
-
configRoot,
|
|
10740
|
-
configPath
|
|
10914
|
+
configRoot: descriptor.configRoot,
|
|
10915
|
+
configPath,
|
|
10916
|
+
sourceScope: descriptor.scope,
|
|
10917
|
+
sourcePrecedence: descriptor.precedence
|
|
10741
10918
|
}));
|
|
10742
10919
|
const configuredSources = resolved.flatMap((entry) => entry.source ? [entry.source] : []);
|
|
10743
10920
|
const issues = resolved.flatMap((entry) => entry.issues);
|
|
10744
10921
|
const withDefaultCodingTeam = configuredSources.some(
|
|
10745
10922
|
(source) => source.kind === "embedded" && source.teamId === BUILTIN_CODING_TEAM_ID
|
|
10746
|
-
) ? configuredSources : [createDefaultCodingTeamSource(
|
|
10923
|
+
) || !descriptor.addDefaultCodingTeam ? configuredSources : [createDefaultCodingTeamSource({
|
|
10924
|
+
sourceScope: descriptor.scope,
|
|
10925
|
+
sourcePrecedence: descriptor.precedence,
|
|
10926
|
+
configPath
|
|
10927
|
+
}), ...configuredSources];
|
|
10747
10928
|
const deduped = dedupeConfiguredTeamSources({
|
|
10748
10929
|
sources: withDefaultCodingTeam,
|
|
10749
10930
|
configPath
|
|
@@ -10753,21 +10934,55 @@ function listConfiguredTeamSources(configRoot = resolveOpenCodeConfigRoot()) {
|
|
|
10753
10934
|
issues: [...issues, ...deduped.issues]
|
|
10754
10935
|
};
|
|
10755
10936
|
}
|
|
10756
|
-
function
|
|
10937
|
+
function listConfiguredTeamSources(input) {
|
|
10938
|
+
const globalConfigRoot = typeof input === "string" ? input : input?.globalConfigRoot ?? resolveOpenCodeConfigRoot();
|
|
10939
|
+
const projectWorktree = typeof input === "string" ? void 0 : input?.projectWorktree;
|
|
10940
|
+
const descriptors = createConfiguredTeamSourceDescriptors({ globalConfigRoot, projectWorktree });
|
|
10941
|
+
const resolved = descriptors.map((descriptor) => listConfiguredTeamSourcesFromDescriptor(descriptor));
|
|
10942
|
+
return {
|
|
10943
|
+
sources: resolved.flatMap((entry) => entry.sources),
|
|
10944
|
+
issues: resolved.flatMap((entry) => entry.issues)
|
|
10945
|
+
};
|
|
10946
|
+
}
|
|
10947
|
+
function createSkippedAgentIssue(filePath, message) {
|
|
10948
|
+
return {
|
|
10949
|
+
level: "error",
|
|
10950
|
+
blocking: false,
|
|
10951
|
+
filePath,
|
|
10952
|
+
code: "agent_profile_load_failed",
|
|
10953
|
+
message: `Skipped Agent '${path3.basename(filePath)}': ${message}`,
|
|
10954
|
+
suggestion: "Fix this Agent profile file; other valid Agents in the same Team remain loadable when possible."
|
|
10955
|
+
};
|
|
10956
|
+
}
|
|
10957
|
+
function loadTeamDefinitionFromDirectoryWithIssues(teamDir, workspaceRoot = process.cwd()) {
|
|
10757
10958
|
const manifest = mapTeamManifest(path3.join(teamDir, TEAM_MANIFEST_FILE));
|
|
10758
10959
|
const policyPath = path3.join(teamDir, TEAM_POLICY_FILE);
|
|
10759
10960
|
if (!existsSync3(policyPath)) {
|
|
10760
10961
|
throw new Error(`${teamDir} is missing ${TEAM_POLICY_FILE}.`);
|
|
10761
10962
|
}
|
|
10762
|
-
const
|
|
10963
|
+
const agentFiles = readdirSync2(teamDir).filter((entry) => entry.endsWith(".agent.md")).sort();
|
|
10964
|
+
const issues = [];
|
|
10965
|
+
const agents = agentFiles.flatMap((entry) => {
|
|
10966
|
+
const agentPath = path3.join(teamDir, entry);
|
|
10967
|
+
try {
|
|
10968
|
+
return [mapAgentProfile(agentPath)];
|
|
10969
|
+
} catch (error45) {
|
|
10970
|
+
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
10971
|
+
issues.push(createSkippedAgentIssue(agentPath, message));
|
|
10972
|
+
return [];
|
|
10973
|
+
}
|
|
10974
|
+
});
|
|
10763
10975
|
if (agents.length === 0) {
|
|
10764
10976
|
throw new Error(`${teamDir} must contain at least one *.agent.md file at the team root.`);
|
|
10765
10977
|
}
|
|
10766
10978
|
return {
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10979
|
+
team: {
|
|
10980
|
+
manifest,
|
|
10981
|
+
policy: mapTeamPolicy(policyPath),
|
|
10982
|
+
agents,
|
|
10983
|
+
documentation: resolveTeamDocumentation(teamDir, workspaceRoot)
|
|
10984
|
+
},
|
|
10985
|
+
issues
|
|
10771
10986
|
};
|
|
10772
10987
|
}
|
|
10773
10988
|
|
|
@@ -10821,7 +11036,10 @@ function normalizeTeamAgentIds(input) {
|
|
|
10821
11036
|
if (nextUsedIds.has(assigned) || localAssignedIds.has(assigned)) {
|
|
10822
11037
|
issues.push({
|
|
10823
11038
|
level: "error",
|
|
10824
|
-
|
|
11039
|
+
code: "canonical_agent_id_collision",
|
|
11040
|
+
message: `Team '${input.team.manifest.id}' cannot assign a unique canonicalAgentId for source agent '${sourceId}'. Candidate '${candidate}' and fallback '${fallback}' both collide.`,
|
|
11041
|
+
path: `agents.${sourceId}.id`,
|
|
11042
|
+
suggestion: "Rename the source Agent id or Team id so CrewBee can derive a unique canonical Agent id."
|
|
10825
11043
|
});
|
|
10826
11044
|
return { issues };
|
|
10827
11045
|
}
|
|
@@ -10894,34 +11112,49 @@ function validateTeamDefinition(team) {
|
|
|
10894
11112
|
if (!agentIds.has(manifest.leader.agentRef)) {
|
|
10895
11113
|
issues.push({
|
|
10896
11114
|
level: "error",
|
|
10897
|
-
|
|
11115
|
+
code: "team_leader_missing",
|
|
11116
|
+
path: "leader.agent_ref",
|
|
11117
|
+
message: `Leader agent '${manifest.leader.agentRef}' is not defined in this Team.`,
|
|
11118
|
+
suggestion: "Add a matching *.agent.md profile or update leader.agent_ref."
|
|
10898
11119
|
});
|
|
10899
11120
|
} else if (leaderAgent?.entryPoint?.exposure !== "user-selectable") {
|
|
10900
11121
|
issues.push({
|
|
10901
11122
|
level: "error",
|
|
10902
|
-
|
|
11123
|
+
code: "team_leader_not_user_selectable",
|
|
11124
|
+
path: "leader.agent_ref",
|
|
11125
|
+
message: `Leader agent '${manifest.leader.agentRef}' must be user-selectable.`,
|
|
11126
|
+
suggestion: "Set entry_point.exposure to user-selectable on the leader Agent profile."
|
|
10903
11127
|
});
|
|
10904
11128
|
}
|
|
10905
11129
|
for (const agentRef of Object.keys(manifest.members)) {
|
|
10906
11130
|
if (!agentIds.has(agentRef)) {
|
|
10907
11131
|
issues.push({
|
|
10908
|
-
level: "
|
|
10909
|
-
|
|
11132
|
+
level: "warning",
|
|
11133
|
+
code: "team_member_missing",
|
|
11134
|
+
path: `members.${agentRef}`,
|
|
11135
|
+
message: `Member agent '${agentRef}' is not defined in this Team.`,
|
|
11136
|
+
suggestion: "Add the member Agent profile or remove this manifest member entry."
|
|
10910
11137
|
});
|
|
10911
11138
|
}
|
|
10912
11139
|
}
|
|
10913
11140
|
if (!team.policy) {
|
|
10914
11141
|
issues.push({
|
|
10915
11142
|
level: "error",
|
|
10916
|
-
|
|
11143
|
+
code: "team_policy_missing",
|
|
11144
|
+
path: "team.policy.yaml",
|
|
11145
|
+
message: `Team '${manifest.id}' must define team.policy.yaml.`,
|
|
11146
|
+
suggestion: "Create team.policy.yaml at the Team root."
|
|
10917
11147
|
});
|
|
10918
11148
|
return issues;
|
|
10919
11149
|
}
|
|
10920
11150
|
for (const [agentId] of Object.entries(manifest.agentRuntime ?? {})) {
|
|
10921
11151
|
if (!agentIds.has(agentId)) {
|
|
10922
11152
|
issues.push({
|
|
10923
|
-
level: "
|
|
10924
|
-
|
|
11153
|
+
level: "warning",
|
|
11154
|
+
code: "team_agent_runtime_target_missing",
|
|
11155
|
+
path: `agent_runtime.${agentId}`,
|
|
11156
|
+
message: `Agent runtime override '${agentId}' is not defined in this Team.`,
|
|
11157
|
+
suggestion: "Remove this runtime override or add the target Agent profile."
|
|
10925
11158
|
});
|
|
10926
11159
|
}
|
|
10927
11160
|
}
|
|
@@ -10934,27 +11167,39 @@ function validateTeamDefinition(team) {
|
|
|
10934
11167
|
if (requestedTools.size === 0) {
|
|
10935
11168
|
issues.push({
|
|
10936
11169
|
level: "error",
|
|
10937
|
-
|
|
11170
|
+
code: "agent_requested_tools_missing",
|
|
11171
|
+
path: `agents.${agent.metadata.id}.runtime_config.requested_tools`,
|
|
11172
|
+
message: `Agent '${agent.metadata.id}' must declare at least one requested tool.`,
|
|
11173
|
+
suggestion: "Add runtime_config.requested_tools with at least one tool name."
|
|
10938
11174
|
});
|
|
10939
11175
|
}
|
|
10940
11176
|
if (agent.runtimeConfig.permission.length === 0) {
|
|
10941
11177
|
issues.push({
|
|
10942
11178
|
level: "error",
|
|
10943
|
-
|
|
11179
|
+
code: "agent_permission_missing",
|
|
11180
|
+
path: `agents.${agent.metadata.id}.runtime_config.permission`,
|
|
11181
|
+
message: `Agent '${agent.metadata.id}' must declare at least one permission rule.`,
|
|
11182
|
+
suggestion: "Add runtime_config.permission with at least one permission rule."
|
|
10944
11183
|
});
|
|
10945
11184
|
}
|
|
10946
11185
|
for (const targetAgentRef of collaborationTargets) {
|
|
10947
11186
|
if (!agentIds.has(targetAgentRef)) {
|
|
10948
11187
|
issues.push({
|
|
10949
|
-
level: "
|
|
10950
|
-
|
|
11188
|
+
level: "warning",
|
|
11189
|
+
code: "agent_collaboration_target_unknown",
|
|
11190
|
+
path: `agents.${agent.metadata.id}.collaboration`,
|
|
11191
|
+
message: `Agent '${agent.metadata.id}' references unknown collaboration target '${targetAgentRef}'.`,
|
|
11192
|
+
suggestion: "Add the target Agent profile or update the collaboration binding."
|
|
10951
11193
|
});
|
|
10952
11194
|
continue;
|
|
10953
11195
|
}
|
|
10954
11196
|
if (targetAgentRef !== manifest.leader.agentRef && !manifest.members[targetAgentRef]) {
|
|
10955
11197
|
issues.push({
|
|
10956
11198
|
level: "error",
|
|
10957
|
-
|
|
11199
|
+
code: "agent_collaboration_target_missing_member_guidance",
|
|
11200
|
+
path: `agents.${agent.metadata.id}.collaboration`,
|
|
11201
|
+
message: `Agent '${agent.metadata.id}' references collaboration target '${targetAgentRef}' without manifest member guidance.`,
|
|
11202
|
+
suggestion: "Add manifest member guidance for this collaboration target or remove the binding."
|
|
10958
11203
|
});
|
|
10959
11204
|
}
|
|
10960
11205
|
}
|
|
@@ -10962,43 +11207,63 @@ function validateTeamDefinition(team) {
|
|
|
10962
11207
|
if (manifest.governance.instructionPrecedence.length === 0) {
|
|
10963
11208
|
issues.push({
|
|
10964
11209
|
level: "error",
|
|
10965
|
-
|
|
11210
|
+
code: "team_governance_instruction_precedence_missing",
|
|
11211
|
+
path: "governance.instruction_precedence",
|
|
11212
|
+
message: `Team '${manifest.id}' must define governance.instructionPrecedence.`,
|
|
11213
|
+
suggestion: "Add governance.instruction_precedence with at least one rule."
|
|
10966
11214
|
});
|
|
10967
11215
|
}
|
|
10968
11216
|
if (!team.policy.instructionPrecedence) {
|
|
10969
11217
|
issues.push({
|
|
10970
11218
|
level: "error",
|
|
10971
|
-
|
|
11219
|
+
code: "team_policy_instruction_precedence_missing",
|
|
11220
|
+
path: "team.policy.yaml.instruction_precedence",
|
|
11221
|
+
message: `Team '${manifest.id}' must define policy.instruction_precedence.`,
|
|
11222
|
+
suggestion: "Add instruction_precedence to team.policy.yaml."
|
|
10972
11223
|
});
|
|
10973
11224
|
}
|
|
10974
11225
|
if (!team.policy.workingRules) {
|
|
10975
11226
|
issues.push({
|
|
10976
11227
|
level: "error",
|
|
10977
|
-
|
|
11228
|
+
code: "team_policy_working_rules_missing",
|
|
11229
|
+
path: "team.policy.yaml.working_rules",
|
|
11230
|
+
message: `Team '${manifest.id}' must define policy.working_rules.`,
|
|
11231
|
+
suggestion: "Add working_rules to team.policy.yaml."
|
|
10978
11232
|
});
|
|
10979
11233
|
}
|
|
10980
11234
|
if (!team.policy.qualityFloor) {
|
|
10981
11235
|
issues.push({
|
|
10982
11236
|
level: "error",
|
|
10983
|
-
|
|
11237
|
+
code: "team_policy_quality_floor_missing",
|
|
11238
|
+
path: "team.policy.yaml.quality_floor",
|
|
11239
|
+
message: `Team '${manifest.id}' must define policy.quality_floor.`,
|
|
11240
|
+
suggestion: "Add quality_floor to team.policy.yaml."
|
|
10984
11241
|
});
|
|
10985
11242
|
}
|
|
10986
11243
|
if (manifest.governance.workingRules.length === 0) {
|
|
10987
11244
|
issues.push({
|
|
10988
11245
|
level: "error",
|
|
10989
|
-
|
|
11246
|
+
code: "team_governance_working_rules_missing",
|
|
11247
|
+
path: "governance.working_rules",
|
|
11248
|
+
message: `Team '${manifest.id}' must define governance.workingRules.`,
|
|
11249
|
+
suggestion: "Add governance.working_rules with at least one rule."
|
|
10990
11250
|
});
|
|
10991
11251
|
}
|
|
10992
11252
|
if (manifest.governance.qualityFloor.requiredChecks.length === 0) {
|
|
10993
11253
|
issues.push({
|
|
10994
11254
|
level: "error",
|
|
10995
|
-
|
|
11255
|
+
code: "team_governance_required_checks_missing",
|
|
11256
|
+
path: "governance.quality_floor.required_checks",
|
|
11257
|
+
message: `Team '${manifest.id}' must define governance.qualityFloor.requiredChecks.`,
|
|
11258
|
+
suggestion: "Add governance.quality_floor.required_checks with at least one check."
|
|
10996
11259
|
});
|
|
10997
11260
|
}
|
|
10998
11261
|
if (!team.documentation?.teamReadme && !EMBEDDED_TEAM_IDS.includes(manifest.id)) {
|
|
10999
11262
|
issues.push({
|
|
11000
11263
|
level: "warning",
|
|
11001
|
-
|
|
11264
|
+
code: "team_documentation_missing",
|
|
11265
|
+
message: `Team '${manifest.id}' has no human-facing TEAM.md or README.md at the team root.`,
|
|
11266
|
+
suggestion: "Add TEAM.md or README.md to document this Team for humans."
|
|
11002
11267
|
});
|
|
11003
11268
|
}
|
|
11004
11269
|
return issues;
|
|
@@ -11012,11 +11277,16 @@ function createSkippedTeamIssue(teamDir, message) {
|
|
|
11012
11277
|
return {
|
|
11013
11278
|
level: "warning",
|
|
11014
11279
|
filePath: teamDir,
|
|
11015
|
-
|
|
11280
|
+
code: "team_load_failed",
|
|
11281
|
+
message: `Skipped Team '${path4.basename(teamDir)}': ${message}`,
|
|
11282
|
+
suggestion: "Fix this Team directory; CrewBee will continue loading other valid Teams."
|
|
11016
11283
|
};
|
|
11017
11284
|
}
|
|
11018
|
-
function loadDefaultTeamLibrary(
|
|
11019
|
-
const
|
|
11285
|
+
function loadDefaultTeamLibrary(input = process.cwd()) {
|
|
11286
|
+
const baseDir = typeof input === "string" ? input : input.projectWorktree ?? process.cwd();
|
|
11287
|
+
const configured = listConfiguredTeamSources(
|
|
11288
|
+
typeof input === "string" ? { projectWorktree: input } : { globalConfigRoot: input.globalConfigRoot, projectWorktree: input.projectWorktree }
|
|
11289
|
+
);
|
|
11020
11290
|
const pendingTeams = [];
|
|
11021
11291
|
for (const source of configured.sources) {
|
|
11022
11292
|
if (!source.enabled) {
|
|
@@ -11031,16 +11301,20 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11031
11301
|
pendingTeams.push({
|
|
11032
11302
|
loader: () => ({ team: embeddedTeam.team, issues: [] }),
|
|
11033
11303
|
priority: source.priority,
|
|
11034
|
-
order: source.order
|
|
11304
|
+
order: source.order,
|
|
11305
|
+
sourcePrecedence: source.sourcePrecedence,
|
|
11306
|
+
sourceScope: source.sourceScope,
|
|
11307
|
+
configPath: source.configPath
|
|
11035
11308
|
});
|
|
11036
11309
|
continue;
|
|
11037
11310
|
}
|
|
11038
11311
|
pendingTeams.push({
|
|
11039
11312
|
loader: () => {
|
|
11040
11313
|
try {
|
|
11314
|
+
const loaded = loadTeamDefinitionFromDirectoryWithIssues(source.teamDir, baseDir);
|
|
11041
11315
|
return {
|
|
11042
|
-
team:
|
|
11043
|
-
issues:
|
|
11316
|
+
team: loaded.team,
|
|
11317
|
+
issues: loaded.issues
|
|
11044
11318
|
};
|
|
11045
11319
|
} catch (error45) {
|
|
11046
11320
|
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
@@ -11050,10 +11324,17 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11050
11324
|
}
|
|
11051
11325
|
},
|
|
11052
11326
|
priority: source.priority,
|
|
11053
|
-
order: source.order
|
|
11327
|
+
order: source.order,
|
|
11328
|
+
sourcePrecedence: source.sourcePrecedence,
|
|
11329
|
+
sourceScope: source.sourceScope,
|
|
11330
|
+
configPath: source.configPath
|
|
11054
11331
|
});
|
|
11055
11332
|
}
|
|
11056
11333
|
pendingTeams.sort((left, right) => {
|
|
11334
|
+
const sourceOrder = left.sourcePrecedence - right.sourcePrecedence;
|
|
11335
|
+
if (sourceOrder !== 0) {
|
|
11336
|
+
return sourceOrder;
|
|
11337
|
+
}
|
|
11057
11338
|
const priorityOrder = left.priority - right.priority;
|
|
11058
11339
|
if (priorityOrder !== 0) {
|
|
11059
11340
|
return priorityOrder;
|
|
@@ -11061,11 +11342,25 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11061
11342
|
return left.order - right.order;
|
|
11062
11343
|
});
|
|
11063
11344
|
const usedCanonicalIds = /* @__PURE__ */ new Set();
|
|
11345
|
+
const usedTeamIds = /* @__PURE__ */ new Map();
|
|
11064
11346
|
const orderedTeams = [];
|
|
11065
11347
|
for (const entry of pendingTeams) {
|
|
11066
11348
|
const loaded = entry.loader();
|
|
11067
11349
|
configured.issues.push(...loaded.issues);
|
|
11068
11350
|
if (loaded.team) {
|
|
11351
|
+
const existing = usedTeamIds.get(loaded.team.manifest.id);
|
|
11352
|
+
if (existing) {
|
|
11353
|
+
configured.issues.push({
|
|
11354
|
+
level: "warning",
|
|
11355
|
+
filePath: entry.configPath,
|
|
11356
|
+
code: "team_id_shadowed_or_duplicate",
|
|
11357
|
+
sourceScope: entry.sourceScope === "project" || entry.sourceScope === "global" ? entry.sourceScope : void 0,
|
|
11358
|
+
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.`,
|
|
11359
|
+
suggestion: entry.sourceScope === "global" && existing.sourceScope === "project" ? "This is expected when a project intentionally overrides a global Team id." : "Rename one Team id or disable one Team entry."
|
|
11360
|
+
});
|
|
11361
|
+
continue;
|
|
11362
|
+
}
|
|
11363
|
+
const usedCanonicalIdsBeforeNormalize = new Set(usedCanonicalIds);
|
|
11069
11364
|
const normalized = normalizeTeamAgentIds({
|
|
11070
11365
|
team: loaded.team,
|
|
11071
11366
|
usedCanonicalIds
|
|
@@ -11075,15 +11370,26 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
11075
11370
|
const validationIssues = validateTeamDefinition(normalized.team);
|
|
11076
11371
|
const errors = validationIssues.filter((issue2) => issue2.level === "error");
|
|
11077
11372
|
if (errors.length > 0) {
|
|
11373
|
+
usedCanonicalIds.clear();
|
|
11374
|
+
for (const usedId of usedCanonicalIdsBeforeNormalize) {
|
|
11375
|
+
usedCanonicalIds.add(usedId);
|
|
11376
|
+
}
|
|
11078
11377
|
configured.issues.push(...errors.map((issue2) => ({
|
|
11079
11378
|
level: "warning",
|
|
11080
11379
|
filePath: issue2.filePath,
|
|
11380
|
+
code: issue2.code ?? "team_validation_failed",
|
|
11381
|
+
path: issue2.path,
|
|
11382
|
+
suggestion: issue2.suggestion,
|
|
11081
11383
|
message: `Skipped Team '${normalized.team?.manifest.id ?? "unknown"}': ${issue2.message}`
|
|
11082
11384
|
})));
|
|
11083
11385
|
continue;
|
|
11084
11386
|
}
|
|
11085
11387
|
configured.issues.push(...validationIssues.filter((issue2) => issue2.level === "warning"));
|
|
11086
11388
|
orderedTeams.push(normalized.team);
|
|
11389
|
+
usedTeamIds.set(normalized.team.manifest.id, {
|
|
11390
|
+
sourceScope: entry.sourceScope,
|
|
11391
|
+
configPath: entry.configPath
|
|
11392
|
+
});
|
|
11087
11393
|
}
|
|
11088
11394
|
}
|
|
11089
11395
|
}
|
|
@@ -12533,7 +12839,7 @@ function getConfig(cfg) {
|
|
|
12533
12839
|
}
|
|
12534
12840
|
async function validateAndLogTeamLibrary(ctx, teamLibrary) {
|
|
12535
12841
|
const issues = validateTeamLibrary(teamLibrary);
|
|
12536
|
-
const errors = issues.filter((issue2) => issue2.level === "error");
|
|
12842
|
+
const errors = issues.filter((issue2) => issue2.level === "error" && issue2.blocking !== false);
|
|
12537
12843
|
if (errors.length > 0) {
|
|
12538
12844
|
throw new Error(errors.map((issue2) => issue2.message).join("\n"));
|
|
12539
12845
|
}
|
|
@@ -12543,7 +12849,14 @@ async function validateAndLogTeamLibrary(ctx, teamLibrary) {
|
|
|
12543
12849
|
service: "crewbee",
|
|
12544
12850
|
level: issue2.level === "warning" ? "warn" : "error",
|
|
12545
12851
|
message: issue2.message,
|
|
12546
|
-
extra:
|
|
12852
|
+
extra: {
|
|
12853
|
+
...issue2.filePath ? { filePath: issue2.filePath } : {},
|
|
12854
|
+
...issue2.code ? { code: issue2.code } : {},
|
|
12855
|
+
...issue2.path ? { path: issue2.path } : {},
|
|
12856
|
+
...issue2.sourceScope ? { sourceScope: issue2.sourceScope } : {},
|
|
12857
|
+
...issue2.fixable !== void 0 ? { fixable: issue2.fixable } : {},
|
|
12858
|
+
...issue2.suggestion ? { suggestion: issue2.suggestion } : {}
|
|
12859
|
+
}
|
|
12547
12860
|
}
|
|
12548
12861
|
}))
|
|
12549
12862
|
);
|
|
@@ -25552,7 +25865,7 @@ function createDelegateTools(input) {
|
|
|
25552
25865
|
}
|
|
25553
25866
|
|
|
25554
25867
|
// src/adapters/opencode/system-transform-hook.ts
|
|
25555
|
-
function createSystemTransformHook(bindings) {
|
|
25868
|
+
function createSystemTransformHook(bindings, getLoadIssues = () => []) {
|
|
25556
25869
|
return async (input, output) => {
|
|
25557
25870
|
if (!input.sessionID) {
|
|
25558
25871
|
return;
|
|
@@ -25561,13 +25874,30 @@ function createSystemTransformHook(bindings) {
|
|
|
25561
25874
|
if (!binding3) {
|
|
25562
25875
|
return;
|
|
25563
25876
|
}
|
|
25564
|
-
|
|
25877
|
+
const lines = [
|
|
25565
25878
|
"CrewBee runtime binding:",
|
|
25566
25879
|
`- Team: ${binding3.teamId}`,
|
|
25567
25880
|
`- Entry Agent: ${binding3.selectedAgentId}`,
|
|
25568
25881
|
`- Active Owner: ${binding3.activeOwnerId}`,
|
|
25569
25882
|
`- Mode: ${binding3.mode}`
|
|
25570
|
-
]
|
|
25883
|
+
];
|
|
25884
|
+
const loadIssues = getLoadIssues();
|
|
25885
|
+
if (loadIssues.length > 0) {
|
|
25886
|
+
lines.push(
|
|
25887
|
+
"- Team Load Warnings:",
|
|
25888
|
+
...loadIssues.map((issue2) => {
|
|
25889
|
+
const details = [
|
|
25890
|
+
issue2.code,
|
|
25891
|
+
issue2.sourceScope ? `scope=${issue2.sourceScope}` : void 0,
|
|
25892
|
+
issue2.filePath,
|
|
25893
|
+
issue2.path ? `path=${issue2.path}` : void 0,
|
|
25894
|
+
issue2.suggestion ? `suggestion=${issue2.suggestion}` : void 0
|
|
25895
|
+
].filter(Boolean).join("; ");
|
|
25896
|
+
return ` - ${issue2.message}${details ? ` (${details})` : ""}`;
|
|
25897
|
+
})
|
|
25898
|
+
);
|
|
25899
|
+
}
|
|
25900
|
+
output.system.push(lines.join("\n"));
|
|
25571
25901
|
};
|
|
25572
25902
|
}
|
|
25573
25903
|
|
|
@@ -26093,7 +26423,10 @@ var OpenCodeCrewBeePlugin = async (ctx) => {
|
|
|
26093
26423
|
getAliasIndex: () => aliasIndex
|
|
26094
26424
|
}),
|
|
26095
26425
|
"tool.execute.after": createToolExecuteAfterHook(),
|
|
26096
|
-
"experimental.chat.system.transform": createSystemTransformHook(
|
|
26426
|
+
"experimental.chat.system.transform": createSystemTransformHook(
|
|
26427
|
+
bindings,
|
|
26428
|
+
() => teamLibrary.loadIssues ?? []
|
|
26429
|
+
),
|
|
26097
26430
|
"experimental.session.compacting": createCompactionHook(ctx, store)
|
|
26098
26431
|
};
|
|
26099
26432
|
};
|