@levelcode/cli 0.2.4 → 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 +695 -449
- 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 };
|
|
@@ -158667,7 +158870,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
158667
158870
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
158668
158871
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
158669
158872
|
- Spawn the editor agent to implement the changes after you have gathered all the context you need.
|
|
158670
|
-
- 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)
|
|
158671
158874
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
158672
158875
|
- Spawn a code-reviewer to review the changes after you have implemented the changes.
|
|
158673
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.
|
|
@@ -158782,7 +158985,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
158782
158985
|
|
|
158783
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.
|
|
158784
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.
|
|
158785
|
-
- 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)
|
|
158786
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.
|
|
158787
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)!
|
|
158788
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.)
|
|
@@ -159642,7 +159845,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
159642
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.
|
|
159643
159846
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
159644
159847
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
159645
|
-
- 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)
|
|
159646
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.
|
|
159647
159850
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
159648
159851
|
- Spawn a code-reviewer-multi-prompt to review the changes after you have implemented the changes.
|
|
@@ -159759,7 +159962,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
159759
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.
|
|
159760
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.
|
|
159761
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.
|
|
159762
|
-
- 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)
|
|
159763
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.
|
|
159764
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)!
|
|
159765
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.)
|
|
@@ -159898,7 +160101,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
159898
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.
|
|
159899
160102
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
159900
160103
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
159901
|
-
- 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)
|
|
159902
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.
|
|
159903
160106
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
159904
160107
|
- Spawn a code-reviewer-multi-prompt to review the changes after you have implemented the changes.
|
|
@@ -160018,7 +160221,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
160018
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.
|
|
160019
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.
|
|
160020
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.
|
|
160021
|
-
- 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)
|
|
160022
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.
|
|
160023
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)!
|
|
160024
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.)
|
|
@@ -160160,7 +160363,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
160160
160363
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
160161
160364
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
160162
160365
|
- Spawn the editor agent to implement the changes after you have gathered all the context you need.
|
|
160163
|
-
- 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)
|
|
160164
160367
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
160165
160368
|
- Spawn a code-reviewer to review the changes after you have implemented the changes.
|
|
160166
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.
|
|
@@ -160443,7 +160646,7 @@ Use the spawn_agents tool to spawn specialized agents to help you complete the u
|
|
|
160443
160646
|
- **Sequence agents properly:** Keep in mind dependencies when spawning different agents. Don't spawn agents in parallel that depend on each other.
|
|
160444
160647
|
- Spawn context-gathering agents (file pickers, code-searcher, directory-lister, glob-matcher, and web/docs researchers) before making edits.
|
|
160445
160648
|
- Spawn the editor agent to implement the changes after you have gathered all the context you need.
|
|
160446
|
-
- 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)
|
|
160447
160650
|
- Spawn commanders sequentially if the second command depends on the the first.
|
|
160448
160651
|
- Spawn a code-reviewer to review the changes after you have implemented the changes.
|
|
160449
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.
|
|
@@ -160561,7 +160764,7 @@ The user asks you to implement a new feature. You respond in multiple steps:
|
|
|
160561
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.
|
|
160562
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.
|
|
160563
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.
|
|
160564
|
-
- 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)
|
|
160565
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.
|
|
160566
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)!
|
|
160567
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.)
|
|
@@ -166013,7 +166216,7 @@ var require_has_flag = __commonJS((exports3, module3) => {
|
|
|
166013
166216
|
|
|
166014
166217
|
// ../node_modules/supports-color/index.js
|
|
166015
166218
|
var require_supports_color = __commonJS((exports3, module3) => {
|
|
166016
|
-
var
|
|
166219
|
+
var os15 = __require("os");
|
|
166017
166220
|
var tty = __require("tty");
|
|
166018
166221
|
var hasFlag = require_has_flag();
|
|
166019
166222
|
var { env: env3 } = process;
|
|
@@ -166070,7 +166273,7 @@ var require_supports_color = __commonJS((exports3, module3) => {
|
|
|
166070
166273
|
return min;
|
|
166071
166274
|
}
|
|
166072
166275
|
if (process.platform === "win32") {
|
|
166073
|
-
const osRelease =
|
|
166276
|
+
const osRelease = os15.release().split(".");
|
|
166074
166277
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
166075
166278
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
166076
166279
|
}
|
|
@@ -166417,8 +166620,8 @@ var require_rg5 = __commonJS((exports3, module3) => {
|
|
|
166417
166620
|
// src/index.tsx
|
|
166418
166621
|
import fs34 from "fs";
|
|
166419
166622
|
import { createRequire as createRequire2 } from "module";
|
|
166420
|
-
import
|
|
166421
|
-
import
|
|
166623
|
+
import os21 from "os";
|
|
166624
|
+
import path51 from "path";
|
|
166422
166625
|
init_project_file_tree();
|
|
166423
166626
|
|
|
166424
166627
|
// ../node_modules/@opentui/core/index-93qf6w1k.js
|
|
@@ -193022,7 +193225,7 @@ init_src();
|
|
|
193022
193225
|
// ../node_modules/open/index.js
|
|
193023
193226
|
import process9 from "process";
|
|
193024
193227
|
import { Buffer as Buffer3 } from "buffer";
|
|
193025
|
-
import
|
|
193228
|
+
import path26 from "path";
|
|
193026
193229
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
193027
193230
|
import { promisify as promisify5 } from "util";
|
|
193028
193231
|
import childProcess from "child_process";
|
|
@@ -193034,7 +193237,7 @@ import fs21, { constants as fsConstants } from "fs/promises";
|
|
|
193034
193237
|
|
|
193035
193238
|
// ../node_modules/wsl-utils/node_modules/is-wsl/index.js
|
|
193036
193239
|
import process4 from "process";
|
|
193037
|
-
import
|
|
193240
|
+
import os11 from "os";
|
|
193038
193241
|
import fs20 from "fs";
|
|
193039
193242
|
|
|
193040
193243
|
// ../node_modules/is-inside-container/index.js
|
|
@@ -193087,7 +193290,7 @@ var isWsl = () => {
|
|
|
193087
193290
|
if (process4.platform !== "linux") {
|
|
193088
193291
|
return false;
|
|
193089
193292
|
}
|
|
193090
|
-
if (
|
|
193293
|
+
if (os11.release().toLowerCase().includes("microsoft")) {
|
|
193091
193294
|
if (isInsideContainer()) {
|
|
193092
193295
|
return false;
|
|
193093
193296
|
}
|
|
@@ -193260,8 +193463,8 @@ async function defaultBrowser2() {
|
|
|
193260
193463
|
|
|
193261
193464
|
// ../node_modules/open/index.js
|
|
193262
193465
|
var execFile5 = promisify5(childProcess.execFile);
|
|
193263
|
-
var __dirname2 =
|
|
193264
|
-
var localXdgOpenPath =
|
|
193466
|
+
var __dirname2 = path26.dirname(fileURLToPath3(import.meta.url));
|
|
193467
|
+
var localXdgOpenPath = path26.join(__dirname2, "xdg-open");
|
|
193265
193468
|
var { platform: platform2, arch } = process9;
|
|
193266
193469
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
193267
193470
|
const powershellPath = await powerShellPath();
|
|
@@ -193514,7 +193717,7 @@ init_logger2();
|
|
|
193514
193717
|
// src/utils/message-history.ts
|
|
193515
193718
|
init_auth3();
|
|
193516
193719
|
import fs26 from "fs";
|
|
193517
|
-
import
|
|
193720
|
+
import path33 from "path";
|
|
193518
193721
|
|
|
193519
193722
|
// src/utils/helpers.ts
|
|
193520
193723
|
var timestampFormatter = null;
|
|
@@ -193589,7 +193792,7 @@ function getSystemMessage(content) {
|
|
|
193589
193792
|
};
|
|
193590
193793
|
}
|
|
193591
193794
|
var getMessageHistoryPath = () => {
|
|
193592
|
-
return
|
|
193795
|
+
return path33.join(getConfigDir2(), "message-history.json");
|
|
193593
193796
|
};
|
|
193594
193797
|
var loadMessageHistory = () => {
|
|
193595
193798
|
const historyPath = getMessageHistoryPath();
|
|
@@ -193748,9 +193951,9 @@ var buildTheme = (baseTheme, mode, customColors, plugins2) => {
|
|
|
193748
193951
|
};
|
|
193749
193952
|
|
|
193750
193953
|
// src/utils/theme-system.ts
|
|
193751
|
-
import { existsSync as existsSync15, readFileSync as
|
|
193752
|
-
import { homedir as
|
|
193753
|
-
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";
|
|
193754
193957
|
var _truecolorSupport = null;
|
|
193755
193958
|
function supportsTruecolor(env3 = getCliEnv()) {
|
|
193756
193959
|
if (_truecolorSupport !== null) {
|
|
@@ -193872,7 +194075,7 @@ var inferThemeFromName = (themeName) => {
|
|
|
193872
194075
|
var stripJsonStyleComments = (raw) => raw.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
193873
194076
|
var safeReadFile = (filePath) => {
|
|
193874
194077
|
try {
|
|
193875
|
-
return
|
|
194078
|
+
return readFileSync7(filePath, "utf8");
|
|
193876
194079
|
} catch {
|
|
193877
194080
|
return null;
|
|
193878
194081
|
}
|
|
@@ -193892,23 +194095,23 @@ var collectExistingPaths = (candidates) => {
|
|
|
193892
194095
|
};
|
|
193893
194096
|
var resolveVSCodeSettingsPaths = (env3 = getCliEnv()) => {
|
|
193894
194097
|
const settings = [];
|
|
193895
|
-
const home =
|
|
194098
|
+
const home = homedir6();
|
|
193896
194099
|
if (process.platform === "darwin") {
|
|
193897
|
-
const base =
|
|
194100
|
+
const base = join11(home, "Library", "Application Support");
|
|
193898
194101
|
for (const product of VS_CODE_PRODUCT_DIRS) {
|
|
193899
|
-
settings.push(
|
|
194102
|
+
settings.push(join11(base, product, "User", "settings.json"));
|
|
193900
194103
|
}
|
|
193901
194104
|
} else if (process.platform === "win32") {
|
|
193902
194105
|
const appData = env3.APPDATA;
|
|
193903
194106
|
if (appData) {
|
|
193904
194107
|
for (const product of VS_CODE_PRODUCT_DIRS) {
|
|
193905
|
-
settings.push(
|
|
194108
|
+
settings.push(join11(appData, product, "User", "settings.json"));
|
|
193906
194109
|
}
|
|
193907
194110
|
}
|
|
193908
194111
|
} else {
|
|
193909
|
-
const configDir = env3.XDG_CONFIG_HOME ??
|
|
194112
|
+
const configDir = env3.XDG_CONFIG_HOME ?? join11(home, ".config");
|
|
193910
194113
|
for (const product of VS_CODE_PRODUCT_DIRS) {
|
|
193911
|
-
settings.push(
|
|
194114
|
+
settings.push(join11(configDir, product, "User", "settings.json"));
|
|
193912
194115
|
}
|
|
193913
194116
|
}
|
|
193914
194117
|
return settings;
|
|
@@ -193916,23 +194119,23 @@ var resolveVSCodeSettingsPaths = (env3 = getCliEnv()) => {
|
|
|
193916
194119
|
var resolveJetBrainsLafPaths = (env3 = getCliEnv()) => {
|
|
193917
194120
|
const candidates = [];
|
|
193918
194121
|
if (env3.IDE_CONFIG_DIR) {
|
|
193919
|
-
candidates.push(
|
|
194122
|
+
candidates.push(join11(env3.IDE_CONFIG_DIR, "options", "laf.xml"));
|
|
193920
194123
|
}
|
|
193921
194124
|
if (env3.JB_IDE_CONFIG_DIR) {
|
|
193922
|
-
candidates.push(
|
|
194125
|
+
candidates.push(join11(env3.JB_IDE_CONFIG_DIR, "options", "laf.xml"));
|
|
193923
194126
|
}
|
|
193924
|
-
const home =
|
|
194127
|
+
const home = homedir6();
|
|
193925
194128
|
const baseDirs = [];
|
|
193926
194129
|
if (process.platform === "darwin") {
|
|
193927
|
-
baseDirs.push(
|
|
194130
|
+
baseDirs.push(join11(home, "Library", "Application Support", "JetBrains"));
|
|
193928
194131
|
} else if (process.platform === "win32") {
|
|
193929
194132
|
const appData = env3.APPDATA;
|
|
193930
194133
|
if (appData) {
|
|
193931
|
-
baseDirs.push(
|
|
194134
|
+
baseDirs.push(join11(appData, "JetBrains"));
|
|
193932
194135
|
}
|
|
193933
194136
|
} else {
|
|
193934
|
-
baseDirs.push(
|
|
193935
|
-
baseDirs.push(
|
|
194137
|
+
baseDirs.push(join11(home, ".config", "JetBrains"));
|
|
194138
|
+
baseDirs.push(join11(home, ".local", "share", "JetBrains"));
|
|
193936
194139
|
}
|
|
193937
194140
|
for (const base of baseDirs) {
|
|
193938
194141
|
try {
|
|
@@ -193940,45 +194143,45 @@ var resolveJetBrainsLafPaths = (env3 = getCliEnv()) => {
|
|
|
193940
194143
|
continue;
|
|
193941
194144
|
const entries = readdirSync6(base);
|
|
193942
194145
|
for (const entry of entries) {
|
|
193943
|
-
const dirPath =
|
|
194146
|
+
const dirPath = join11(base, entry);
|
|
193944
194147
|
try {
|
|
193945
194148
|
if (!statSync4(dirPath).isDirectory())
|
|
193946
194149
|
continue;
|
|
193947
194150
|
} catch {
|
|
193948
194151
|
continue;
|
|
193949
194152
|
}
|
|
193950
|
-
candidates.push(
|
|
194153
|
+
candidates.push(join11(dirPath, "options", "laf.xml"));
|
|
193951
194154
|
}
|
|
193952
194155
|
} catch {}
|
|
193953
194156
|
}
|
|
193954
194157
|
return candidates;
|
|
193955
194158
|
};
|
|
193956
194159
|
var resolveZedSettingsPaths = (env3 = getCliEnv()) => {
|
|
193957
|
-
const home =
|
|
194160
|
+
const home = homedir6();
|
|
193958
194161
|
const paths2 = [];
|
|
193959
194162
|
const configDirs = new Set;
|
|
193960
|
-
const xdgConfig = env3.XDG_CONFIG_HOME ??
|
|
193961
|
-
configDirs.add(
|
|
193962
|
-
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"));
|
|
193963
194166
|
if (process.platform === "darwin") {
|
|
193964
|
-
configDirs.add(
|
|
193965
|
-
configDirs.add(
|
|
194167
|
+
configDirs.add(join11(home, "Library", "Application Support", "Zed"));
|
|
194168
|
+
configDirs.add(join11(home, "Library", "Application Support", "dev.zed.Zed"));
|
|
193966
194169
|
} else if (process.platform === "win32") {
|
|
193967
194170
|
const appData = env3.APPDATA;
|
|
193968
194171
|
if (appData) {
|
|
193969
|
-
configDirs.add(
|
|
193970
|
-
configDirs.add(
|
|
194172
|
+
configDirs.add(join11(appData, "Zed"));
|
|
194173
|
+
configDirs.add(join11(appData, "dev.zed.Zed"));
|
|
193971
194174
|
}
|
|
193972
194175
|
} else {
|
|
193973
|
-
configDirs.add(
|
|
193974
|
-
configDirs.add(
|
|
193975
|
-
configDirs.add(
|
|
193976
|
-
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"));
|
|
193977
194180
|
}
|
|
193978
|
-
const legacyConfig =
|
|
194181
|
+
const legacyConfig = join11(home, ".zed");
|
|
193979
194182
|
configDirs.add(legacyConfig);
|
|
193980
194183
|
for (const dir of configDirs) {
|
|
193981
|
-
paths2.push(
|
|
194184
|
+
paths2.push(join11(dir, "settings.json"));
|
|
193982
194185
|
}
|
|
193983
194186
|
return paths2;
|
|
193984
194187
|
};
|
|
@@ -194499,7 +194702,7 @@ var setupFileWatchers = () => {
|
|
|
194499
194702
|
const watchTargets = [];
|
|
194500
194703
|
const watchedDirs = new Set;
|
|
194501
194704
|
if (process.platform === "darwin") {
|
|
194502
|
-
watchTargets.push(
|
|
194705
|
+
watchTargets.push(join11(homedir6(), "Library/Preferences/.GlobalPreferences.plist"), join11(homedir6(), "Library/Preferences/com.apple.Terminal.plist"));
|
|
194503
194706
|
}
|
|
194504
194707
|
if (isVSCodeFamilyTerminal()) {
|
|
194505
194708
|
watchTargets.push(...resolveVSCodeSettingsPaths());
|
|
@@ -194512,7 +194715,7 @@ var setupFileWatchers = () => {
|
|
|
194512
194715
|
}
|
|
194513
194716
|
for (const target of watchTargets) {
|
|
194514
194717
|
if (existsSync15(target)) {
|
|
194515
|
-
const parentDir =
|
|
194718
|
+
const parentDir = dirname11(target);
|
|
194516
194719
|
if (watchedDirs.has(parentDir))
|
|
194517
194720
|
continue;
|
|
194518
194721
|
watchedDirs.add(parentDir);
|
|
@@ -194628,8 +194831,8 @@ async function handleImageCommand(args2) {
|
|
|
194628
194831
|
}
|
|
194629
194832
|
|
|
194630
194833
|
// src/commands/init.ts
|
|
194631
|
-
import { existsSync as existsSync16, mkdirSync as
|
|
194632
|
-
import
|
|
194834
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
194835
|
+
import path34 from "path";
|
|
194633
194836
|
init_knowledge();
|
|
194634
194837
|
|
|
194635
194838
|
// ../common/src/templates/initial-agents-dir/types/agent-definition.ts
|
|
@@ -195641,12 +195844,12 @@ var COMMON_TYPE_FILES = [
|
|
|
195641
195844
|
];
|
|
195642
195845
|
function handleInitializationFlowLocally() {
|
|
195643
195846
|
const projectRoot2 = getProjectRoot();
|
|
195644
|
-
const knowledgePath =
|
|
195847
|
+
const knowledgePath = path34.join(projectRoot2, PRIMARY_KNOWLEDGE_FILE_NAME);
|
|
195645
195848
|
const messages = [];
|
|
195646
195849
|
if (existsSync16(knowledgePath)) {
|
|
195647
195850
|
messages.push(`\uD83D\uDCCB \`${PRIMARY_KNOWLEDGE_FILE_NAME}\` already exists.`);
|
|
195648
195851
|
} else {
|
|
195649
|
-
|
|
195852
|
+
writeFileSync5(knowledgePath, INITIAL_KNOWLEDGE_FILE);
|
|
195650
195853
|
messages.push(`\u2705 Created \`${PRIMARY_KNOWLEDGE_FILE_NAME}\``);
|
|
195651
195854
|
trackEvent2("cli.knowledge_file_updated" /* KNOWLEDGE_FILE_UPDATED */, {
|
|
195652
195855
|
action: "created",
|
|
@@ -195654,22 +195857,22 @@ function handleInitializationFlowLocally() {
|
|
|
195654
195857
|
fileSizeBytes: Buffer.byteLength(INITIAL_KNOWLEDGE_FILE, "utf8")
|
|
195655
195858
|
});
|
|
195656
195859
|
}
|
|
195657
|
-
const agentsDir =
|
|
195658
|
-
const agentsTypesDir =
|
|
195860
|
+
const agentsDir = path34.join(projectRoot2, ".agents");
|
|
195861
|
+
const agentsTypesDir = path34.join(agentsDir, "types");
|
|
195659
195862
|
if (existsSync16(agentsDir)) {
|
|
195660
195863
|
messages.push("\uD83D\uDCCB `.agents/` already exists.");
|
|
195661
195864
|
} else {
|
|
195662
|
-
|
|
195865
|
+
mkdirSync6(agentsDir, { recursive: true });
|
|
195663
195866
|
messages.push("\u2705 Created `.agents/`");
|
|
195664
195867
|
}
|
|
195665
195868
|
if (existsSync16(agentsTypesDir)) {
|
|
195666
195869
|
messages.push("\uD83D\uDCCB `.agents/types/` already exists.");
|
|
195667
195870
|
} else {
|
|
195668
|
-
|
|
195871
|
+
mkdirSync6(agentsTypesDir, { recursive: true });
|
|
195669
195872
|
messages.push("\u2705 Created `.agents/types/`");
|
|
195670
195873
|
}
|
|
195671
195874
|
for (const { fileName, source } of COMMON_TYPE_FILES) {
|
|
195672
|
-
const targetPath =
|
|
195875
|
+
const targetPath = path34.join(agentsTypesDir, fileName);
|
|
195673
195876
|
if (existsSync16(targetPath)) {
|
|
195674
195877
|
messages.push(`\uD83D\uDCCB \`.agents/types/${fileName}\` already exists.`);
|
|
195675
195878
|
continue;
|
|
@@ -195678,7 +195881,7 @@ function handleInitializationFlowLocally() {
|
|
|
195678
195881
|
if (!source || source.trim().length === 0) {
|
|
195679
195882
|
throw new Error("Source content is empty");
|
|
195680
195883
|
}
|
|
195681
|
-
|
|
195884
|
+
writeFileSync5(targetPath, source);
|
|
195682
195885
|
messages.push(`\u2705 Copied \`.agents/types/${fileName}\``);
|
|
195683
195886
|
} catch (error46) {
|
|
195684
195887
|
messages.push(`\u26A0\uFE0F Failed to copy \`.agents/types/${fileName}\`: ${error46 instanceof Error ? error46.message : String(error46 ?? "Unknown")}`);
|
|
@@ -195961,6 +196164,7 @@ function getSkillByName(name18) {
|
|
|
195961
196164
|
|
|
195962
196165
|
// src/commands/command-registry.ts
|
|
195963
196166
|
init_team_fs();
|
|
196167
|
+
init_team_discovery();
|
|
195964
196168
|
init_dev_phases();
|
|
195965
196169
|
init_team_hook_emitter();
|
|
195966
196170
|
init_analytics2();
|
|
@@ -196228,7 +196432,18 @@ var COMMAND_REGISTRY = [
|
|
|
196228
196432
|
defineCommand({
|
|
196229
196433
|
name: "team:delete",
|
|
196230
196434
|
handler: (params2) => {
|
|
196231
|
-
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
|
+
}
|
|
196232
196447
|
if (!activeTeam) {
|
|
196233
196448
|
params2.setMessages((prev) => [
|
|
196234
196449
|
...prev,
|
|
@@ -196262,7 +196477,17 @@ var COMMAND_REGISTRY = [
|
|
|
196262
196477
|
defineCommand({
|
|
196263
196478
|
name: "team:status",
|
|
196264
196479
|
handler: (params2) => {
|
|
196265
|
-
|
|
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
|
+
}
|
|
196266
196491
|
if (!activeTeam) {
|
|
196267
196492
|
params2.setMessages((prev) => [
|
|
196268
196493
|
...prev,
|
|
@@ -196352,7 +196577,17 @@ Valid phases: ${validPhases.join(", ")}`)
|
|
|
196352
196577
|
clearInput(params2);
|
|
196353
196578
|
return;
|
|
196354
196579
|
}
|
|
196355
|
-
|
|
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
|
+
}
|
|
196356
196591
|
if (!activeTeam) {
|
|
196357
196592
|
params2.setMessages((prev) => [
|
|
196358
196593
|
...prev,
|
|
@@ -196468,7 +196703,17 @@ Valid phases: ${validPhases.join(", ")}`)
|
|
|
196468
196703
|
defineCommand({
|
|
196469
196704
|
name: "team:members",
|
|
196470
196705
|
handler: (params2) => {
|
|
196471
|
-
|
|
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
|
+
}
|
|
196472
196717
|
if (!activeTeam) {
|
|
196473
196718
|
params2.setMessages((prev) => [
|
|
196474
196719
|
...prev,
|
|
@@ -196575,6 +196820,7 @@ Valid phases: ${validPhases.join(", ")}`)
|
|
|
196575
196820
|
}),
|
|
196576
196821
|
defineCommand({
|
|
196577
196822
|
name: "gpt-5-agent",
|
|
196823
|
+
aliases: ["titan-agent", "titan"],
|
|
196578
196824
|
handler: (params2) => {
|
|
196579
196825
|
params2.setInputValue({
|
|
196580
196826
|
text: "@Titan Agent ",
|
|
@@ -200228,18 +200474,18 @@ var Separator = ({
|
|
|
200228
200474
|
init_chat_store();
|
|
200229
200475
|
|
|
200230
200476
|
// src/utils/strings.ts
|
|
200231
|
-
import
|
|
200477
|
+
import path36 from "path";
|
|
200232
200478
|
|
|
200233
200479
|
// src/utils/clipboard-image.ts
|
|
200234
200480
|
init_image_handler();
|
|
200235
200481
|
import { spawnSync } from "child_process";
|
|
200236
|
-
import { existsSync as existsSync17, mkdirSync as
|
|
200237
|
-
import
|
|
200238
|
-
import
|
|
200482
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
200483
|
+
import os13 from "os";
|
|
200484
|
+
import path35 from "path";
|
|
200239
200485
|
function getClipboardTempDir() {
|
|
200240
|
-
const tempDir =
|
|
200486
|
+
const tempDir = path35.join(os13.tmpdir(), "levelcode-clipboard-images");
|
|
200241
200487
|
if (!existsSync17(tempDir)) {
|
|
200242
|
-
|
|
200488
|
+
mkdirSync7(tempDir, { recursive: true });
|
|
200243
200489
|
}
|
|
200244
200490
|
return tempDir;
|
|
200245
200491
|
}
|
|
@@ -200266,7 +200512,7 @@ function readImageMacOS() {
|
|
|
200266
200512
|
try {
|
|
200267
200513
|
const tempDir = getClipboardTempDir();
|
|
200268
200514
|
const filename = generateImageFilename();
|
|
200269
|
-
const imagePath =
|
|
200515
|
+
const imagePath = path35.join(tempDir, filename);
|
|
200270
200516
|
const pngpasteResult = spawnSync("pngpaste", [imagePath], {
|
|
200271
200517
|
encoding: "utf-8",
|
|
200272
200518
|
timeout: 5000
|
|
@@ -200346,7 +200592,7 @@ function readImageLinux() {
|
|
|
200346
200592
|
try {
|
|
200347
200593
|
const tempDir = getClipboardTempDir();
|
|
200348
200594
|
const filename = generateImageFilename();
|
|
200349
|
-
const imagePath =
|
|
200595
|
+
const imagePath = path35.join(tempDir, filename);
|
|
200350
200596
|
let result = spawnSync("xclip", [
|
|
200351
200597
|
"-selection",
|
|
200352
200598
|
"clipboard",
|
|
@@ -200355,7 +200601,7 @@ function readImageLinux() {
|
|
|
200355
200601
|
"-o"
|
|
200356
200602
|
], { timeout: 5000, maxBuffer: 50 * 1024 * 1024 });
|
|
200357
200603
|
if (result.status === 0 && result.stdout && result.stdout.length > 0) {
|
|
200358
|
-
|
|
200604
|
+
writeFileSync6(imagePath, result.stdout);
|
|
200359
200605
|
return { success: true, imagePath, filename };
|
|
200360
200606
|
}
|
|
200361
200607
|
result = spawnSync("wl-paste", ["--type", "image/png"], {
|
|
@@ -200363,7 +200609,7 @@ function readImageLinux() {
|
|
|
200363
200609
|
maxBuffer: 50 * 1024 * 1024
|
|
200364
200610
|
});
|
|
200365
200611
|
if (result.status === 0 && result.stdout && result.stdout.length > 0) {
|
|
200366
|
-
|
|
200612
|
+
writeFileSync6(imagePath, result.stdout);
|
|
200367
200613
|
return { success: true, imagePath, filename };
|
|
200368
200614
|
}
|
|
200369
200615
|
return {
|
|
@@ -200396,7 +200642,7 @@ function readImageWindows() {
|
|
|
200396
200642
|
try {
|
|
200397
200643
|
const tempDir = getClipboardTempDir();
|
|
200398
200644
|
const filename = generateImageFilename();
|
|
200399
|
-
const imagePath =
|
|
200645
|
+
const imagePath = path35.join(tempDir, filename);
|
|
200400
200646
|
const script = `
|
|
200401
200647
|
Add-Type -AssemblyName System.Windows.Forms
|
|
200402
200648
|
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
@@ -200671,7 +200917,7 @@ function createPasteHandler(options2) {
|
|
|
200671
200917
|
const looksLikeImageFilename = isImageFile(eventText) && !eventText.includes("/") && !eventText.includes("\\");
|
|
200672
200918
|
if (looksLikeImageFilename) {
|
|
200673
200919
|
const clipboardFilePath = readClipboardImageFilePath();
|
|
200674
|
-
if (clipboardFilePath &&
|
|
200920
|
+
if (clipboardFilePath && path36.basename(clipboardFilePath) === eventText) {
|
|
200675
200921
|
onPasteImagePath(clipboardFilePath);
|
|
200676
200922
|
return;
|
|
200677
200923
|
}
|
|
@@ -203364,8 +203610,8 @@ var usePublishStore = create()(immer2((set3) => ({
|
|
|
203364
203610
|
|
|
203365
203611
|
// src/utils/local-agent-registry.ts
|
|
203366
203612
|
import fs28 from "fs";
|
|
203367
|
-
import
|
|
203368
|
-
import
|
|
203613
|
+
import os14 from "os";
|
|
203614
|
+
import path37 from "path";
|
|
203369
203615
|
init_src();
|
|
203370
203616
|
init_project_files();
|
|
203371
203617
|
init_constants6();
|
|
@@ -203395,9 +203641,9 @@ async function initializeAgentRegistry() {
|
|
|
203395
203641
|
}
|
|
203396
203642
|
}
|
|
203397
203643
|
var getDefaultAgentDirs2 = () => {
|
|
203398
|
-
const cwdAgents =
|
|
203399
|
-
const parentAgents =
|
|
203400
|
-
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);
|
|
203401
203647
|
return [cwdAgents, parentAgents, homeAgents];
|
|
203402
203648
|
};
|
|
203403
203649
|
var buildAgentFilePathMap = (agentsDirs) => {
|
|
@@ -203407,7 +203653,7 @@ var buildAgentFilePathMap = (agentsDirs) => {
|
|
|
203407
203653
|
try {
|
|
203408
203654
|
const entries = fs28.readdirSync(dir, { withFileTypes: true });
|
|
203409
203655
|
for (const entry of entries) {
|
|
203410
|
-
const fullPath =
|
|
203656
|
+
const fullPath = path37.join(dir, entry.name);
|
|
203411
203657
|
if (entry.isDirectory() && !entry.name.startsWith(".")) {
|
|
203412
203658
|
scanDirectory(fullPath);
|
|
203413
203659
|
continue;
|
|
@@ -203457,16 +203703,16 @@ var findAgentsDirectory = () => {
|
|
|
203457
203703
|
}
|
|
203458
203704
|
const projectRoot2 = getProjectRoot() || process.cwd();
|
|
203459
203705
|
if (projectRoot2) {
|
|
203460
|
-
const rootCandidate =
|
|
203706
|
+
const rootCandidate = path37.join(projectRoot2, AGENTS_DIR_NAME);
|
|
203461
203707
|
if (fs28.existsSync(rootCandidate) && fs28.statSync(rootCandidate).isDirectory()) {
|
|
203462
203708
|
cachedAgentsDir = rootCandidate;
|
|
203463
203709
|
return cachedAgentsDir;
|
|
203464
203710
|
}
|
|
203465
203711
|
}
|
|
203466
203712
|
let currentDir = process.cwd();
|
|
203467
|
-
const filesystemRoot =
|
|
203713
|
+
const filesystemRoot = path37.parse(currentDir).root;
|
|
203468
203714
|
while (true) {
|
|
203469
|
-
const candidate =
|
|
203715
|
+
const candidate = path37.join(currentDir, AGENTS_DIR_NAME);
|
|
203470
203716
|
if (fs28.existsSync(candidate) && fs28.statSync(candidate).isDirectory()) {
|
|
203471
203717
|
cachedAgentsDir = candidate;
|
|
203472
203718
|
return cachedAgentsDir;
|
|
@@ -203474,7 +203720,7 @@ var findAgentsDirectory = () => {
|
|
|
203474
203720
|
if (currentDir === filesystemRoot) {
|
|
203475
203721
|
break;
|
|
203476
203722
|
}
|
|
203477
|
-
const parentDir =
|
|
203723
|
+
const parentDir = path37.dirname(currentDir);
|
|
203478
203724
|
if (parentDir === currentDir) {
|
|
203479
203725
|
break;
|
|
203480
203726
|
}
|
|
@@ -210479,7 +210725,7 @@ function constructs(existing, list2) {
|
|
|
210479
210725
|
// ../node_modules/micromark-extension-gfm-autolink-literal/dev/lib/syntax.js
|
|
210480
210726
|
var wwwPrefix = { tokenize: tokenizeWwwPrefix, partial: true };
|
|
210481
210727
|
var domain2 = { tokenize: tokenizeDomain, partial: true };
|
|
210482
|
-
var
|
|
210728
|
+
var path38 = { tokenize: tokenizePath, partial: true };
|
|
210483
210729
|
var trail = { tokenize: tokenizeTrail, partial: true };
|
|
210484
210730
|
var emailDomainDotTrail = {
|
|
210485
210731
|
tokenize: tokenizeEmailDomainDotTrail,
|
|
@@ -210579,7 +210825,7 @@ function tokenizeWwwAutolink(effects, ok3, nok) {
|
|
|
210579
210825
|
}
|
|
210580
210826
|
effects.enter("literalAutolink");
|
|
210581
210827
|
effects.enter("literalAutolinkWww");
|
|
210582
|
-
return effects.check(wwwPrefix, effects.attempt(domain2, effects.attempt(
|
|
210828
|
+
return effects.check(wwwPrefix, effects.attempt(domain2, effects.attempt(path38, wwwAfter), nok), nok)(code3);
|
|
210583
210829
|
}
|
|
210584
210830
|
function wwwAfter(code3) {
|
|
210585
210831
|
effects.exit("literalAutolinkWww");
|
|
@@ -210629,7 +210875,7 @@ function tokenizeProtocolAutolink(effects, ok3, nok) {
|
|
|
210629
210875
|
return nok(code3);
|
|
210630
210876
|
}
|
|
210631
210877
|
function afterProtocol(code3) {
|
|
210632
|
-
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);
|
|
210633
210879
|
}
|
|
210634
210880
|
function protocolAfter(code3) {
|
|
210635
210881
|
effects.exit("literalAutolinkHttp");
|
|
@@ -216368,9 +216614,9 @@ class VFile {
|
|
|
216368
216614
|
get dirname() {
|
|
216369
216615
|
return typeof this.path === "string" ? default3.dirname(this.path) : undefined;
|
|
216370
216616
|
}
|
|
216371
|
-
set dirname(
|
|
216617
|
+
set dirname(dirname12) {
|
|
216372
216618
|
assertPath(this.basename, "dirname");
|
|
216373
|
-
this.path = default3.join(
|
|
216619
|
+
this.path = default3.join(dirname12 || "", this.basename);
|
|
216374
216620
|
}
|
|
216375
216621
|
get extname() {
|
|
216376
216622
|
return typeof this.path === "string" ? default3.extname(this.path) : undefined;
|
|
@@ -217525,14 +217771,14 @@ function getAgentStatusInfo(status, theme) {
|
|
|
217525
217771
|
}
|
|
217526
217772
|
|
|
217527
217773
|
// src/utils/path-helpers.ts
|
|
217528
|
-
import
|
|
217529
|
-
import
|
|
217774
|
+
import os15 from "os";
|
|
217775
|
+
import path39 from "path";
|
|
217530
217776
|
init_project_files();
|
|
217531
217777
|
function formatCwd(cwd, env3) {
|
|
217532
217778
|
if (!cwd)
|
|
217533
217779
|
return "";
|
|
217534
217780
|
const resolvedEnv = env3 ?? getCliEnv();
|
|
217535
|
-
const homeDir = resolvedEnv.HOME || resolvedEnv.USERPROFILE ||
|
|
217781
|
+
const homeDir = resolvedEnv.HOME || resolvedEnv.USERPROFILE || os15.homedir();
|
|
217536
217782
|
if (homeDir && cwd.startsWith(homeDir)) {
|
|
217537
217783
|
return "~" + cwd.slice(homeDir.length);
|
|
217538
217784
|
}
|
|
@@ -217544,7 +217790,7 @@ function getRelativePath3(filePath) {
|
|
|
217544
217790
|
const projectRoot2 = getProjectRoot();
|
|
217545
217791
|
if (!projectRoot2)
|
|
217546
217792
|
return filePath;
|
|
217547
|
-
return
|
|
217793
|
+
return path39.relative(projectRoot2, filePath);
|
|
217548
217794
|
}
|
|
217549
217795
|
|
|
217550
217796
|
// src/components/tools/diff-viewer.tsx
|
|
@@ -218121,7 +218367,7 @@ init_logger2();
|
|
|
218121
218367
|
|
|
218122
218368
|
// src/native/ripgrep.ts
|
|
218123
218369
|
init_src();
|
|
218124
|
-
import
|
|
218370
|
+
import path40 from "path";
|
|
218125
218371
|
var {spawnSync: spawnSync2 } = globalThis.Bun;
|
|
218126
218372
|
init_logger2();
|
|
218127
218373
|
var getRipgrepPath = async () => {
|
|
@@ -218129,9 +218375,9 @@ var getRipgrepPath = async () => {
|
|
|
218129
218375
|
if (!env3.LEVELCODE_IS_BINARY) {
|
|
218130
218376
|
return getBundledRgPath();
|
|
218131
218377
|
}
|
|
218132
|
-
const binaryDir =
|
|
218378
|
+
const binaryDir = path40.dirname(process.execPath);
|
|
218133
218379
|
const rgFileName = process.platform === "win32" ? "rg.exe" : "rg";
|
|
218134
|
-
const outPath =
|
|
218380
|
+
const outPath = path40.join(binaryDir, rgFileName);
|
|
218135
218381
|
const outPathExists = await Bun.file(outPath).exists();
|
|
218136
218382
|
if (outPathExists) {
|
|
218137
218383
|
return outPath;
|
|
@@ -218648,7 +218894,7 @@ var ReadDocsComponent = defineToolComponent({
|
|
|
218648
218894
|
});
|
|
218649
218895
|
|
|
218650
218896
|
// src/utils/create-run-config.ts
|
|
218651
|
-
import
|
|
218897
|
+
import path41 from "path";
|
|
218652
218898
|
|
|
218653
218899
|
// ../node_modules/ts-pattern/dist/index.js
|
|
218654
218900
|
var t2 = Symbol.for("@ts-pattern/matcher");
|
|
@@ -219902,11 +220148,11 @@ var SENSITIVE_PATTERNS = {
|
|
|
219902
220148
|
var isEnvFile = (basename2) => (basename2 === ".env" || basename2.startsWith(".env.")) && !isEnvTemplateFile(basename2);
|
|
219903
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));
|
|
219904
220150
|
var ENV_TEMPLATE_SUFFIXES = [".env.example", ".env.sample", ".env.template"];
|
|
219905
|
-
var isEnvTemplateFile = (filePath) => ENV_TEMPLATE_SUFFIXES.some((suffix) =>
|
|
220151
|
+
var isEnvTemplateFile = (filePath) => ENV_TEMPLATE_SUFFIXES.some((suffix) => path41.basename(filePath).endsWith(suffix));
|
|
219906
220152
|
function isSensitiveFile(filePath) {
|
|
219907
|
-
const basename2 =
|
|
220153
|
+
const basename2 = path41.basename(filePath);
|
|
219908
220154
|
const basenameLower = basename2.toLowerCase();
|
|
219909
|
-
const ext =
|
|
220155
|
+
const ext = path41.extname(filePath).toLowerCase();
|
|
219910
220156
|
return isEnvFile(basename2) || SENSITIVE_EXTENSIONS.has(ext) || SENSITIVE_BASENAMES.has(basename2) || matchesPattern(basenameLower);
|
|
219911
220157
|
}
|
|
219912
220158
|
var createRunConfig = (params2) => {
|
|
@@ -222441,10 +222687,10 @@ var TerminalLink = ({
|
|
|
222441
222687
|
|
|
222442
222688
|
// src/utils/open-file.ts
|
|
222443
222689
|
import { spawn as spawn4 } from "child_process";
|
|
222444
|
-
import
|
|
222690
|
+
import os16 from "os";
|
|
222445
222691
|
init_logger2();
|
|
222446
|
-
var isWindows =
|
|
222447
|
-
var isMac =
|
|
222692
|
+
var isWindows = os16.platform() === "win32";
|
|
222693
|
+
var isMac = os16.platform() === "darwin";
|
|
222448
222694
|
var escapeForShell = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
222449
222695
|
var escapeForCmd = (value) => `"${value.replace(/"/g, '""')}"`;
|
|
222450
222696
|
var replaceFilePlaceholder = (command, filePath) => {
|
|
@@ -226619,10 +226865,10 @@ function getDeviceInfo() {
|
|
|
226619
226865
|
win32: "windows",
|
|
226620
226866
|
linux: "linux"
|
|
226621
226867
|
};
|
|
226622
|
-
const
|
|
226868
|
+
const os17 = platformToOs[process.platform] ?? "linux";
|
|
226623
226869
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
226624
226870
|
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
226625
|
-
return { os:
|
|
226871
|
+
return { os: os17, timezone, locale };
|
|
226626
226872
|
}
|
|
226627
226873
|
|
|
226628
226874
|
// src/hooks/use-input-history.ts
|
|
@@ -227014,16 +227260,16 @@ init_logger2();
|
|
|
227014
227260
|
init_project_files();
|
|
227015
227261
|
init_logger2();
|
|
227016
227262
|
import * as fs29 from "fs";
|
|
227017
|
-
import
|
|
227263
|
+
import path42 from "path";
|
|
227018
227264
|
var RUN_STATE_FILENAME = "run-state.json";
|
|
227019
227265
|
var CHAT_MESSAGES_FILENAME = "chat-messages.json";
|
|
227020
227266
|
function getRunStatePath() {
|
|
227021
227267
|
const chatDir = getCurrentChatDir();
|
|
227022
|
-
return
|
|
227268
|
+
return path42.join(chatDir, RUN_STATE_FILENAME);
|
|
227023
227269
|
}
|
|
227024
227270
|
function getChatMessagesPath() {
|
|
227025
227271
|
const chatDir = getCurrentChatDir();
|
|
227026
|
-
return
|
|
227272
|
+
return path42.join(chatDir, CHAT_MESSAGES_FILENAME);
|
|
227027
227273
|
}
|
|
227028
227274
|
function saveChatState(runState, messages) {
|
|
227029
227275
|
try {
|
|
@@ -227041,8 +227287,8 @@ function loadMostRecentChatState(chatId) {
|
|
|
227041
227287
|
try {
|
|
227042
227288
|
let chatDir = null;
|
|
227043
227289
|
if (chatId && chatId.trim().length > 0) {
|
|
227044
|
-
const baseDir =
|
|
227045
|
-
const candidateDir =
|
|
227290
|
+
const baseDir = path42.join(getProjectDataDir(), "chats");
|
|
227291
|
+
const candidateDir = path42.join(baseDir, chatId.trim());
|
|
227046
227292
|
if (fs29.existsSync(candidateDir) && fs29.statSync(candidateDir).isDirectory()) {
|
|
227047
227293
|
chatDir = candidateDir;
|
|
227048
227294
|
} else {
|
|
@@ -227056,8 +227302,8 @@ function loadMostRecentChatState(chatId) {
|
|
|
227056
227302
|
logger2.debug("No previous chat directory found");
|
|
227057
227303
|
return null;
|
|
227058
227304
|
}
|
|
227059
|
-
const runStatePath =
|
|
227060
|
-
const messagesPath =
|
|
227305
|
+
const runStatePath = path42.join(chatDir, RUN_STATE_FILENAME);
|
|
227306
|
+
const messagesPath = path42.join(chatDir, CHAT_MESSAGES_FILENAME);
|
|
227061
227307
|
if (!fs29.existsSync(runStatePath) || !fs29.existsSync(messagesPath)) {
|
|
227062
227308
|
logger2.debug({ runStatePath, messagesPath }, "Missing state files in chat directory");
|
|
227063
227309
|
return null;
|
|
@@ -227066,7 +227312,7 @@ function loadMostRecentChatState(chatId) {
|
|
|
227066
227312
|
const messagesContent = fs29.readFileSync(messagesPath, "utf8");
|
|
227067
227313
|
const runState = JSON.parse(runStateContent);
|
|
227068
227314
|
const messages = JSON.parse(messagesContent);
|
|
227069
|
-
const resolvedChatId =
|
|
227315
|
+
const resolvedChatId = path42.basename(chatDir);
|
|
227070
227316
|
logger2.info({ runStatePath, messagesPath, messageCount: messages.length, chatId: resolvedChatId }, "Loaded chat state from chat directory");
|
|
227071
227317
|
return { runState, messages, chatId: resolvedChatId };
|
|
227072
227318
|
} catch (error46) {
|
|
@@ -229914,7 +230160,7 @@ function useSearchableList({
|
|
|
229914
230160
|
init_project_files();
|
|
229915
230161
|
init_logger2();
|
|
229916
230162
|
import * as fs31 from "fs";
|
|
229917
|
-
import
|
|
230163
|
+
import path43 from "path";
|
|
229918
230164
|
function getFirstUserPrompt(messages) {
|
|
229919
230165
|
for (const msg of messages) {
|
|
229920
230166
|
if (msg?.variant === "user" && msg.content) {
|
|
@@ -229929,14 +230175,14 @@ function getFirstUserPrompt(messages) {
|
|
|
229929
230175
|
}
|
|
229930
230176
|
function getAllChats(maxChats = 500) {
|
|
229931
230177
|
try {
|
|
229932
|
-
const chatsDir =
|
|
230178
|
+
const chatsDir = path43.join(getProjectDataDir(), "chats");
|
|
229933
230179
|
if (!fs31.existsSync(chatsDir)) {
|
|
229934
230180
|
return [];
|
|
229935
230181
|
}
|
|
229936
230182
|
const chatDirs = fs31.readdirSync(chatsDir);
|
|
229937
230183
|
const chatDirInfos = [];
|
|
229938
230184
|
for (const chatId of chatDirs) {
|
|
229939
|
-
const chatPath =
|
|
230185
|
+
const chatPath = path43.join(chatsDir, chatId);
|
|
229940
230186
|
try {
|
|
229941
230187
|
const stat = fs31.statSync(chatPath);
|
|
229942
230188
|
if (!stat.isDirectory())
|
|
@@ -229944,7 +230190,7 @@ function getAllChats(maxChats = 500) {
|
|
|
229944
230190
|
chatDirInfos.push({
|
|
229945
230191
|
chatId,
|
|
229946
230192
|
chatPath,
|
|
229947
|
-
messagesPath:
|
|
230193
|
+
messagesPath: path43.join(chatPath, "chat-messages.json"),
|
|
229948
230194
|
mtime: stat.mtime
|
|
229949
230195
|
});
|
|
229950
230196
|
} catch {}
|
|
@@ -231059,20 +231305,20 @@ var LoginModal = ({
|
|
|
231059
231305
|
|
|
231060
231306
|
// src/components/project-picker-screen.tsx
|
|
231061
231307
|
var import_react130 = __toESM(require_react(), 1);
|
|
231062
|
-
import
|
|
231308
|
+
import os19 from "os";
|
|
231063
231309
|
|
|
231064
231310
|
// src/hooks/use-directory-browser.ts
|
|
231065
231311
|
var import_react128 = __toESM(require_react(), 1);
|
|
231066
231312
|
import { existsSync as existsSync20, statSync as statSync8 } from "fs";
|
|
231067
|
-
import
|
|
231068
|
-
import
|
|
231313
|
+
import os17 from "os";
|
|
231314
|
+
import path45 from "path";
|
|
231069
231315
|
|
|
231070
231316
|
// src/utils/directory-browser.ts
|
|
231071
231317
|
import { readdirSync as readdirSync8, statSync as statSync7 } from "fs";
|
|
231072
|
-
import
|
|
231318
|
+
import path44 from "path";
|
|
231073
231319
|
function getDirectories(dirPath) {
|
|
231074
231320
|
const entries = [];
|
|
231075
|
-
const parentDir =
|
|
231321
|
+
const parentDir = path44.dirname(dirPath);
|
|
231076
231322
|
if (parentDir !== dirPath) {
|
|
231077
231323
|
entries.push({
|
|
231078
231324
|
name: "..",
|
|
@@ -231086,7 +231332,7 @@ function getDirectories(dirPath) {
|
|
|
231086
231332
|
for (const item of items) {
|
|
231087
231333
|
if (item.startsWith("."))
|
|
231088
231334
|
continue;
|
|
231089
|
-
const fullPath =
|
|
231335
|
+
const fullPath = path44.join(dirPath, item);
|
|
231090
231336
|
try {
|
|
231091
231337
|
const stat = statSync7(fullPath);
|
|
231092
231338
|
if (stat.isDirectory()) {
|
|
@@ -231107,7 +231353,7 @@ function getDirectories(dirPath) {
|
|
|
231107
231353
|
}
|
|
231108
231354
|
function hasGitDirectory(dirPath) {
|
|
231109
231355
|
try {
|
|
231110
|
-
const gitPath =
|
|
231356
|
+
const gitPath = path44.join(dirPath, ".git");
|
|
231111
231357
|
return statSync7(gitPath).isDirectory();
|
|
231112
231358
|
} catch {
|
|
231113
231359
|
return false;
|
|
@@ -231118,12 +231364,12 @@ function hasGitDirectory(dirPath) {
|
|
|
231118
231364
|
function useDirectoryBrowser({
|
|
231119
231365
|
initialPath
|
|
231120
231366
|
} = {}) {
|
|
231121
|
-
const [currentPath, setCurrentPath] = import_react128.useState(initialPath ??
|
|
231367
|
+
const [currentPath, setCurrentPath] = import_react128.useState(initialPath ?? os17.homedir());
|
|
231122
231368
|
const directories = import_react128.useMemo(() => getDirectories(currentPath), [currentPath]);
|
|
231123
231369
|
const isGitRepo = import_react128.useMemo(() => hasGitDirectory(currentPath), [currentPath]);
|
|
231124
231370
|
const expandPath = import_react128.useCallback((inputPath) => {
|
|
231125
231371
|
if (inputPath.startsWith("~")) {
|
|
231126
|
-
return
|
|
231372
|
+
return path45.join(os17.homedir(), inputPath.slice(1));
|
|
231127
231373
|
}
|
|
231128
231374
|
return inputPath;
|
|
231129
231375
|
}, []);
|
|
@@ -231154,28 +231400,28 @@ function useDirectoryBrowser({
|
|
|
231154
231400
|
// src/hooks/use-path-tab-completion.ts
|
|
231155
231401
|
var import_react129 = __toESM(require_react(), 1);
|
|
231156
231402
|
import { existsSync as existsSync22, statSync as statSync10 } from "fs";
|
|
231157
|
-
import
|
|
231403
|
+
import path47 from "path";
|
|
231158
231404
|
|
|
231159
231405
|
// src/utils/path-completion.ts
|
|
231160
231406
|
import { existsSync as existsSync21, readdirSync as readdirSync9, statSync as statSync9 } from "fs";
|
|
231161
|
-
import
|
|
231162
|
-
import
|
|
231407
|
+
import os18 from "os";
|
|
231408
|
+
import path46 from "path";
|
|
231163
231409
|
function getPathCompletion(inputPath) {
|
|
231164
231410
|
if (!inputPath)
|
|
231165
231411
|
return null;
|
|
231166
231412
|
let expandedPath = inputPath;
|
|
231167
|
-
const homeDir =
|
|
231413
|
+
const homeDir = os18.homedir();
|
|
231168
231414
|
if (expandedPath.startsWith("~")) {
|
|
231169
|
-
expandedPath =
|
|
231415
|
+
expandedPath = path46.join(homeDir, expandedPath.slice(1));
|
|
231170
231416
|
}
|
|
231171
231417
|
let parentDir;
|
|
231172
231418
|
let partial2;
|
|
231173
|
-
if (expandedPath.endsWith(
|
|
231419
|
+
if (expandedPath.endsWith(path46.sep)) {
|
|
231174
231420
|
parentDir = expandedPath;
|
|
231175
231421
|
partial2 = "";
|
|
231176
231422
|
} else {
|
|
231177
|
-
parentDir =
|
|
231178
|
-
partial2 =
|
|
231423
|
+
parentDir = path46.dirname(expandedPath);
|
|
231424
|
+
partial2 = path46.basename(expandedPath).toLowerCase();
|
|
231179
231425
|
}
|
|
231180
231426
|
try {
|
|
231181
231427
|
if (!existsSync21(parentDir) || !statSync9(parentDir).isDirectory()) {
|
|
@@ -231190,7 +231436,7 @@ function getPathCompletion(inputPath) {
|
|
|
231190
231436
|
for (const item of items) {
|
|
231191
231437
|
if (item.startsWith(".") && !partial2.startsWith("."))
|
|
231192
231438
|
continue;
|
|
231193
|
-
const fullPath =
|
|
231439
|
+
const fullPath = path46.join(parentDir, item);
|
|
231194
231440
|
try {
|
|
231195
231441
|
if (!statSync9(fullPath).isDirectory())
|
|
231196
231442
|
continue;
|
|
@@ -231204,7 +231450,7 @@ function getPathCompletion(inputPath) {
|
|
|
231204
231450
|
if (matches.length === 0)
|
|
231205
231451
|
return null;
|
|
231206
231452
|
if (matches.length === 1) {
|
|
231207
|
-
let completed =
|
|
231453
|
+
let completed = path46.join(parentDir, matches[0]) + path46.sep;
|
|
231208
231454
|
if (inputPath.startsWith("~") && completed.startsWith(homeDir)) {
|
|
231209
231455
|
completed = "~" + completed.slice(homeDir.length);
|
|
231210
231456
|
}
|
|
@@ -231219,7 +231465,7 @@ function getPathCompletion(inputPath) {
|
|
|
231219
231465
|
}
|
|
231220
231466
|
if (commonLength > partial2.length) {
|
|
231221
231467
|
const commonPrefix = sortedMatches[0].slice(0, commonLength);
|
|
231222
|
-
let completed =
|
|
231468
|
+
let completed = path46.join(parentDir, commonPrefix);
|
|
231223
231469
|
if (inputPath.startsWith("~") && completed.startsWith(homeDir)) {
|
|
231224
231470
|
completed = "~" + completed.slice(homeDir.length);
|
|
231225
231471
|
}
|
|
@@ -231256,7 +231502,7 @@ function usePathTabCompletion({
|
|
|
231256
231502
|
setSearchQuery(completed);
|
|
231257
231503
|
}
|
|
231258
231504
|
} else if (searchQuery.length > 0) {
|
|
231259
|
-
const relativePath =
|
|
231505
|
+
const relativePath = path47.join(currentPath, searchQuery);
|
|
231260
231506
|
const completed = getPathCompletion(relativePath);
|
|
231261
231507
|
if (completed) {
|
|
231262
231508
|
if (completed.endsWith("/")) {
|
|
@@ -231269,7 +231515,7 @@ function usePathTabCompletion({
|
|
|
231269
231515
|
}
|
|
231270
231516
|
} catch {}
|
|
231271
231517
|
}
|
|
231272
|
-
if (completed.startsWith(currentPath +
|
|
231518
|
+
if (completed.startsWith(currentPath + path47.sep)) {
|
|
231273
231519
|
setSearchQuery(completed.slice(currentPath.length + 1));
|
|
231274
231520
|
} else {
|
|
231275
231521
|
setSearchQuery(completed);
|
|
@@ -231285,10 +231531,10 @@ function usePathTabCompletion({
|
|
|
231285
231531
|
init_auth3();
|
|
231286
231532
|
init_logger2();
|
|
231287
231533
|
import fs32 from "fs";
|
|
231288
|
-
import
|
|
231534
|
+
import path48 from "path";
|
|
231289
231535
|
var MAX_RECENT_PROJECTS = 10;
|
|
231290
231536
|
var getRecentProjectsPath = () => {
|
|
231291
|
-
return
|
|
231537
|
+
return path48.join(getConfigDir2(), "recent-projects.json");
|
|
231292
231538
|
};
|
|
231293
231539
|
var loadRecentProjects = () => {
|
|
231294
231540
|
const recentProjectsPath = getRecentProjectsPath();
|
|
@@ -231389,7 +231635,7 @@ var ProjectPickerScreen = ({
|
|
|
231389
231635
|
resetKey: currentPath
|
|
231390
231636
|
});
|
|
231391
231637
|
const recentProjects = import_react130.useMemo(() => {
|
|
231392
|
-
const homeDir =
|
|
231638
|
+
const homeDir = os19.homedir();
|
|
231393
231639
|
return loadRecentProjects().filter((project) => project.path !== homeDir);
|
|
231394
231640
|
}, []);
|
|
231395
231641
|
const { terminalWidth, terminalHeight } = useTerminalLayout();
|
|
@@ -231855,15 +232101,15 @@ init_chat_store();
|
|
|
231855
232101
|
|
|
231856
232102
|
// src/utils/git.ts
|
|
231857
232103
|
import { existsSync as existsSync23 } from "fs";
|
|
231858
|
-
import { dirname as
|
|
232104
|
+
import { dirname as dirname12, join as join12 } from "path";
|
|
231859
232105
|
function findGitRoot(params2) {
|
|
231860
232106
|
const { cwd } = params2;
|
|
231861
232107
|
let currentDir = cwd;
|
|
231862
|
-
while (currentDir !==
|
|
231863
|
-
if (existsSync23(
|
|
232108
|
+
while (currentDir !== dirname12(currentDir)) {
|
|
232109
|
+
if (existsSync23(join12(currentDir, ".git"))) {
|
|
231864
232110
|
return currentDir;
|
|
231865
232111
|
}
|
|
231866
|
-
currentDir =
|
|
232112
|
+
currentDir = dirname12(currentDir);
|
|
231867
232113
|
}
|
|
231868
232114
|
return null;
|
|
231869
232115
|
}
|
|
@@ -232134,11 +232380,11 @@ init_project_files();
|
|
|
232134
232380
|
init_logger2();
|
|
232135
232381
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
232136
232382
|
import fs33 from "fs";
|
|
232137
|
-
import
|
|
232138
|
-
import
|
|
232383
|
+
import os20 from "os";
|
|
232384
|
+
import path49 from "path";
|
|
232139
232385
|
function findEnvrcDirectory(startDir) {
|
|
232140
|
-
let currentDir =
|
|
232141
|
-
const root2 =
|
|
232386
|
+
let currentDir = path49.resolve(startDir);
|
|
232387
|
+
const root2 = path49.parse(currentDir).root;
|
|
232142
232388
|
while (currentDir !== root2) {
|
|
232143
232389
|
let entries;
|
|
232144
232390
|
try {
|
|
@@ -232154,7 +232400,7 @@ function findEnvrcDirectory(startDir) {
|
|
|
232154
232400
|
if (hasGit) {
|
|
232155
232401
|
break;
|
|
232156
232402
|
}
|
|
232157
|
-
const parentDir =
|
|
232403
|
+
const parentDir = path49.dirname(currentDir);
|
|
232158
232404
|
if (parentDir === currentDir)
|
|
232159
232405
|
break;
|
|
232160
232406
|
currentDir = parentDir;
|
|
@@ -232162,7 +232408,7 @@ function findEnvrcDirectory(startDir) {
|
|
|
232162
232408
|
return null;
|
|
232163
232409
|
}
|
|
232164
232410
|
function isDirenvAvailable() {
|
|
232165
|
-
if (
|
|
232411
|
+
if (os20.platform() === "win32") {
|
|
232166
232412
|
return false;
|
|
232167
232413
|
}
|
|
232168
232414
|
try {
|
|
@@ -232254,10 +232500,10 @@ init_auth3();
|
|
|
232254
232500
|
init_logger2();
|
|
232255
232501
|
|
|
232256
232502
|
// src/utils/project-picker.ts
|
|
232257
|
-
import
|
|
232503
|
+
import path50 from "path";
|
|
232258
232504
|
function shouldShowProjectPicker(startCwd, homeDir) {
|
|
232259
|
-
const relativeToHome =
|
|
232260
|
-
return relativeToHome === "" || !relativeToHome.startsWith("..") && !
|
|
232505
|
+
const relativeToHome = path50.relative(startCwd, homeDir);
|
|
232506
|
+
return relativeToHome === "" || !relativeToHome.startsWith("..") && !path50.isAbsolute(relativeToHome);
|
|
232261
232507
|
}
|
|
232262
232508
|
|
|
232263
232509
|
// src/utils/renderer-cleanup.ts
|
|
@@ -232417,7 +232663,7 @@ async function main2() {
|
|
|
232417
232663
|
process.exit(1);
|
|
232418
232664
|
}
|
|
232419
232665
|
const projectRoot2 = getProjectRoot();
|
|
232420
|
-
const homeDir =
|
|
232666
|
+
const homeDir = os21.homedir();
|
|
232421
232667
|
const startCwd = process.cwd();
|
|
232422
232668
|
const showProjectPicker = shouldShowProjectPicker(startCwd, homeDir);
|
|
232423
232669
|
if (isPublishCommand || !hasAgentOverride) {
|
|
@@ -232496,12 +232742,12 @@ async function main2() {
|
|
|
232496
232742
|
}, [currentProjectRoot, loadFileTree]);
|
|
232497
232743
|
const handleProjectChange = import_react135.default.useCallback(async (newProjectPath) => {
|
|
232498
232744
|
process.chdir(newProjectPath);
|
|
232499
|
-
const isGitRepo = fs34.existsSync(
|
|
232500
|
-
const pathDepth = newProjectPath.split(
|
|
232745
|
+
const isGitRepo = fs34.existsSync(path51.join(newProjectPath, ".git"));
|
|
232746
|
+
const pathDepth = newProjectPath.split(path51.sep).filter(Boolean).length;
|
|
232501
232747
|
trackEvent2("cli.change_directory" /* CHANGE_DIRECTORY */, {
|
|
232502
232748
|
isGitRepo,
|
|
232503
232749
|
pathDepth,
|
|
232504
|
-
isHomeDir: newProjectPath ===
|
|
232750
|
+
isHomeDir: newProjectPath === os21.homedir()
|
|
232505
232751
|
});
|
|
232506
232752
|
setProjectRoot(newProjectPath);
|
|
232507
232753
|
resetLevelCodeClient();
|