@levelcode/cli 0.2.3 → 0.2.5
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/index.js +1173 -470
- package/dist/rg-0p18sjte. +0 -0
- package/dist/rg-3agys64c. +0 -0
- package/dist/rg-ch8fa8g7. +0 -0
- package/dist/rg-maqk0g78.exe +0 -0
- package/dist/rg-r6ev1ksc. +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -73839,19 +73839,167 @@ var init_dev_phases = __esm(() => {
|
|
|
73839
73839
|
];
|
|
73840
73840
|
});
|
|
73841
73841
|
|
|
73842
|
-
// ../
|
|
73842
|
+
// ../common/src/utils/team-discovery.ts
|
|
73843
73843
|
import * as fs5 from "fs";
|
|
73844
|
+
import * as path8 from "path";
|
|
73845
|
+
import * as os4 from "os";
|
|
73846
|
+
function getLastActiveTeamPath() {
|
|
73847
|
+
return path8.join(os4.homedir(), ".config", "levelcode", "teams", ".last-active-team");
|
|
73848
|
+
}
|
|
73849
|
+
function setLastActiveTeam(teamName) {
|
|
73850
|
+
try {
|
|
73851
|
+
const filePath = getLastActiveTeamPath();
|
|
73852
|
+
fs5.mkdirSync(path8.dirname(filePath), { recursive: true });
|
|
73853
|
+
fs5.writeFileSync(filePath, teamName, "utf-8");
|
|
73854
|
+
} catch {}
|
|
73855
|
+
}
|
|
73856
|
+
function getLastActiveTeam() {
|
|
73857
|
+
try {
|
|
73858
|
+
const filePath = getLastActiveTeamPath();
|
|
73859
|
+
if (!fs5.existsSync(filePath)) {
|
|
73860
|
+
return null;
|
|
73861
|
+
}
|
|
73862
|
+
const name17 = fs5.readFileSync(filePath, "utf-8").trim();
|
|
73863
|
+
return name17 || null;
|
|
73864
|
+
} catch {
|
|
73865
|
+
return null;
|
|
73866
|
+
}
|
|
73867
|
+
}
|
|
73868
|
+
function readTeamEntries() {
|
|
73869
|
+
let teamsDir;
|
|
73870
|
+
try {
|
|
73871
|
+
teamsDir = getTeamsDir();
|
|
73872
|
+
} catch {
|
|
73873
|
+
return [];
|
|
73874
|
+
}
|
|
73875
|
+
if (!fs5.existsSync(teamsDir)) {
|
|
73876
|
+
return [];
|
|
73877
|
+
}
|
|
73878
|
+
try {
|
|
73879
|
+
return fs5.readdirSync(teamsDir, { withFileTypes: true });
|
|
73880
|
+
} catch {
|
|
73881
|
+
return [];
|
|
73882
|
+
}
|
|
73883
|
+
}
|
|
73884
|
+
function safeLoadTeamConfig(teamName) {
|
|
73885
|
+
try {
|
|
73886
|
+
const config2 = loadTeamConfig(teamName);
|
|
73887
|
+
if (!config2 || !Array.isArray(config2.members)) {
|
|
73888
|
+
return null;
|
|
73889
|
+
}
|
|
73890
|
+
return config2;
|
|
73891
|
+
} catch {
|
|
73892
|
+
return null;
|
|
73893
|
+
}
|
|
73894
|
+
}
|
|
73895
|
+
function loadAllTeamConfigs() {
|
|
73896
|
+
const entries = readTeamEntries();
|
|
73897
|
+
const results = [];
|
|
73898
|
+
for (const entry of entries) {
|
|
73899
|
+
if (!entry.isDirectory()) {
|
|
73900
|
+
continue;
|
|
73901
|
+
}
|
|
73902
|
+
const config2 = safeLoadTeamConfig(entry.name);
|
|
73903
|
+
if (config2) {
|
|
73904
|
+
results.push({ teamName: config2.name, config: config2 });
|
|
73905
|
+
}
|
|
73906
|
+
}
|
|
73907
|
+
return results;
|
|
73908
|
+
}
|
|
73909
|
+
function findCurrentTeam(agentId) {
|
|
73910
|
+
const allTeams = loadAllTeamConfigs();
|
|
73911
|
+
for (const { teamName, config: config2 } of allTeams) {
|
|
73912
|
+
if (config2.leadAgentId === `lead-${agentId}`) {
|
|
73913
|
+
return { teamName, config: config2 };
|
|
73914
|
+
}
|
|
73915
|
+
for (const member of config2.members) {
|
|
73916
|
+
if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
|
|
73917
|
+
return { teamName, config: config2 };
|
|
73918
|
+
}
|
|
73919
|
+
}
|
|
73920
|
+
}
|
|
73921
|
+
if (allTeams.length === 1) {
|
|
73922
|
+
return allTeams[0];
|
|
73923
|
+
}
|
|
73924
|
+
const lastActive = getLastActiveTeam();
|
|
73925
|
+
if (lastActive) {
|
|
73926
|
+
const match = allTeams.find((t2) => t2.teamName === lastActive);
|
|
73927
|
+
if (match) {
|
|
73928
|
+
return match;
|
|
73929
|
+
}
|
|
73930
|
+
}
|
|
73931
|
+
return null;
|
|
73932
|
+
}
|
|
73933
|
+
function findCurrentTeamAndAgent(agentId) {
|
|
73934
|
+
const allTeams = loadAllTeamConfigs();
|
|
73935
|
+
for (const { teamName, config: config2 } of allTeams) {
|
|
73936
|
+
for (const member of config2.members) {
|
|
73937
|
+
if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
|
|
73938
|
+
return { teamName, agentName: member.name, config: config2 };
|
|
73939
|
+
}
|
|
73940
|
+
}
|
|
73941
|
+
}
|
|
73942
|
+
let resolved = null;
|
|
73943
|
+
if (allTeams.length === 1) {
|
|
73944
|
+
resolved = allTeams[0];
|
|
73945
|
+
} else {
|
|
73946
|
+
const lastActive = getLastActiveTeam();
|
|
73947
|
+
if (lastActive) {
|
|
73948
|
+
resolved = allTeams.find((t2) => t2.teamName === lastActive) ?? null;
|
|
73949
|
+
}
|
|
73950
|
+
}
|
|
73951
|
+
if (resolved) {
|
|
73952
|
+
const leadMember = resolved.config.members.find((m) => m.agentId === resolved.config.leadAgentId);
|
|
73953
|
+
const agentName = leadMember?.name ?? "team-lead";
|
|
73954
|
+
return { teamName: resolved.teamName, agentName, config: resolved.config };
|
|
73955
|
+
}
|
|
73956
|
+
return null;
|
|
73957
|
+
}
|
|
73958
|
+
function findTeamByName(name17) {
|
|
73959
|
+
try {
|
|
73960
|
+
validateTeamName(name17);
|
|
73961
|
+
} catch {
|
|
73962
|
+
return null;
|
|
73963
|
+
}
|
|
73964
|
+
return safeLoadTeamConfig(name17);
|
|
73965
|
+
}
|
|
73966
|
+
function listAllTeams() {
|
|
73967
|
+
const entries = readTeamEntries();
|
|
73968
|
+
const results = [];
|
|
73969
|
+
for (const entry of entries) {
|
|
73970
|
+
if (!entry.isDirectory()) {
|
|
73971
|
+
continue;
|
|
73972
|
+
}
|
|
73973
|
+
const config2 = safeLoadTeamConfig(entry.name);
|
|
73974
|
+
if (!config2) {
|
|
73975
|
+
continue;
|
|
73976
|
+
}
|
|
73977
|
+
results.push({
|
|
73978
|
+
name: config2.name,
|
|
73979
|
+
phase: config2.phase,
|
|
73980
|
+
memberCount: config2.members.length
|
|
73981
|
+
});
|
|
73982
|
+
}
|
|
73983
|
+
return results;
|
|
73984
|
+
}
|
|
73985
|
+
var init_team_discovery = __esm(() => {
|
|
73986
|
+
init_team_fs();
|
|
73987
|
+
});
|
|
73988
|
+
|
|
73989
|
+
// ../packages/agent-runtime/src/team-context.ts
|
|
73990
|
+
import * as fs6 from "fs";
|
|
73844
73991
|
function findTeamContext(agentIdentifier) {
|
|
73845
73992
|
const teamsDir = getTeamsDir();
|
|
73846
|
-
if (!
|
|
73993
|
+
if (!fs6.existsSync(teamsDir)) {
|
|
73847
73994
|
return null;
|
|
73848
73995
|
}
|
|
73849
73996
|
let entries;
|
|
73850
73997
|
try {
|
|
73851
|
-
entries =
|
|
73998
|
+
entries = fs6.readdirSync(teamsDir, { withFileTypes: true });
|
|
73852
73999
|
} catch {
|
|
73853
74000
|
return null;
|
|
73854
74001
|
}
|
|
74002
|
+
const allTeams = [];
|
|
73855
74003
|
for (const entry of entries) {
|
|
73856
74004
|
if (!entry.isDirectory()) {
|
|
73857
74005
|
continue;
|
|
@@ -73860,16 +74008,35 @@ function findTeamContext(agentIdentifier) {
|
|
|
73860
74008
|
if (!config2) {
|
|
73861
74009
|
continue;
|
|
73862
74010
|
}
|
|
74011
|
+
allTeams.push({ teamName: config2.name, config: config2 });
|
|
74012
|
+
}
|
|
74013
|
+
for (const { teamName, config: config2 } of allTeams) {
|
|
73863
74014
|
for (const member of config2.members) {
|
|
73864
74015
|
if (member.agentId === agentIdentifier || member.agentId === `lead-${agentIdentifier}`) {
|
|
73865
|
-
return { teamName
|
|
74016
|
+
return { teamName, agentName: member.name, config: config2 };
|
|
73866
74017
|
}
|
|
73867
74018
|
}
|
|
73868
74019
|
}
|
|
74020
|
+
function resolveFromTeam(team) {
|
|
74021
|
+
const leadMember = team.config.members.find((m) => m.agentId === team.config.leadAgentId);
|
|
74022
|
+
const agentName = leadMember?.name ?? "team-lead";
|
|
74023
|
+
return { teamName: team.teamName, agentName, config: team.config };
|
|
74024
|
+
}
|
|
74025
|
+
if (allTeams.length === 1) {
|
|
74026
|
+
return resolveFromTeam(allTeams[0]);
|
|
74027
|
+
}
|
|
74028
|
+
const lastActive = getLastActiveTeam();
|
|
74029
|
+
if (lastActive) {
|
|
74030
|
+
const match = allTeams.find((t2) => t2.teamName === lastActive);
|
|
74031
|
+
if (match) {
|
|
74032
|
+
return resolveFromTeam(match);
|
|
74033
|
+
}
|
|
74034
|
+
}
|
|
73869
74035
|
return null;
|
|
73870
74036
|
}
|
|
73871
74037
|
var init_team_context = __esm(() => {
|
|
73872
74038
|
init_team_fs();
|
|
74039
|
+
init_team_discovery();
|
|
73873
74040
|
});
|
|
73874
74041
|
|
|
73875
74042
|
// ../common/src/util/zod-schema.ts
|
|
@@ -83766,12 +83933,12 @@ async function postStreamProcessing(toolCall, fileProcessingState2, writeToClien
|
|
|
83766
83933
|
if (errors4.length > 1) {
|
|
83767
83934
|
throw new Error(`Internal error: Unexpected number of matching errors for ${JSON.stringify(toolCall)}, found ${errors4.length}, expected 1`);
|
|
83768
83935
|
}
|
|
83769
|
-
const { path:
|
|
83936
|
+
const { path: path9, error: error46 } = errors4[0];
|
|
83770
83937
|
return [
|
|
83771
83938
|
{
|
|
83772
83939
|
type: "json",
|
|
83773
83940
|
value: {
|
|
83774
|
-
file:
|
|
83941
|
+
file: path9,
|
|
83775
83942
|
errorMessage: error46
|
|
83776
83943
|
}
|
|
83777
83944
|
}
|
|
@@ -84165,7 +84332,7 @@ var init_messages2 = __esm(() => {
|
|
|
84165
84332
|
});
|
|
84166
84333
|
|
|
84167
84334
|
// ../packages/agent-runtime/src/find-files/request-files-prompt.ts
|
|
84168
|
-
import { dirname as
|
|
84335
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, normalize } from "path";
|
|
84169
84336
|
async function requestRelevantFiles(params2) {
|
|
84170
84337
|
const { messages, fileContext, assistantPrompt, logger: logger2 } = params2;
|
|
84171
84338
|
const countPerRequest = 12;
|
|
@@ -84306,11 +84473,11 @@ function getExampleFileList(params2) {
|
|
|
84306
84473
|
const selectedFiles = new Set;
|
|
84307
84474
|
const selectedDirectories = new Set;
|
|
84308
84475
|
for (const filePath of randomFilePaths) {
|
|
84309
|
-
if (selectedFiles.has(filePath) || selectedDirectories.has(
|
|
84476
|
+
if (selectedFiles.has(filePath) || selectedDirectories.has(dirname6(filePath))) {
|
|
84310
84477
|
continue;
|
|
84311
84478
|
}
|
|
84312
84479
|
selectedFiles.add(filePath);
|
|
84313
|
-
selectedDirectories.add(
|
|
84480
|
+
selectedDirectories.add(dirname6(filePath));
|
|
84314
84481
|
}
|
|
84315
84482
|
return import_lodash8.uniq([...selectedFiles, ...randomFilePaths]).slice(0, count);
|
|
84316
84483
|
}
|
|
@@ -87343,13 +87510,13 @@ var init_team_hook_emitter = __esm(() => {
|
|
|
87343
87510
|
});
|
|
87344
87511
|
|
|
87345
87512
|
// ../packages/agent-runtime/src/tools/handlers/tool/task-completed.ts
|
|
87346
|
-
import * as
|
|
87513
|
+
import * as fs7 from "fs";
|
|
87347
87514
|
function getActiveTeamName() {
|
|
87348
87515
|
const teamsDir = getTeamsDir();
|
|
87349
|
-
if (!
|
|
87516
|
+
if (!fs7.existsSync(teamsDir)) {
|
|
87350
87517
|
return null;
|
|
87351
87518
|
}
|
|
87352
|
-
const entries =
|
|
87519
|
+
const entries = fs7.readdirSync(teamsDir, { withFileTypes: true });
|
|
87353
87520
|
const teamDirs = entries.filter((e) => e.isDirectory());
|
|
87354
87521
|
if (teamDirs.length === 0) {
|
|
87355
87522
|
return null;
|
|
@@ -87627,105 +87794,6 @@ var init_write_todos2 = __esm(() => {
|
|
|
87627
87794
|
init_messages();
|
|
87628
87795
|
});
|
|
87629
87796
|
|
|
87630
|
-
// ../common/src/utils/team-discovery.ts
|
|
87631
|
-
import * as fs7 from "fs";
|
|
87632
|
-
function readTeamEntries() {
|
|
87633
|
-
let teamsDir;
|
|
87634
|
-
try {
|
|
87635
|
-
teamsDir = getTeamsDir();
|
|
87636
|
-
} catch {
|
|
87637
|
-
return [];
|
|
87638
|
-
}
|
|
87639
|
-
if (!fs7.existsSync(teamsDir)) {
|
|
87640
|
-
return [];
|
|
87641
|
-
}
|
|
87642
|
-
try {
|
|
87643
|
-
return fs7.readdirSync(teamsDir, { withFileTypes: true });
|
|
87644
|
-
} catch {
|
|
87645
|
-
return [];
|
|
87646
|
-
}
|
|
87647
|
-
}
|
|
87648
|
-
function safeLoadTeamConfig(teamName) {
|
|
87649
|
-
try {
|
|
87650
|
-
const config2 = loadTeamConfig(teamName);
|
|
87651
|
-
if (!config2 || !Array.isArray(config2.members)) {
|
|
87652
|
-
return null;
|
|
87653
|
-
}
|
|
87654
|
-
return config2;
|
|
87655
|
-
} catch {
|
|
87656
|
-
return null;
|
|
87657
|
-
}
|
|
87658
|
-
}
|
|
87659
|
-
function findCurrentTeam(agentId) {
|
|
87660
|
-
const entries = readTeamEntries();
|
|
87661
|
-
for (const entry of entries) {
|
|
87662
|
-
if (!entry.isDirectory()) {
|
|
87663
|
-
continue;
|
|
87664
|
-
}
|
|
87665
|
-
const config2 = safeLoadTeamConfig(entry.name);
|
|
87666
|
-
if (!config2) {
|
|
87667
|
-
continue;
|
|
87668
|
-
}
|
|
87669
|
-
if (config2.leadAgentId === `lead-${agentId}`) {
|
|
87670
|
-
return { teamName: config2.name, config: config2 };
|
|
87671
|
-
}
|
|
87672
|
-
for (const member of config2.members) {
|
|
87673
|
-
if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
|
|
87674
|
-
return { teamName: config2.name, config: config2 };
|
|
87675
|
-
}
|
|
87676
|
-
}
|
|
87677
|
-
}
|
|
87678
|
-
return null;
|
|
87679
|
-
}
|
|
87680
|
-
function findCurrentTeamAndAgent(agentId) {
|
|
87681
|
-
const entries = readTeamEntries();
|
|
87682
|
-
for (const entry of entries) {
|
|
87683
|
-
if (!entry.isDirectory()) {
|
|
87684
|
-
continue;
|
|
87685
|
-
}
|
|
87686
|
-
const config2 = safeLoadTeamConfig(entry.name);
|
|
87687
|
-
if (!config2) {
|
|
87688
|
-
continue;
|
|
87689
|
-
}
|
|
87690
|
-
for (const member of config2.members) {
|
|
87691
|
-
if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
|
|
87692
|
-
return { teamName: config2.name, agentName: member.name, config: config2 };
|
|
87693
|
-
}
|
|
87694
|
-
}
|
|
87695
|
-
}
|
|
87696
|
-
return null;
|
|
87697
|
-
}
|
|
87698
|
-
function findTeamByName(name17) {
|
|
87699
|
-
try {
|
|
87700
|
-
validateTeamName(name17);
|
|
87701
|
-
} catch {
|
|
87702
|
-
return null;
|
|
87703
|
-
}
|
|
87704
|
-
return safeLoadTeamConfig(name17);
|
|
87705
|
-
}
|
|
87706
|
-
function listAllTeams() {
|
|
87707
|
-
const entries = readTeamEntries();
|
|
87708
|
-
const results = [];
|
|
87709
|
-
for (const entry of entries) {
|
|
87710
|
-
if (!entry.isDirectory()) {
|
|
87711
|
-
continue;
|
|
87712
|
-
}
|
|
87713
|
-
const config2 = safeLoadTeamConfig(entry.name);
|
|
87714
|
-
if (!config2) {
|
|
87715
|
-
continue;
|
|
87716
|
-
}
|
|
87717
|
-
results.push({
|
|
87718
|
-
name: config2.name,
|
|
87719
|
-
phase: config2.phase,
|
|
87720
|
-
memberCount: config2.members.length
|
|
87721
|
-
});
|
|
87722
|
-
}
|
|
87723
|
-
return results;
|
|
87724
|
-
}
|
|
87725
|
-
var init_team_discovery = __esm(() => {
|
|
87726
|
-
init_team_fs();
|
|
87727
|
-
});
|
|
87728
|
-
|
|
87729
87797
|
// ../packages/agent-runtime/src/tools/handlers/tool/send-message.ts
|
|
87730
87798
|
function errorResult(message) {
|
|
87731
87799
|
return { output: jsonToolResult({ message }) };
|
|
@@ -88131,7 +88199,7 @@ var init_task_list2 = __esm(() => {
|
|
|
88131
88199
|
|
|
88132
88200
|
// ../packages/agent-runtime/src/tools/handlers/tool/task-update.ts
|
|
88133
88201
|
import * as fs8 from "fs";
|
|
88134
|
-
import * as
|
|
88202
|
+
import * as path9 from "path";
|
|
88135
88203
|
function errorResult4(message) {
|
|
88136
88204
|
return { output: jsonToolResult({ error: message }) };
|
|
88137
88205
|
}
|
|
@@ -88181,7 +88249,7 @@ var VALID_STATUSES, handleTaskUpdate = async (params2) => {
|
|
|
88181
88249
|
}
|
|
88182
88250
|
if (status === "deleted") {
|
|
88183
88251
|
try {
|
|
88184
|
-
const taskPath =
|
|
88252
|
+
const taskPath = path9.join(getTasksDir(teamName), `${taskId}.json`);
|
|
88185
88253
|
if (fs8.existsSync(taskPath)) {
|
|
88186
88254
|
fs8.unlinkSync(taskPath);
|
|
88187
88255
|
}
|
|
@@ -88326,6 +88394,7 @@ var handleTeamCreate = async (params2) => {
|
|
|
88326
88394
|
const errorMessage = error46 instanceof Error ? error46.message : String(error46);
|
|
88327
88395
|
return errorResult5(`Failed to create team "${team_name}": ${errorMessage}`);
|
|
88328
88396
|
}
|
|
88397
|
+
setLastActiveTeam(team_name);
|
|
88329
88398
|
trackTeamCreated({ trackEvent: trackEvent2, userId: userId ?? "", logger: logger2 }, team_name, teamConfig.members.length);
|
|
88330
88399
|
let teamFilePath;
|
|
88331
88400
|
let taskDirPath;
|
|
@@ -88348,6 +88417,7 @@ var handleTeamCreate = async (params2) => {
|
|
|
88348
88417
|
var init_team_create2 = __esm(() => {
|
|
88349
88418
|
init_messages();
|
|
88350
88419
|
init_team_fs();
|
|
88420
|
+
init_team_discovery();
|
|
88351
88421
|
init_team_analytics();
|
|
88352
88422
|
});
|
|
88353
88423
|
|
|
@@ -89393,10 +89463,79 @@ var init_run_programmatic_step = __esm(() => {
|
|
|
89393
89463
|
runIdToStepAll = new Set;
|
|
89394
89464
|
});
|
|
89395
89465
|
|
|
89466
|
+
// ../packages/agent-runtime/src/team-lifecycle.ts
|
|
89467
|
+
async function updateAgentStatus(teamName, agentId, status, logger2) {
|
|
89468
|
+
const teamMap = registry2.get(teamName);
|
|
89469
|
+
if (teamMap) {
|
|
89470
|
+
const entry = teamMap.get(agentId);
|
|
89471
|
+
if (entry) {
|
|
89472
|
+
entry.status = status;
|
|
89473
|
+
}
|
|
89474
|
+
}
|
|
89475
|
+
const config2 = loadTeamConfig(teamName);
|
|
89476
|
+
if (!config2) {
|
|
89477
|
+
logger2.debug({ teamName, agentId, status }, "updateAgentStatus: team config not found");
|
|
89478
|
+
return;
|
|
89479
|
+
}
|
|
89480
|
+
const memberIndex = config2.members.findIndex((m) => m.agentId === agentId);
|
|
89481
|
+
if (memberIndex === -1) {
|
|
89482
|
+
logger2.debug({ teamName, agentId, status }, "updateAgentStatus: member not found in team config");
|
|
89483
|
+
return;
|
|
89484
|
+
}
|
|
89485
|
+
config2.members[memberIndex].status = status;
|
|
89486
|
+
await saveTeamConfig(teamName, config2);
|
|
89487
|
+
logger2.debug({ teamName, agentId, status }, `updateAgentStatus: set status to "${status}"`);
|
|
89488
|
+
}
|
|
89489
|
+
async function markAgentIdle(params2) {
|
|
89490
|
+
const { teamName, agentId, agentName, lastTaskId, trackEvent: trackEvent2, userId, logger: logger2 } = params2;
|
|
89491
|
+
await updateAgentStatus(teamName, agentId, "idle", logger2);
|
|
89492
|
+
const config2 = loadTeamConfig(teamName);
|
|
89493
|
+
if (config2) {
|
|
89494
|
+
const member = config2.members.find((m) => m.agentId === agentId);
|
|
89495
|
+
if (member) {
|
|
89496
|
+
member.currentTaskId = undefined;
|
|
89497
|
+
await saveTeamConfig(teamName, config2);
|
|
89498
|
+
}
|
|
89499
|
+
}
|
|
89500
|
+
emitTeammateIdle({
|
|
89501
|
+
agentName,
|
|
89502
|
+
teamName,
|
|
89503
|
+
lastTaskId,
|
|
89504
|
+
trackEvent: trackEvent2,
|
|
89505
|
+
userId,
|
|
89506
|
+
logger: logger2
|
|
89507
|
+
});
|
|
89508
|
+
if (config2) {
|
|
89509
|
+
const leadMember = config2.members.find((m) => m.agentId === config2.leadAgentId);
|
|
89510
|
+
const leadName = leadMember?.name ?? "team-lead";
|
|
89511
|
+
const notification = {
|
|
89512
|
+
type: "idle_notification",
|
|
89513
|
+
from: agentName,
|
|
89514
|
+
timestamp: new Date().toISOString(),
|
|
89515
|
+
summary: lastTaskId ? `Completed task ${lastTaskId}, now idle` : "Agent is idle and ready for work",
|
|
89516
|
+
completedTaskId: lastTaskId
|
|
89517
|
+
};
|
|
89518
|
+
await sendMessage(teamName, leadName, notification);
|
|
89519
|
+
logger2.debug({ teamName, agentName, leadName, lastTaskId }, "markAgentIdle: sent idle notification to team lead");
|
|
89520
|
+
}
|
|
89521
|
+
}
|
|
89522
|
+
async function checkIdleAfterTurn(params2) {
|
|
89523
|
+
const { producedOutput, ...rest } = params2;
|
|
89524
|
+
if (!producedOutput) {
|
|
89525
|
+
await markAgentIdle(rest);
|
|
89526
|
+
}
|
|
89527
|
+
}
|
|
89528
|
+
var registry2;
|
|
89529
|
+
var init_team_lifecycle = __esm(() => {
|
|
89530
|
+
init_team_fs();
|
|
89531
|
+
init_team_hook_emitter();
|
|
89532
|
+
registry2 = new Map;
|
|
89533
|
+
});
|
|
89534
|
+
|
|
89396
89535
|
// ../common/src/constants/knowledge.ts
|
|
89397
|
-
import
|
|
89536
|
+
import path10 from "path";
|
|
89398
89537
|
function isKnowledgeFile(filePath) {
|
|
89399
|
-
const fileName =
|
|
89538
|
+
const fileName = path10.basename(filePath).toLowerCase();
|
|
89400
89539
|
if (KNOWLEDGE_FILE_NAMES_LOWERCASE.includes(fileName)) {
|
|
89401
89540
|
return true;
|
|
89402
89541
|
}
|
|
@@ -90397,6 +90536,69 @@ async function loopAgentSteps(params2) {
|
|
|
90397
90536
|
currentPrompt = undefined;
|
|
90398
90537
|
currentParams = undefined;
|
|
90399
90538
|
}
|
|
90539
|
+
const postLoopTeamContext = findTeamContext(userInputId2);
|
|
90540
|
+
if (postLoopTeamContext && !signal.aborted) {
|
|
90541
|
+
try {
|
|
90542
|
+
await checkIdleAfterTurn({
|
|
90543
|
+
teamName: postLoopTeamContext.teamName,
|
|
90544
|
+
agentId: currentAgentState.agentId,
|
|
90545
|
+
agentName: postLoopTeamContext.agentName,
|
|
90546
|
+
producedOutput: totalSteps > 0,
|
|
90547
|
+
trackEvent: params2.trackEvent,
|
|
90548
|
+
userId: userId ?? "",
|
|
90549
|
+
logger: logger2
|
|
90550
|
+
});
|
|
90551
|
+
} catch (idleErr) {
|
|
90552
|
+
logger2.debug({ error: idleErr }, "checkIdleAfterTurn failed (non-fatal)");
|
|
90553
|
+
}
|
|
90554
|
+
}
|
|
90555
|
+
if (postLoopTeamContext && !signal.aborted) {
|
|
90556
|
+
try {
|
|
90557
|
+
await new Promise((resolve6) => setTimeout(resolve6, 2000));
|
|
90558
|
+
if (!signal.aborted) {
|
|
90559
|
+
const wakeInbox = drainInbox({
|
|
90560
|
+
teamName: postLoopTeamContext.teamName,
|
|
90561
|
+
agentName: postLoopTeamContext.agentName,
|
|
90562
|
+
logger: logger2
|
|
90563
|
+
});
|
|
90564
|
+
if (wakeInbox.formattedContent) {
|
|
90565
|
+
logger2.debug({
|
|
90566
|
+
teamName: postLoopTeamContext.teamName,
|
|
90567
|
+
agentName: postLoopTeamContext.agentName,
|
|
90568
|
+
messageCount: wakeInbox.messages.length
|
|
90569
|
+
}, "Post-loop wake: new messages detected, running one more step");
|
|
90570
|
+
currentAgentState.messageHistory = [
|
|
90571
|
+
...currentAgentState.messageHistory,
|
|
90572
|
+
userMessage(withSystemTags(wakeInbox.formattedContent))
|
|
90573
|
+
];
|
|
90574
|
+
currentAgentState.stepsRemaining = Math.max(currentAgentState.stepsRemaining, 1);
|
|
90575
|
+
const wakeStep = await runAgentStep({
|
|
90576
|
+
...params2,
|
|
90577
|
+
agentState: currentAgentState,
|
|
90578
|
+
agentTemplate,
|
|
90579
|
+
prompt: undefined,
|
|
90580
|
+
runId,
|
|
90581
|
+
spawnParams: undefined,
|
|
90582
|
+
system,
|
|
90583
|
+
tools,
|
|
90584
|
+
additionalToolDefinitions: async () => {
|
|
90585
|
+
if (!cachedAdditionalToolDefinitions) {
|
|
90586
|
+
cachedAdditionalToolDefinitions = await additionalToolDefinitions({
|
|
90587
|
+
...params2,
|
|
90588
|
+
agentTemplate
|
|
90589
|
+
});
|
|
90590
|
+
}
|
|
90591
|
+
return cachedAdditionalToolDefinitions;
|
|
90592
|
+
}
|
|
90593
|
+
});
|
|
90594
|
+
totalSteps++;
|
|
90595
|
+
currentAgentState = wakeStep.agentState;
|
|
90596
|
+
}
|
|
90597
|
+
}
|
|
90598
|
+
} catch (wakeErr) {
|
|
90599
|
+
logger2.debug({ error: wakeErr }, "Post-loop wake check failed (non-fatal)");
|
|
90600
|
+
}
|
|
90601
|
+
}
|
|
90400
90602
|
if (clearUserPromptMessagesAfterResponse) {
|
|
90401
90603
|
currentAgentState.messageHistory = expireMessages(currentAgentState.messageHistory, "userPrompt");
|
|
90402
90604
|
}
|
|
@@ -90711,6 +90913,7 @@ var init_run_agent_step = __esm(() => {
|
|
|
90711
90913
|
init_prompt_agent_stream();
|
|
90712
90914
|
init_run_programmatic_step();
|
|
90713
90915
|
init_team_context();
|
|
90916
|
+
init_team_lifecycle();
|
|
90714
90917
|
init_prompts2();
|
|
90715
90918
|
init_team_prompt();
|
|
90716
90919
|
init_agent_registry();
|
|
@@ -107828,24 +108031,24 @@ var init_credentials = __esm(() => {
|
|
|
107828
108031
|
|
|
107829
108032
|
// ../sdk/src/credentials.ts
|
|
107830
108033
|
import fs9 from "fs";
|
|
107831
|
-
import
|
|
107832
|
-
import
|
|
108034
|
+
import path11 from "path";
|
|
108035
|
+
import os5 from "os";
|
|
107833
108036
|
var claudeOAuthSchema, credentialsFileSchema, ensureDirectoryExistsSync = (dir) => {
|
|
107834
108037
|
if (!fs9.existsSync(dir)) {
|
|
107835
108038
|
fs9.mkdirSync(dir, { recursive: true });
|
|
107836
108039
|
}
|
|
107837
108040
|
}, getLegacyConfigDir = (clientEnv = env2) => {
|
|
107838
108041
|
const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
|
|
107839
|
-
return
|
|
108042
|
+
return path11.join(os5.homedir(), ".config", `manicode${envSuffix}`);
|
|
107840
108043
|
}, getConfigDir = (clientEnv = env2) => {
|
|
107841
108044
|
const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
|
|
107842
|
-
return
|
|
108045
|
+
return path11.join(os5.homedir(), ".config", `levelcode${envSuffix}`);
|
|
107843
108046
|
}, migrateFromLegacyConfigDir = (clientEnv = env2) => {
|
|
107844
108047
|
const newDir = getConfigDir(clientEnv);
|
|
107845
|
-
const newCredsPath =
|
|
108048
|
+
const newCredsPath = path11.join(newDir, "credentials.json");
|
|
107846
108049
|
if (fs9.existsSync(newCredsPath))
|
|
107847
108050
|
return;
|
|
107848
|
-
const legacyCredsPath =
|
|
108051
|
+
const legacyCredsPath = path11.join(getLegacyConfigDir(clientEnv), "credentials.json");
|
|
107849
108052
|
if (!fs9.existsSync(legacyCredsPath))
|
|
107850
108053
|
return;
|
|
107851
108054
|
try {
|
|
@@ -107854,7 +108057,7 @@ var claudeOAuthSchema, credentialsFileSchema, ensureDirectoryExistsSync = (dir)
|
|
|
107854
108057
|
} catch {}
|
|
107855
108058
|
}, getCredentialsPath = (clientEnv = env2) => {
|
|
107856
108059
|
migrateFromLegacyConfigDir(clientEnv);
|
|
107857
|
-
return
|
|
108060
|
+
return path11.join(getConfigDir(clientEnv), "credentials.json");
|
|
107858
108061
|
}, getClaudeOAuthCredentials = (clientEnv = env2) => {
|
|
107859
108062
|
const envToken = getClaudeOAuthTokenFromEnv();
|
|
107860
108063
|
if (envToken) {
|
|
@@ -107987,7 +108190,7 @@ var init_credentials2 = __esm(() => {
|
|
|
107987
108190
|
});
|
|
107988
108191
|
|
|
107989
108192
|
// ../sdk/src/impl/model-provider.ts
|
|
107990
|
-
import
|
|
108193
|
+
import path12 from "path";
|
|
107991
108194
|
function markClaudeOAuthRateLimited(resetAt) {
|
|
107992
108195
|
const fiveMinutesFromNow = Date.now() + 5 * 60 * 1000;
|
|
107993
108196
|
claudeOAuthRateLimitedUntil = resetAt ? resetAt.getTime() : fiveMinutesFromNow;
|
|
@@ -108128,7 +108331,7 @@ function createLevelCodeBackendModel(apiKey, model) {
|
|
|
108128
108331
|
const openrouterApiKey = getByokOpenrouterApiKeyFromEnv();
|
|
108129
108332
|
return new OpenAICompatibleChatLanguageModel(model, {
|
|
108130
108333
|
provider: "levelcode",
|
|
108131
|
-
url: ({ path: endpoint }) => new URL(
|
|
108334
|
+
url: ({ path: endpoint }) => new URL(path12.join("/api/v1", endpoint), WEBSITE_URL).toString(),
|
|
108132
108335
|
headers: () => ({
|
|
108133
108336
|
Authorization: `Bearer ${apiKey}`,
|
|
108134
108337
|
"user-agent": `ai-sdk/openai-compatible/${VERSION6}/levelcode`,
|
|
@@ -115153,23 +115356,23 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
115153
115356
|
|
|
115154
115357
|
// ../packages/code-map/src/init-node.ts
|
|
115155
115358
|
import * as fs10 from "fs";
|
|
115156
|
-
import * as
|
|
115359
|
+
import * as path13 from "path";
|
|
115157
115360
|
async function initTreeSitterForNode() {
|
|
115158
115361
|
await Parser.init({
|
|
115159
115362
|
locateFile: (name18, scriptDir) => {
|
|
115160
115363
|
if (name18 === "tree-sitter.wasm") {
|
|
115161
|
-
const fallback =
|
|
115364
|
+
const fallback = path13.join(scriptDir, name18);
|
|
115162
115365
|
if (fs10.existsSync(fallback)) {
|
|
115163
115366
|
return fallback;
|
|
115164
115367
|
}
|
|
115165
|
-
const pkgDir =
|
|
115166
|
-
const wasm =
|
|
115368
|
+
const pkgDir = path13.dirname(__require.resolve("C:\\Users\\kkvin\\levelcode-project\\levelcode\\node_modules\\web-tree-sitter\\tree-sitter.cjs"));
|
|
115369
|
+
const wasm = path13.join(pkgDir, "tree-sitter.wasm");
|
|
115167
115370
|
if (fs10.existsSync(wasm)) {
|
|
115168
115371
|
return wasm;
|
|
115169
115372
|
}
|
|
115170
115373
|
throw new Error(`Internal error: web-tree-sitter/tree-sitter.wasm not found at ${wasm}. Ensure the file is included in your deployment bundle.`);
|
|
115171
115374
|
}
|
|
115172
|
-
return
|
|
115375
|
+
return path13.join(scriptDir, name18);
|
|
115173
115376
|
}
|
|
115174
115377
|
});
|
|
115175
115378
|
}
|
|
@@ -115220,30 +115423,30 @@ function getDirnameDynamically() {
|
|
|
115220
115423
|
|
|
115221
115424
|
// ../packages/code-map/src/languages.ts
|
|
115222
115425
|
import * as fs11 from "fs";
|
|
115223
|
-
import * as
|
|
115426
|
+
import * as path14 from "path";
|
|
115224
115427
|
function getWasmDir() {
|
|
115225
115428
|
return customWasmDir;
|
|
115226
115429
|
}
|
|
115227
115430
|
function resolveWasmPath(wasmFileName) {
|
|
115228
115431
|
const customWasmDirPath = getWasmDir();
|
|
115229
115432
|
if (customWasmDirPath) {
|
|
115230
|
-
return
|
|
115433
|
+
return path14.join(customWasmDirPath, wasmFileName);
|
|
115231
115434
|
}
|
|
115232
115435
|
const envWasmDir = process.env.LEVELCODE_WASM_DIR;
|
|
115233
115436
|
if (envWasmDir) {
|
|
115234
|
-
return
|
|
115437
|
+
return path14.join(envWasmDir, wasmFileName);
|
|
115235
115438
|
}
|
|
115236
115439
|
const moduleDir = (() => {
|
|
115237
|
-
const
|
|
115238
|
-
if (typeof
|
|
115239
|
-
return
|
|
115440
|
+
const dirname8 = getDirnameDynamically();
|
|
115441
|
+
if (typeof dirname8 !== "undefined") {
|
|
115442
|
+
return dirname8;
|
|
115240
115443
|
}
|
|
115241
115444
|
return process.cwd();
|
|
115242
115445
|
})();
|
|
115243
115446
|
const possiblePaths = [
|
|
115244
|
-
|
|
115245
|
-
|
|
115246
|
-
|
|
115447
|
+
path14.join(moduleDir, "..", "wasm", wasmFileName),
|
|
115448
|
+
path14.join(moduleDir, "wasm", wasmFileName),
|
|
115449
|
+
path14.join(process.cwd(), "dist", "wasm", wasmFileName)
|
|
115247
115450
|
];
|
|
115248
115451
|
for (const wasmPath of possiblePaths) {
|
|
115249
115452
|
try {
|
|
@@ -115287,7 +115490,7 @@ class UnifiedLanguageLoader {
|
|
|
115287
115490
|
}
|
|
115288
115491
|
}
|
|
115289
115492
|
function findLanguageConfigByExtension(filePath) {
|
|
115290
|
-
const ext =
|
|
115493
|
+
const ext = path14.extname(filePath);
|
|
115291
115494
|
return languageTable.find((c) => c.extensions.includes(ext));
|
|
115292
115495
|
}
|
|
115293
115496
|
async function createLanguageConfig(filePath, runtimeLoader) {
|
|
@@ -115301,7 +115504,7 @@ async function createLanguageConfig(filePath, runtimeLoader) {
|
|
|
115301
115504
|
const lang = await runtimeLoader.loadLanguage(cfg.wasmFile);
|
|
115302
115505
|
const parser = new Parser;
|
|
115303
115506
|
parser.setLanguage(lang);
|
|
115304
|
-
const queryContent =
|
|
115507
|
+
const queryContent = path14.isAbsolute(cfg.queryPathOrContent) ? fs11.readFileSync(cfg.queryPathOrContent, "utf8") : cfg.queryPathOrContent;
|
|
115305
115508
|
cfg.language = lang;
|
|
115306
115509
|
cfg.parser = parser;
|
|
115307
115510
|
cfg.query = new Query2(lang, queryContent);
|
|
@@ -115404,14 +115607,14 @@ var init_languages = __esm(() => {
|
|
|
115404
115607
|
|
|
115405
115608
|
// ../packages/code-map/src/parse.ts
|
|
115406
115609
|
import * as fs12 from "fs";
|
|
115407
|
-
import * as
|
|
115610
|
+
import * as path15 from "path";
|
|
115408
115611
|
async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
115409
115612
|
const startTime2 = Date.now();
|
|
115410
115613
|
const tokenScores = {};
|
|
115411
115614
|
const externalCalls = {};
|
|
115412
115615
|
const fileCallsMap = new Map;
|
|
115413
115616
|
for (const filePath of filePaths) {
|
|
115414
|
-
const fullPath =
|
|
115617
|
+
const fullPath = path15.join(projectRoot, filePath);
|
|
115415
115618
|
const languageConfig = await getLanguageConfig(fullPath);
|
|
115416
115619
|
if (languageConfig) {
|
|
115417
115620
|
let parseResults;
|
|
@@ -115423,7 +115626,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
|
|
|
115423
115626
|
const { identifiers, calls, numLines } = parseResults;
|
|
115424
115627
|
const tokenScoresForFile = {};
|
|
115425
115628
|
tokenScores[filePath] = tokenScoresForFile;
|
|
115426
|
-
const dirs =
|
|
115629
|
+
const dirs = path15.dirname(fullPath).split(path15.sep);
|
|
115427
115630
|
const depth = dirs.length;
|
|
115428
115631
|
const tokenBaseScore = 0.8 ** depth * Math.sqrt(numLines / (identifiers.length + 1));
|
|
115429
115632
|
for (const identifier of identifiers) {
|
|
@@ -115639,8 +115842,8 @@ var init_validate_agents = __esm(() => {
|
|
|
115639
115842
|
|
|
115640
115843
|
// ../sdk/src/agents/load-agents.ts
|
|
115641
115844
|
import fs13 from "fs";
|
|
115642
|
-
import
|
|
115643
|
-
import
|
|
115845
|
+
import os6 from "os";
|
|
115846
|
+
import path16 from "path";
|
|
115644
115847
|
import { pathToFileURL } from "url";
|
|
115645
115848
|
function resolveMcpEnv(env3, agentId, mcpServerName) {
|
|
115646
115849
|
if (!env3)
|
|
@@ -115759,12 +115962,12 @@ var agentFileExtensions, getAllAgentFiles = (dir) => {
|
|
|
115759
115962
|
try {
|
|
115760
115963
|
const entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
115761
115964
|
for (const entry of entries) {
|
|
115762
|
-
const fullPath =
|
|
115965
|
+
const fullPath = path16.join(dir, entry.name);
|
|
115763
115966
|
if (entry.isDirectory()) {
|
|
115764
115967
|
files.push(...getAllAgentFiles(fullPath));
|
|
115765
115968
|
continue;
|
|
115766
115969
|
}
|
|
115767
|
-
const extension =
|
|
115970
|
+
const extension = path16.extname(entry.name).toLowerCase();
|
|
115768
115971
|
const isAgentFile = entry.isFile() && agentFileExtensions.has(extension) && !entry.name.endsWith(".d.ts") && !entry.name.endsWith(".test.ts");
|
|
115769
115972
|
if (isAgentFile) {
|
|
115770
115973
|
files.push(fullPath);
|
|
@@ -115773,9 +115976,9 @@ var agentFileExtensions, getAllAgentFiles = (dir) => {
|
|
|
115773
115976
|
} catch {}
|
|
115774
115977
|
return files;
|
|
115775
115978
|
}, getDefaultAgentDirs = () => {
|
|
115776
|
-
const cwdAgents =
|
|
115777
|
-
const parentAgents =
|
|
115778
|
-
const homeAgents =
|
|
115979
|
+
const cwdAgents = path16.join(process.cwd(), ".agents");
|
|
115980
|
+
const parentAgents = path16.join(process.cwd(), "..", ".agents");
|
|
115981
|
+
const homeAgents = path16.join(os6.homedir(), ".agents");
|
|
115779
115982
|
return [cwdAgents, parentAgents, homeAgents];
|
|
115780
115983
|
};
|
|
115781
115984
|
var init_load_agents = __esm(() => {
|
|
@@ -119280,8 +119483,8 @@ var require_gray_matter = __commonJS((exports3, module3) => {
|
|
|
119280
119483
|
|
|
119281
119484
|
// ../sdk/src/skills/load-skills.ts
|
|
119282
119485
|
import fs14 from "fs";
|
|
119283
|
-
import
|
|
119284
|
-
import
|
|
119486
|
+
import os7 from "os";
|
|
119487
|
+
import path17 from "path";
|
|
119285
119488
|
function parseFrontmatter(content) {
|
|
119286
119489
|
try {
|
|
119287
119490
|
const parsed = import_gray_matter.default(content);
|
|
@@ -119297,7 +119500,7 @@ function parseFrontmatter(content) {
|
|
|
119297
119500
|
}
|
|
119298
119501
|
}
|
|
119299
119502
|
function loadSkillFromFile(skillDir, skillFilePath, verbose) {
|
|
119300
|
-
const dirName =
|
|
119503
|
+
const dirName = path17.basename(skillDir);
|
|
119301
119504
|
let content;
|
|
119302
119505
|
try {
|
|
119303
119506
|
content = fs14.readFileSync(skillFilePath, "utf8");
|
|
@@ -119346,7 +119549,7 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
|
|
|
119346
119549
|
return skills;
|
|
119347
119550
|
}
|
|
119348
119551
|
for (const entry of entries) {
|
|
119349
|
-
const skillDir =
|
|
119552
|
+
const skillDir = path17.join(skillsDir, entry);
|
|
119350
119553
|
try {
|
|
119351
119554
|
const stat = fs14.statSync(skillDir);
|
|
119352
119555
|
if (!stat.isDirectory())
|
|
@@ -119360,7 +119563,7 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
|
|
|
119360
119563
|
}
|
|
119361
119564
|
continue;
|
|
119362
119565
|
}
|
|
119363
|
-
const skillFilePath =
|
|
119566
|
+
const skillFilePath = path17.join(skillDir, SKILL_FILE_NAME);
|
|
119364
119567
|
try {
|
|
119365
119568
|
fs14.statSync(skillFilePath);
|
|
119366
119569
|
} catch {
|
|
@@ -119374,12 +119577,12 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
|
|
|
119374
119577
|
return skills;
|
|
119375
119578
|
}
|
|
119376
119579
|
function getDefaultSkillsDirs(cwd) {
|
|
119377
|
-
const home =
|
|
119580
|
+
const home = os7.homedir();
|
|
119378
119581
|
return [
|
|
119379
|
-
|
|
119380
|
-
|
|
119381
|
-
|
|
119382
|
-
|
|
119582
|
+
path17.join(home, ".claude", SKILLS_DIR_NAME),
|
|
119583
|
+
path17.join(home, ".agents", SKILLS_DIR_NAME),
|
|
119584
|
+
path17.join(cwd, ".claude", SKILLS_DIR_NAME),
|
|
119585
|
+
path17.join(cwd, ".agents", SKILLS_DIR_NAME)
|
|
119383
119586
|
];
|
|
119384
119587
|
}
|
|
119385
119588
|
async function loadSkills(options2 = {}) {
|
|
@@ -119400,8 +119603,8 @@ var init_load_skills = __esm(() => {
|
|
|
119400
119603
|
});
|
|
119401
119604
|
|
|
119402
119605
|
// ../sdk/src/run-state.ts
|
|
119403
|
-
import * as
|
|
119404
|
-
import
|
|
119606
|
+
import * as os8 from "os";
|
|
119607
|
+
import path18 from "path";
|
|
119405
119608
|
function selectHighestPriorityKnowledgeFile(candidates) {
|
|
119406
119609
|
for (const priorityName of KNOWLEDGE_FILE_NAMES_LOWERCASE) {
|
|
119407
119610
|
const match = candidates.find((f) => f.toLowerCase().endsWith(priorityName));
|
|
@@ -119510,7 +119713,7 @@ async function discoverProjectFiles(params2) {
|
|
|
119510
119713
|
let error46;
|
|
119511
119714
|
const projectFilePromises = Object.fromEntries(filePaths.map((filePath) => [
|
|
119512
119715
|
filePath,
|
|
119513
|
-
fs15.readFile(
|
|
119716
|
+
fs15.readFile(path18.join(cwd, filePath), "utf8").catch((err2) => {
|
|
119514
119717
|
error46 = err2;
|
|
119515
119718
|
return "[ERROR_READING_FILE]";
|
|
119516
119719
|
})
|
|
@@ -119526,7 +119729,7 @@ async function discoverProjectFiles(params2) {
|
|
|
119526
119729
|
}
|
|
119527
119730
|
async function loadUserKnowledgeFiles(params2) {
|
|
119528
119731
|
const { fs: fs15, logger: logger2 } = params2;
|
|
119529
|
-
const homeDir = params2.homeDir ??
|
|
119732
|
+
const homeDir = params2.homeDir ?? os8.homedir();
|
|
119530
119733
|
const userKnowledgeFiles = {};
|
|
119531
119734
|
let entries;
|
|
119532
119735
|
try {
|
|
@@ -119548,7 +119751,7 @@ async function loadUserKnowledgeFiles(params2) {
|
|
|
119548
119751
|
for (const priorityName of KNOWLEDGE_FILE_NAMES_LOWERCASE) {
|
|
119549
119752
|
const actualFileName = candidates.get(priorityName);
|
|
119550
119753
|
if (actualFileName) {
|
|
119551
|
-
const filePath =
|
|
119754
|
+
const filePath = path18.join(homeDir, actualFileName);
|
|
119552
119755
|
try {
|
|
119553
119756
|
const content = await fs15.readFile(filePath, "utf8");
|
|
119554
119757
|
const tildeKey = `~/${actualFileName}`;
|
|
@@ -119565,7 +119768,7 @@ function selectKnowledgeFilePaths(allFilePaths) {
|
|
|
119565
119768
|
const knowledgeCandidates = allFilePaths.filter(isKnowledgeFile);
|
|
119566
119769
|
const byDirectory = new Map;
|
|
119567
119770
|
for (const filePath of knowledgeCandidates) {
|
|
119568
|
-
const dir =
|
|
119771
|
+
const dir = path18.dirname(filePath);
|
|
119569
119772
|
if (!byDirectory.has(dir)) {
|
|
119570
119773
|
byDirectory.set(dir, []);
|
|
119571
119774
|
}
|
|
@@ -119675,8 +119878,8 @@ async function initialSessionState(params2) {
|
|
|
119675
119878
|
shell: "bash",
|
|
119676
119879
|
nodeVersion: process.version,
|
|
119677
119880
|
arch: process.arch,
|
|
119678
|
-
homedir:
|
|
119679
|
-
cpus:
|
|
119881
|
+
homedir: os8.homedir(),
|
|
119882
|
+
cpus: os8.cpus().length ?? 1
|
|
119680
119883
|
}
|
|
119681
119884
|
});
|
|
119682
119885
|
if (maxAgentSteps) {
|
|
@@ -119786,14 +119989,14 @@ var init_run_state = __esm(() => {
|
|
|
119786
119989
|
});
|
|
119787
119990
|
|
|
119788
119991
|
// ../sdk/src/tools/change-file.ts
|
|
119789
|
-
import
|
|
119992
|
+
import path19 from "path";
|
|
119790
119993
|
function containsUpwardTraversal(dirPath) {
|
|
119791
|
-
const normalized =
|
|
119994
|
+
const normalized = path19.normalize(dirPath);
|
|
119792
119995
|
return normalized.includes("..");
|
|
119793
119996
|
}
|
|
119794
119997
|
function containsPathTraversal(filePath) {
|
|
119795
|
-
const normalized =
|
|
119796
|
-
return
|
|
119998
|
+
const normalized = path19.normalize(filePath);
|
|
119999
|
+
return path19.isAbsolute(normalized) || normalized.startsWith("..");
|
|
119797
120000
|
}
|
|
119798
120001
|
async function changeFile(params2) {
|
|
119799
120002
|
const { parameters, cwd, fs: fs15 } = params2;
|
|
@@ -119856,10 +120059,10 @@ async function applyChanges(params2) {
|
|
|
119856
120059
|
for (const change of changes) {
|
|
119857
120060
|
const { path: filePath, content, type } = change;
|
|
119858
120061
|
try {
|
|
119859
|
-
const fullPath =
|
|
120062
|
+
const fullPath = path19.join(projectRoot, filePath);
|
|
119860
120063
|
const exists = await fileExists({ filePath: fullPath, fs: fs15 });
|
|
119861
120064
|
if (!exists) {
|
|
119862
|
-
const dirPath =
|
|
120065
|
+
const dirPath = path19.dirname(fullPath);
|
|
119863
120066
|
await fs15.mkdir(dirPath, { recursive: true });
|
|
119864
120067
|
}
|
|
119865
120068
|
if (type === "file") {
|
|
@@ -119955,7 +120158,7 @@ function formatCodeSearchOutput(stdout) {
|
|
|
119955
120158
|
|
|
119956
120159
|
// ../sdk/src/native/ripgrep.ts
|
|
119957
120160
|
import { existsSync as existsSync10 } from "fs";
|
|
119958
|
-
import { join as
|
|
120161
|
+
import { join as join8, dirname as dirname9 } from "path";
|
|
119959
120162
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
119960
120163
|
function getBundledRgPath(importMetaUrl, env3 = getSdkEnv()) {
|
|
119961
120164
|
if (env3.LEVELCODE_RG_PATH) {
|
|
@@ -119982,24 +120185,24 @@ function getBundledRgPath(importMetaUrl, env3 = getSdkEnv()) {
|
|
|
119982
120185
|
const metaUrl = importMetaUrl || import.meta.url;
|
|
119983
120186
|
if (metaUrl) {
|
|
119984
120187
|
const currentFile = fileURLToPath2(metaUrl);
|
|
119985
|
-
const currentDir =
|
|
119986
|
-
const devPath =
|
|
120188
|
+
const currentDir = dirname9(currentFile);
|
|
120189
|
+
const devPath = join8(currentDir, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
|
|
119987
120190
|
if (existsSync10(devPath)) {
|
|
119988
120191
|
vendorPath = devPath;
|
|
119989
120192
|
}
|
|
119990
|
-
const distPath =
|
|
120193
|
+
const distPath = join8(currentDir, "vendor", "ripgrep", platformDir, binaryName);
|
|
119991
120194
|
if (existsSync10(distPath)) {
|
|
119992
120195
|
vendorPath = distPath;
|
|
119993
120196
|
}
|
|
119994
120197
|
}
|
|
119995
120198
|
if (!vendorPath) {
|
|
119996
|
-
const
|
|
119997
|
-
if (typeof
|
|
119998
|
-
const cjsPath =
|
|
120199
|
+
const dirname10 = new Function(`try { return __dirname; } catch (e) { return undefined; }`)();
|
|
120200
|
+
if (typeof dirname10 !== "undefined") {
|
|
120201
|
+
const cjsPath = join8(dirname10, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
|
|
119999
120202
|
if (existsSync10(cjsPath)) {
|
|
120000
120203
|
vendorPath = cjsPath;
|
|
120001
120204
|
}
|
|
120002
|
-
const cjsPath2 =
|
|
120205
|
+
const cjsPath2 = join8(dirname10, "vendor", "ripgrep", platformDir, binaryName);
|
|
120003
120206
|
if (existsSync10(cjsPath2)) {
|
|
120004
120207
|
vendorPath = cjsPath2;
|
|
120005
120208
|
}
|
|
@@ -120008,7 +120211,7 @@ function getBundledRgPath(importMetaUrl, env3 = getSdkEnv()) {
|
|
|
120008
120211
|
if (vendorPath && existsSync10(vendorPath)) {
|
|
120009
120212
|
return vendorPath;
|
|
120010
120213
|
}
|
|
120011
|
-
const distVendorPath =
|
|
120214
|
+
const distVendorPath = join8(process.cwd(), "node_modules", "@levelcode", "sdk", "dist", "vendor", "ripgrep", platformDir, binaryName);
|
|
120012
120215
|
if (existsSync10(distVendorPath)) {
|
|
120013
120216
|
return distVendorPath;
|
|
120014
120217
|
}
|
|
@@ -120021,7 +120224,7 @@ var init_ripgrep = __esm(() => {
|
|
|
120021
120224
|
// ../sdk/src/tools/code-search.ts
|
|
120022
120225
|
import { spawn as spawn2 } from "child_process";
|
|
120023
120226
|
import * as fs15 from "fs";
|
|
120024
|
-
import * as
|
|
120227
|
+
import * as path20 from "path";
|
|
120025
120228
|
function codeSearch({
|
|
120026
120229
|
projectPath,
|
|
120027
120230
|
pattern,
|
|
@@ -120035,9 +120238,9 @@ function codeSearch({
|
|
|
120035
120238
|
}) {
|
|
120036
120239
|
return new Promise((resolve8) => {
|
|
120037
120240
|
let isResolved = false;
|
|
120038
|
-
const projectRoot =
|
|
120039
|
-
const searchCwd = cwd ?
|
|
120040
|
-
if (!searchCwd.startsWith(projectRoot +
|
|
120241
|
+
const projectRoot = path20.resolve(projectPath);
|
|
120242
|
+
const searchCwd = cwd ? path20.resolve(projectRoot, cwd) : projectRoot;
|
|
120243
|
+
if (!searchCwd.startsWith(projectRoot + path20.sep) && searchCwd !== projectRoot) {
|
|
120041
120244
|
return resolve8([
|
|
120042
120245
|
{
|
|
120043
120246
|
type: "json",
|
|
@@ -120050,7 +120253,7 @@ function codeSearch({
|
|
|
120050
120253
|
const flagsArray = (flags2 || "").split(" ").filter(Boolean).map((token) => token.replace(/^['"]|['"]$/g, ""));
|
|
120051
120254
|
const existingHiddenDirs = INCLUDED_HIDDEN_DIRS.filter((dir) => {
|
|
120052
120255
|
try {
|
|
120053
|
-
return fs15.statSync(
|
|
120256
|
+
return fs15.statSync(path20.join(searchCwd, dir)).isDirectory();
|
|
120054
120257
|
} catch {
|
|
120055
120258
|
return false;
|
|
120056
120259
|
}
|
|
@@ -122986,11 +123189,11 @@ var init_glob2 = __esm(() => {
|
|
|
122986
123189
|
});
|
|
122987
123190
|
|
|
122988
123191
|
// ../sdk/src/tools/list-directory.ts
|
|
122989
|
-
import * as
|
|
123192
|
+
import * as path21 from "path";
|
|
122990
123193
|
async function listDirectory(params2) {
|
|
122991
123194
|
const { directoryPath, projectPath, fs: fs16 } = params2;
|
|
122992
123195
|
try {
|
|
122993
|
-
const resolvedPath =
|
|
123196
|
+
const resolvedPath = path21.resolve(projectPath, directoryPath);
|
|
122994
123197
|
if (!resolvedPath.startsWith(projectPath)) {
|
|
122995
123198
|
return [
|
|
122996
123199
|
{
|
|
@@ -123038,7 +123241,7 @@ async function listDirectory(params2) {
|
|
|
123038
123241
|
var init_list_directory2 = () => {};
|
|
123039
123242
|
|
|
123040
123243
|
// ../sdk/src/tools/read-files.ts
|
|
123041
|
-
import
|
|
123244
|
+
import path22, { isAbsolute as isAbsolute4 } from "path";
|
|
123042
123245
|
async function getFiles(params2) {
|
|
123043
123246
|
const { filePaths, cwd, fs: fs16, fileFilter } = params2;
|
|
123044
123247
|
const hasCustomFilter = fileFilter !== undefined;
|
|
@@ -123048,8 +123251,8 @@ async function getFiles(params2) {
|
|
|
123048
123251
|
if (!filePath) {
|
|
123049
123252
|
continue;
|
|
123050
123253
|
}
|
|
123051
|
-
const relativePath = filePath.startsWith(cwd) ?
|
|
123052
|
-
const fullPath =
|
|
123254
|
+
const relativePath = filePath.startsWith(cwd) ? path22.relative(cwd, filePath) : filePath;
|
|
123255
|
+
const fullPath = path22.join(cwd, relativePath);
|
|
123053
123256
|
if (isAbsolute4(relativePath) || !fullPath.startsWith(cwd)) {
|
|
123054
123257
|
result[relativePath] = FILE_READ_STATUS.OUTSIDE_PROJECT;
|
|
123055
123258
|
continue;
|
|
@@ -123098,8 +123301,8 @@ var init_read_files3 = __esm(() => {
|
|
|
123098
123301
|
// ../sdk/src/tools/run-terminal-command.ts
|
|
123099
123302
|
import { spawn as spawn3 } from "child_process";
|
|
123100
123303
|
import * as fs16 from "fs";
|
|
123101
|
-
import * as
|
|
123102
|
-
import * as
|
|
123304
|
+
import * as os9 from "os";
|
|
123305
|
+
import * as path23 from "path";
|
|
123103
123306
|
function findWindowsBash(env3) {
|
|
123104
123307
|
const customPath = env3.LEVELCODE_GIT_BASH_PATH;
|
|
123105
123308
|
if (customPath && fs16.existsSync(customPath)) {
|
|
@@ -123111,12 +123314,12 @@ function findWindowsBash(env3) {
|
|
|
123111
123314
|
}
|
|
123112
123315
|
}
|
|
123113
123316
|
const pathEnv = env3.PATH || env3.Path || "";
|
|
123114
|
-
const pathDirs = pathEnv.split(
|
|
123317
|
+
const pathDirs = pathEnv.split(path23.delimiter);
|
|
123115
123318
|
const wslFallbackPaths = [];
|
|
123116
123319
|
for (const dir of pathDirs) {
|
|
123117
123320
|
const dirLower = dir.toLowerCase();
|
|
123118
123321
|
const isWslPath = WSL_BASH_PATH_PATTERNS.some((pattern) => dirLower.includes(pattern));
|
|
123119
|
-
const bashPath =
|
|
123322
|
+
const bashPath = path23.join(dir, "bash.exe");
|
|
123120
123323
|
if (fs16.existsSync(bashPath)) {
|
|
123121
123324
|
if (isWslPath) {
|
|
123122
123325
|
wslFallbackPaths.push(bashPath);
|
|
@@ -123124,7 +123327,7 @@ function findWindowsBash(env3) {
|
|
|
123124
123327
|
return bashPath;
|
|
123125
123328
|
}
|
|
123126
123329
|
}
|
|
123127
|
-
const bashPathNoExt =
|
|
123330
|
+
const bashPathNoExt = path23.join(dir, "bash");
|
|
123128
123331
|
if (fs16.existsSync(bashPathNoExt)) {
|
|
123129
123332
|
if (isWslPath) {
|
|
123130
123333
|
wslFallbackPaths.push(bashPathNoExt);
|
|
@@ -123165,7 +123368,7 @@ function runTerminalCommand({
|
|
|
123165
123368
|
throw new Error("BACKGROUND process_type not implemented");
|
|
123166
123369
|
}
|
|
123167
123370
|
return new Promise((resolve10, reject2) => {
|
|
123168
|
-
const isWindows =
|
|
123371
|
+
const isWindows = os9.platform() === "win32";
|
|
123169
123372
|
const processEnv2 = {
|
|
123170
123373
|
...getSystemProcessEnv(),
|
|
123171
123374
|
...env3 ?? {}
|
|
@@ -123184,7 +123387,7 @@ function runTerminalCommand({
|
|
|
123184
123387
|
shell = "bash";
|
|
123185
123388
|
shellArgs = ["-c"];
|
|
123186
123389
|
}
|
|
123187
|
-
const resolvedCwd =
|
|
123390
|
+
const resolvedCwd = path23.resolve(cwd);
|
|
123188
123391
|
const childProcess = spawn3(shell, [...shellArgs, command], {
|
|
123189
123392
|
cwd: resolvedCwd,
|
|
123190
123393
|
env: processEnv2,
|
|
@@ -123264,7 +123467,7 @@ var init_run_terminal_command2 = __esm(() => {
|
|
|
123264
123467
|
});
|
|
123265
123468
|
|
|
123266
123469
|
// ../sdk/src/run.ts
|
|
123267
|
-
import
|
|
123470
|
+
import path24 from "path";
|
|
123268
123471
|
async function run2(options2) {
|
|
123269
123472
|
const { signal } = options2;
|
|
123270
123473
|
if (signal?.aborted) {
|
|
@@ -123659,7 +123862,7 @@ async function handleToolCall({
|
|
|
123659
123862
|
const resolvedCwd = requireCwd(cwd, "run_terminal_command");
|
|
123660
123863
|
result = await runTerminalCommand({
|
|
123661
123864
|
...input,
|
|
123662
|
-
cwd:
|
|
123865
|
+
cwd: path24.resolve(resolvedCwd, input.cwd ?? "."),
|
|
123663
123866
|
env: env3
|
|
123664
123867
|
});
|
|
123665
123868
|
} else if (toolName39 === "code_search") {
|
|
@@ -124161,8 +124364,8 @@ var init_client4 = __esm(() => {
|
|
|
124161
124364
|
|
|
124162
124365
|
// ../sdk/src/agents/load-mcp-config.ts
|
|
124163
124366
|
import fs17 from "fs";
|
|
124164
|
-
import
|
|
124165
|
-
import
|
|
124367
|
+
import os10 from "os";
|
|
124368
|
+
import path25 from "path";
|
|
124166
124369
|
function resolveMcpEnv2(env3, mcpServerName) {
|
|
124167
124370
|
if (!env3)
|
|
124168
124371
|
return {};
|
|
@@ -124196,7 +124399,7 @@ function loadMCPConfigSync(options2) {
|
|
|
124196
124399
|
};
|
|
124197
124400
|
const mcpConfigDirs = getDefaultMcpConfigDirs();
|
|
124198
124401
|
for (const dir of mcpConfigDirs) {
|
|
124199
|
-
const configPath =
|
|
124402
|
+
const configPath = path25.join(dir, MCP_CONFIG_FILE_NAME);
|
|
124200
124403
|
try {
|
|
124201
124404
|
if (!fs17.existsSync(configPath)) {
|
|
124202
124405
|
continue;
|
|
@@ -124234,9 +124437,9 @@ function loadMCPConfigSync(options2) {
|
|
|
124234
124437
|
return mergedConfig;
|
|
124235
124438
|
}
|
|
124236
124439
|
var mcpFileSchema, envKey = "env", processEnv2, MCP_CONFIG_FILE_NAME = "mcp.json", getDefaultMcpConfigDirs = () => {
|
|
124237
|
-
const cwdAgents =
|
|
124238
|
-
const parentAgents =
|
|
124239
|
-
const homeAgents =
|
|
124440
|
+
const cwdAgents = path25.join(process.cwd(), ".agents");
|
|
124441
|
+
const parentAgents = path25.join(process.cwd(), "..", ".agents");
|
|
124442
|
+
const homeAgents = path25.join(os10.homedir(), ".agents");
|
|
124240
124443
|
return [cwdAgents, parentAgents, homeAgents];
|
|
124241
124444
|
};
|
|
124242
124445
|
var init_load_mcp_config = __esm(() => {
|
|
@@ -127410,10 +127613,10 @@ var require_on_exit_leak_free = __commonJS((exports3, module3) => {
|
|
|
127410
127613
|
exit: onExit,
|
|
127411
127614
|
beforeExit: onBeforeExit
|
|
127412
127615
|
};
|
|
127413
|
-
var
|
|
127616
|
+
var registry3;
|
|
127414
127617
|
function ensureRegistry() {
|
|
127415
|
-
if (
|
|
127416
|
-
|
|
127618
|
+
if (registry3 === undefined) {
|
|
127619
|
+
registry3 = new FinalizationRegistry(clear);
|
|
127417
127620
|
}
|
|
127418
127621
|
}
|
|
127419
127622
|
function install(event) {
|
|
@@ -127428,7 +127631,7 @@ var require_on_exit_leak_free = __commonJS((exports3, module3) => {
|
|
|
127428
127631
|
}
|
|
127429
127632
|
process.removeListener(event, functions[event]);
|
|
127430
127633
|
if (refs.exit.length === 0 && refs.beforeExit.length === 0) {
|
|
127431
|
-
|
|
127634
|
+
registry3 = undefined;
|
|
127432
127635
|
}
|
|
127433
127636
|
}
|
|
127434
127637
|
function onExit() {
|
|
@@ -127462,7 +127665,7 @@ var require_on_exit_leak_free = __commonJS((exports3, module3) => {
|
|
|
127462
127665
|
const ref = new WeakRef(obj);
|
|
127463
127666
|
ref.fn = fn;
|
|
127464
127667
|
ensureRegistry();
|
|
127465
|
-
|
|
127668
|
+
registry3.register(obj, ref);
|
|
127466
127669
|
refs[event].push(ref);
|
|
127467
127670
|
}
|
|
127468
127671
|
function register(obj, fn) {
|
|
@@ -127472,10 +127675,10 @@ var require_on_exit_leak_free = __commonJS((exports3, module3) => {
|
|
|
127472
127675
|
_register("beforeExit", obj, fn);
|
|
127473
127676
|
}
|
|
127474
127677
|
function unregister(obj) {
|
|
127475
|
-
if (
|
|
127678
|
+
if (registry3 === undefined) {
|
|
127476
127679
|
return;
|
|
127477
127680
|
}
|
|
127478
|
-
|
|
127681
|
+
registry3.unregister(obj);
|
|
127479
127682
|
for (const event of ["exit", "beforeExit"]) {
|
|
127480
127683
|
refs[event] = refs[event].filter((ref) => {
|
|
127481
127684
|
const _obj = ref.deref();
|
|
@@ -127625,7 +127828,7 @@ var require_thread_stream = __commonJS((exports3, module3) => {
|
|
|
127625
127828
|
var { version: version3 } = require_package();
|
|
127626
127829
|
var { EventEmitter: EventEmitter11 } = __require("events");
|
|
127627
127830
|
var { Worker: Worker2 } = __require("worker_threads");
|
|
127628
|
-
var { join:
|
|
127831
|
+
var { join: join11 } = __require("path");
|
|
127629
127832
|
var { pathToFileURL: pathToFileURL2 } = __require("url");
|
|
127630
127833
|
var { wait } = require_wait();
|
|
127631
127834
|
var {
|
|
@@ -127652,7 +127855,7 @@ var require_thread_stream = __commonJS((exports3, module3) => {
|
|
|
127652
127855
|
}
|
|
127653
127856
|
var FinalizationRegistry2 = process.env.NODE_V8_COVERAGE ? FakeFinalizationRegistry : global.FinalizationRegistry || FakeFinalizationRegistry;
|
|
127654
127857
|
var WeakRef2 = process.env.NODE_V8_COVERAGE ? FakeWeakRef : global.WeakRef || FakeWeakRef;
|
|
127655
|
-
var
|
|
127858
|
+
var registry3 = new FinalizationRegistry2((worker) => {
|
|
127656
127859
|
if (worker.exited) {
|
|
127657
127860
|
return;
|
|
127658
127861
|
}
|
|
@@ -127661,7 +127864,7 @@ var require_thread_stream = __commonJS((exports3, module3) => {
|
|
|
127661
127864
|
function createWorker(stream2, opts) {
|
|
127662
127865
|
const { filename, workerData } = opts;
|
|
127663
127866
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
127664
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
127867
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join11(__dirname, "lib", "worker.js");
|
|
127665
127868
|
const worker = new Worker2(toExecute, {
|
|
127666
127869
|
...opts.workerOpts,
|
|
127667
127870
|
trackUnmanagedFds: false,
|
|
@@ -127680,7 +127883,7 @@ var require_thread_stream = __commonJS((exports3, module3) => {
|
|
|
127680
127883
|
worker.stream = new FakeWeakRef(stream2);
|
|
127681
127884
|
worker.on("message", onWorkerMessage);
|
|
127682
127885
|
worker.on("exit", onWorkerExit);
|
|
127683
|
-
|
|
127886
|
+
registry3.register(stream2, worker);
|
|
127684
127887
|
return worker;
|
|
127685
127888
|
}
|
|
127686
127889
|
function drain(stream2) {
|
|
@@ -127774,7 +127977,7 @@ var require_thread_stream = __commonJS((exports3, module3) => {
|
|
|
127774
127977
|
if (stream2 === undefined) {
|
|
127775
127978
|
return;
|
|
127776
127979
|
}
|
|
127777
|
-
|
|
127980
|
+
registry3.unregister(stream2);
|
|
127778
127981
|
stream2.worker.exited = true;
|
|
127779
127982
|
stream2.worker.off("exit", onWorkerExit);
|
|
127780
127983
|
destroy(stream2, code !== 0 ? new Error("the worker thread exited") : null);
|
|
@@ -128045,7 +128248,7 @@ var require_transport = __commonJS((exports3, module3) => {
|
|
|
128045
128248
|
var __dirname = "C:\\Users\\kkvin\\levelcode-project\\levelcode\\node_modules\\pino\\lib";
|
|
128046
128249
|
var { createRequire } = __require("module");
|
|
128047
128250
|
var getCallers = require_caller();
|
|
128048
|
-
var { join:
|
|
128251
|
+
var { join: join11, isAbsolute: isAbsolute5, sep: sep5 } = __require("path");
|
|
128049
128252
|
var sleep3 = require_atomic_sleep();
|
|
128050
128253
|
var onExit = require_on_exit_leak_free();
|
|
128051
128254
|
var ThreadStream = require_thread_stream();
|
|
@@ -128107,7 +128310,7 @@ var require_transport = __commonJS((exports3, module3) => {
|
|
|
128107
128310
|
throw new Error("only one of target or targets can be specified");
|
|
128108
128311
|
}
|
|
128109
128312
|
if (targets) {
|
|
128110
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
128313
|
+
target = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
|
|
128111
128314
|
options2.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
128112
128315
|
return {
|
|
128113
128316
|
...dest,
|
|
@@ -128124,7 +128327,7 @@ var require_transport = __commonJS((exports3, module3) => {
|
|
|
128124
128327
|
});
|
|
128125
128328
|
});
|
|
128126
128329
|
} else if (pipeline) {
|
|
128127
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
128330
|
+
target = bundlerOverrides["pino-worker"] || join11(__dirname, "worker.js");
|
|
128128
128331
|
options2.pipelines = [pipeline.map((dest) => {
|
|
128129
128332
|
return {
|
|
128130
128333
|
...dest,
|
|
@@ -128146,7 +128349,7 @@ var require_transport = __commonJS((exports3, module3) => {
|
|
|
128146
128349
|
return origin;
|
|
128147
128350
|
}
|
|
128148
128351
|
if (origin === "pino/file") {
|
|
128149
|
-
return
|
|
128352
|
+
return join11(__dirname, "..", "file.js");
|
|
128150
128353
|
}
|
|
128151
128354
|
let fixTarget2;
|
|
128152
128355
|
for (const filePath of callers) {
|
|
@@ -129048,7 +129251,7 @@ var require_safe_stable_stringify = __commonJS((exports3, module3) => {
|
|
|
129048
129251
|
return circularValue;
|
|
129049
129252
|
}
|
|
129050
129253
|
let res = "";
|
|
129051
|
-
let
|
|
129254
|
+
let join11 = ",";
|
|
129052
129255
|
const originalIndentation = indentation;
|
|
129053
129256
|
if (Array.isArray(value)) {
|
|
129054
129257
|
if (value.length === 0) {
|
|
@@ -129062,7 +129265,7 @@ var require_safe_stable_stringify = __commonJS((exports3, module3) => {
|
|
|
129062
129265
|
indentation += spacer;
|
|
129063
129266
|
res += `
|
|
129064
129267
|
${indentation}`;
|
|
129065
|
-
|
|
129268
|
+
join11 = `,
|
|
129066
129269
|
${indentation}`;
|
|
129067
129270
|
}
|
|
129068
129271
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -129070,13 +129273,13 @@ ${indentation}`;
|
|
|
129070
129273
|
for (;i2 < maximumValuesToStringify - 1; i2++) {
|
|
129071
129274
|
const tmp2 = stringifyFnReplacer(String(i2), value, stack, replacer, spacer, indentation);
|
|
129072
129275
|
res += tmp2 !== undefined ? tmp2 : "null";
|
|
129073
|
-
res +=
|
|
129276
|
+
res += join11;
|
|
129074
129277
|
}
|
|
129075
129278
|
const tmp = stringifyFnReplacer(String(i2), value, stack, replacer, spacer, indentation);
|
|
129076
129279
|
res += tmp !== undefined ? tmp : "null";
|
|
129077
129280
|
if (value.length - 1 > maximumBreadth) {
|
|
129078
129281
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
129079
|
-
res += `${
|
|
129282
|
+
res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
129080
129283
|
}
|
|
129081
129284
|
if (spacer !== "") {
|
|
129082
129285
|
res += `
|
|
@@ -129097,7 +129300,7 @@ ${originalIndentation}`;
|
|
|
129097
129300
|
let separator = "";
|
|
129098
129301
|
if (spacer !== "") {
|
|
129099
129302
|
indentation += spacer;
|
|
129100
|
-
|
|
129303
|
+
join11 = `,
|
|
129101
129304
|
${indentation}`;
|
|
129102
129305
|
whitespace = " ";
|
|
129103
129306
|
}
|
|
@@ -129111,13 +129314,13 @@ ${indentation}`;
|
|
|
129111
129314
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
129112
129315
|
if (tmp !== undefined) {
|
|
129113
129316
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
129114
|
-
separator =
|
|
129317
|
+
separator = join11;
|
|
129115
129318
|
}
|
|
129116
129319
|
}
|
|
129117
129320
|
if (keyLength > maximumBreadth) {
|
|
129118
129321
|
const removedKeys = keyLength - maximumBreadth;
|
|
129119
129322
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
129120
|
-
separator =
|
|
129323
|
+
separator = join11;
|
|
129121
129324
|
}
|
|
129122
129325
|
if (spacer !== "" && separator.length > 1) {
|
|
129123
129326
|
res = `
|
|
@@ -129157,7 +129360,7 @@ ${originalIndentation}`;
|
|
|
129157
129360
|
}
|
|
129158
129361
|
const originalIndentation = indentation;
|
|
129159
129362
|
let res = "";
|
|
129160
|
-
let
|
|
129363
|
+
let join11 = ",";
|
|
129161
129364
|
if (Array.isArray(value)) {
|
|
129162
129365
|
if (value.length === 0) {
|
|
129163
129366
|
return "[]";
|
|
@@ -129170,7 +129373,7 @@ ${originalIndentation}`;
|
|
|
129170
129373
|
indentation += spacer;
|
|
129171
129374
|
res += `
|
|
129172
129375
|
${indentation}`;
|
|
129173
|
-
|
|
129376
|
+
join11 = `,
|
|
129174
129377
|
${indentation}`;
|
|
129175
129378
|
}
|
|
129176
129379
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -129178,13 +129381,13 @@ ${indentation}`;
|
|
|
129178
129381
|
for (;i2 < maximumValuesToStringify - 1; i2++) {
|
|
129179
129382
|
const tmp2 = stringifyArrayReplacer(String(i2), value[i2], stack, replacer, spacer, indentation);
|
|
129180
129383
|
res += tmp2 !== undefined ? tmp2 : "null";
|
|
129181
|
-
res +=
|
|
129384
|
+
res += join11;
|
|
129182
129385
|
}
|
|
129183
129386
|
const tmp = stringifyArrayReplacer(String(i2), value[i2], stack, replacer, spacer, indentation);
|
|
129184
129387
|
res += tmp !== undefined ? tmp : "null";
|
|
129185
129388
|
if (value.length - 1 > maximumBreadth) {
|
|
129186
129389
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
129187
|
-
res += `${
|
|
129390
|
+
res += `${join11}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
129188
129391
|
}
|
|
129189
129392
|
if (spacer !== "") {
|
|
129190
129393
|
res += `
|
|
@@ -129197,7 +129400,7 @@ ${originalIndentation}`;
|
|
|
129197
129400
|
let whitespace = "";
|
|
129198
129401
|
if (spacer !== "") {
|
|
129199
129402
|
indentation += spacer;
|
|
129200
|
-
|
|
129403
|
+
join11 = `,
|
|
129201
129404
|
${indentation}`;
|
|
129202
129405
|
whitespace = " ";
|
|
129203
129406
|
}
|
|
@@ -129206,7 +129409,7 @@ ${indentation}`;
|
|
|
129206
129409
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
129207
129410
|
if (tmp !== undefined) {
|
|
129208
129411
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
129209
|
-
separator =
|
|
129412
|
+
separator = join11;
|
|
129210
129413
|
}
|
|
129211
129414
|
}
|
|
129212
129415
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -129263,20 +129466,20 @@ ${originalIndentation}`;
|
|
|
129263
129466
|
indentation += spacer;
|
|
129264
129467
|
let res2 = `
|
|
129265
129468
|
${indentation}`;
|
|
129266
|
-
const
|
|
129469
|
+
const join12 = `,
|
|
129267
129470
|
${indentation}`;
|
|
129268
129471
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
129269
129472
|
let i2 = 0;
|
|
129270
129473
|
for (;i2 < maximumValuesToStringify - 1; i2++) {
|
|
129271
129474
|
const tmp2 = stringifyIndent(String(i2), value[i2], stack, spacer, indentation);
|
|
129272
129475
|
res2 += tmp2 !== undefined ? tmp2 : "null";
|
|
129273
|
-
res2 +=
|
|
129476
|
+
res2 += join12;
|
|
129274
129477
|
}
|
|
129275
129478
|
const tmp = stringifyIndent(String(i2), value[i2], stack, spacer, indentation);
|
|
129276
129479
|
res2 += tmp !== undefined ? tmp : "null";
|
|
129277
129480
|
if (value.length - 1 > maximumBreadth) {
|
|
129278
129481
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
129279
|
-
res2 += `${
|
|
129482
|
+
res2 += `${join12}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
129280
129483
|
}
|
|
129281
129484
|
res2 += `
|
|
129282
129485
|
${originalIndentation}`;
|
|
@@ -129292,16 +129495,16 @@ ${originalIndentation}`;
|
|
|
129292
129495
|
return '"[Object]"';
|
|
129293
129496
|
}
|
|
129294
129497
|
indentation += spacer;
|
|
129295
|
-
const
|
|
129498
|
+
const join11 = `,
|
|
129296
129499
|
${indentation}`;
|
|
129297
129500
|
let res = "";
|
|
129298
129501
|
let separator = "";
|
|
129299
129502
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
129300
129503
|
if (isTypedArrayWithEntries(value)) {
|
|
129301
|
-
res += stringifyTypedArray(value,
|
|
129504
|
+
res += stringifyTypedArray(value, join11, maximumBreadth);
|
|
129302
129505
|
keys = keys.slice(value.length);
|
|
129303
129506
|
maximumPropertiesToStringify -= value.length;
|
|
129304
|
-
separator =
|
|
129507
|
+
separator = join11;
|
|
129305
129508
|
}
|
|
129306
129509
|
if (deterministic) {
|
|
129307
129510
|
keys = sort(keys, comparator);
|
|
@@ -129312,13 +129515,13 @@ ${indentation}`;
|
|
|
129312
129515
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
129313
129516
|
if (tmp !== undefined) {
|
|
129314
129517
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
129315
|
-
separator =
|
|
129518
|
+
separator = join11;
|
|
129316
129519
|
}
|
|
129317
129520
|
}
|
|
129318
129521
|
if (keyLength > maximumBreadth) {
|
|
129319
129522
|
const removedKeys = keyLength - maximumBreadth;
|
|
129320
129523
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
129321
|
-
separator =
|
|
129524
|
+
separator = join11;
|
|
129322
129525
|
}
|
|
129323
129526
|
if (separator !== "") {
|
|
129324
129527
|
res = `
|
|
@@ -129618,7 +129821,7 @@ var require_multistream = __commonJS((exports3, module3) => {
|
|
|
129618
129821
|
|
|
129619
129822
|
// ../node_modules/pino/pino.js
|
|
129620
129823
|
var require_pino = __commonJS((exports3, module3) => {
|
|
129621
|
-
var
|
|
129824
|
+
var os12 = __require("os");
|
|
129622
129825
|
var stdSerializers = require_pino_std_serializers();
|
|
129623
129826
|
var caller = require_caller();
|
|
129624
129827
|
var redaction = require_redaction();
|
|
@@ -129665,7 +129868,7 @@ var require_pino = __commonJS((exports3, module3) => {
|
|
|
129665
129868
|
} = symbols;
|
|
129666
129869
|
var { epochTime, nullTime } = time3;
|
|
129667
129870
|
var { pid } = process;
|
|
129668
|
-
var hostname3 =
|
|
129871
|
+
var hostname3 = os12.hostname();
|
|
129669
129872
|
var defaultErrorSerializer = stdSerializers.err;
|
|
129670
129873
|
var defaultOptions3 = {
|
|
129671
129874
|
level: "info",
|
|
@@ -129977,10 +130180,10 @@ var init_analytics2 = __esm(() => {
|
|
|
129977
130180
|
});
|
|
129978
130181
|
|
|
129979
130182
|
// src/project-files.ts
|
|
129980
|
-
import { mkdirSync as
|
|
129981
|
-
import
|
|
130183
|
+
import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, statSync as statSync2 } from "fs";
|
|
130184
|
+
import path27 from "path";
|
|
129982
130185
|
function ensureChatDirectory(dir) {
|
|
129983
|
-
|
|
130186
|
+
mkdirSync4(dir, { recursive: true });
|
|
129984
130187
|
}
|
|
129985
130188
|
function setProjectRoot(dir) {
|
|
129986
130189
|
projectRoot = dir;
|
|
@@ -130007,18 +130210,18 @@ function getProjectDataDir() {
|
|
|
130007
130210
|
if (!root) {
|
|
130008
130211
|
throw new Error("Project root not set");
|
|
130009
130212
|
}
|
|
130010
|
-
const baseName =
|
|
130011
|
-
const baseDir =
|
|
130213
|
+
const baseName = path27.basename(root);
|
|
130214
|
+
const baseDir = path27.join(getConfigDir2(), "projects", baseName);
|
|
130012
130215
|
return baseDir;
|
|
130013
130216
|
}
|
|
130014
130217
|
function getMostRecentChatDir() {
|
|
130015
130218
|
try {
|
|
130016
|
-
const chatsDir =
|
|
130219
|
+
const chatsDir = path27.join(getProjectDataDir(), "chats");
|
|
130017
130220
|
if (!statSync2(chatsDir, { throwIfNoEntry: false })) {
|
|
130018
130221
|
return null;
|
|
130019
130222
|
}
|
|
130020
130223
|
const chatDirs = readdirSync5(chatsDir).map((name18) => {
|
|
130021
|
-
const fullPath =
|
|
130224
|
+
const fullPath = path27.join(chatsDir, name18);
|
|
130022
130225
|
try {
|
|
130023
130226
|
const stat = statSync2(fullPath);
|
|
130024
130227
|
return { name: name18, fullPath, mtime: stat.mtime };
|
|
@@ -130037,7 +130240,7 @@ function getMostRecentChatDir() {
|
|
|
130037
130240
|
}
|
|
130038
130241
|
function getCurrentChatDir() {
|
|
130039
130242
|
const chatId = getCurrentChatId();
|
|
130040
|
-
const dir =
|
|
130243
|
+
const dir = path27.join(getProjectDataDir(), "chats", chatId);
|
|
130041
130244
|
ensureChatDirectory(dir);
|
|
130042
130245
|
return dir;
|
|
130043
130246
|
}
|
|
@@ -130053,8 +130256,8 @@ __export(exports_logger, {
|
|
|
130053
130256
|
logger: () => logger2,
|
|
130054
130257
|
clearLogFile: () => clearLogFile
|
|
130055
130258
|
});
|
|
130056
|
-
import { appendFileSync, existsSync as existsSync12, mkdirSync as
|
|
130057
|
-
import
|
|
130259
|
+
import { appendFileSync, existsSync as existsSync12, mkdirSync as mkdirSync5, unlinkSync as unlinkSync3 } from "fs";
|
|
130260
|
+
import path28, { dirname as dirname10 } from "path";
|
|
130058
130261
|
import { format as stringFormat2 } from "util";
|
|
130059
130262
|
function safeStringify2(obj) {
|
|
130060
130263
|
const seen = new WeakSet;
|
|
@@ -130075,7 +130278,7 @@ function setLogPath(p) {
|
|
|
130075
130278
|
if (p === logPath)
|
|
130076
130279
|
return;
|
|
130077
130280
|
logPath = p;
|
|
130078
|
-
|
|
130281
|
+
mkdirSync5(dirname10(p), { recursive: true });
|
|
130079
130282
|
const fileStream = import_pino.pino.destination({
|
|
130080
130283
|
dest: p,
|
|
130081
130284
|
mkdir: true,
|
|
@@ -130091,7 +130294,7 @@ function setLogPath(p) {
|
|
|
130091
130294
|
}
|
|
130092
130295
|
function clearLogFile() {
|
|
130093
130296
|
const projectRoot2 = getProjectRoot();
|
|
130094
|
-
const defaultLog =
|
|
130297
|
+
const defaultLog = path28.join(projectRoot2, "debug", "cli.jsonl");
|
|
130095
130298
|
const targets = new Set;
|
|
130096
130299
|
if (logPath) {
|
|
130097
130300
|
targets.add(logPath);
|
|
@@ -130116,7 +130319,7 @@ function sendAnalyticsAndLog(level, data, msg, ...args2) {
|
|
|
130116
130319
|
projectRoot2 = undefined;
|
|
130117
130320
|
}
|
|
130118
130321
|
if (projectRoot2) {
|
|
130119
|
-
const logTarget = IS_DEV ?
|
|
130322
|
+
const logTarget = IS_DEV ? path28.join(projectRoot2, "debug", "cli.jsonl") : path28.join(getCurrentChatDir(), "log.jsonl");
|
|
130120
130323
|
setLogPath(logTarget);
|
|
130121
130324
|
}
|
|
130122
130325
|
}
|
|
@@ -130211,8 +130414,8 @@ var init_logger2 = __esm(() => {
|
|
|
130211
130414
|
|
|
130212
130415
|
// src/utils/auth.ts
|
|
130213
130416
|
import fs23 from "fs";
|
|
130214
|
-
import
|
|
130215
|
-
import
|
|
130417
|
+
import os12 from "os";
|
|
130418
|
+
import path29 from "path";
|
|
130216
130419
|
async function logoutUser() {
|
|
130217
130420
|
try {
|
|
130218
130421
|
const user = getUserCredentials();
|
|
@@ -130243,15 +130446,15 @@ async function logoutUser() {
|
|
|
130243
130446
|
return true;
|
|
130244
130447
|
}
|
|
130245
130448
|
var userSchema2, claudeOAuthSchema2, credentialsSchema, getLegacyConfigDir2 = () => {
|
|
130246
|
-
return
|
|
130449
|
+
return path29.join(os12.homedir(), ".config", "manicode" + (env2.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${env2.NEXT_PUBLIC_CB_ENVIRONMENT}` : ""));
|
|
130247
130450
|
}, getConfigDir2 = () => {
|
|
130248
|
-
return
|
|
130451
|
+
return path29.join(os12.homedir(), ".config", "levelcode" + (env2.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${env2.NEXT_PUBLIC_CB_ENVIRONMENT}` : ""));
|
|
130249
130452
|
}, migrateFromLegacyConfigDir2 = () => {
|
|
130250
130453
|
const newDir = getConfigDir2();
|
|
130251
|
-
const newCredsPath =
|
|
130454
|
+
const newCredsPath = path29.join(newDir, "credentials.json");
|
|
130252
130455
|
if (fs23.existsSync(newCredsPath))
|
|
130253
130456
|
return;
|
|
130254
|
-
const legacyCredsPath =
|
|
130457
|
+
const legacyCredsPath = path29.join(getLegacyConfigDir2(), "credentials.json");
|
|
130255
130458
|
if (!fs23.existsSync(legacyCredsPath))
|
|
130256
130459
|
return;
|
|
130257
130460
|
try {
|
|
@@ -130262,7 +130465,7 @@ var userSchema2, claudeOAuthSchema2, credentialsSchema, getLegacyConfigDir2 = ()
|
|
|
130262
130465
|
} catch {}
|
|
130263
130466
|
}, getCredentialsPath2 = () => {
|
|
130264
130467
|
migrateFromLegacyConfigDir2();
|
|
130265
|
-
return
|
|
130468
|
+
return path29.join(getConfigDir2(), "credentials.json");
|
|
130266
130469
|
}, userFromJson = (json2, profileName = "default") => {
|
|
130267
130470
|
try {
|
|
130268
130471
|
const allCredentials = credentialsSchema.parse(JSON.parse(json2));
|
|
@@ -130386,9 +130589,9 @@ var init_auth3 = __esm(() => {
|
|
|
130386
130589
|
|
|
130387
130590
|
// src/utils/settings.ts
|
|
130388
130591
|
import fs24 from "fs";
|
|
130389
|
-
import
|
|
130592
|
+
import path30 from "path";
|
|
130390
130593
|
var DEFAULT_SETTINGS, getSettingsPath = () => {
|
|
130391
|
-
return
|
|
130594
|
+
return path30.join(getConfigDir2(), "settings.json");
|
|
130392
130595
|
}, ensureConfigDirExists = () => {
|
|
130393
130596
|
const configDir = getConfigDir2();
|
|
130394
130597
|
if (!fs24.existsSync(configDir)) {
|
|
@@ -157951,9 +158154,9 @@ var init_esm30 = __esm(() => {
|
|
|
157951
158154
|
});
|
|
157952
158155
|
|
|
157953
158156
|
// src/utils/image-handler.ts
|
|
157954
|
-
import { readFileSync as
|
|
157955
|
-
import { homedir as
|
|
157956
|
-
import
|
|
158157
|
+
import { readFileSync as readFileSync6, statSync as statSync3 } from "fs";
|
|
158158
|
+
import { homedir as homedir5 } from "os";
|
|
158159
|
+
import path31 from "path";
|
|
157957
158160
|
function normalizeUserProvidedPath(filePath) {
|
|
157958
158161
|
let normalized = filePath;
|
|
157959
158162
|
normalized = normalized.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([0-9a-fA-F]{4})/g, (_, bracedCode, shortCode) => {
|
|
@@ -157965,18 +158168,18 @@ function normalizeUserProvidedPath(filePath) {
|
|
|
157965
158168
|
return normalized;
|
|
157966
158169
|
}
|
|
157967
158170
|
function isImageFile(filePath) {
|
|
157968
|
-
const ext =
|
|
158171
|
+
const ext = path31.extname(filePath).toLowerCase();
|
|
157969
158172
|
return SUPPORTED_IMAGE_EXTENSIONS.has(ext);
|
|
157970
158173
|
}
|
|
157971
158174
|
function resolveFilePath(filePath, cwd) {
|
|
157972
158175
|
const normalized = normalizeUserProvidedPath(filePath);
|
|
157973
158176
|
if (normalized.startsWith("~")) {
|
|
157974
|
-
return
|
|
158177
|
+
return path31.join(homedir5(), normalized.slice(1));
|
|
157975
158178
|
}
|
|
157976
|
-
if (
|
|
158179
|
+
if (path31.isAbsolute(normalized)) {
|
|
157977
158180
|
return normalized;
|
|
157978
158181
|
}
|
|
157979
|
-
return
|
|
158182
|
+
return path31.resolve(cwd, normalized);
|
|
157980
158183
|
}
|
|
157981
158184
|
async function compressImageToFitSize(fileBuffer) {
|
|
157982
158185
|
const image2 = await Jimp.read(fileBuffer);
|
|
@@ -158051,13 +158254,13 @@ async function processImageFile(filePath, cwd) {
|
|
|
158051
158254
|
error: `Unsupported image format: ${filePath}. Supported: ${Array.from(SUPPORTED_IMAGE_EXTENSIONS).join(", ")}`
|
|
158052
158255
|
};
|
|
158053
158256
|
}
|
|
158054
|
-
const mediaType = getImageMimeType(
|
|
158257
|
+
const mediaType = getImageMimeType(path31.extname(resolvedPath));
|
|
158055
158258
|
if (!mediaType) {
|
|
158056
158259
|
return { success: false, error: `Could not determine image type for: ${filePath}` };
|
|
158057
158260
|
}
|
|
158058
158261
|
let fileBuffer;
|
|
158059
158262
|
try {
|
|
158060
|
-
fileBuffer =
|
|
158263
|
+
fileBuffer = readFileSync6(resolvedPath);
|
|
158061
158264
|
} catch (error46) {
|
|
158062
158265
|
logger2.debug({ resolvedPath, error: error46 }, "Image handler: Failed to read file");
|
|
158063
158266
|
return { success: false, error: `Could not read file: ${filePath}` };
|
|
@@ -158092,7 +158295,7 @@ async function processImageFile(filePath, cwd) {
|
|
|
158092
158295
|
type: "image",
|
|
158093
158296
|
image: base64Data,
|
|
158094
158297
|
mediaType: finalMediaType,
|
|
158095
|
-
filename:
|
|
158298
|
+
filename: path31.basename(resolvedPath),
|
|
158096
158299
|
size: processedBuffer.length,
|
|
158097
158300
|
width,
|
|
158098
158301
|
height
|
|
@@ -158149,14 +158352,14 @@ __export(exports_pending_attachments, {
|
|
|
158149
158352
|
addClipboardPlaceholder: () => addClipboardPlaceholder
|
|
158150
158353
|
});
|
|
158151
158354
|
import { existsSync as existsSync14 } from "fs";
|
|
158152
|
-
import
|
|
158355
|
+
import path32 from "path";
|
|
158153
158356
|
function exitImageModeIfActive() {
|
|
158154
158357
|
if (useChatStore.getState().inputMode === "image") {
|
|
158155
158358
|
useChatStore.getState().setInputMode("default");
|
|
158156
158359
|
}
|
|
158157
158360
|
}
|
|
158158
158361
|
async function addPendingImageFromFile(imagePath, cwd, replacePlaceholder) {
|
|
158159
|
-
const filename =
|
|
158362
|
+
const filename = path32.basename(imagePath);
|
|
158160
158363
|
if (replacePlaceholder) {
|
|
158161
158364
|
useChatStore.setState((state) => ({
|
|
158162
158365
|
pendingAttachments: state.pendingAttachments.map((att) => att.kind === "image" && att.path === replacePlaceholder ? { ...att, path: imagePath, filename } : att)
|
|
@@ -158221,7 +158424,7 @@ function addClipboardPlaceholder() {
|
|
|
158221
158424
|
return placeholderPath;
|
|
158222
158425
|
}
|
|
158223
158426
|
function addPendingImageWithError(imagePath, note) {
|
|
158224
|
-
const filename =
|
|
158427
|
+
const filename = path32.basename(imagePath);
|
|
158225
158428
|
useChatStore.getState().addPendingImage({
|
|
158226
158429
|
path: imagePath,
|
|
158227
158430
|
filename,
|
|
@@ -158253,7 +158456,7 @@ async function validateAndAddImage(imagePath, cwd) {
|
|
|
158253
158456
|
return { success: false, error: error46 };
|
|
158254
158457
|
}
|
|
158255
158458
|
if (!isImageFile(resolvedPath)) {
|
|
158256
|
-
const ext =
|
|
158459
|
+
const ext = path32.extname(imagePath).toLowerCase();
|
|
158257
158460
|
const error46 = ext ? `unsupported format ${ext}` : "unsupported format";
|
|
158258
158461
|
addPendingImageWithError(resolvedPath, `\u274C ${error46}`);
|
|
158259
158462
|
return { success: false, error: error46 };
|
|
@@ -158588,7 +158791,14 @@ var init_bundled_agents_generated = __esm(() => {
|
|
|
158588
158791
|
"propose_str_replace",
|
|
158589
158792
|
"propose_write_file",
|
|
158590
158793
|
"skill",
|
|
158591
|
-
"set_output"
|
|
158794
|
+
"set_output",
|
|
158795
|
+
"team_create",
|
|
158796
|
+
"team_delete",
|
|
158797
|
+
"send_message",
|
|
158798
|
+
"task_create",
|
|
158799
|
+
"task_get",
|
|
158800
|
+
"task_update",
|
|
158801
|
+
"task_list"
|
|
158592
158802
|
],
|
|
158593
158803
|
spawnableAgents: [
|
|
158594
158804
|
"file-picker",
|
|
@@ -158603,7 +158813,17 @@ var init_bundled_agents_generated = __esm(() => {
|
|
|
158603
158813
|
"gpt-5-agent",
|
|
158604
158814
|
"editor",
|
|
158605
158815
|
"code-reviewer",
|
|
158606
|
-
"context-pruner"
|
|
158816
|
+
"context-pruner",
|
|
158817
|
+
"coordinator",
|
|
158818
|
+
"team-manager",
|
|
158819
|
+
"senior-engineer",
|
|
158820
|
+
"team-mid-level-engineer",
|
|
158821
|
+
"team-junior-engineer",
|
|
158822
|
+
"team-researcher",
|
|
158823
|
+
"team-designer",
|
|
158824
|
+
"team-product-lead",
|
|
158825
|
+
"team-tester",
|
|
158826
|
+
"team-scientist"
|
|
158607
158827
|
],
|
|
158608
158828
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
158609
158829
|
|
|
@@ -158650,7 +158870,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
158650
158870
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
158651
158871
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
158652
158872
|
- Spawn the editor agent to implement the changes after you have gathered all the context you need.
|
|
158653
|
-
- Spawn the thinker after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent is a last resort for complex problems)
|
|
158873
|
+
- Spawn the thinker after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
158654
158874
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
158655
158875
|
- Spawn a code-reviewer to review the changes after you have implemented the changes.
|
|
158656
158876
|
- **No need to include context:** When prompting an agent, realize that many agents can already see the entire conversation history, so you can be brief in prompting them without needing to include context.
|
|
@@ -158666,6 +158886,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
158666
158886
|
|
|
158667
158887
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
158668
158888
|
|
|
158889
|
+
# Agent Swarms / Teams
|
|
158890
|
+
|
|
158891
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
158892
|
+
|
|
158893
|
+
**Creating and Managing Teams:**
|
|
158894
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
158895
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
158896
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
158897
|
+
|
|
158898
|
+
**Task Management:**
|
|
158899
|
+
- Use \`task_create\` to create tasks for team members
|
|
158900
|
+
- Use \`task_list\` to see all tasks and their status
|
|
158901
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
158902
|
+
- Use \`task_get\` to read full task details
|
|
158903
|
+
|
|
158904
|
+
**Communication:**
|
|
158905
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
158906
|
+
|
|
158907
|
+
**Spawning Team Agents:**
|
|
158908
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
158909
|
+
\`\`\`
|
|
158910
|
+
spawn_agents([{
|
|
158911
|
+
agent: "team-manager",
|
|
158912
|
+
prompt: "Manage the frontend tasks",
|
|
158913
|
+
team_name: "my-project",
|
|
158914
|
+
team_role: "manager"
|
|
158915
|
+
}])
|
|
158916
|
+
\`\`\`
|
|
158917
|
+
|
|
158918
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
158919
|
+
|
|
158920
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
158921
|
+
|
|
158922
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
158923
|
+
|
|
158924
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
158925
|
+
|
|
158669
158926
|
# Other response guidelines
|
|
158670
158927
|
|
|
158671
158928
|
- Your goal is to produce the highest quality results, even if it comes at the cost of more credits used.
|
|
@@ -158728,7 +158985,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
158728
158985
|
|
|
158729
158986
|
- Iteratively spawn file pickers, code-searchers, directory-listers, glob-matchers, commanders, and web/docs researchers to gather context as needed. The file-picker agent in particular is very useful to find relevant files -- try spawning multiple in parallel (say, 2-5) to explore different parts of the codebase. Use read_subtree if you need to grok a particular part of the codebase. Read all the relevant files using the read_files tool.
|
|
158730
158987
|
- For any task requiring 3+ steps, use the write_todos tool to write out your step-by-step implementation plan. Include ALL of the applicable tasks in the list. You should include a step to review the changes after you have implemented the changes.: You should include at least one step to validate/test your changes: be specific about whether to typecheck, run tests, run lints, etc. You may be able to do reviewing and validation in parallel in the same step. Skip write_todos for simple tasks like quick edits or answering questions.
|
|
158731
|
-
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent is a last resort for complex problems)
|
|
158988
|
+
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
158732
158989
|
- IMPORTANT: You must spawn the editor agent to implement the changes after you have gathered all the context you need. This agent will do the best job of implementing the changes so you must spawn it for all non-trivial changes. Do not pass any prompt or params to the editor agent when spawning it. It will make its own best choices of what to do.
|
|
158733
158990
|
- For non-trivial changes, test them by running appropriate validation commands for the project (e.g. typechecks, tests, lints, etc.). Try to run all appropriate commands in parallel. If you can, only test the area of the project that you are editing, rather than the entire project. You may have to explore the project to find the appropriate commands. Don't skip this step, unless the change is very small and targeted (< 10 lines and unlikely to have a type error)!
|
|
158734
158991
|
- Spawn a code-reviewer to review the changes after you have implemented changes. (Skip this step only if the change is extremely straightforward and obvious.)
|
|
@@ -158784,7 +159041,14 @@ After completing the user request, summarize your changes in a sentence or a few
|
|
|
158784
159041
|
"propose_write_file",
|
|
158785
159042
|
"ask_user",
|
|
158786
159043
|
"skill",
|
|
158787
|
-
"set_output"
|
|
159044
|
+
"set_output",
|
|
159045
|
+
"team_create",
|
|
159046
|
+
"team_delete",
|
|
159047
|
+
"send_message",
|
|
159048
|
+
"task_create",
|
|
159049
|
+
"task_get",
|
|
159050
|
+
"task_update",
|
|
159051
|
+
"task_list"
|
|
158788
159052
|
],
|
|
158789
159053
|
spawnableAgents: [
|
|
158790
159054
|
"file-picker",
|
|
@@ -158794,7 +159058,17 @@ After completing the user request, summarize your changes in a sentence or a few
|
|
|
158794
159058
|
"researcher-web",
|
|
158795
159059
|
"researcher-docs",
|
|
158796
159060
|
"commander",
|
|
158797
|
-
"context-pruner"
|
|
159061
|
+
"context-pruner",
|
|
159062
|
+
"coordinator",
|
|
159063
|
+
"team-manager",
|
|
159064
|
+
"senior-engineer",
|
|
159065
|
+
"team-mid-level-engineer",
|
|
159066
|
+
"team-junior-engineer",
|
|
159067
|
+
"team-researcher",
|
|
159068
|
+
"team-designer",
|
|
159069
|
+
"team-product-lead",
|
|
159070
|
+
"team-tester",
|
|
159071
|
+
"team-scientist"
|
|
158798
159072
|
],
|
|
158799
159073
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
158800
159074
|
|
|
@@ -158855,6 +159129,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
158855
159129
|
|
|
158856
159130
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
158857
159131
|
|
|
159132
|
+
# Agent Swarms / Teams
|
|
159133
|
+
|
|
159134
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
159135
|
+
|
|
159136
|
+
**Creating and Managing Teams:**
|
|
159137
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
159138
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
159139
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
159140
|
+
|
|
159141
|
+
**Task Management:**
|
|
159142
|
+
- Use \`task_create\` to create tasks for team members
|
|
159143
|
+
- Use \`task_list\` to see all tasks and their status
|
|
159144
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
159145
|
+
- Use \`task_get\` to read full task details
|
|
159146
|
+
|
|
159147
|
+
**Communication:**
|
|
159148
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
159149
|
+
|
|
159150
|
+
**Spawning Team Agents:**
|
|
159151
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
159152
|
+
\`\`\`
|
|
159153
|
+
spawn_agents([{
|
|
159154
|
+
agent: "team-manager",
|
|
159155
|
+
prompt: "Manage the frontend tasks",
|
|
159156
|
+
team_name: "my-project",
|
|
159157
|
+
team_role: "manager"
|
|
159158
|
+
}])
|
|
159159
|
+
\`\`\`
|
|
159160
|
+
|
|
159161
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
159162
|
+
|
|
159163
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
159164
|
+
|
|
159165
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
159166
|
+
|
|
159167
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
159168
|
+
|
|
158858
159169
|
# Other response guidelines
|
|
158859
159170
|
|
|
158860
159171
|
- Prioritize speed: quickly getting the user request done is your first priority. Do not call any unnecessary tools. Spawn more agents in parallel to speed up the process. Be extremely concise in your responses. Use 2 words where you would have used 2 sentences.
|
|
@@ -158970,7 +159281,14 @@ After getting context on the user request from the codebase or from research, us
|
|
|
158970
159281
|
"propose_write_file",
|
|
158971
159282
|
"ask_user",
|
|
158972
159283
|
"skill",
|
|
158973
|
-
"set_output"
|
|
159284
|
+
"set_output",
|
|
159285
|
+
"team_create",
|
|
159286
|
+
"team_delete",
|
|
159287
|
+
"send_message",
|
|
159288
|
+
"task_create",
|
|
159289
|
+
"task_get",
|
|
159290
|
+
"task_update",
|
|
159291
|
+
"task_list"
|
|
158974
159292
|
],
|
|
158975
159293
|
spawnableAgents: [
|
|
158976
159294
|
"file-picker",
|
|
@@ -158980,7 +159298,17 @@ After getting context on the user request from the codebase or from research, us
|
|
|
158980
159298
|
"researcher-web",
|
|
158981
159299
|
"researcher-docs",
|
|
158982
159300
|
"commander",
|
|
158983
|
-
"context-pruner"
|
|
159301
|
+
"context-pruner",
|
|
159302
|
+
"coordinator",
|
|
159303
|
+
"team-manager",
|
|
159304
|
+
"senior-engineer",
|
|
159305
|
+
"team-mid-level-engineer",
|
|
159306
|
+
"team-junior-engineer",
|
|
159307
|
+
"team-researcher",
|
|
159308
|
+
"team-designer",
|
|
159309
|
+
"team-product-lead",
|
|
159310
|
+
"team-tester",
|
|
159311
|
+
"team-scientist"
|
|
158984
159312
|
],
|
|
158985
159313
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
158986
159314
|
|
|
@@ -159041,6 +159369,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
159041
159369
|
|
|
159042
159370
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
159043
159371
|
|
|
159372
|
+
# Agent Swarms / Teams
|
|
159373
|
+
|
|
159374
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
159375
|
+
|
|
159376
|
+
**Creating and Managing Teams:**
|
|
159377
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
159378
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
159379
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
159380
|
+
|
|
159381
|
+
**Task Management:**
|
|
159382
|
+
- Use \`task_create\` to create tasks for team members
|
|
159383
|
+
- Use \`task_list\` to see all tasks and their status
|
|
159384
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
159385
|
+
- Use \`task_get\` to read full task details
|
|
159386
|
+
|
|
159387
|
+
**Communication:**
|
|
159388
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
159389
|
+
|
|
159390
|
+
**Spawning Team Agents:**
|
|
159391
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
159392
|
+
\`\`\`
|
|
159393
|
+
spawn_agents([{
|
|
159394
|
+
agent: "team-manager",
|
|
159395
|
+
prompt: "Manage the frontend tasks",
|
|
159396
|
+
team_name: "my-project",
|
|
159397
|
+
team_role: "manager"
|
|
159398
|
+
}])
|
|
159399
|
+
\`\`\`
|
|
159400
|
+
|
|
159401
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
159402
|
+
|
|
159403
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
159404
|
+
|
|
159405
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
159406
|
+
|
|
159407
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
159408
|
+
|
|
159044
159409
|
# Other response guidelines
|
|
159045
159410
|
|
|
159046
159411
|
- Prioritize speed: quickly getting the user request done is your first priority. Do not call any unnecessary tools. Spawn more agents in parallel to speed up the process. Be extremely concise in your responses. Use 2 words where you would have used 2 sentences.
|
|
@@ -159157,7 +159522,14 @@ After getting context on the user request from the codebase or from research, us
|
|
|
159157
159522
|
"propose_write_file",
|
|
159158
159523
|
"ask_user",
|
|
159159
159524
|
"skill",
|
|
159160
|
-
"set_output"
|
|
159525
|
+
"set_output",
|
|
159526
|
+
"team_create",
|
|
159527
|
+
"team_delete",
|
|
159528
|
+
"send_message",
|
|
159529
|
+
"task_create",
|
|
159530
|
+
"task_get",
|
|
159531
|
+
"task_update",
|
|
159532
|
+
"task_list"
|
|
159161
159533
|
],
|
|
159162
159534
|
spawnableAgents: [
|
|
159163
159535
|
"file-picker",
|
|
@@ -159168,7 +159540,17 @@ After getting context on the user request from the codebase or from research, us
|
|
|
159168
159540
|
"researcher-docs",
|
|
159169
159541
|
"commander-lite",
|
|
159170
159542
|
"editor-glm",
|
|
159171
|
-
"context-pruner"
|
|
159543
|
+
"context-pruner",
|
|
159544
|
+
"coordinator",
|
|
159545
|
+
"team-manager",
|
|
159546
|
+
"senior-engineer",
|
|
159547
|
+
"team-mid-level-engineer",
|
|
159548
|
+
"team-junior-engineer",
|
|
159549
|
+
"team-researcher",
|
|
159550
|
+
"team-designer",
|
|
159551
|
+
"team-product-lead",
|
|
159552
|
+
"team-tester",
|
|
159553
|
+
"team-scientist"
|
|
159172
159554
|
],
|
|
159173
159555
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
159174
159556
|
|
|
@@ -159230,6 +159612,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
159230
159612
|
|
|
159231
159613
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
159232
159614
|
|
|
159615
|
+
# Agent Swarms / Teams
|
|
159616
|
+
|
|
159617
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
159618
|
+
|
|
159619
|
+
**Creating and Managing Teams:**
|
|
159620
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
159621
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
159622
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
159623
|
+
|
|
159624
|
+
**Task Management:**
|
|
159625
|
+
- Use \`task_create\` to create tasks for team members
|
|
159626
|
+
- Use \`task_list\` to see all tasks and their status
|
|
159627
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
159628
|
+
- Use \`task_get\` to read full task details
|
|
159629
|
+
|
|
159630
|
+
**Communication:**
|
|
159631
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
159632
|
+
|
|
159633
|
+
**Spawning Team Agents:**
|
|
159634
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
159635
|
+
\`\`\`
|
|
159636
|
+
spawn_agents([{
|
|
159637
|
+
agent: "team-manager",
|
|
159638
|
+
prompt: "Manage the frontend tasks",
|
|
159639
|
+
team_name: "my-project",
|
|
159640
|
+
team_role: "manager"
|
|
159641
|
+
}])
|
|
159642
|
+
\`\`\`
|
|
159643
|
+
|
|
159644
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
159645
|
+
|
|
159646
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
159647
|
+
|
|
159648
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
159649
|
+
|
|
159650
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
159651
|
+
|
|
159233
159652
|
# Other response guidelines
|
|
159234
159653
|
|
|
159235
159654
|
- Your goal is to produce the highest quality results, even if it comes at the cost of more credits used.
|
|
@@ -159348,7 +159767,14 @@ At the end of your turn, use the suggest_followups tool to suggest around 3 next
|
|
|
159348
159767
|
"propose_str_replace",
|
|
159349
159768
|
"propose_write_file",
|
|
159350
159769
|
"skill",
|
|
159351
|
-
"set_output"
|
|
159770
|
+
"set_output",
|
|
159771
|
+
"team_create",
|
|
159772
|
+
"team_delete",
|
|
159773
|
+
"send_message",
|
|
159774
|
+
"task_create",
|
|
159775
|
+
"task_get",
|
|
159776
|
+
"task_update",
|
|
159777
|
+
"task_list"
|
|
159352
159778
|
],
|
|
159353
159779
|
spawnableAgents: [
|
|
159354
159780
|
"file-picker-max",
|
|
@@ -159363,7 +159789,17 @@ At the end of your turn, use the suggest_followups tool to suggest around 3 next
|
|
|
159363
159789
|
"thinker-best-of-n-opus",
|
|
159364
159790
|
"editor-multi-prompt",
|
|
159365
159791
|
"code-reviewer-multi-prompt",
|
|
159366
|
-
"context-pruner"
|
|
159792
|
+
"context-pruner",
|
|
159793
|
+
"coordinator",
|
|
159794
|
+
"team-manager",
|
|
159795
|
+
"senior-engineer",
|
|
159796
|
+
"team-mid-level-engineer",
|
|
159797
|
+
"team-junior-engineer",
|
|
159798
|
+
"team-researcher",
|
|
159799
|
+
"team-designer",
|
|
159800
|
+
"team-product-lead",
|
|
159801
|
+
"team-tester",
|
|
159802
|
+
"team-scientist"
|
|
159367
159803
|
],
|
|
159368
159804
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
159369
159805
|
|
|
@@ -159409,7 +159845,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
159409
159845
|
- **Spawn multiple agents in parallel:** This increases the speed of your response **and** allows you to be more comprehensive by spawning more total agents to synthesize the best response.
|
|
159410
159846
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
159411
159847
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
159412
|
-
- Spawn the thinker-best-of-n-opus after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent is a last resort for complex problems)
|
|
159848
|
+
- Spawn the thinker-best-of-n-opus after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
159413
159849
|
- IMPORTANT: You must spawn the editor-multi-prompt agent to implement the changes after you have gathered all the context you need. You must spawn this agent for non-trivial changes, since it writes much better code than you would with the str_replace or write_file tools. Don't spawn the editor in parallel with context-gathering agents.
|
|
159414
159850
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
159415
159851
|
- Spawn a code-reviewer-multi-prompt to review the changes after you have implemented the changes.
|
|
@@ -159426,6 +159862,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
159426
159862
|
|
|
159427
159863
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
159428
159864
|
|
|
159865
|
+
# Agent Swarms / Teams
|
|
159866
|
+
|
|
159867
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
159868
|
+
|
|
159869
|
+
**Creating and Managing Teams:**
|
|
159870
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
159871
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
159872
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
159873
|
+
|
|
159874
|
+
**Task Management:**
|
|
159875
|
+
- Use \`task_create\` to create tasks for team members
|
|
159876
|
+
- Use \`task_list\` to see all tasks and their status
|
|
159877
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
159878
|
+
- Use \`task_get\` to read full task details
|
|
159879
|
+
|
|
159880
|
+
**Communication:**
|
|
159881
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
159882
|
+
|
|
159883
|
+
**Spawning Team Agents:**
|
|
159884
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
159885
|
+
\`\`\`
|
|
159886
|
+
spawn_agents([{
|
|
159887
|
+
agent: "team-manager",
|
|
159888
|
+
prompt: "Manage the frontend tasks",
|
|
159889
|
+
team_name: "my-project",
|
|
159890
|
+
team_role: "manager"
|
|
159891
|
+
}])
|
|
159892
|
+
\`\`\`
|
|
159893
|
+
|
|
159894
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
159895
|
+
|
|
159896
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
159897
|
+
|
|
159898
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
159899
|
+
|
|
159900
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
159901
|
+
|
|
159429
159902
|
# Other response guidelines
|
|
159430
159903
|
|
|
159431
159904
|
- Your goal is to produce the highest quality results, even if it comes at the cost of more credits used.
|
|
@@ -159489,7 +159962,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
159489
159962
|
- Iteratively spawn file pickers, code-searchers, directory-listers, glob-matchers, commanders, and web/docs researchers to gather context as needed. The file-picker agent in particular is very useful to find relevant files -- try spawning multiple in parallel (say, 2-5) to explore different parts of the codebase. Use read_subtree if you need to grok a particular part of the codebase. Read all the relevant files using the read_files tool.
|
|
159490
159963
|
- Important: Read as many files as could possibly be relevant to the task over several steps to improve your understanding of the user's request and produce the best possible code changes. Find more examples within the codebase similar to the user's request, dependencies that help with understanding how things work, tests, etc. This is frequently 12-20 files, depending on the task.
|
|
159491
159964
|
- For any task requiring 3+ steps, use the write_todos tool to write out your step-by-step implementation plan. Include ALL of the applicable tasks in the list. You should include a step to review the changes after you have implemented the changes.: You should include at least one step to validate/test your changes: be specific about whether to typecheck, run tests, run lints, etc. You may be able to do reviewing and validation in parallel in the same step. Skip write_todos for simple tasks like quick edits or answering questions.
|
|
159492
|
-
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent is a last resort for complex problems)
|
|
159965
|
+
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
159493
159966
|
- IMPORTANT: You must spawn the editor-multi-prompt agent to implement non-trivial code changes, since it will generate the best code changes from multiple implementation proposals. This is the best way to make high quality code changes -- strongly prefer using this agent over the str_replace or write_file tools, unless the change is very straightforward and obvious. You should also prompt it to implement the full task rather than just a single step.
|
|
159494
159967
|
- For non-trivial changes, test them by running appropriate validation commands for the project (e.g. typechecks, tests, lints, etc.). Try to run all appropriate commands in parallel. Typecheck and test the specific area of the project that you are editing *AND* then typecheck and test the entire project if necessary. You may have to explore the project to find the appropriate commands. Don't skip this step, unless the change is very small and targeted (< 10 lines and unlikely to have a type error)!
|
|
159495
159968
|
- Spawn a code-reviewer-multi-prompt to review the changes after you have implemented changes. (Skip this step only if the change is extremely straightforward and obvious.)
|
|
@@ -159549,7 +160022,14 @@ After completing the user request, summarize your changes in a sentence or a few
|
|
|
159549
160022
|
"propose_write_file",
|
|
159550
160023
|
"ask_user",
|
|
159551
160024
|
"skill",
|
|
159552
|
-
"set_output"
|
|
160025
|
+
"set_output",
|
|
160026
|
+
"team_create",
|
|
160027
|
+
"team_delete",
|
|
160028
|
+
"send_message",
|
|
160029
|
+
"task_create",
|
|
160030
|
+
"task_get",
|
|
160031
|
+
"task_update",
|
|
160032
|
+
"task_list"
|
|
159553
160033
|
],
|
|
159554
160034
|
spawnableAgents: [
|
|
159555
160035
|
"file-picker-max",
|
|
@@ -159564,7 +160044,17 @@ After completing the user request, summarize your changes in a sentence or a few
|
|
|
159564
160044
|
"thinker-best-of-n-opus",
|
|
159565
160045
|
"editor-multi-prompt",
|
|
159566
160046
|
"code-reviewer-multi-prompt",
|
|
159567
|
-
"context-pruner"
|
|
160047
|
+
"context-pruner",
|
|
160048
|
+
"coordinator",
|
|
160049
|
+
"team-manager",
|
|
160050
|
+
"senior-engineer",
|
|
160051
|
+
"team-mid-level-engineer",
|
|
160052
|
+
"team-junior-engineer",
|
|
160053
|
+
"team-researcher",
|
|
160054
|
+
"team-designer",
|
|
160055
|
+
"team-product-lead",
|
|
160056
|
+
"team-tester",
|
|
160057
|
+
"team-scientist"
|
|
159568
160058
|
],
|
|
159569
160059
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
159570
160060
|
|
|
@@ -159611,7 +160101,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
159611
160101
|
- **Spawn multiple agents in parallel:** This increases the speed of your response **and** allows you to be more comprehensive by spawning more total agents to synthesize the best response.
|
|
159612
160102
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
159613
160103
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
159614
|
-
- Spawn the thinker-best-of-n-opus after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent is a last resort for complex problems)
|
|
160104
|
+
- Spawn the thinker-best-of-n-opus after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
159615
160105
|
- IMPORTANT: You must spawn the editor-multi-prompt agent to implement the changes after you have gathered all the context you need. You must spawn this agent for non-trivial changes, since it writes much better code than you would with the str_replace or write_file tools. Don't spawn the editor in parallel with context-gathering agents.
|
|
159616
160106
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
159617
160107
|
- Spawn a code-reviewer-multi-prompt to review the changes after you have implemented the changes.
|
|
@@ -159628,6 +160118,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
159628
160118
|
|
|
159629
160119
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
159630
160120
|
|
|
160121
|
+
# Agent Swarms / Teams
|
|
160122
|
+
|
|
160123
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
160124
|
+
|
|
160125
|
+
**Creating and Managing Teams:**
|
|
160126
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
160127
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
160128
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
160129
|
+
|
|
160130
|
+
**Task Management:**
|
|
160131
|
+
- Use \`task_create\` to create tasks for team members
|
|
160132
|
+
- Use \`task_list\` to see all tasks and their status
|
|
160133
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
160134
|
+
- Use \`task_get\` to read full task details
|
|
160135
|
+
|
|
160136
|
+
**Communication:**
|
|
160137
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
160138
|
+
|
|
160139
|
+
**Spawning Team Agents:**
|
|
160140
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
160141
|
+
\`\`\`
|
|
160142
|
+
spawn_agents([{
|
|
160143
|
+
agent: "team-manager",
|
|
160144
|
+
prompt: "Manage the frontend tasks",
|
|
160145
|
+
team_name: "my-project",
|
|
160146
|
+
team_role: "manager"
|
|
160147
|
+
}])
|
|
160148
|
+
\`\`\`
|
|
160149
|
+
|
|
160150
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
160151
|
+
|
|
160152
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
160153
|
+
|
|
160154
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
160155
|
+
|
|
160156
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
160157
|
+
|
|
159631
160158
|
# Other response guidelines
|
|
159632
160159
|
|
|
159633
160160
|
- Your goal is to produce the highest quality results, even if it comes at the cost of more credits used.
|
|
@@ -159694,7 +160221,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
159694
160221
|
- Important: Read as many files as could possibly be relevant to the task over several steps to improve your understanding of the user's request and produce the best possible code changes. Find more examples within the codebase similar to the user's request, dependencies that help with understanding how things work, tests, etc. This is frequently 12-20 files, depending on the task.
|
|
159695
160222
|
After getting context on the user request from the codebase or from research, use the ask_user tool to ask the user for important clarifications on their request or alternate implementation strategies. You should skip this step if the choice is obvious -- only ask the user if you need their help making the best choice.
|
|
159696
160223
|
- For any task requiring 3+ steps, use the write_todos tool to write out your step-by-step implementation plan. Include ALL of the applicable tasks in the list. You should include a step to review the changes after you have implemented the changes.: You should include at least one step to validate/test your changes: be specific about whether to typecheck, run tests, run lints, etc. You may be able to do reviewing and validation in parallel in the same step. Skip write_todos for simple tasks like quick edits or answering questions.
|
|
159697
|
-
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent is a last resort for complex problems)
|
|
160224
|
+
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
159698
160225
|
- IMPORTANT: You must spawn the editor-multi-prompt agent to implement non-trivial code changes, since it will generate the best code changes from multiple implementation proposals. This is the best way to make high quality code changes -- strongly prefer using this agent over the str_replace or write_file tools, unless the change is very straightforward and obvious. You should also prompt it to implement the full task rather than just a single step.
|
|
159699
160226
|
- For non-trivial changes, test them by running appropriate validation commands for the project (e.g. typechecks, tests, lints, etc.). Try to run all appropriate commands in parallel. Typecheck and test the specific area of the project that you are editing *AND* then typecheck and test the entire project if necessary. You may have to explore the project to find the appropriate commands. Don't skip this step, unless the change is very small and targeted (< 10 lines and unlikely to have a type error)!
|
|
159700
160227
|
- Spawn a code-reviewer-multi-prompt to review the changes after you have implemented changes. (Skip this step only if the change is extremely straightforward and obvious.)
|
|
@@ -159756,7 +160283,14 @@ At the end of your turn, use the suggest_followups tool to suggest around 3 next
|
|
|
159756
160283
|
"propose_write_file",
|
|
159757
160284
|
"ask_user",
|
|
159758
160285
|
"skill",
|
|
159759
|
-
"set_output"
|
|
160286
|
+
"set_output",
|
|
160287
|
+
"team_create",
|
|
160288
|
+
"team_delete",
|
|
160289
|
+
"send_message",
|
|
160290
|
+
"task_create",
|
|
160291
|
+
"task_get",
|
|
160292
|
+
"task_update",
|
|
160293
|
+
"task_list"
|
|
159760
160294
|
],
|
|
159761
160295
|
spawnableAgents: [
|
|
159762
160296
|
"file-picker",
|
|
@@ -159771,7 +160305,17 @@ At the end of your turn, use the suggest_followups tool to suggest around 3 next
|
|
|
159771
160305
|
"gpt-5-agent",
|
|
159772
160306
|
"editor",
|
|
159773
160307
|
"code-reviewer",
|
|
159774
|
-
"context-pruner"
|
|
160308
|
+
"context-pruner",
|
|
160309
|
+
"coordinator",
|
|
160310
|
+
"team-manager",
|
|
160311
|
+
"senior-engineer",
|
|
160312
|
+
"team-mid-level-engineer",
|
|
160313
|
+
"team-junior-engineer",
|
|
160314
|
+
"team-researcher",
|
|
160315
|
+
"team-designer",
|
|
160316
|
+
"team-product-lead",
|
|
160317
|
+
"team-tester",
|
|
160318
|
+
"team-scientist"
|
|
159775
160319
|
],
|
|
159776
160320
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
159777
160321
|
|
|
@@ -159819,7 +160363,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
159819
160363
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
159820
160364
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
159821
160365
|
- Spawn the editor agent to implement the changes after you have gathered all the context you need.
|
|
159822
|
-
- Spawn the thinker after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent is a last resort for complex problems)
|
|
160366
|
+
- Spawn the thinker after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
159823
160367
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
159824
160368
|
- Spawn a code-reviewer to review the changes after you have implemented the changes.
|
|
159825
160369
|
- **No need to include context:** When prompting an agent, realize that many agents can already see the entire conversation history, so you can be brief in prompting them without needing to include context.
|
|
@@ -159835,6 +160379,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
159835
160379
|
|
|
159836
160380
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
159837
160381
|
|
|
160382
|
+
# Agent Swarms / Teams
|
|
160383
|
+
|
|
160384
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
160385
|
+
|
|
160386
|
+
**Creating and Managing Teams:**
|
|
160387
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
160388
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
160389
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
160390
|
+
|
|
160391
|
+
**Task Management:**
|
|
160392
|
+
- Use \`task_create\` to create tasks for team members
|
|
160393
|
+
- Use \`task_list\` to see all tasks and their status
|
|
160394
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
160395
|
+
- Use \`task_get\` to read full task details
|
|
160396
|
+
|
|
160397
|
+
**Communication:**
|
|
160398
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
160399
|
+
|
|
160400
|
+
**Spawning Team Agents:**
|
|
160401
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
160402
|
+
\`\`\`
|
|
160403
|
+
spawn_agents([{
|
|
160404
|
+
agent: "team-manager",
|
|
160405
|
+
prompt: "Manage the frontend tasks",
|
|
160406
|
+
team_name: "my-project",
|
|
160407
|
+
team_role: "manager"
|
|
160408
|
+
}])
|
|
160409
|
+
\`\`\`
|
|
160410
|
+
|
|
160411
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
160412
|
+
|
|
160413
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
160414
|
+
|
|
160415
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
160416
|
+
|
|
160417
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
160418
|
+
|
|
159838
160419
|
# Other response guidelines
|
|
159839
160420
|
|
|
159840
160421
|
- Your goal is to produce the highest quality results, even if it comes at the cost of more credits used.
|
|
@@ -159985,7 +160566,14 @@ This is more like an extremely short PRD which describes the end result of what
|
|
|
159985
160566
|
"propose_write_file",
|
|
159986
160567
|
"ask_user",
|
|
159987
160568
|
"skill",
|
|
159988
|
-
"set_output"
|
|
160569
|
+
"set_output",
|
|
160570
|
+
"team_create",
|
|
160571
|
+
"team_delete",
|
|
160572
|
+
"send_message",
|
|
160573
|
+
"task_create",
|
|
160574
|
+
"task_get",
|
|
160575
|
+
"task_update",
|
|
160576
|
+
"task_list"
|
|
159989
160577
|
],
|
|
159990
160578
|
spawnableAgents: [
|
|
159991
160579
|
"file-picker",
|
|
@@ -160000,7 +160588,17 @@ This is more like an extremely short PRD which describes the end result of what
|
|
|
160000
160588
|
"gpt-5-agent",
|
|
160001
160589
|
"editor",
|
|
160002
160590
|
"code-reviewer",
|
|
160003
|
-
"context-pruner"
|
|
160591
|
+
"context-pruner",
|
|
160592
|
+
"coordinator",
|
|
160593
|
+
"team-manager",
|
|
160594
|
+
"senior-engineer",
|
|
160595
|
+
"team-mid-level-engineer",
|
|
160596
|
+
"team-junior-engineer",
|
|
160597
|
+
"team-researcher",
|
|
160598
|
+
"team-designer",
|
|
160599
|
+
"team-product-lead",
|
|
160600
|
+
"team-tester",
|
|
160601
|
+
"team-scientist"
|
|
160004
160602
|
],
|
|
160005
160603
|
systemPrompt: `You are Sage, a strategic assistant that orchestrates complex coding tasks through specialized sub-agents. You are the AI agent behind the product, LevelCode, a CLI tool where users can chat with you to code with AI.
|
|
160006
160604
|
|
|
@@ -160048,7 +160646,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
160048
160646
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
160049
160647
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
160050
160648
|
- Spawn the editor agent to implement the changes after you have gathered all the context you need.
|
|
160051
|
-
- Spawn the thinker after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent is a last resort for complex problems)
|
|
160649
|
+
- Spawn the thinker after gathering context to solve complex problems or when the user asks you to think about a problem. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
160052
160650
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
160053
160651
|
- Spawn a code-reviewer to review the changes after you have implemented the changes.
|
|
160054
160652
|
- **No need to include context:** When prompting an agent, realize that many agents can already see the entire conversation history, so you can be brief in prompting them without needing to include context.
|
|
@@ -160064,6 +160662,43 @@ The user can use the "/usage" command to see how many credits they have used and
|
|
|
160064
160662
|
|
|
160065
160663
|
For other questions, you can direct them to levelcode.vercel.app, or especially levelcode.vercel.app/docs for detailed information about the product.
|
|
160066
160664
|
|
|
160665
|
+
# Agent Swarms / Teams
|
|
160666
|
+
|
|
160667
|
+
LevelCode has a built-in agent swarms system for organizing multiple agents into coordinated teams. You have full access to these tools:
|
|
160668
|
+
|
|
160669
|
+
**Creating and Managing Teams:**
|
|
160670
|
+
- Use the \`team_create\` tool to create a new team: \`team_create({ team_name: "my-project" })\`
|
|
160671
|
+
- Use the \`team_delete\` tool to delete a team when done
|
|
160672
|
+
- Teams are stored at ~/.config/levelcode/teams/
|
|
160673
|
+
|
|
160674
|
+
**Task Management:**
|
|
160675
|
+
- Use \`task_create\` to create tasks for team members
|
|
160676
|
+
- Use \`task_list\` to see all tasks and their status
|
|
160677
|
+
- Use \`task_update\` to update task status, assign owners, set dependencies
|
|
160678
|
+
- Use \`task_get\` to read full task details
|
|
160679
|
+
|
|
160680
|
+
**Communication:**
|
|
160681
|
+
- Use \`send_message\` to send messages between team members (DM, broadcast, shutdown requests)
|
|
160682
|
+
|
|
160683
|
+
**Spawning Team Agents:**
|
|
160684
|
+
When spawning agents with \`spawn_agents\`, you can assign them to a team:
|
|
160685
|
+
\`\`\`
|
|
160686
|
+
spawn_agents([{
|
|
160687
|
+
agent: "team-manager",
|
|
160688
|
+
prompt: "Manage the frontend tasks",
|
|
160689
|
+
team_name: "my-project",
|
|
160690
|
+
team_role: "manager"
|
|
160691
|
+
}])
|
|
160692
|
+
\`\`\`
|
|
160693
|
+
|
|
160694
|
+
**Available team roles:** coordinator, manager, senior-engineer, mid-level-engineer, junior-engineer, researcher, designer, product-lead, tester, scientist, and more.
|
|
160695
|
+
|
|
160696
|
+
**Development Phases:** Teams progress through phases: planning \u2192 pre-alpha \u2192 alpha \u2192 beta \u2192 production \u2192 mature.
|
|
160697
|
+
|
|
160698
|
+
**Slash Commands:** Users can use /team:create, /team:delete, /team:status, /team:phase, /team:enable, /team:disable, /team:members to manage teams.
|
|
160699
|
+
|
|
160700
|
+
When the user asks about teams, swarms, or multi-agent collaboration, use these tools directly. Do NOT say the feature is unavailable or needs external setup.
|
|
160701
|
+
|
|
160067
160702
|
# Other response guidelines
|
|
160068
160703
|
|
|
160069
160704
|
- Your goal is to produce the highest quality results, even if it comes at the cost of more credits used.
|
|
@@ -160129,7 +160764,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
160129
160764
|
- Iteratively spawn file pickers, code-searchers, directory-listers, glob-matchers, commanders, and web/docs researchers to gather context as needed. The file-picker agent in particular is very useful to find relevant files -- try spawning multiple in parallel (say, 2-5) to explore different parts of the codebase. Use read_subtree if you need to grok a particular part of the codebase. Read all the relevant files using the read_files tool.
|
|
160130
160765
|
After getting context on the user request from the codebase or from research, use the ask_user tool to ask the user for important clarifications on their request or alternate implementation strategies. You should skip this step if the choice is obvious -- only ask the user if you need their help making the best choice.
|
|
160131
160766
|
- For any task requiring 3+ steps, use the write_todos tool to write out your step-by-step implementation plan. Include ALL of the applicable tasks in the list. You should include a step to review the changes after you have implemented the changes.: You should include at least one step to validate/test your changes: be specific about whether to typecheck, run tests, run lints, etc. You may be able to do reviewing and validation in parallel in the same step. Skip write_todos for simple tasks like quick edits or answering questions.
|
|
160132
|
-
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent is a last resort for complex problems)
|
|
160767
|
+
- For quick problems, briefly explain your reasoning to the user. If you need to think longer, write your thoughts within the <think> tags. Finally, for complex problems, spawn the thinker agent to help find the best solution. (gpt-5-agent / Titan Agent is a last resort for complex problems)
|
|
160133
160768
|
- IMPORTANT: You must spawn the editor agent to implement the changes after you have gathered all the context you need. This agent will do the best job of implementing the changes so you must spawn it for all non-trivial changes. Do not pass any prompt or params to the editor agent when spawning it. It will make its own best choices of what to do.
|
|
160134
160769
|
- For non-trivial changes, test them by running appropriate validation commands for the project (e.g. typechecks, tests, lints, etc.). Try to run all appropriate commands in parallel. If you can, only test the area of the project that you are editing, rather than the entire project. You may have to explore the project to find the appropriate commands. Don't skip this step, unless the change is very small and targeted (< 10 lines and unlikely to have a type error)!
|
|
160135
160770
|
- Spawn a code-reviewer to review the changes after you have implemented changes. (Skip this step only if the change is extremely straightforward and obvious.)
|
|
@@ -165581,7 +166216,7 @@ var require_has_flag = __commonJS((exports3, module3) => {
|
|
|
165581
166216
|
|
|
165582
166217
|
// ../node_modules/supports-color/index.js
|
|
165583
166218
|
var require_supports_color = __commonJS((exports3, module3) => {
|
|
165584
|
-
var
|
|
166219
|
+
var os15 = __require("os");
|
|
165585
166220
|
var tty = __require("tty");
|
|
165586
166221
|
var hasFlag = require_has_flag();
|
|
165587
166222
|
var { env: env3 } = process;
|
|
@@ -165638,7 +166273,7 @@ var require_supports_color = __commonJS((exports3, module3) => {
|
|
|
165638
166273
|
return min;
|
|
165639
166274
|
}
|
|
165640
166275
|
if (process.platform === "win32") {
|
|
165641
|
-
const osRelease =
|
|
166276
|
+
const osRelease = os15.release().split(".");
|
|
165642
166277
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
165643
166278
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
165644
166279
|
}
|
|
@@ -165957,11 +166592,36 @@ var require_extend = __commonJS((exports3, module3) => {
|
|
|
165957
166592
|
};
|
|
165958
166593
|
});
|
|
165959
166594
|
|
|
166595
|
+
// ../sdk/dist/vendor/ripgrep/arm64-darwin/rg
|
|
166596
|
+
var require_rg = __commonJS((exports3, module3) => {
|
|
166597
|
+
module3.exports = "./rg-r6ev1ksc.";
|
|
166598
|
+
});
|
|
166599
|
+
|
|
166600
|
+
// ../sdk/dist/vendor/ripgrep/x64-darwin/rg
|
|
166601
|
+
var require_rg2 = __commonJS((exports3, module3) => {
|
|
166602
|
+
module3.exports = "./rg-ch8fa8g7.";
|
|
166603
|
+
});
|
|
166604
|
+
|
|
166605
|
+
// ../sdk/dist/vendor/ripgrep/arm64-linux/rg
|
|
166606
|
+
var require_rg3 = __commonJS((exports3, module3) => {
|
|
166607
|
+
module3.exports = "./rg-3agys64c.";
|
|
166608
|
+
});
|
|
166609
|
+
|
|
166610
|
+
// ../sdk/dist/vendor/ripgrep/x64-linux/rg
|
|
166611
|
+
var require_rg4 = __commonJS((exports3, module3) => {
|
|
166612
|
+
module3.exports = "./rg-0p18sjte.";
|
|
166613
|
+
});
|
|
166614
|
+
|
|
166615
|
+
// ../sdk/dist/vendor/ripgrep/x64-win32/rg.exe
|
|
166616
|
+
var require_rg5 = __commonJS((exports3, module3) => {
|
|
166617
|
+
module3.exports = "./rg-maqk0g78.exe";
|
|
166618
|
+
});
|
|
166619
|
+
|
|
165960
166620
|
// src/index.tsx
|
|
165961
166621
|
import fs34 from "fs";
|
|
165962
166622
|
import { createRequire as createRequire2 } from "module";
|
|
165963
|
-
import
|
|
165964
|
-
import
|
|
166623
|
+
import os21 from "os";
|
|
166624
|
+
import path51 from "path";
|
|
165965
166625
|
init_project_file_tree();
|
|
165966
166626
|
|
|
165967
166627
|
// ../node_modules/@opentui/core/index-93qf6w1k.js
|
|
@@ -192565,7 +193225,7 @@ init_src();
|
|
|
192565
193225
|
// ../node_modules/open/index.js
|
|
192566
193226
|
import process9 from "process";
|
|
192567
193227
|
import { Buffer as Buffer3 } from "buffer";
|
|
192568
|
-
import
|
|
193228
|
+
import path26 from "path";
|
|
192569
193229
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
192570
193230
|
import { promisify as promisify5 } from "util";
|
|
192571
193231
|
import childProcess from "child_process";
|
|
@@ -192577,7 +193237,7 @@ import fs21, { constants as fsConstants } from "fs/promises";
|
|
|
192577
193237
|
|
|
192578
193238
|
// ../node_modules/wsl-utils/node_modules/is-wsl/index.js
|
|
192579
193239
|
import process4 from "process";
|
|
192580
|
-
import
|
|
193240
|
+
import os11 from "os";
|
|
192581
193241
|
import fs20 from "fs";
|
|
192582
193242
|
|
|
192583
193243
|
// ../node_modules/is-inside-container/index.js
|
|
@@ -192630,7 +193290,7 @@ var isWsl = () => {
|
|
|
192630
193290
|
if (process4.platform !== "linux") {
|
|
192631
193291
|
return false;
|
|
192632
193292
|
}
|
|
192633
|
-
if (
|
|
193293
|
+
if (os11.release().toLowerCase().includes("microsoft")) {
|
|
192634
193294
|
if (isInsideContainer()) {
|
|
192635
193295
|
return false;
|
|
192636
193296
|
}
|
|
@@ -192803,8 +193463,8 @@ async function defaultBrowser2() {
|
|
|
192803
193463
|
|
|
192804
193464
|
// ../node_modules/open/index.js
|
|
192805
193465
|
var execFile5 = promisify5(childProcess.execFile);
|
|
192806
|
-
var __dirname2 =
|
|
192807
|
-
var localXdgOpenPath =
|
|
193466
|
+
var __dirname2 = path26.dirname(fileURLToPath3(import.meta.url));
|
|
193467
|
+
var localXdgOpenPath = path26.join(__dirname2, "xdg-open");
|
|
192808
193468
|
var { platform: platform2, arch } = process9;
|
|
192809
193469
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
192810
193470
|
const powershellPath = await powerShellPath();
|
|
@@ -193057,7 +193717,7 @@ init_logger2();
|
|
|
193057
193717
|
// src/utils/message-history.ts
|
|
193058
193718
|
init_auth3();
|
|
193059
193719
|
import fs26 from "fs";
|
|
193060
|
-
import
|
|
193720
|
+
import path33 from "path";
|
|
193061
193721
|
|
|
193062
193722
|
// src/utils/helpers.ts
|
|
193063
193723
|
var timestampFormatter = null;
|
|
@@ -193132,7 +193792,7 @@ function getSystemMessage(content) {
|
|
|
193132
193792
|
};
|
|
193133
193793
|
}
|
|
193134
193794
|
var getMessageHistoryPath = () => {
|
|
193135
|
-
return
|
|
193795
|
+
return path33.join(getConfigDir2(), "message-history.json");
|
|
193136
193796
|
};
|
|
193137
193797
|
var loadMessageHistory = () => {
|
|
193138
193798
|
const historyPath = getMessageHistoryPath();
|
|
@@ -193291,9 +193951,9 @@ var buildTheme = (baseTheme, mode, customColors, plugins2) => {
|
|
|
193291
193951
|
};
|
|
193292
193952
|
|
|
193293
193953
|
// src/utils/theme-system.ts
|
|
193294
|
-
import { existsSync as existsSync15, readFileSync as
|
|
193295
|
-
import { homedir as
|
|
193296
|
-
import { dirname as
|
|
193954
|
+
import { existsSync as existsSync15, readFileSync as readFileSync7, readdirSync as readdirSync6, statSync as statSync4, watch } from "fs";
|
|
193955
|
+
import { homedir as homedir6 } from "os";
|
|
193956
|
+
import { dirname as dirname11, join as join11 } from "path";
|
|
193297
193957
|
var _truecolorSupport = null;
|
|
193298
193958
|
function supportsTruecolor(env3 = getCliEnv()) {
|
|
193299
193959
|
if (_truecolorSupport !== null) {
|
|
@@ -193415,7 +194075,7 @@ var inferThemeFromName = (themeName) => {
|
|
|
193415
194075
|
var stripJsonStyleComments = (raw) => raw.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
193416
194076
|
var safeReadFile = (filePath) => {
|
|
193417
194077
|
try {
|
|
193418
|
-
return
|
|
194078
|
+
return readFileSync7(filePath, "utf8");
|
|
193419
194079
|
} catch {
|
|
193420
194080
|
return null;
|
|
193421
194081
|
}
|
|
@@ -193435,23 +194095,23 @@ var collectExistingPaths = (candidates) => {
|
|
|
193435
194095
|
};
|
|
193436
194096
|
var resolveVSCodeSettingsPaths = (env3 = getCliEnv()) => {
|
|
193437
194097
|
const settings = [];
|
|
193438
|
-
const home =
|
|
194098
|
+
const home = homedir6();
|
|
193439
194099
|
if (process.platform === "darwin") {
|
|
193440
|
-
const base =
|
|
194100
|
+
const base = join11(home, "Library", "Application Support");
|
|
193441
194101
|
for (const product of VS_CODE_PRODUCT_DIRS) {
|
|
193442
|
-
settings.push(
|
|
194102
|
+
settings.push(join11(base, product, "User", "settings.json"));
|
|
193443
194103
|
}
|
|
193444
194104
|
} else if (process.platform === "win32") {
|
|
193445
194105
|
const appData = env3.APPDATA;
|
|
193446
194106
|
if (appData) {
|
|
193447
194107
|
for (const product of VS_CODE_PRODUCT_DIRS) {
|
|
193448
|
-
settings.push(
|
|
194108
|
+
settings.push(join11(appData, product, "User", "settings.json"));
|
|
193449
194109
|
}
|
|
193450
194110
|
}
|
|
193451
194111
|
} else {
|
|
193452
|
-
const configDir = env3.XDG_CONFIG_HOME ??
|
|
194112
|
+
const configDir = env3.XDG_CONFIG_HOME ?? join11(home, ".config");
|
|
193453
194113
|
for (const product of VS_CODE_PRODUCT_DIRS) {
|
|
193454
|
-
settings.push(
|
|
194114
|
+
settings.push(join11(configDir, product, "User", "settings.json"));
|
|
193455
194115
|
}
|
|
193456
194116
|
}
|
|
193457
194117
|
return settings;
|
|
@@ -193459,23 +194119,23 @@ var resolveVSCodeSettingsPaths = (env3 = getCliEnv()) => {
|
|
|
193459
194119
|
var resolveJetBrainsLafPaths = (env3 = getCliEnv()) => {
|
|
193460
194120
|
const candidates = [];
|
|
193461
194121
|
if (env3.IDE_CONFIG_DIR) {
|
|
193462
|
-
candidates.push(
|
|
194122
|
+
candidates.push(join11(env3.IDE_CONFIG_DIR, "options", "laf.xml"));
|
|
193463
194123
|
}
|
|
193464
194124
|
if (env3.JB_IDE_CONFIG_DIR) {
|
|
193465
|
-
candidates.push(
|
|
194125
|
+
candidates.push(join11(env3.JB_IDE_CONFIG_DIR, "options", "laf.xml"));
|
|
193466
194126
|
}
|
|
193467
|
-
const home =
|
|
194127
|
+
const home = homedir6();
|
|
193468
194128
|
const baseDirs = [];
|
|
193469
194129
|
if (process.platform === "darwin") {
|
|
193470
|
-
baseDirs.push(
|
|
194130
|
+
baseDirs.push(join11(home, "Library", "Application Support", "JetBrains"));
|
|
193471
194131
|
} else if (process.platform === "win32") {
|
|
193472
194132
|
const appData = env3.APPDATA;
|
|
193473
194133
|
if (appData) {
|
|
193474
|
-
baseDirs.push(
|
|
194134
|
+
baseDirs.push(join11(appData, "JetBrains"));
|
|
193475
194135
|
}
|
|
193476
194136
|
} else {
|
|
193477
|
-
baseDirs.push(
|
|
193478
|
-
baseDirs.push(
|
|
194137
|
+
baseDirs.push(join11(home, ".config", "JetBrains"));
|
|
194138
|
+
baseDirs.push(join11(home, ".local", "share", "JetBrains"));
|
|
193479
194139
|
}
|
|
193480
194140
|
for (const base of baseDirs) {
|
|
193481
194141
|
try {
|
|
@@ -193483,45 +194143,45 @@ var resolveJetBrainsLafPaths = (env3 = getCliEnv()) => {
|
|
|
193483
194143
|
continue;
|
|
193484
194144
|
const entries = readdirSync6(base);
|
|
193485
194145
|
for (const entry of entries) {
|
|
193486
|
-
const dirPath =
|
|
194146
|
+
const dirPath = join11(base, entry);
|
|
193487
194147
|
try {
|
|
193488
194148
|
if (!statSync4(dirPath).isDirectory())
|
|
193489
194149
|
continue;
|
|
193490
194150
|
} catch {
|
|
193491
194151
|
continue;
|
|
193492
194152
|
}
|
|
193493
|
-
candidates.push(
|
|
194153
|
+
candidates.push(join11(dirPath, "options", "laf.xml"));
|
|
193494
194154
|
}
|
|
193495
194155
|
} catch {}
|
|
193496
194156
|
}
|
|
193497
194157
|
return candidates;
|
|
193498
194158
|
};
|
|
193499
194159
|
var resolveZedSettingsPaths = (env3 = getCliEnv()) => {
|
|
193500
|
-
const home =
|
|
194160
|
+
const home = homedir6();
|
|
193501
194161
|
const paths2 = [];
|
|
193502
194162
|
const configDirs = new Set;
|
|
193503
|
-
const xdgConfig = env3.XDG_CONFIG_HOME ??
|
|
193504
|
-
configDirs.add(
|
|
193505
|
-
configDirs.add(
|
|
194163
|
+
const xdgConfig = env3.XDG_CONFIG_HOME ?? join11(home, ".config");
|
|
194164
|
+
configDirs.add(join11(xdgConfig, "zed"));
|
|
194165
|
+
configDirs.add(join11(xdgConfig, "dev.zed.Zed"));
|
|
193506
194166
|
if (process.platform === "darwin") {
|
|
193507
|
-
configDirs.add(
|
|
193508
|
-
configDirs.add(
|
|
194167
|
+
configDirs.add(join11(home, "Library", "Application Support", "Zed"));
|
|
194168
|
+
configDirs.add(join11(home, "Library", "Application Support", "dev.zed.Zed"));
|
|
193509
194169
|
} else if (process.platform === "win32") {
|
|
193510
194170
|
const appData = env3.APPDATA;
|
|
193511
194171
|
if (appData) {
|
|
193512
|
-
configDirs.add(
|
|
193513
|
-
configDirs.add(
|
|
194172
|
+
configDirs.add(join11(appData, "Zed"));
|
|
194173
|
+
configDirs.add(join11(appData, "dev.zed.Zed"));
|
|
193514
194174
|
}
|
|
193515
194175
|
} else {
|
|
193516
|
-
configDirs.add(
|
|
193517
|
-
configDirs.add(
|
|
193518
|
-
configDirs.add(
|
|
193519
|
-
configDirs.add(
|
|
194176
|
+
configDirs.add(join11(home, ".config", "zed"));
|
|
194177
|
+
configDirs.add(join11(home, ".config", "dev.zed.Zed"));
|
|
194178
|
+
configDirs.add(join11(home, ".local", "share", "zed"));
|
|
194179
|
+
configDirs.add(join11(home, ".local", "share", "dev.zed.Zed"));
|
|
193520
194180
|
}
|
|
193521
|
-
const legacyConfig =
|
|
194181
|
+
const legacyConfig = join11(home, ".zed");
|
|
193522
194182
|
configDirs.add(legacyConfig);
|
|
193523
194183
|
for (const dir of configDirs) {
|
|
193524
|
-
paths2.push(
|
|
194184
|
+
paths2.push(join11(dir, "settings.json"));
|
|
193525
194185
|
}
|
|
193526
194186
|
return paths2;
|
|
193527
194187
|
};
|
|
@@ -194042,7 +194702,7 @@ var setupFileWatchers = () => {
|
|
|
194042
194702
|
const watchTargets = [];
|
|
194043
194703
|
const watchedDirs = new Set;
|
|
194044
194704
|
if (process.platform === "darwin") {
|
|
194045
|
-
watchTargets.push(
|
|
194705
|
+
watchTargets.push(join11(homedir6(), "Library/Preferences/.GlobalPreferences.plist"), join11(homedir6(), "Library/Preferences/com.apple.Terminal.plist"));
|
|
194046
194706
|
}
|
|
194047
194707
|
if (isVSCodeFamilyTerminal()) {
|
|
194048
194708
|
watchTargets.push(...resolveVSCodeSettingsPaths());
|
|
@@ -194055,7 +194715,7 @@ var setupFileWatchers = () => {
|
|
|
194055
194715
|
}
|
|
194056
194716
|
for (const target of watchTargets) {
|
|
194057
194717
|
if (existsSync15(target)) {
|
|
194058
|
-
const parentDir =
|
|
194718
|
+
const parentDir = dirname11(target);
|
|
194059
194719
|
if (watchedDirs.has(parentDir))
|
|
194060
194720
|
continue;
|
|
194061
194721
|
watchedDirs.add(parentDir);
|
|
@@ -194171,8 +194831,8 @@ async function handleImageCommand(args2) {
|
|
|
194171
194831
|
}
|
|
194172
194832
|
|
|
194173
194833
|
// src/commands/init.ts
|
|
194174
|
-
import { existsSync as existsSync16, mkdirSync as
|
|
194175
|
-
import
|
|
194834
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
194835
|
+
import path34 from "path";
|
|
194176
194836
|
init_knowledge();
|
|
194177
194837
|
|
|
194178
194838
|
// ../common/src/templates/initial-agents-dir/types/agent-definition.ts
|
|
@@ -195184,12 +195844,12 @@ var COMMON_TYPE_FILES = [
|
|
|
195184
195844
|
];
|
|
195185
195845
|
function handleInitializationFlowLocally() {
|
|
195186
195846
|
const projectRoot2 = getProjectRoot();
|
|
195187
|
-
const knowledgePath =
|
|
195847
|
+
const knowledgePath = path34.join(projectRoot2, PRIMARY_KNOWLEDGE_FILE_NAME);
|
|
195188
195848
|
const messages = [];
|
|
195189
195849
|
if (existsSync16(knowledgePath)) {
|
|
195190
195850
|
messages.push(`\uD83D\uDCCB \`${PRIMARY_KNOWLEDGE_FILE_NAME}\` already exists.`);
|
|
195191
195851
|
} else {
|
|
195192
|
-
|
|
195852
|
+
writeFileSync5(knowledgePath, INITIAL_KNOWLEDGE_FILE);
|
|
195193
195853
|
messages.push(`\u2705 Created \`${PRIMARY_KNOWLEDGE_FILE_NAME}\``);
|
|
195194
195854
|
trackEvent2("cli.knowledge_file_updated" /* KNOWLEDGE_FILE_UPDATED */, {
|
|
195195
195855
|
action: "created",
|
|
@@ -195197,22 +195857,22 @@ function handleInitializationFlowLocally() {
|
|
|
195197
195857
|
fileSizeBytes: Buffer.byteLength(INITIAL_KNOWLEDGE_FILE, "utf8")
|
|
195198
195858
|
});
|
|
195199
195859
|
}
|
|
195200
|
-
const agentsDir =
|
|
195201
|
-
const agentsTypesDir =
|
|
195860
|
+
const agentsDir = path34.join(projectRoot2, ".agents");
|
|
195861
|
+
const agentsTypesDir = path34.join(agentsDir, "types");
|
|
195202
195862
|
if (existsSync16(agentsDir)) {
|
|
195203
195863
|
messages.push("\uD83D\uDCCB `.agents/` already exists.");
|
|
195204
195864
|
} else {
|
|
195205
|
-
|
|
195865
|
+
mkdirSync6(agentsDir, { recursive: true });
|
|
195206
195866
|
messages.push("\u2705 Created `.agents/`");
|
|
195207
195867
|
}
|
|
195208
195868
|
if (existsSync16(agentsTypesDir)) {
|
|
195209
195869
|
messages.push("\uD83D\uDCCB `.agents/types/` already exists.");
|
|
195210
195870
|
} else {
|
|
195211
|
-
|
|
195871
|
+
mkdirSync6(agentsTypesDir, { recursive: true });
|
|
195212
195872
|
messages.push("\u2705 Created `.agents/types/`");
|
|
195213
195873
|
}
|
|
195214
195874
|
for (const { fileName, source } of COMMON_TYPE_FILES) {
|
|
195215
|
-
const targetPath =
|
|
195875
|
+
const targetPath = path34.join(agentsTypesDir, fileName);
|
|
195216
195876
|
if (existsSync16(targetPath)) {
|
|
195217
195877
|
messages.push(`\uD83D\uDCCB \`.agents/types/${fileName}\` already exists.`);
|
|
195218
195878
|
continue;
|
|
@@ -195221,7 +195881,7 @@ function handleInitializationFlowLocally() {
|
|
|
195221
195881
|
if (!source || source.trim().length === 0) {
|
|
195222
195882
|
throw new Error("Source content is empty");
|
|
195223
195883
|
}
|
|
195224
|
-
|
|
195884
|
+
writeFileSync5(targetPath, source);
|
|
195225
195885
|
messages.push(`\u2705 Copied \`.agents/types/${fileName}\``);
|
|
195226
195886
|
} catch (error46) {
|
|
195227
195887
|
messages.push(`\u26A0\uFE0F Failed to copy \`.agents/types/${fileName}\`: ${error46 instanceof Error ? error46.message : String(error46 ?? "Unknown")}`);
|
|
@@ -195504,6 +196164,7 @@ function getSkillByName(name18) {
|
|
|
195504
196164
|
|
|
195505
196165
|
// src/commands/command-registry.ts
|
|
195506
196166
|
init_team_fs();
|
|
196167
|
+
init_team_discovery();
|
|
195507
196168
|
init_dev_phases();
|
|
195508
196169
|
init_team_hook_emitter();
|
|
195509
196170
|
init_analytics2();
|
|
@@ -195771,7 +196432,18 @@ var COMMAND_REGISTRY = [
|
|
|
195771
196432
|
defineCommand({
|
|
195772
196433
|
name: "team:delete",
|
|
195773
196434
|
handler: (params2) => {
|
|
195774
|
-
const {
|
|
196435
|
+
const { reset } = useTeamStore.getState();
|
|
196436
|
+
let activeTeam = useTeamStore.getState().activeTeam;
|
|
196437
|
+
if (!activeTeam) {
|
|
196438
|
+
const teams = listAllTeams();
|
|
196439
|
+
if (teams.length > 0) {
|
|
196440
|
+
const diskConfig = loadTeamConfig(teams[0].name);
|
|
196441
|
+
if (diskConfig) {
|
|
196442
|
+
useTeamStore.getState().setActiveTeam(diskConfig);
|
|
196443
|
+
activeTeam = diskConfig;
|
|
196444
|
+
}
|
|
196445
|
+
}
|
|
196446
|
+
}
|
|
195775
196447
|
if (!activeTeam) {
|
|
195776
196448
|
params2.setMessages((prev) => [
|
|
195777
196449
|
...prev,
|
|
@@ -195805,7 +196477,17 @@ var COMMAND_REGISTRY = [
|
|
|
195805
196477
|
defineCommand({
|
|
195806
196478
|
name: "team:status",
|
|
195807
196479
|
handler: (params2) => {
|
|
195808
|
-
|
|
196480
|
+
let activeTeam = useTeamStore.getState().activeTeam;
|
|
196481
|
+
if (!activeTeam) {
|
|
196482
|
+
const teams = listAllTeams();
|
|
196483
|
+
if (teams.length > 0) {
|
|
196484
|
+
const diskConfig = loadTeamConfig(teams[0].name);
|
|
196485
|
+
if (diskConfig) {
|
|
196486
|
+
useTeamStore.getState().setActiveTeam(diskConfig);
|
|
196487
|
+
activeTeam = diskConfig;
|
|
196488
|
+
}
|
|
196489
|
+
}
|
|
196490
|
+
}
|
|
195809
196491
|
if (!activeTeam) {
|
|
195810
196492
|
params2.setMessages((prev) => [
|
|
195811
196493
|
...prev,
|
|
@@ -195895,7 +196577,17 @@ Valid phases: ${validPhases.join(", ")}`)
|
|
|
195895
196577
|
clearInput(params2);
|
|
195896
196578
|
return;
|
|
195897
196579
|
}
|
|
195898
|
-
|
|
196580
|
+
let activeTeam = useTeamStore.getState().activeTeam;
|
|
196581
|
+
if (!activeTeam) {
|
|
196582
|
+
const teams = listAllTeams();
|
|
196583
|
+
if (teams.length > 0) {
|
|
196584
|
+
const diskConfig = loadTeamConfig(teams[0].name);
|
|
196585
|
+
if (diskConfig) {
|
|
196586
|
+
useTeamStore.getState().setActiveTeam(diskConfig);
|
|
196587
|
+
activeTeam = diskConfig;
|
|
196588
|
+
}
|
|
196589
|
+
}
|
|
196590
|
+
}
|
|
195899
196591
|
if (!activeTeam) {
|
|
195900
196592
|
params2.setMessages((prev) => [
|
|
195901
196593
|
...prev,
|
|
@@ -196011,7 +196703,17 @@ Valid phases: ${validPhases.join(", ")}`)
|
|
|
196011
196703
|
defineCommand({
|
|
196012
196704
|
name: "team:members",
|
|
196013
196705
|
handler: (params2) => {
|
|
196014
|
-
|
|
196706
|
+
let activeTeam = useTeamStore.getState().activeTeam;
|
|
196707
|
+
if (!activeTeam) {
|
|
196708
|
+
const teams = listAllTeams();
|
|
196709
|
+
if (teams.length > 0) {
|
|
196710
|
+
const diskConfig = loadTeamConfig(teams[0].name);
|
|
196711
|
+
if (diskConfig) {
|
|
196712
|
+
useTeamStore.getState().setActiveTeam(diskConfig);
|
|
196713
|
+
activeTeam = diskConfig;
|
|
196714
|
+
}
|
|
196715
|
+
}
|
|
196716
|
+
}
|
|
196015
196717
|
if (!activeTeam) {
|
|
196016
196718
|
params2.setMessages((prev) => [
|
|
196017
196719
|
...prev,
|
|
@@ -196118,6 +196820,7 @@ Valid phases: ${validPhases.join(", ")}`)
|
|
|
196118
196820
|
}),
|
|
196119
196821
|
defineCommand({
|
|
196120
196822
|
name: "gpt-5-agent",
|
|
196823
|
+
aliases: ["titan-agent", "titan"],
|
|
196121
196824
|
handler: (params2) => {
|
|
196122
196825
|
params2.setInputValue({
|
|
196123
196826
|
text: "@Titan Agent ",
|
|
@@ -199771,18 +200474,18 @@ var Separator = ({
|
|
|
199771
200474
|
init_chat_store();
|
|
199772
200475
|
|
|
199773
200476
|
// src/utils/strings.ts
|
|
199774
|
-
import
|
|
200477
|
+
import path36 from "path";
|
|
199775
200478
|
|
|
199776
200479
|
// src/utils/clipboard-image.ts
|
|
199777
200480
|
init_image_handler();
|
|
199778
200481
|
import { spawnSync } from "child_process";
|
|
199779
|
-
import { existsSync as existsSync17, mkdirSync as
|
|
199780
|
-
import
|
|
199781
|
-
import
|
|
200482
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
200483
|
+
import os13 from "os";
|
|
200484
|
+
import path35 from "path";
|
|
199782
200485
|
function getClipboardTempDir() {
|
|
199783
|
-
const tempDir =
|
|
200486
|
+
const tempDir = path35.join(os13.tmpdir(), "levelcode-clipboard-images");
|
|
199784
200487
|
if (!existsSync17(tempDir)) {
|
|
199785
|
-
|
|
200488
|
+
mkdirSync7(tempDir, { recursive: true });
|
|
199786
200489
|
}
|
|
199787
200490
|
return tempDir;
|
|
199788
200491
|
}
|
|
@@ -199809,7 +200512,7 @@ function readImageMacOS() {
|
|
|
199809
200512
|
try {
|
|
199810
200513
|
const tempDir = getClipboardTempDir();
|
|
199811
200514
|
const filename = generateImageFilename();
|
|
199812
|
-
const imagePath =
|
|
200515
|
+
const imagePath = path35.join(tempDir, filename);
|
|
199813
200516
|
const pngpasteResult = spawnSync("pngpaste", [imagePath], {
|
|
199814
200517
|
encoding: "utf-8",
|
|
199815
200518
|
timeout: 5000
|
|
@@ -199889,7 +200592,7 @@ function readImageLinux() {
|
|
|
199889
200592
|
try {
|
|
199890
200593
|
const tempDir = getClipboardTempDir();
|
|
199891
200594
|
const filename = generateImageFilename();
|
|
199892
|
-
const imagePath =
|
|
200595
|
+
const imagePath = path35.join(tempDir, filename);
|
|
199893
200596
|
let result = spawnSync("xclip", [
|
|
199894
200597
|
"-selection",
|
|
199895
200598
|
"clipboard",
|
|
@@ -199898,7 +200601,7 @@ function readImageLinux() {
|
|
|
199898
200601
|
"-o"
|
|
199899
200602
|
], { timeout: 5000, maxBuffer: 50 * 1024 * 1024 });
|
|
199900
200603
|
if (result.status === 0 && result.stdout && result.stdout.length > 0) {
|
|
199901
|
-
|
|
200604
|
+
writeFileSync6(imagePath, result.stdout);
|
|
199902
200605
|
return { success: true, imagePath, filename };
|
|
199903
200606
|
}
|
|
199904
200607
|
result = spawnSync("wl-paste", ["--type", "image/png"], {
|
|
@@ -199906,7 +200609,7 @@ function readImageLinux() {
|
|
|
199906
200609
|
maxBuffer: 50 * 1024 * 1024
|
|
199907
200610
|
});
|
|
199908
200611
|
if (result.status === 0 && result.stdout && result.stdout.length > 0) {
|
|
199909
|
-
|
|
200612
|
+
writeFileSync6(imagePath, result.stdout);
|
|
199910
200613
|
return { success: true, imagePath, filename };
|
|
199911
200614
|
}
|
|
199912
200615
|
return {
|
|
@@ -199939,7 +200642,7 @@ function readImageWindows() {
|
|
|
199939
200642
|
try {
|
|
199940
200643
|
const tempDir = getClipboardTempDir();
|
|
199941
200644
|
const filename = generateImageFilename();
|
|
199942
|
-
const imagePath =
|
|
200645
|
+
const imagePath = path35.join(tempDir, filename);
|
|
199943
200646
|
const script = `
|
|
199944
200647
|
Add-Type -AssemblyName System.Windows.Forms
|
|
199945
200648
|
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
@@ -200214,7 +200917,7 @@ function createPasteHandler(options2) {
|
|
|
200214
200917
|
const looksLikeImageFilename = isImageFile(eventText) && !eventText.includes("/") && !eventText.includes("\\");
|
|
200215
200918
|
if (looksLikeImageFilename) {
|
|
200216
200919
|
const clipboardFilePath = readClipboardImageFilePath();
|
|
200217
|
-
if (clipboardFilePath &&
|
|
200920
|
+
if (clipboardFilePath && path36.basename(clipboardFilePath) === eventText) {
|
|
200218
200921
|
onPasteImagePath(clipboardFilePath);
|
|
200219
200922
|
return;
|
|
200220
200923
|
}
|
|
@@ -202907,8 +203610,8 @@ var usePublishStore = create()(immer2((set3) => ({
|
|
|
202907
203610
|
|
|
202908
203611
|
// src/utils/local-agent-registry.ts
|
|
202909
203612
|
import fs28 from "fs";
|
|
202910
|
-
import
|
|
202911
|
-
import
|
|
203613
|
+
import os14 from "os";
|
|
203614
|
+
import path37 from "path";
|
|
202912
203615
|
init_src();
|
|
202913
203616
|
init_project_files();
|
|
202914
203617
|
init_constants6();
|
|
@@ -202938,9 +203641,9 @@ async function initializeAgentRegistry() {
|
|
|
202938
203641
|
}
|
|
202939
203642
|
}
|
|
202940
203643
|
var getDefaultAgentDirs2 = () => {
|
|
202941
|
-
const cwdAgents =
|
|
202942
|
-
const parentAgents =
|
|
202943
|
-
const homeAgents =
|
|
203644
|
+
const cwdAgents = path37.join(process.cwd(), AGENTS_DIR_NAME);
|
|
203645
|
+
const parentAgents = path37.join(process.cwd(), "..", AGENTS_DIR_NAME);
|
|
203646
|
+
const homeAgents = path37.join(os14.homedir(), AGENTS_DIR_NAME);
|
|
202944
203647
|
return [cwdAgents, parentAgents, homeAgents];
|
|
202945
203648
|
};
|
|
202946
203649
|
var buildAgentFilePathMap = (agentsDirs) => {
|
|
@@ -202950,7 +203653,7 @@ var buildAgentFilePathMap = (agentsDirs) => {
|
|
|
202950
203653
|
try {
|
|
202951
203654
|
const entries = fs28.readdirSync(dir, { withFileTypes: true });
|
|
202952
203655
|
for (const entry of entries) {
|
|
202953
|
-
const fullPath =
|
|
203656
|
+
const fullPath = path37.join(dir, entry.name);
|
|
202954
203657
|
if (entry.isDirectory() && !entry.name.startsWith(".")) {
|
|
202955
203658
|
scanDirectory(fullPath);
|
|
202956
203659
|
continue;
|
|
@@ -203000,16 +203703,16 @@ var findAgentsDirectory = () => {
|
|
|
203000
203703
|
}
|
|
203001
203704
|
const projectRoot2 = getProjectRoot() || process.cwd();
|
|
203002
203705
|
if (projectRoot2) {
|
|
203003
|
-
const rootCandidate =
|
|
203706
|
+
const rootCandidate = path37.join(projectRoot2, AGENTS_DIR_NAME);
|
|
203004
203707
|
if (fs28.existsSync(rootCandidate) && fs28.statSync(rootCandidate).isDirectory()) {
|
|
203005
203708
|
cachedAgentsDir = rootCandidate;
|
|
203006
203709
|
return cachedAgentsDir;
|
|
203007
203710
|
}
|
|
203008
203711
|
}
|
|
203009
203712
|
let currentDir = process.cwd();
|
|
203010
|
-
const filesystemRoot =
|
|
203713
|
+
const filesystemRoot = path37.parse(currentDir).root;
|
|
203011
203714
|
while (true) {
|
|
203012
|
-
const candidate =
|
|
203715
|
+
const candidate = path37.join(currentDir, AGENTS_DIR_NAME);
|
|
203013
203716
|
if (fs28.existsSync(candidate) && fs28.statSync(candidate).isDirectory()) {
|
|
203014
203717
|
cachedAgentsDir = candidate;
|
|
203015
203718
|
return cachedAgentsDir;
|
|
@@ -203017,7 +203720,7 @@ var findAgentsDirectory = () => {
|
|
|
203017
203720
|
if (currentDir === filesystemRoot) {
|
|
203018
203721
|
break;
|
|
203019
203722
|
}
|
|
203020
|
-
const parentDir =
|
|
203723
|
+
const parentDir = path37.dirname(currentDir);
|
|
203021
203724
|
if (parentDir === currentDir) {
|
|
203022
203725
|
break;
|
|
203023
203726
|
}
|
|
@@ -210022,7 +210725,7 @@ function constructs(existing, list2) {
|
|
|
210022
210725
|
// ../node_modules/micromark-extension-gfm-autolink-literal/dev/lib/syntax.js
|
|
210023
210726
|
var wwwPrefix = { tokenize: tokenizeWwwPrefix, partial: true };
|
|
210024
210727
|
var domain2 = { tokenize: tokenizeDomain, partial: true };
|
|
210025
|
-
var
|
|
210728
|
+
var path38 = { tokenize: tokenizePath, partial: true };
|
|
210026
210729
|
var trail = { tokenize: tokenizeTrail, partial: true };
|
|
210027
210730
|
var emailDomainDotTrail = {
|
|
210028
210731
|
tokenize: tokenizeEmailDomainDotTrail,
|
|
@@ -210122,7 +210825,7 @@ function tokenizeWwwAutolink(effects, ok3, nok) {
|
|
|
210122
210825
|
}
|
|
210123
210826
|
effects.enter("literalAutolink");
|
|
210124
210827
|
effects.enter("literalAutolinkWww");
|
|
210125
|
-
return effects.check(wwwPrefix, effects.attempt(domain2, effects.attempt(
|
|
210828
|
+
return effects.check(wwwPrefix, effects.attempt(domain2, effects.attempt(path38, wwwAfter), nok), nok)(code3);
|
|
210126
210829
|
}
|
|
210127
210830
|
function wwwAfter(code3) {
|
|
210128
210831
|
effects.exit("literalAutolinkWww");
|
|
@@ -210172,7 +210875,7 @@ function tokenizeProtocolAutolink(effects, ok3, nok) {
|
|
|
210172
210875
|
return nok(code3);
|
|
210173
210876
|
}
|
|
210174
210877
|
function afterProtocol(code3) {
|
|
210175
|
-
return code3 === codes.eof || asciiControl(code3) || markdownLineEndingOrSpace(code3) || unicodeWhitespace(code3) || unicodePunctuation(code3) ? nok(code3) : effects.attempt(domain2, effects.attempt(
|
|
210878
|
+
return code3 === codes.eof || asciiControl(code3) || markdownLineEndingOrSpace(code3) || unicodeWhitespace(code3) || unicodePunctuation(code3) ? nok(code3) : effects.attempt(domain2, effects.attempt(path38, protocolAfter), nok)(code3);
|
|
210176
210879
|
}
|
|
210177
210880
|
function protocolAfter(code3) {
|
|
210178
210881
|
effects.exit("literalAutolinkHttp");
|
|
@@ -215911,9 +216614,9 @@ class VFile {
|
|
|
215911
216614
|
get dirname() {
|
|
215912
216615
|
return typeof this.path === "string" ? default3.dirname(this.path) : undefined;
|
|
215913
216616
|
}
|
|
215914
|
-
set dirname(
|
|
216617
|
+
set dirname(dirname12) {
|
|
215915
216618
|
assertPath(this.basename, "dirname");
|
|
215916
|
-
this.path = default3.join(
|
|
216619
|
+
this.path = default3.join(dirname12 || "", this.basename);
|
|
215917
216620
|
}
|
|
215918
216621
|
get extname() {
|
|
215919
216622
|
return typeof this.path === "string" ? default3.extname(this.path) : undefined;
|
|
@@ -217068,14 +217771,14 @@ function getAgentStatusInfo(status, theme) {
|
|
|
217068
217771
|
}
|
|
217069
217772
|
|
|
217070
217773
|
// src/utils/path-helpers.ts
|
|
217071
|
-
import
|
|
217072
|
-
import
|
|
217774
|
+
import os15 from "os";
|
|
217775
|
+
import path39 from "path";
|
|
217073
217776
|
init_project_files();
|
|
217074
217777
|
function formatCwd(cwd, env3) {
|
|
217075
217778
|
if (!cwd)
|
|
217076
217779
|
return "";
|
|
217077
217780
|
const resolvedEnv = env3 ?? getCliEnv();
|
|
217078
|
-
const homeDir = resolvedEnv.HOME || resolvedEnv.USERPROFILE ||
|
|
217781
|
+
const homeDir = resolvedEnv.HOME || resolvedEnv.USERPROFILE || os15.homedir();
|
|
217079
217782
|
if (homeDir && cwd.startsWith(homeDir)) {
|
|
217080
217783
|
return "~" + cwd.slice(homeDir.length);
|
|
217081
217784
|
}
|
|
@@ -217087,7 +217790,7 @@ function getRelativePath3(filePath) {
|
|
|
217087
217790
|
const projectRoot2 = getProjectRoot();
|
|
217088
217791
|
if (!projectRoot2)
|
|
217089
217792
|
return filePath;
|
|
217090
|
-
return
|
|
217793
|
+
return path39.relative(projectRoot2, filePath);
|
|
217091
217794
|
}
|
|
217092
217795
|
|
|
217093
217796
|
// src/components/tools/diff-viewer.tsx
|
|
@@ -217664,7 +218367,7 @@ init_logger2();
|
|
|
217664
218367
|
|
|
217665
218368
|
// src/native/ripgrep.ts
|
|
217666
218369
|
init_src();
|
|
217667
|
-
import
|
|
218370
|
+
import path40 from "path";
|
|
217668
218371
|
var {spawnSync: spawnSync2 } = globalThis.Bun;
|
|
217669
218372
|
init_logger2();
|
|
217670
218373
|
var getRipgrepPath = async () => {
|
|
@@ -217672,9 +218375,9 @@ var getRipgrepPath = async () => {
|
|
|
217672
218375
|
if (!env3.LEVELCODE_IS_BINARY) {
|
|
217673
218376
|
return getBundledRgPath();
|
|
217674
218377
|
}
|
|
217675
|
-
const binaryDir =
|
|
218378
|
+
const binaryDir = path40.dirname(process.execPath);
|
|
217676
218379
|
const rgFileName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
217677
|
-
const outPath =
|
|
218380
|
+
const outPath = path40.join(binaryDir, rgFileName);
|
|
217678
218381
|
const outPathExists = await Bun.file(outPath).exists();
|
|
217679
218382
|
if (outPathExists) {
|
|
217680
218383
|
return outPath;
|
|
@@ -217682,15 +218385,15 @@ var getRipgrepPath = async () => {
|
|
|
217682
218385
|
try {
|
|
217683
218386
|
let embeddedRgPath;
|
|
217684
218387
|
if (process.platform === "darwin" && process.arch === "arm64") {
|
|
217685
|
-
embeddedRgPath = (
|
|
218388
|
+
embeddedRgPath = require_rg();
|
|
217686
218389
|
} else if (process.platform === "darwin" && process.arch === "x64") {
|
|
217687
|
-
embeddedRgPath = (
|
|
218390
|
+
embeddedRgPath = require_rg2();
|
|
217688
218391
|
} else if (process.platform === "linux" && process.arch === "arm64") {
|
|
217689
|
-
embeddedRgPath = (
|
|
218392
|
+
embeddedRgPath = require_rg3();
|
|
217690
218393
|
} else if (process.platform === "linux" && process.arch === "x64") {
|
|
217691
|
-
embeddedRgPath = (
|
|
218394
|
+
embeddedRgPath = require_rg4();
|
|
217692
218395
|
} else if (process.platform === "win32" && process.arch === "x64") {
|
|
217693
|
-
embeddedRgPath = (
|
|
218396
|
+
embeddedRgPath = require_rg5();
|
|
217694
218397
|
} else {
|
|
217695
218398
|
throw new Error(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
217696
218399
|
}
|
|
@@ -218191,7 +218894,7 @@ var ReadDocsComponent = defineToolComponent({
|
|
|
218191
218894
|
});
|
|
218192
218895
|
|
|
218193
218896
|
// src/utils/create-run-config.ts
|
|
218194
|
-
import
|
|
218897
|
+
import path41 from "path";
|
|
218195
218898
|
|
|
218196
218899
|
// ../node_modules/ts-pattern/dist/index.js
|
|
218197
218900
|
var t2 = Symbol.for("@ts-pattern/matcher");
|
|
@@ -219445,11 +220148,11 @@ var SENSITIVE_PATTERNS = {
|
|
|
219445
220148
|
var isEnvFile = (basename2) => (basename2 === ".env" || basename2.startsWith(".env.")) && !isEnvTemplateFile(basename2);
|
|
219446
220149
|
var matchesPattern = (str2) => SENSITIVE_PATTERNS.prefix.some((p2) => str2.startsWith(p2) && !str2.endsWith(".pub")) || SENSITIVE_PATTERNS.suffix.some((s2) => str2.endsWith(s2)) || SENSITIVE_PATTERNS.substring.some((sub) => str2.includes(sub));
|
|
219447
220150
|
var ENV_TEMPLATE_SUFFIXES = [".env.example", ".env.sample", ".env.template"];
|
|
219448
|
-
var isEnvTemplateFile = (filePath) => ENV_TEMPLATE_SUFFIXES.some((suffix) =>
|
|
220151
|
+
var isEnvTemplateFile = (filePath) => ENV_TEMPLATE_SUFFIXES.some((suffix) => path41.basename(filePath).endsWith(suffix));
|
|
219449
220152
|
function isSensitiveFile(filePath) {
|
|
219450
|
-
const basename2 =
|
|
220153
|
+
const basename2 = path41.basename(filePath);
|
|
219451
220154
|
const basenameLower = basename2.toLowerCase();
|
|
219452
|
-
const ext =
|
|
220155
|
+
const ext = path41.extname(filePath).toLowerCase();
|
|
219453
220156
|
return isEnvFile(basename2) || SENSITIVE_EXTENSIONS.has(ext) || SENSITIVE_BASENAMES.has(basename2) || matchesPattern(basenameLower);
|
|
219454
220157
|
}
|
|
219455
220158
|
var createRunConfig = (params2) => {
|
|
@@ -221984,10 +222687,10 @@ var TerminalLink = ({
|
|
|
221984
222687
|
|
|
221985
222688
|
// src/utils/open-file.ts
|
|
221986
222689
|
import { spawn as spawn4 } from "child_process";
|
|
221987
|
-
import
|
|
222690
|
+
import os16 from "os";
|
|
221988
222691
|
init_logger2();
|
|
221989
|
-
var isWindows =
|
|
221990
|
-
var isMac =
|
|
222692
|
+
var isWindows = os16.platform() === "win32";
|
|
222693
|
+
var isMac = os16.platform() === "darwin";
|
|
221991
222694
|
var escapeForShell = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
221992
222695
|
var escapeForCmd = (value) => `"${value.replace(/"/g, '""')}"`;
|
|
221993
222696
|
var replaceFilePlaceholder = (command, filePath) => {
|
|
@@ -226162,10 +226865,10 @@ function getDeviceInfo() {
|
|
|
226162
226865
|
win32: "windows",
|
|
226163
226866
|
linux: "linux"
|
|
226164
226867
|
};
|
|
226165
|
-
const
|
|
226868
|
+
const os17 = platformToOs[process.platform] ?? "linux";
|
|
226166
226869
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
226167
226870
|
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
226168
|
-
return { os:
|
|
226871
|
+
return { os: os17, timezone, locale };
|
|
226169
226872
|
}
|
|
226170
226873
|
|
|
226171
226874
|
// src/hooks/use-input-history.ts
|
|
@@ -226557,16 +227260,16 @@ init_logger2();
|
|
|
226557
227260
|
init_project_files();
|
|
226558
227261
|
init_logger2();
|
|
226559
227262
|
import * as fs29 from "fs";
|
|
226560
|
-
import
|
|
227263
|
+
import path42 from "path";
|
|
226561
227264
|
var RUN_STATE_FILENAME = "run-state.json";
|
|
226562
227265
|
var CHAT_MESSAGES_FILENAME = "chat-messages.json";
|
|
226563
227266
|
function getRunStatePath() {
|
|
226564
227267
|
const chatDir = getCurrentChatDir();
|
|
226565
|
-
return
|
|
227268
|
+
return path42.join(chatDir, RUN_STATE_FILENAME);
|
|
226566
227269
|
}
|
|
226567
227270
|
function getChatMessagesPath() {
|
|
226568
227271
|
const chatDir = getCurrentChatDir();
|
|
226569
|
-
return
|
|
227272
|
+
return path42.join(chatDir, CHAT_MESSAGES_FILENAME);
|
|
226570
227273
|
}
|
|
226571
227274
|
function saveChatState(runState, messages) {
|
|
226572
227275
|
try {
|
|
@@ -226584,8 +227287,8 @@ function loadMostRecentChatState(chatId) {
|
|
|
226584
227287
|
try {
|
|
226585
227288
|
let chatDir = null;
|
|
226586
227289
|
if (chatId && chatId.trim().length > 0) {
|
|
226587
|
-
const baseDir =
|
|
226588
|
-
const candidateDir =
|
|
227290
|
+
const baseDir = path42.join(getProjectDataDir(), "chats");
|
|
227291
|
+
const candidateDir = path42.join(baseDir, chatId.trim());
|
|
226589
227292
|
if (fs29.existsSync(candidateDir) && fs29.statSync(candidateDir).isDirectory()) {
|
|
226590
227293
|
chatDir = candidateDir;
|
|
226591
227294
|
} else {
|
|
@@ -226599,8 +227302,8 @@ function loadMostRecentChatState(chatId) {
|
|
|
226599
227302
|
logger2.debug("No previous chat directory found");
|
|
226600
227303
|
return null;
|
|
226601
227304
|
}
|
|
226602
|
-
const runStatePath =
|
|
226603
|
-
const messagesPath =
|
|
227305
|
+
const runStatePath = path42.join(chatDir, RUN_STATE_FILENAME);
|
|
227306
|
+
const messagesPath = path42.join(chatDir, CHAT_MESSAGES_FILENAME);
|
|
226604
227307
|
if (!fs29.existsSync(runStatePath) || !fs29.existsSync(messagesPath)) {
|
|
226605
227308
|
logger2.debug({ runStatePath, messagesPath }, "Missing state files in chat directory");
|
|
226606
227309
|
return null;
|
|
@@ -226609,7 +227312,7 @@ function loadMostRecentChatState(chatId) {
|
|
|
226609
227312
|
const messagesContent = fs29.readFileSync(messagesPath, "utf8");
|
|
226610
227313
|
const runState = JSON.parse(runStateContent);
|
|
226611
227314
|
const messages = JSON.parse(messagesContent);
|
|
226612
|
-
const resolvedChatId =
|
|
227315
|
+
const resolvedChatId = path42.basename(chatDir);
|
|
226613
227316
|
logger2.info({ runStatePath, messagesPath, messageCount: messages.length, chatId: resolvedChatId }, "Loaded chat state from chat directory");
|
|
226614
227317
|
return { runState, messages, chatId: resolvedChatId };
|
|
226615
227318
|
} catch (error46) {
|
|
@@ -229457,7 +230160,7 @@ function useSearchableList({
|
|
|
229457
230160
|
init_project_files();
|
|
229458
230161
|
init_logger2();
|
|
229459
230162
|
import * as fs31 from "fs";
|
|
229460
|
-
import
|
|
230163
|
+
import path43 from "path";
|
|
229461
230164
|
function getFirstUserPrompt(messages) {
|
|
229462
230165
|
for (const msg of messages) {
|
|
229463
230166
|
if (msg?.variant === "user" && msg.content) {
|
|
@@ -229472,14 +230175,14 @@ function getFirstUserPrompt(messages) {
|
|
|
229472
230175
|
}
|
|
229473
230176
|
function getAllChats(maxChats = 500) {
|
|
229474
230177
|
try {
|
|
229475
|
-
const chatsDir =
|
|
230178
|
+
const chatsDir = path43.join(getProjectDataDir(), "chats");
|
|
229476
230179
|
if (!fs31.existsSync(chatsDir)) {
|
|
229477
230180
|
return [];
|
|
229478
230181
|
}
|
|
229479
230182
|
const chatDirs = fs31.readdirSync(chatsDir);
|
|
229480
230183
|
const chatDirInfos = [];
|
|
229481
230184
|
for (const chatId of chatDirs) {
|
|
229482
|
-
const chatPath =
|
|
230185
|
+
const chatPath = path43.join(chatsDir, chatId);
|
|
229483
230186
|
try {
|
|
229484
230187
|
const stat = fs31.statSync(chatPath);
|
|
229485
230188
|
if (!stat.isDirectory())
|
|
@@ -229487,7 +230190,7 @@ function getAllChats(maxChats = 500) {
|
|
|
229487
230190
|
chatDirInfos.push({
|
|
229488
230191
|
chatId,
|
|
229489
230192
|
chatPath,
|
|
229490
|
-
messagesPath:
|
|
230193
|
+
messagesPath: path43.join(chatPath, "chat-messages.json"),
|
|
229491
230194
|
mtime: stat.mtime
|
|
229492
230195
|
});
|
|
229493
230196
|
} catch {}
|
|
@@ -230602,20 +231305,20 @@ var LoginModal = ({
|
|
|
230602
231305
|
|
|
230603
231306
|
// src/components/project-picker-screen.tsx
|
|
230604
231307
|
var import_react130 = __toESM(require_react(), 1);
|
|
230605
|
-
import
|
|
231308
|
+
import os19 from "os";
|
|
230606
231309
|
|
|
230607
231310
|
// src/hooks/use-directory-browser.ts
|
|
230608
231311
|
var import_react128 = __toESM(require_react(), 1);
|
|
230609
231312
|
import { existsSync as existsSync20, statSync as statSync8 } from "fs";
|
|
230610
|
-
import
|
|
230611
|
-
import
|
|
231313
|
+
import os17 from "os";
|
|
231314
|
+
import path45 from "path";
|
|
230612
231315
|
|
|
230613
231316
|
// src/utils/directory-browser.ts
|
|
230614
231317
|
import { readdirSync as readdirSync8, statSync as statSync7 } from "fs";
|
|
230615
|
-
import
|
|
231318
|
+
import path44 from "path";
|
|
230616
231319
|
function getDirectories(dirPath) {
|
|
230617
231320
|
const entries = [];
|
|
230618
|
-
const parentDir =
|
|
231321
|
+
const parentDir = path44.dirname(dirPath);
|
|
230619
231322
|
if (parentDir !== dirPath) {
|
|
230620
231323
|
entries.push({
|
|
230621
231324
|
name: "..",
|
|
@@ -230629,7 +231332,7 @@ function getDirectories(dirPath) {
|
|
|
230629
231332
|
for (const item of items) {
|
|
230630
231333
|
if (item.startsWith("."))
|
|
230631
231334
|
continue;
|
|
230632
|
-
const fullPath =
|
|
231335
|
+
const fullPath = path44.join(dirPath, item);
|
|
230633
231336
|
try {
|
|
230634
231337
|
const stat = statSync7(fullPath);
|
|
230635
231338
|
if (stat.isDirectory()) {
|
|
@@ -230650,7 +231353,7 @@ function getDirectories(dirPath) {
|
|
|
230650
231353
|
}
|
|
230651
231354
|
function hasGitDirectory(dirPath) {
|
|
230652
231355
|
try {
|
|
230653
|
-
const gitPath =
|
|
231356
|
+
const gitPath = path44.join(dirPath, ".git");
|
|
230654
231357
|
return statSync7(gitPath).isDirectory();
|
|
230655
231358
|
} catch {
|
|
230656
231359
|
return false;
|
|
@@ -230661,12 +231364,12 @@ function hasGitDirectory(dirPath) {
|
|
|
230661
231364
|
function useDirectoryBrowser({
|
|
230662
231365
|
initialPath
|
|
230663
231366
|
} = {}) {
|
|
230664
|
-
const [currentPath, setCurrentPath] = import_react128.useState(initialPath ??
|
|
231367
|
+
const [currentPath, setCurrentPath] = import_react128.useState(initialPath ?? os17.homedir());
|
|
230665
231368
|
const directories = import_react128.useMemo(() => getDirectories(currentPath), [currentPath]);
|
|
230666
231369
|
const isGitRepo = import_react128.useMemo(() => hasGitDirectory(currentPath), [currentPath]);
|
|
230667
231370
|
const expandPath = import_react128.useCallback((inputPath) => {
|
|
230668
231371
|
if (inputPath.startsWith("~")) {
|
|
230669
|
-
return
|
|
231372
|
+
return path45.join(os17.homedir(), inputPath.slice(1));
|
|
230670
231373
|
}
|
|
230671
231374
|
return inputPath;
|
|
230672
231375
|
}, []);
|
|
@@ -230697,28 +231400,28 @@ function useDirectoryBrowser({
|
|
|
230697
231400
|
// src/hooks/use-path-tab-completion.ts
|
|
230698
231401
|
var import_react129 = __toESM(require_react(), 1);
|
|
230699
231402
|
import { existsSync as existsSync22, statSync as statSync10 } from "fs";
|
|
230700
|
-
import
|
|
231403
|
+
import path47 from "path";
|
|
230701
231404
|
|
|
230702
231405
|
// src/utils/path-completion.ts
|
|
230703
231406
|
import { existsSync as existsSync21, readdirSync as readdirSync9, statSync as statSync9 } from "fs";
|
|
230704
|
-
import
|
|
230705
|
-
import
|
|
231407
|
+
import os18 from "os";
|
|
231408
|
+
import path46 from "path";
|
|
230706
231409
|
function getPathCompletion(inputPath) {
|
|
230707
231410
|
if (!inputPath)
|
|
230708
231411
|
return null;
|
|
230709
231412
|
let expandedPath = inputPath;
|
|
230710
|
-
const homeDir =
|
|
231413
|
+
const homeDir = os18.homedir();
|
|
230711
231414
|
if (expandedPath.startsWith("~")) {
|
|
230712
|
-
expandedPath =
|
|
231415
|
+
expandedPath = path46.join(homeDir, expandedPath.slice(1));
|
|
230713
231416
|
}
|
|
230714
231417
|
let parentDir;
|
|
230715
231418
|
let partial2;
|
|
230716
|
-
if (expandedPath.endsWith(
|
|
231419
|
+
if (expandedPath.endsWith(path46.sep)) {
|
|
230717
231420
|
parentDir = expandedPath;
|
|
230718
231421
|
partial2 = "";
|
|
230719
231422
|
} else {
|
|
230720
|
-
parentDir =
|
|
230721
|
-
partial2 =
|
|
231423
|
+
parentDir = path46.dirname(expandedPath);
|
|
231424
|
+
partial2 = path46.basename(expandedPath).toLowerCase();
|
|
230722
231425
|
}
|
|
230723
231426
|
try {
|
|
230724
231427
|
if (!existsSync21(parentDir) || !statSync9(parentDir).isDirectory()) {
|
|
@@ -230733,7 +231436,7 @@ function getPathCompletion(inputPath) {
|
|
|
230733
231436
|
for (const item of items) {
|
|
230734
231437
|
if (item.startsWith(".") && !partial2.startsWith("."))
|
|
230735
231438
|
continue;
|
|
230736
|
-
const fullPath =
|
|
231439
|
+
const fullPath = path46.join(parentDir, item);
|
|
230737
231440
|
try {
|
|
230738
231441
|
if (!statSync9(fullPath).isDirectory())
|
|
230739
231442
|
continue;
|
|
@@ -230747,7 +231450,7 @@ function getPathCompletion(inputPath) {
|
|
|
230747
231450
|
if (matches.length === 0)
|
|
230748
231451
|
return null;
|
|
230749
231452
|
if (matches.length === 1) {
|
|
230750
|
-
let completed =
|
|
231453
|
+
let completed = path46.join(parentDir, matches[0]) + path46.sep;
|
|
230751
231454
|
if (inputPath.startsWith("~") && completed.startsWith(homeDir)) {
|
|
230752
231455
|
completed = "~" + completed.slice(homeDir.length);
|
|
230753
231456
|
}
|
|
@@ -230762,7 +231465,7 @@ function getPathCompletion(inputPath) {
|
|
|
230762
231465
|
}
|
|
230763
231466
|
if (commonLength > partial2.length) {
|
|
230764
231467
|
const commonPrefix = sortedMatches[0].slice(0, commonLength);
|
|
230765
|
-
let completed =
|
|
231468
|
+
let completed = path46.join(parentDir, commonPrefix);
|
|
230766
231469
|
if (inputPath.startsWith("~") && completed.startsWith(homeDir)) {
|
|
230767
231470
|
completed = "~" + completed.slice(homeDir.length);
|
|
230768
231471
|
}
|
|
@@ -230799,7 +231502,7 @@ function usePathTabCompletion({
|
|
|
230799
231502
|
setSearchQuery(completed);
|
|
230800
231503
|
}
|
|
230801
231504
|
} else if (searchQuery.length > 0) {
|
|
230802
|
-
const relativePath =
|
|
231505
|
+
const relativePath = path47.join(currentPath, searchQuery);
|
|
230803
231506
|
const completed = getPathCompletion(relativePath);
|
|
230804
231507
|
if (completed) {
|
|
230805
231508
|
if (completed.endsWith("/")) {
|
|
@@ -230812,7 +231515,7 @@ function usePathTabCompletion({
|
|
|
230812
231515
|
}
|
|
230813
231516
|
} catch {}
|
|
230814
231517
|
}
|
|
230815
|
-
if (completed.startsWith(currentPath +
|
|
231518
|
+
if (completed.startsWith(currentPath + path47.sep)) {
|
|
230816
231519
|
setSearchQuery(completed.slice(currentPath.length + 1));
|
|
230817
231520
|
} else {
|
|
230818
231521
|
setSearchQuery(completed);
|
|
@@ -230828,10 +231531,10 @@ function usePathTabCompletion({
|
|
|
230828
231531
|
init_auth3();
|
|
230829
231532
|
init_logger2();
|
|
230830
231533
|
import fs32 from "fs";
|
|
230831
|
-
import
|
|
231534
|
+
import path48 from "path";
|
|
230832
231535
|
var MAX_RECENT_PROJECTS = 10;
|
|
230833
231536
|
var getRecentProjectsPath = () => {
|
|
230834
|
-
return
|
|
231537
|
+
return path48.join(getConfigDir2(), "recent-projects.json");
|
|
230835
231538
|
};
|
|
230836
231539
|
var loadRecentProjects = () => {
|
|
230837
231540
|
const recentProjectsPath = getRecentProjectsPath();
|
|
@@ -230932,7 +231635,7 @@ var ProjectPickerScreen = ({
|
|
|
230932
231635
|
resetKey: currentPath
|
|
230933
231636
|
});
|
|
230934
231637
|
const recentProjects = import_react130.useMemo(() => {
|
|
230935
|
-
const homeDir =
|
|
231638
|
+
const homeDir = os19.homedir();
|
|
230936
231639
|
return loadRecentProjects().filter((project) => project.path !== homeDir);
|
|
230937
231640
|
}, []);
|
|
230938
231641
|
const { terminalWidth, terminalHeight } = useTerminalLayout();
|
|
@@ -231398,15 +232101,15 @@ init_chat_store();
|
|
|
231398
232101
|
|
|
231399
232102
|
// src/utils/git.ts
|
|
231400
232103
|
import { existsSync as existsSync23 } from "fs";
|
|
231401
|
-
import { dirname as
|
|
232104
|
+
import { dirname as dirname12, join as join12 } from "path";
|
|
231402
232105
|
function findGitRoot(params2) {
|
|
231403
232106
|
const { cwd } = params2;
|
|
231404
232107
|
let currentDir = cwd;
|
|
231405
|
-
while (currentDir !==
|
|
231406
|
-
if (existsSync23(
|
|
232108
|
+
while (currentDir !== dirname12(currentDir)) {
|
|
232109
|
+
if (existsSync23(join12(currentDir, ".git"))) {
|
|
231407
232110
|
return currentDir;
|
|
231408
232111
|
}
|
|
231409
|
-
currentDir =
|
|
232112
|
+
currentDir = dirname12(currentDir);
|
|
231410
232113
|
}
|
|
231411
232114
|
return null;
|
|
231412
232115
|
}
|
|
@@ -231677,11 +232380,11 @@ init_project_files();
|
|
|
231677
232380
|
init_logger2();
|
|
231678
232381
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
231679
232382
|
import fs33 from "fs";
|
|
231680
|
-
import
|
|
231681
|
-
import
|
|
232383
|
+
import os20 from "os";
|
|
232384
|
+
import path49 from "path";
|
|
231682
232385
|
function findEnvrcDirectory(startDir) {
|
|
231683
|
-
let currentDir =
|
|
231684
|
-
const root2 =
|
|
232386
|
+
let currentDir = path49.resolve(startDir);
|
|
232387
|
+
const root2 = path49.parse(currentDir).root;
|
|
231685
232388
|
while (currentDir !== root2) {
|
|
231686
232389
|
let entries;
|
|
231687
232390
|
try {
|
|
@@ -231697,7 +232400,7 @@ function findEnvrcDirectory(startDir) {
|
|
|
231697
232400
|
if (hasGit) {
|
|
231698
232401
|
break;
|
|
231699
232402
|
}
|
|
231700
|
-
const parentDir =
|
|
232403
|
+
const parentDir = path49.dirname(currentDir);
|
|
231701
232404
|
if (parentDir === currentDir)
|
|
231702
232405
|
break;
|
|
231703
232406
|
currentDir = parentDir;
|
|
@@ -231705,7 +232408,7 @@ function findEnvrcDirectory(startDir) {
|
|
|
231705
232408
|
return null;
|
|
231706
232409
|
}
|
|
231707
232410
|
function isDirenvAvailable() {
|
|
231708
|
-
if (
|
|
232411
|
+
if (os20.platform() === "win32") {
|
|
231709
232412
|
return false;
|
|
231710
232413
|
}
|
|
231711
232414
|
try {
|
|
@@ -231797,10 +232500,10 @@ init_auth3();
|
|
|
231797
232500
|
init_logger2();
|
|
231798
232501
|
|
|
231799
232502
|
// src/utils/project-picker.ts
|
|
231800
|
-
import
|
|
232503
|
+
import path50 from "path";
|
|
231801
232504
|
function shouldShowProjectPicker(startCwd, homeDir) {
|
|
231802
|
-
const relativeToHome =
|
|
231803
|
-
return relativeToHome === "" || !relativeToHome.startsWith("..") && !
|
|
232505
|
+
const relativeToHome = path50.relative(startCwd, homeDir);
|
|
232506
|
+
return relativeToHome === "" || !relativeToHome.startsWith("..") && !path50.isAbsolute(relativeToHome);
|
|
231804
232507
|
}
|
|
231805
232508
|
|
|
231806
232509
|
// src/utils/renderer-cleanup.ts
|
|
@@ -231960,7 +232663,7 @@ async function main2() {
|
|
|
231960
232663
|
process.exit(1);
|
|
231961
232664
|
}
|
|
231962
232665
|
const projectRoot2 = getProjectRoot();
|
|
231963
|
-
const homeDir =
|
|
232666
|
+
const homeDir = os21.homedir();
|
|
231964
232667
|
const startCwd = process.cwd();
|
|
231965
232668
|
const showProjectPicker = shouldShowProjectPicker(startCwd, homeDir);
|
|
231966
232669
|
if (isPublishCommand || !hasAgentOverride) {
|
|
@@ -232039,12 +232742,12 @@ async function main2() {
|
|
|
232039
232742
|
}, [currentProjectRoot, loadFileTree]);
|
|
232040
232743
|
const handleProjectChange = import_react135.default.useCallback(async (newProjectPath) => {
|
|
232041
232744
|
process.chdir(newProjectPath);
|
|
232042
|
-
const isGitRepo = fs34.existsSync(
|
|
232043
|
-
const pathDepth = newProjectPath.split(
|
|
232745
|
+
const isGitRepo = fs34.existsSync(path51.join(newProjectPath, ".git"));
|
|
232746
|
+
const pathDepth = newProjectPath.split(path51.sep).filter(Boolean).length;
|
|
232044
232747
|
trackEvent2("cli.change_directory" /* CHANGE_DIRECTORY */, {
|
|
232045
232748
|
isGitRepo,
|
|
232046
232749
|
pathDepth,
|
|
232047
|
-
isHomeDir: newProjectPath ===
|
|
232750
|
+
isHomeDir: newProjectPath === os21.homedir()
|
|
232048
232751
|
});
|
|
232049
232752
|
setProjectRoot(newProjectPath);
|
|
232050
232753
|
resetLevelCodeClient();
|