@massa-ai/tools-api 1.61.0 → 1.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +586 -512
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8103,12 +8103,12 @@ import path8 from "path";
|
|
|
8103
8103
|
function isHost(v) {
|
|
8104
8104
|
return typeof v === "string" && HOSTS.includes(v);
|
|
8105
8105
|
}
|
|
8106
|
-
function fileLayout(host, activeDir,
|
|
8106
|
+
function fileLayout(host, activeDir, activeExt, variantsRoot) {
|
|
8107
8107
|
return {
|
|
8108
8108
|
host,
|
|
8109
8109
|
route: "files",
|
|
8110
8110
|
activeDir,
|
|
8111
|
-
|
|
8111
|
+
activeExt,
|
|
8112
8112
|
variantsRoot,
|
|
8113
8113
|
variantDir: (profile) => path8.join(variantsRoot, profile)
|
|
8114
8114
|
};
|
|
@@ -8122,19 +8122,19 @@ function resolveHostLayout(host, opts = {}) {
|
|
|
8122
8122
|
case "claude": {
|
|
8123
8123
|
const marketplaceRoot = opts.marketplaceRoot?.claude;
|
|
8124
8124
|
if (override === undefined && marketplaceRoot !== undefined) {
|
|
8125
|
-
return fileLayout(host, path8.join(marketplaceRoot, "agents"), "
|
|
8125
|
+
return fileLayout(host, path8.join(marketplaceRoot, "agents"), ".md", path8.join(marketplaceRoot, "agent-profiles"));
|
|
8126
8126
|
}
|
|
8127
8127
|
const root = override ?? path8.join(targetHome, ".claude");
|
|
8128
|
-
return fileLayout(host, path8.join(root, "agents"), "
|
|
8128
|
+
return fileLayout(host, path8.join(root, "agents"), ".md", path8.join(root, "massa-ai", "agent-profiles"));
|
|
8129
8129
|
}
|
|
8130
8130
|
case "codex": {
|
|
8131
8131
|
const root = override ?? path8.join(targetHome, ".codex");
|
|
8132
|
-
return fileLayout(host, path8.join(root, "agents"), "
|
|
8132
|
+
return fileLayout(host, path8.join(root, "agents"), ".toml", path8.join(root, "massa-ai", "agent-profiles"));
|
|
8133
8133
|
}
|
|
8134
8134
|
case "opencode": {
|
|
8135
8135
|
const root = override ?? path8.join(targetHome, ".config", "opencode");
|
|
8136
8136
|
const pluginsDir = path8.join(root, "plugins", "massa-ai");
|
|
8137
|
-
return fileLayout(host, path8.join(root, "agents"), "
|
|
8137
|
+
return fileLayout(host, path8.join(root, "agents"), ".md", path8.join(pluginsDir, "agent-profiles"));
|
|
8138
8138
|
}
|
|
8139
8139
|
}
|
|
8140
8140
|
}
|
|
@@ -8468,6 +8468,90 @@ function readInstalledPluginVersion(opts = {}) {
|
|
|
8468
8468
|
var DEFAULT_PLUGIN_KEY = "massa-ai@massa-ai";
|
|
8469
8469
|
var init_claude_marketplace = () => {};
|
|
8470
8470
|
|
|
8471
|
+
// ../../packages/shared/dist/profile-switch/ownership.js
|
|
8472
|
+
import fs8 from "fs";
|
|
8473
|
+
import path12 from "path";
|
|
8474
|
+
function isLegacyAgentName(fileName) {
|
|
8475
|
+
const base = path12.basename(fileName).replace(/\.[^.]*$/, "");
|
|
8476
|
+
return base.startsWith("massa-ai-") && LEGACY_AGENT_NAMES.includes(base.slice("massa-ai-".length));
|
|
8477
|
+
}
|
|
8478
|
+
function hasOwnedMarker(content) {
|
|
8479
|
+
const lines = content.split(`
|
|
8480
|
+
`);
|
|
8481
|
+
if (lines[0] !== "---")
|
|
8482
|
+
return false;
|
|
8483
|
+
const close = lines.indexOf("---", 1);
|
|
8484
|
+
return close !== -1 && lines[close + 1] === OWNED_MARKER_MD;
|
|
8485
|
+
}
|
|
8486
|
+
function isRegularFile(filePath) {
|
|
8487
|
+
try {
|
|
8488
|
+
return fs8.lstatSync(filePath).isFile();
|
|
8489
|
+
} catch {
|
|
8490
|
+
return false;
|
|
8491
|
+
}
|
|
8492
|
+
}
|
|
8493
|
+
function isOwnedAgentFile(filePath) {
|
|
8494
|
+
if (!isRegularFile(filePath))
|
|
8495
|
+
return false;
|
|
8496
|
+
if (!filePath.endsWith(".toml") && isLegacyAgentName(filePath))
|
|
8497
|
+
return true;
|
|
8498
|
+
let content;
|
|
8499
|
+
try {
|
|
8500
|
+
content = fs8.readFileSync(filePath, "utf8");
|
|
8501
|
+
} catch {
|
|
8502
|
+
return false;
|
|
8503
|
+
}
|
|
8504
|
+
if (filePath.endsWith(".toml"))
|
|
8505
|
+
return content.split(`
|
|
8506
|
+
`)[0] === OWNED_MARKER_TOML;
|
|
8507
|
+
return hasOwnedMarker(content);
|
|
8508
|
+
}
|
|
8509
|
+
function isOwnedAgentLink(linkPath) {
|
|
8510
|
+
try {
|
|
8511
|
+
if (!fs8.lstatSync(linkPath).isSymbolicLink())
|
|
8512
|
+
return false;
|
|
8513
|
+
} catch {
|
|
8514
|
+
return false;
|
|
8515
|
+
}
|
|
8516
|
+
if (isLegacyAgentName(linkPath))
|
|
8517
|
+
return true;
|
|
8518
|
+
const base = path12.basename(linkPath);
|
|
8519
|
+
const target = fs8.readlinkSync(linkPath);
|
|
8520
|
+
if (target.endsWith(`/opencode-plugin/agents/${base}`))
|
|
8521
|
+
return true;
|
|
8522
|
+
const escaped = base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8523
|
+
if (new RegExp(`/plugins/massa-ai/agent-profiles/.*/${escaped}$`).test(target))
|
|
8524
|
+
return true;
|
|
8525
|
+
try {
|
|
8526
|
+
return fs8.statSync(linkPath).isFile() && hasOwnedMarker(fs8.readFileSync(linkPath, "utf8"));
|
|
8527
|
+
} catch {
|
|
8528
|
+
return false;
|
|
8529
|
+
}
|
|
8530
|
+
}
|
|
8531
|
+
var OWNED_MARKER_MD = "<!-- massa-ai-owned: true -->", OWNED_MARKER_TOML = "# massa-ai-owned", LEGACY_AGENT_NAMES;
|
|
8532
|
+
var init_ownership = __esm(() => {
|
|
8533
|
+
LEGACY_AGENT_NAMES = [
|
|
8534
|
+
"architecture-specialist",
|
|
8535
|
+
"audit-specialist",
|
|
8536
|
+
"builder",
|
|
8537
|
+
"context-curator",
|
|
8538
|
+
"designer",
|
|
8539
|
+
"documentation-agent",
|
|
8540
|
+
"furps-analyst",
|
|
8541
|
+
"investigator",
|
|
8542
|
+
"judge",
|
|
8543
|
+
"meta-judge",
|
|
8544
|
+
"mobile-specialist",
|
|
8545
|
+
"navigator",
|
|
8546
|
+
"plan-critic",
|
|
8547
|
+
"planner",
|
|
8548
|
+
"requirements-analyst",
|
|
8549
|
+
"reviewer",
|
|
8550
|
+
"test-engineer",
|
|
8551
|
+
"verification-agent"
|
|
8552
|
+
];
|
|
8553
|
+
});
|
|
8554
|
+
|
|
8471
8555
|
// ../../packages/shared/dist/profile-switch/frontmatter.js
|
|
8472
8556
|
function parseFrontmatter(raw2) {
|
|
8473
8557
|
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/.exec(raw2);
|
|
@@ -8525,12 +8609,12 @@ function unquoteScalar(s) {
|
|
|
8525
8609
|
}
|
|
8526
8610
|
|
|
8527
8611
|
// ../../packages/shared/dist/profile-switch/doctor.js
|
|
8528
|
-
import
|
|
8612
|
+
import fs9 from "fs";
|
|
8529
8613
|
import os6 from "os";
|
|
8530
|
-
import
|
|
8614
|
+
import path13 from "path";
|
|
8531
8615
|
function readTextFile(filePath) {
|
|
8532
8616
|
try {
|
|
8533
|
-
return
|
|
8617
|
+
return fs9.readFileSync(filePath, "utf8");
|
|
8534
8618
|
} catch {
|
|
8535
8619
|
return null;
|
|
8536
8620
|
}
|
|
@@ -8546,7 +8630,7 @@ function readJsonFile(filePath) {
|
|
|
8546
8630
|
}
|
|
8547
8631
|
}
|
|
8548
8632
|
function readPluginVersion(pluginRoot) {
|
|
8549
|
-
const manifest = readJsonFile(
|
|
8633
|
+
const manifest = readJsonFile(path13.join(pluginRoot, ".claude-plugin", "plugin.json"));
|
|
8550
8634
|
return typeof manifest?.version === "string" ? manifest.version : null;
|
|
8551
8635
|
}
|
|
8552
8636
|
function detectEnvOverride(env3) {
|
|
@@ -8559,19 +8643,19 @@ function detectEnvOverride(env3) {
|
|
|
8559
8643
|
return null;
|
|
8560
8644
|
}
|
|
8561
8645
|
function readRoles(liveRoot, activeProfile) {
|
|
8562
|
-
const agentsDir =
|
|
8646
|
+
const agentsDir = path13.join(liveRoot, "agents");
|
|
8563
8647
|
let entries;
|
|
8564
8648
|
try {
|
|
8565
|
-
entries =
|
|
8649
|
+
entries = fs9.readdirSync(agentsDir, { withFileTypes: true });
|
|
8566
8650
|
} catch {
|
|
8567
8651
|
return [];
|
|
8568
8652
|
}
|
|
8569
8653
|
const roles = [];
|
|
8570
8654
|
for (const entry of entries) {
|
|
8571
|
-
if (!entry.
|
|
8655
|
+
if (!entry.name.endsWith(".md") || !isOwnedAgentFile(path13.join(agentsDir, entry.name))) {
|
|
8572
8656
|
continue;
|
|
8573
8657
|
}
|
|
8574
|
-
const activeRaw = readTextFile(
|
|
8658
|
+
const activeRaw = readTextFile(path13.join(agentsDir, entry.name));
|
|
8575
8659
|
let model = null;
|
|
8576
8660
|
let effort = null;
|
|
8577
8661
|
if (activeRaw !== null) {
|
|
@@ -8583,7 +8667,7 @@ function readRoles(liveRoot, activeProfile) {
|
|
|
8583
8667
|
}
|
|
8584
8668
|
let staleVariant = false;
|
|
8585
8669
|
if (activeProfile && activeRaw !== null) {
|
|
8586
|
-
const variantRaw = readTextFile(
|
|
8670
|
+
const variantRaw = readTextFile(path13.join(liveRoot, "agent-profiles", activeProfile, entry.name));
|
|
8587
8671
|
if (variantRaw !== null) {
|
|
8588
8672
|
staleVariant = variantRaw !== activeRaw;
|
|
8589
8673
|
}
|
|
@@ -8595,7 +8679,7 @@ function readRoles(liveRoot, activeProfile) {
|
|
|
8595
8679
|
function runtimeDriftReport(opts = {}) {
|
|
8596
8680
|
const targetHome = opts.targetHome ?? os6.homedir();
|
|
8597
8681
|
const host = opts.host ?? "claude";
|
|
8598
|
-
const stateFilePath = opts.stateFilePath ??
|
|
8682
|
+
const stateFilePath = opts.stateFilePath ?? path13.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8599
8683
|
let state = opts.state ?? null;
|
|
8600
8684
|
if (state === null) {
|
|
8601
8685
|
try {
|
|
@@ -8644,13 +8728,14 @@ function runtimeDriftReport(opts = {}) {
|
|
|
8644
8728
|
var ENV_OVERRIDE_VARS;
|
|
8645
8729
|
var init_doctor = __esm(() => {
|
|
8646
8730
|
init_claude_marketplace();
|
|
8731
|
+
init_ownership();
|
|
8647
8732
|
init_state();
|
|
8648
8733
|
ENV_OVERRIDE_VARS = ["CLAUDE_CODE_SUBAGENT_MODEL"];
|
|
8649
8734
|
});
|
|
8650
8735
|
|
|
8651
8736
|
// ../../packages/shared/dist/profile-switch/engine.js
|
|
8652
|
-
import
|
|
8653
|
-
import
|
|
8737
|
+
import fs10 from "fs";
|
|
8738
|
+
import path14 from "path";
|
|
8654
8739
|
import os7 from "os";
|
|
8655
8740
|
import crypto5 from "crypto";
|
|
8656
8741
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
@@ -8660,7 +8745,7 @@ function namedError3(name, message) {
|
|
|
8660
8745
|
return err;
|
|
8661
8746
|
}
|
|
8662
8747
|
function defaultStatePath(targetHome) {
|
|
8663
|
-
return
|
|
8748
|
+
return path14.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8664
8749
|
}
|
|
8665
8750
|
function resolveCommon(opts) {
|
|
8666
8751
|
const targetHome = opts.targetHome ?? os7.homedir();
|
|
@@ -8671,7 +8756,7 @@ function marketplaceRoots(targetHome, state) {
|
|
|
8671
8756
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
8672
8757
|
}
|
|
8673
8758
|
function claudeMarketplaceUnresolvedReason(targetHome) {
|
|
8674
|
-
const registryPath =
|
|
8759
|
+
const registryPath = path14.join(targetHome, ".claude", "plugins", "installed_plugins.json");
|
|
8675
8760
|
return `claude installRoute is "marketplace" but no install root could be resolved from ${registryPath} ` + "\u2014 re-run the Claude plugin installer, or verify the plugin registry file";
|
|
8676
8761
|
}
|
|
8677
8762
|
function listProfiles(opts = {}) {
|
|
@@ -8712,7 +8797,7 @@ function listProfiles(opts = {}) {
|
|
|
8712
8797
|
...claudeDriftFields(host)
|
|
8713
8798
|
};
|
|
8714
8799
|
}
|
|
8715
|
-
const installed =
|
|
8800
|
+
const installed = fs10.existsSync(layout.activeDir);
|
|
8716
8801
|
const availableProfiles = listVariantProfiles(layout);
|
|
8717
8802
|
const platform = state.platforms[host];
|
|
8718
8803
|
return {
|
|
@@ -8729,20 +8814,20 @@ function listProfiles(opts = {}) {
|
|
|
8729
8814
|
return { hosts };
|
|
8730
8815
|
}
|
|
8731
8816
|
function listVariantProfiles(layout) {
|
|
8732
|
-
if (!
|
|
8817
|
+
if (!fs10.existsSync(layout.variantsRoot))
|
|
8733
8818
|
return [];
|
|
8734
|
-
return
|
|
8819
|
+
return fs10.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
8735
8820
|
}
|
|
8736
|
-
function
|
|
8737
|
-
|
|
8738
|
-
if (starIdx === -1)
|
|
8739
|
-
return filename === glob;
|
|
8740
|
-
const prefix = glob.slice(0, starIdx);
|
|
8741
|
-
const suffix = glob.slice(starIdx + 1);
|
|
8742
|
-
return filename.length >= prefix.length + suffix.length && filename.startsWith(prefix) && filename.endsWith(suffix);
|
|
8821
|
+
function matchingFileNames(dir, ext) {
|
|
8822
|
+
return fs10.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(ext) && !isLegacyAgentName(e.name) && isOwnedAgentFile(path14.join(dir, e.name))).map((e) => e.name);
|
|
8743
8823
|
}
|
|
8744
|
-
function
|
|
8745
|
-
|
|
8824
|
+
function destIsAbsent(dest) {
|
|
8825
|
+
try {
|
|
8826
|
+
fs10.lstatSync(dest);
|
|
8827
|
+
return false;
|
|
8828
|
+
} catch {
|
|
8829
|
+
return true;
|
|
8830
|
+
}
|
|
8746
8831
|
}
|
|
8747
8832
|
function detectGitAvailability(dir) {
|
|
8748
8833
|
try {
|
|
@@ -8768,7 +8853,7 @@ function gitTrackedFileNames(dir, filenames) {
|
|
|
8768
8853
|
}
|
|
8769
8854
|
}
|
|
8770
8855
|
function checkTrackedPathGuard(activeDir, filenames) {
|
|
8771
|
-
if (filenames.length === 0 || !
|
|
8856
|
+
if (filenames.length === 0 || !fs10.existsSync(activeDir))
|
|
8772
8857
|
return GUARD_PASS;
|
|
8773
8858
|
const availability = detectGitAvailability(activeDir);
|
|
8774
8859
|
if (availability === "no-git")
|
|
@@ -8779,53 +8864,45 @@ function checkTrackedPathGuard(activeDir, filenames) {
|
|
|
8779
8864
|
if (tracked.size === 0)
|
|
8780
8865
|
return GUARD_PASS;
|
|
8781
8866
|
const offending = filenames.find((name) => tracked.has(name));
|
|
8782
|
-
return { blocked: true, path:
|
|
8867
|
+
return { blocked: true, path: path14.join(activeDir, offending), unchecked: false };
|
|
8783
8868
|
}
|
|
8784
8869
|
function assertStateWritable(stateFilePath) {
|
|
8785
|
-
const dir =
|
|
8870
|
+
const dir = path14.dirname(stateFilePath);
|
|
8786
8871
|
try {
|
|
8787
|
-
|
|
8872
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
8788
8873
|
} catch (err) {
|
|
8789
8874
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
8790
8875
|
}
|
|
8791
|
-
const checkPath =
|
|
8876
|
+
const checkPath = fs10.existsSync(stateFilePath) ? stateFilePath : dir;
|
|
8792
8877
|
try {
|
|
8793
|
-
|
|
8878
|
+
fs10.accessSync(checkPath, fs10.constants.W_OK);
|
|
8794
8879
|
} catch (err) {
|
|
8795
8880
|
throw UnwritableInstallStateError(stateFilePath, err.message);
|
|
8796
8881
|
}
|
|
8797
8882
|
}
|
|
8798
8883
|
function copyFileRouteVariant(layout, variantDir) {
|
|
8799
|
-
|
|
8884
|
+
fs10.mkdirSync(layout.activeDir, { recursive: true });
|
|
8800
8885
|
let changed = 0;
|
|
8801
|
-
for (const
|
|
8802
|
-
|
|
8886
|
+
for (const name of matchingFileNames(variantDir, layout.activeExt)) {
|
|
8887
|
+
const dest = path14.join(layout.activeDir, name);
|
|
8888
|
+
if (!destIsAbsent(dest) && !isOwnedAgentFile(dest))
|
|
8803
8889
|
continue;
|
|
8804
|
-
|
|
8890
|
+
fs10.copyFileSync(path14.join(variantDir, name), dest);
|
|
8805
8891
|
changed++;
|
|
8806
8892
|
}
|
|
8807
8893
|
return changed;
|
|
8808
8894
|
}
|
|
8809
8895
|
function repointOpencodeVariant(layout, variantDir) {
|
|
8810
|
-
|
|
8896
|
+
fs10.mkdirSync(layout.activeDir, { recursive: true });
|
|
8811
8897
|
let changed = 0;
|
|
8812
|
-
for (const
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
const target = path13.resolve(path13.join(variantDir, entry.name));
|
|
8817
|
-
let destExists = true;
|
|
8818
|
-
let destIsSymlink = false;
|
|
8819
|
-
try {
|
|
8820
|
-
destIsSymlink = fs9.lstatSync(dest).isSymbolicLink();
|
|
8821
|
-
} catch {
|
|
8822
|
-
destExists = false;
|
|
8823
|
-
}
|
|
8824
|
-
if (destExists && !destIsSymlink)
|
|
8898
|
+
for (const name of matchingFileNames(variantDir, layout.activeExt)) {
|
|
8899
|
+
const dest = path14.join(layout.activeDir, name);
|
|
8900
|
+
const target = path14.resolve(path14.join(variantDir, name));
|
|
8901
|
+
if (!destIsAbsent(dest) && !isOwnedAgentLink(dest))
|
|
8825
8902
|
continue;
|
|
8826
8903
|
const tmp = `${dest}.massa-ai-switch.${crypto5.randomUUID()}`;
|
|
8827
|
-
|
|
8828
|
-
|
|
8904
|
+
fs10.symlinkSync(target, tmp);
|
|
8905
|
+
fs10.renameSync(tmp, dest);
|
|
8829
8906
|
changed++;
|
|
8830
8907
|
}
|
|
8831
8908
|
return changed;
|
|
@@ -8865,13 +8942,13 @@ function switchProfile(opts) {
|
|
|
8865
8942
|
if (fileHosts.length === 0) {
|
|
8866
8943
|
return { profile: opts.profile, dryRun, hosts: orderRows(universe, skipRows), restartRequired: false };
|
|
8867
8944
|
}
|
|
8868
|
-
const installedFileHosts = fileHosts.filter((h) =>
|
|
8945
|
+
const installedFileHosts = fileHosts.filter((h) => fs10.existsSync(h.layout.activeDir));
|
|
8869
8946
|
if (installedFileHosts.length === 0)
|
|
8870
8947
|
throw NoHostsDetectedError();
|
|
8871
8948
|
const withAvailability = fileHosts.map((h) => {
|
|
8872
|
-
const variantsRootExists =
|
|
8949
|
+
const variantsRootExists = fs10.existsSync(h.layout.variantsRoot);
|
|
8873
8950
|
const variantDir = h.layout.variantDir(opts.profile);
|
|
8874
|
-
const available = variantsRootExists &&
|
|
8951
|
+
const available = variantsRootExists && fs10.existsSync(variantDir) && fs10.statSync(variantDir).isDirectory();
|
|
8875
8952
|
return { ...h, variantsRootExists, variantDir, available };
|
|
8876
8953
|
});
|
|
8877
8954
|
if (!withAvailability.some((h) => h.available)) {
|
|
@@ -8910,7 +8987,7 @@ function switchProfile(opts) {
|
|
|
8910
8987
|
rows.push({ host: h.host, status: "would-switch" });
|
|
8911
8988
|
continue;
|
|
8912
8989
|
}
|
|
8913
|
-
const candidateNames = matchingFileNames(h.variantDir, h.layout.
|
|
8990
|
+
const candidateNames = matchingFileNames(h.variantDir, h.layout.activeExt);
|
|
8914
8991
|
const guard2 = checkTrackedPathGuard(h.layout.activeDir, candidateNames);
|
|
8915
8992
|
if (guard2.blocked) {
|
|
8916
8993
|
rows.push({
|
|
@@ -8952,6 +9029,7 @@ var init_engine = __esm(() => {
|
|
|
8952
9029
|
init_state();
|
|
8953
9030
|
init_lock();
|
|
8954
9031
|
init_claude_marketplace();
|
|
9032
|
+
init_ownership();
|
|
8955
9033
|
init_doctor();
|
|
8956
9034
|
SwitchEngineError = class SwitchEngineError extends Error {
|
|
8957
9035
|
constructor(message) {
|
|
@@ -8969,25 +9047,25 @@ function reportSucceeded(report) {
|
|
|
8969
9047
|
}
|
|
8970
9048
|
|
|
8971
9049
|
// ../../packages/shared/dist/profile-switch/variant-sync.js
|
|
8972
|
-
import
|
|
8973
|
-
import
|
|
9050
|
+
import fs11 from "fs";
|
|
9051
|
+
import path15 from "path";
|
|
8974
9052
|
import os8 from "os";
|
|
8975
9053
|
import crypto6 from "crypto";
|
|
8976
9054
|
function defaultStatePath2(targetHome) {
|
|
8977
|
-
return
|
|
9055
|
+
return path15.join(targetHome, ".config", "massa-ai", "install-state.json");
|
|
8978
9056
|
}
|
|
8979
9057
|
function marketplaceRoots2(targetHome, state) {
|
|
8980
9058
|
return state.platforms.claude?.installRoute === "marketplace" ? { claude: resolveClaudeMarketplaceRoot({ targetHome }) ?? undefined } : {};
|
|
8981
9059
|
}
|
|
8982
9060
|
function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
8983
9061
|
const unique = `${process.pid}.${++tempFileCounter2}.${crypto6.randomBytes(6).toString("hex")}`;
|
|
8984
|
-
const tempFile =
|
|
9062
|
+
const tempFile = path15.join(destDir, `.${destName}.${unique}.tmp`);
|
|
8985
9063
|
try {
|
|
8986
|
-
|
|
8987
|
-
|
|
9064
|
+
fs11.writeFileSync(tempFile, content);
|
|
9065
|
+
fs11.renameSync(tempFile, path15.join(destDir, destName));
|
|
8988
9066
|
} catch (error) {
|
|
8989
9067
|
try {
|
|
8990
|
-
|
|
9068
|
+
fs11.unlinkSync(tempFile);
|
|
8991
9069
|
} catch {}
|
|
8992
9070
|
throw error;
|
|
8993
9071
|
}
|
|
@@ -8995,20 +9073,20 @@ function writeFileIntoDirAtomically(destDir, destName, content) {
|
|
|
8995
9073
|
function isSafeDirName(name) {
|
|
8996
9074
|
if (name === "." || name === "..")
|
|
8997
9075
|
return false;
|
|
8998
|
-
if (name.includes("/") || name.includes("\\") || name.includes(
|
|
9076
|
+
if (name.includes("/") || name.includes("\\") || name.includes(path15.sep))
|
|
8999
9077
|
return false;
|
|
9000
|
-
return
|
|
9078
|
+
return path15.basename(name) === name;
|
|
9001
9079
|
}
|
|
9002
9080
|
function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
9003
9081
|
const layout = resolveHostLayout(host, { targetHome, marketplaceRoot });
|
|
9004
9082
|
if (layout.route === "skip") {
|
|
9005
9083
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: layout.reason };
|
|
9006
9084
|
}
|
|
9007
|
-
const srcDir =
|
|
9008
|
-
if (!
|
|
9085
|
+
const srcDir = path15.join(sourceRoot, "apps", `${host}-plugin`, "agent-profiles");
|
|
9086
|
+
if (!fs11.existsSync(srcDir) || !fs11.statSync(srcDir).isDirectory()) {
|
|
9009
9087
|
return { host, status: "skipped", profiles: [], retained: [], files: 0, reason: "no generated variants for this host" };
|
|
9010
9088
|
}
|
|
9011
|
-
if (!
|
|
9089
|
+
if (!fs11.existsSync(layout.variantsRoot)) {
|
|
9012
9090
|
return {
|
|
9013
9091
|
host,
|
|
9014
9092
|
status: "skipped",
|
|
@@ -9020,24 +9098,24 @@ function syncHost(host, sourceRoot, targetHome, marketplaceRoot) {
|
|
|
9020
9098
|
}
|
|
9021
9099
|
const profiles = [];
|
|
9022
9100
|
let files = 0;
|
|
9023
|
-
for (const entry of
|
|
9101
|
+
for (const entry of fs11.readdirSync(srcDir, { withFileTypes: true })) {
|
|
9024
9102
|
if (!entry.isDirectory())
|
|
9025
9103
|
continue;
|
|
9026
9104
|
if (!isSafeDirName(entry.name))
|
|
9027
9105
|
continue;
|
|
9028
|
-
const srcProfileDir =
|
|
9029
|
-
const destProfileDir =
|
|
9030
|
-
|
|
9031
|
-
for (const fileEntry of
|
|
9106
|
+
const srcProfileDir = path15.join(srcDir, entry.name);
|
|
9107
|
+
const destProfileDir = path15.join(layout.variantsRoot, entry.name);
|
|
9108
|
+
fs11.mkdirSync(destProfileDir, { recursive: true });
|
|
9109
|
+
for (const fileEntry of fs11.readdirSync(srcProfileDir, { withFileTypes: true })) {
|
|
9032
9110
|
if (!fileEntry.isFile())
|
|
9033
9111
|
continue;
|
|
9034
|
-
const content =
|
|
9112
|
+
const content = fs11.readFileSync(path15.join(srcProfileDir, fileEntry.name));
|
|
9035
9113
|
writeFileIntoDirAtomically(destProfileDir, fileEntry.name, content);
|
|
9036
9114
|
files++;
|
|
9037
9115
|
}
|
|
9038
9116
|
profiles.push(entry.name);
|
|
9039
9117
|
}
|
|
9040
|
-
const retained =
|
|
9118
|
+
const retained = fs11.readdirSync(layout.variantsRoot, { withFileTypes: true }).filter((e) => e.isDirectory() && !profiles.includes(e.name)).map((e) => e.name).sort();
|
|
9041
9119
|
return { host, status: "synced", profiles: profiles.sort(), retained, files };
|
|
9042
9120
|
}
|
|
9043
9121
|
function syncGeneratedVariants(opts) {
|
|
@@ -9072,14 +9150,14 @@ var init_variant_sync = __esm(() => {
|
|
|
9072
9150
|
});
|
|
9073
9151
|
|
|
9074
9152
|
// ../../packages/shared/dist/profile-switch/repo-root.js
|
|
9075
|
-
import
|
|
9076
|
-
import
|
|
9153
|
+
import fs12 from "fs";
|
|
9154
|
+
import path16 from "path";
|
|
9077
9155
|
function findRepoRootWithMarker(startDir, marker, maxLevels) {
|
|
9078
9156
|
let dir = startDir;
|
|
9079
9157
|
for (let i = 0;i <= maxLevels; i++) {
|
|
9080
|
-
if (
|
|
9158
|
+
if (fs12.existsSync(path16.join(dir, marker)))
|
|
9081
9159
|
return dir;
|
|
9082
|
-
const parent =
|
|
9160
|
+
const parent = path16.dirname(dir);
|
|
9083
9161
|
if (parent === dir)
|
|
9084
9162
|
break;
|
|
9085
9163
|
dir = parent;
|
|
@@ -9102,11 +9180,6 @@ var init_rules = __esm(() => {
|
|
|
9102
9180
|
defaultEnabled: true,
|
|
9103
9181
|
description: "Load the massa-ai skill as the workflow router before substantive work."
|
|
9104
9182
|
},
|
|
9105
|
-
{
|
|
9106
|
-
id: "persona-router",
|
|
9107
|
-
defaultEnabled: true,
|
|
9108
|
-
description: "Select one cataloged specialist persona after massa-ai context is available."
|
|
9109
|
-
},
|
|
9110
9183
|
{
|
|
9111
9184
|
id: "dedupe-guardrails",
|
|
9112
9185
|
defaultEnabled: true,
|
|
@@ -9195,6 +9268,7 @@ var init_dist = __esm(() => {
|
|
|
9195
9268
|
init_state();
|
|
9196
9269
|
init_lock();
|
|
9197
9270
|
init_engine();
|
|
9271
|
+
init_ownership();
|
|
9198
9272
|
init_variant_sync();
|
|
9199
9273
|
init_repo_root();
|
|
9200
9274
|
init_doctor();
|
|
@@ -10720,7 +10794,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
10720
10794
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
10721
10795
|
const len = $0.length;
|
|
10722
10796
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
10723
|
-
}, defaultPlatform,
|
|
10797
|
+
}, defaultPlatform, path17, sep, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a12, b = {}) => Object.assign({}, a12, b), defaults = (def) => {
|
|
10724
10798
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
10725
10799
|
return minimatch;
|
|
10726
10800
|
}
|
|
@@ -10778,11 +10852,11 @@ var init_esm = __esm(() => {
|
|
|
10778
10852
|
starRE = /^\*+$/;
|
|
10779
10853
|
qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
10780
10854
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
10781
|
-
|
|
10855
|
+
path17 = {
|
|
10782
10856
|
win32: { sep: "\\" },
|
|
10783
10857
|
posix: { sep: "/" }
|
|
10784
10858
|
};
|
|
10785
|
-
sep = defaultPlatform === "win32" ?
|
|
10859
|
+
sep = defaultPlatform === "win32" ? path17.win32.sep : path17.posix.sep;
|
|
10786
10860
|
minimatch.sep = sep;
|
|
10787
10861
|
GLOBSTAR = Symbol("globstar **");
|
|
10788
10862
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -12748,12 +12822,12 @@ var init_esm4 = __esm(() => {
|
|
|
12748
12822
|
childrenCache() {
|
|
12749
12823
|
return this.#children;
|
|
12750
12824
|
}
|
|
12751
|
-
resolve(
|
|
12752
|
-
if (!
|
|
12825
|
+
resolve(path18) {
|
|
12826
|
+
if (!path18) {
|
|
12753
12827
|
return this;
|
|
12754
12828
|
}
|
|
12755
|
-
const rootPath = this.getRootString(
|
|
12756
|
-
const dir =
|
|
12829
|
+
const rootPath = this.getRootString(path18);
|
|
12830
|
+
const dir = path18.substring(rootPath.length);
|
|
12757
12831
|
const dirParts = dir.split(this.splitSep);
|
|
12758
12832
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
12759
12833
|
return result;
|
|
@@ -13281,8 +13355,8 @@ var init_esm4 = __esm(() => {
|
|
|
13281
13355
|
newChild(name, type = UNKNOWN, opts = {}) {
|
|
13282
13356
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
13283
13357
|
}
|
|
13284
|
-
getRootString(
|
|
13285
|
-
return win32.parse(
|
|
13358
|
+
getRootString(path18) {
|
|
13359
|
+
return win32.parse(path18).root;
|
|
13286
13360
|
}
|
|
13287
13361
|
getRoot(rootPath) {
|
|
13288
13362
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -13307,8 +13381,8 @@ var init_esm4 = __esm(() => {
|
|
|
13307
13381
|
constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
|
|
13308
13382
|
super(name, type, root, roots, nocase, children, opts);
|
|
13309
13383
|
}
|
|
13310
|
-
getRootString(
|
|
13311
|
-
return
|
|
13384
|
+
getRootString(path18) {
|
|
13385
|
+
return path18.startsWith("/") ? "/" : "";
|
|
13312
13386
|
}
|
|
13313
13387
|
getRoot(_rootPath) {
|
|
13314
13388
|
return this.root;
|
|
@@ -13327,8 +13401,8 @@ var init_esm4 = __esm(() => {
|
|
|
13327
13401
|
#children;
|
|
13328
13402
|
nocase;
|
|
13329
13403
|
#fs;
|
|
13330
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
13331
|
-
this.#fs = fsFromOption(
|
|
13404
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs13 = defaultFS } = {}) {
|
|
13405
|
+
this.#fs = fsFromOption(fs13);
|
|
13332
13406
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
13333
13407
|
cwd = fileURLToPath(cwd);
|
|
13334
13408
|
}
|
|
@@ -13364,11 +13438,11 @@ var init_esm4 = __esm(() => {
|
|
|
13364
13438
|
}
|
|
13365
13439
|
this.cwd = prev;
|
|
13366
13440
|
}
|
|
13367
|
-
depth(
|
|
13368
|
-
if (typeof
|
|
13369
|
-
|
|
13441
|
+
depth(path18 = this.cwd) {
|
|
13442
|
+
if (typeof path18 === "string") {
|
|
13443
|
+
path18 = this.cwd.resolve(path18);
|
|
13370
13444
|
}
|
|
13371
|
-
return
|
|
13445
|
+
return path18.depth();
|
|
13372
13446
|
}
|
|
13373
13447
|
childrenCache() {
|
|
13374
13448
|
return this.#children;
|
|
@@ -13784,9 +13858,9 @@ var init_esm4 = __esm(() => {
|
|
|
13784
13858
|
process2();
|
|
13785
13859
|
return results;
|
|
13786
13860
|
}
|
|
13787
|
-
chdir(
|
|
13861
|
+
chdir(path18 = this.cwd) {
|
|
13788
13862
|
const oldCwd = this.cwd;
|
|
13789
|
-
this.cwd = typeof
|
|
13863
|
+
this.cwd = typeof path18 === "string" ? this.cwd.resolve(path18) : path18;
|
|
13790
13864
|
this.cwd[setAsCwd](oldCwd);
|
|
13791
13865
|
}
|
|
13792
13866
|
};
|
|
@@ -13803,8 +13877,8 @@ var init_esm4 = __esm(() => {
|
|
|
13803
13877
|
parseRootPath(dir) {
|
|
13804
13878
|
return win32.parse(dir).root.toUpperCase();
|
|
13805
13879
|
}
|
|
13806
|
-
newRoot(
|
|
13807
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
13880
|
+
newRoot(fs13) {
|
|
13881
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs13 });
|
|
13808
13882
|
}
|
|
13809
13883
|
isAbsolute(p) {
|
|
13810
13884
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -13820,8 +13894,8 @@ var init_esm4 = __esm(() => {
|
|
|
13820
13894
|
parseRootPath(_dir) {
|
|
13821
13895
|
return "/";
|
|
13822
13896
|
}
|
|
13823
|
-
newRoot(
|
|
13824
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
13897
|
+
newRoot(fs13) {
|
|
13898
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs13 });
|
|
13825
13899
|
}
|
|
13826
13900
|
isAbsolute(p) {
|
|
13827
13901
|
return p.startsWith("/");
|
|
@@ -14078,8 +14152,8 @@ class MatchRecord {
|
|
|
14078
14152
|
this.store.set(target, current === undefined ? n2 : n2 & current);
|
|
14079
14153
|
}
|
|
14080
14154
|
entries() {
|
|
14081
|
-
return [...this.store.entries()].map(([
|
|
14082
|
-
|
|
14155
|
+
return [...this.store.entries()].map(([path18, n2]) => [
|
|
14156
|
+
path18,
|
|
14083
14157
|
!!(n2 & 2),
|
|
14084
14158
|
!!(n2 & 1)
|
|
14085
14159
|
]);
|
|
@@ -14283,9 +14357,9 @@ class GlobUtil {
|
|
|
14283
14357
|
signal;
|
|
14284
14358
|
maxDepth;
|
|
14285
14359
|
includeChildMatches;
|
|
14286
|
-
constructor(patterns,
|
|
14360
|
+
constructor(patterns, path18, opts) {
|
|
14287
14361
|
this.patterns = patterns;
|
|
14288
|
-
this.path =
|
|
14362
|
+
this.path = path18;
|
|
14289
14363
|
this.opts = opts;
|
|
14290
14364
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
14291
14365
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -14304,11 +14378,11 @@ class GlobUtil {
|
|
|
14304
14378
|
});
|
|
14305
14379
|
}
|
|
14306
14380
|
}
|
|
14307
|
-
#ignored(
|
|
14308
|
-
return this.seen.has(
|
|
14381
|
+
#ignored(path18) {
|
|
14382
|
+
return this.seen.has(path18) || !!this.#ignore?.ignored?.(path18);
|
|
14309
14383
|
}
|
|
14310
|
-
#childrenIgnored(
|
|
14311
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
14384
|
+
#childrenIgnored(path18) {
|
|
14385
|
+
return !!this.#ignore?.childrenIgnored?.(path18);
|
|
14312
14386
|
}
|
|
14313
14387
|
pause() {
|
|
14314
14388
|
this.paused = true;
|
|
@@ -14525,8 +14599,8 @@ var init_walker = __esm(() => {
|
|
|
14525
14599
|
init_processor();
|
|
14526
14600
|
GlobWalker = class GlobWalker extends GlobUtil {
|
|
14527
14601
|
matches = new Set;
|
|
14528
|
-
constructor(patterns,
|
|
14529
|
-
super(patterns,
|
|
14602
|
+
constructor(patterns, path18, opts) {
|
|
14603
|
+
super(patterns, path18, opts);
|
|
14530
14604
|
}
|
|
14531
14605
|
matchEmit(e) {
|
|
14532
14606
|
this.matches.add(e);
|
|
@@ -14563,8 +14637,8 @@ var init_walker = __esm(() => {
|
|
|
14563
14637
|
};
|
|
14564
14638
|
GlobStream = class GlobStream extends GlobUtil {
|
|
14565
14639
|
results;
|
|
14566
|
-
constructor(patterns,
|
|
14567
|
-
super(patterns,
|
|
14640
|
+
constructor(patterns, path18, opts) {
|
|
14641
|
+
super(patterns, path18, opts);
|
|
14568
14642
|
this.results = new Minipass({
|
|
14569
14643
|
signal: this.signal,
|
|
14570
14644
|
objectMode: true
|
|
@@ -14992,20 +15066,20 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
14992
15066
|
var throwError = (message, Ctor) => {
|
|
14993
15067
|
throw new Ctor(message);
|
|
14994
15068
|
};
|
|
14995
|
-
var checkPath = (
|
|
14996
|
-
if (!isString(
|
|
15069
|
+
var checkPath = (path18, originalPath, doThrow) => {
|
|
15070
|
+
if (!isString(path18)) {
|
|
14997
15071
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
14998
15072
|
}
|
|
14999
|
-
if (!
|
|
15073
|
+
if (!path18) {
|
|
15000
15074
|
return doThrow(`path must not be empty`, TypeError);
|
|
15001
15075
|
}
|
|
15002
|
-
if (checkPath.isNotRelative(
|
|
15076
|
+
if (checkPath.isNotRelative(path18)) {
|
|
15003
15077
|
const r2 = "`path.relative()`d";
|
|
15004
15078
|
return doThrow(`path should be a ${r2} string, but got "${originalPath}"`, RangeError);
|
|
15005
15079
|
}
|
|
15006
15080
|
return true;
|
|
15007
15081
|
};
|
|
15008
|
-
var isNotRelative = (
|
|
15082
|
+
var isNotRelative = (path18) => REGEX_TEST_INVALID_PATH.test(path18);
|
|
15009
15083
|
checkPath.isNotRelative = isNotRelative;
|
|
15010
15084
|
checkPath.convert = (p) => p;
|
|
15011
15085
|
|
|
@@ -15048,7 +15122,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
15048
15122
|
addPattern(pattern) {
|
|
15049
15123
|
return this.add(pattern);
|
|
15050
15124
|
}
|
|
15051
|
-
_testOne(
|
|
15125
|
+
_testOne(path18, checkUnignored) {
|
|
15052
15126
|
let ignored = false;
|
|
15053
15127
|
let unignored = false;
|
|
15054
15128
|
this._rules.forEach((rule) => {
|
|
@@ -15056,7 +15130,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
15056
15130
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
15057
15131
|
return;
|
|
15058
15132
|
}
|
|
15059
|
-
const matched = rule.regex.test(
|
|
15133
|
+
const matched = rule.regex.test(path18);
|
|
15060
15134
|
if (matched) {
|
|
15061
15135
|
ignored = !negative;
|
|
15062
15136
|
unignored = negative;
|
|
@@ -15068,39 +15142,39 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
15068
15142
|
};
|
|
15069
15143
|
}
|
|
15070
15144
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
15071
|
-
const
|
|
15072
|
-
checkPath(
|
|
15073
|
-
return this._t(
|
|
15145
|
+
const path18 = originalPath && checkPath.convert(originalPath);
|
|
15146
|
+
checkPath(path18, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
15147
|
+
return this._t(path18, cache, checkUnignored, slices);
|
|
15074
15148
|
}
|
|
15075
|
-
_t(
|
|
15076
|
-
if (
|
|
15077
|
-
return cache[
|
|
15149
|
+
_t(path18, cache, checkUnignored, slices) {
|
|
15150
|
+
if (path18 in cache) {
|
|
15151
|
+
return cache[path18];
|
|
15078
15152
|
}
|
|
15079
15153
|
if (!slices) {
|
|
15080
|
-
slices =
|
|
15154
|
+
slices = path18.split(SLASH);
|
|
15081
15155
|
}
|
|
15082
15156
|
slices.pop();
|
|
15083
15157
|
if (!slices.length) {
|
|
15084
|
-
return cache[
|
|
15158
|
+
return cache[path18] = this._testOne(path18, checkUnignored);
|
|
15085
15159
|
}
|
|
15086
15160
|
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
15087
|
-
return cache[
|
|
15161
|
+
return cache[path18] = parent.ignored ? parent : this._testOne(path18, checkUnignored);
|
|
15088
15162
|
}
|
|
15089
|
-
ignores(
|
|
15090
|
-
return this._test(
|
|
15163
|
+
ignores(path18) {
|
|
15164
|
+
return this._test(path18, this._ignoreCache, false).ignored;
|
|
15091
15165
|
}
|
|
15092
15166
|
createFilter() {
|
|
15093
|
-
return (
|
|
15167
|
+
return (path18) => !this.ignores(path18);
|
|
15094
15168
|
}
|
|
15095
15169
|
filter(paths) {
|
|
15096
15170
|
return makeArray(paths).filter(this.createFilter());
|
|
15097
15171
|
}
|
|
15098
|
-
test(
|
|
15099
|
-
return this._test(
|
|
15172
|
+
test(path18) {
|
|
15173
|
+
return this._test(path18, this._testCache, true);
|
|
15100
15174
|
}
|
|
15101
15175
|
}
|
|
15102
15176
|
var factory = (options) => new Ignore2(options);
|
|
15103
|
-
var isPathValid = (
|
|
15177
|
+
var isPathValid = (path18) => checkPath(path18 && checkPath.convert(path18), path18, RETURN_FALSE);
|
|
15104
15178
|
factory.isPathValid = isPathValid;
|
|
15105
15179
|
factory.default = factory;
|
|
15106
15180
|
module.exports = factory;
|
|
@@ -15108,7 +15182,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
15108
15182
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
15109
15183
|
checkPath.convert = makePosix;
|
|
15110
15184
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
15111
|
-
checkPath.isNotRelative = (
|
|
15185
|
+
checkPath.isNotRelative = (path18) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path18) || isNotRelative(path18);
|
|
15112
15186
|
}
|
|
15113
15187
|
});
|
|
15114
15188
|
|
|
@@ -15170,18 +15244,18 @@ function validatePolicy(policy, opts = {}) {
|
|
|
15170
15244
|
}
|
|
15171
15245
|
}
|
|
15172
15246
|
}
|
|
15173
|
-
function
|
|
15247
|
+
function matchesGlob(path18, pattern) {
|
|
15174
15248
|
let re = regexCache.get(pattern);
|
|
15175
15249
|
if (!re) {
|
|
15176
15250
|
re = globToRegex(pattern);
|
|
15177
15251
|
regexCache.set(pattern, re);
|
|
15178
15252
|
}
|
|
15179
|
-
return re.test(
|
|
15253
|
+
return re.test(path18);
|
|
15180
15254
|
}
|
|
15181
15255
|
var DEFAULT_POLICY, applyPolicy = (filePath, policy) => {
|
|
15182
15256
|
const normalized = filePath.trim();
|
|
15183
15257
|
for (const rule of policy.rules) {
|
|
15184
|
-
if (
|
|
15258
|
+
if (matchesGlob(normalized, rule.pattern))
|
|
15185
15259
|
return rule.disposition;
|
|
15186
15260
|
}
|
|
15187
15261
|
return "Keep";
|
|
@@ -15193,8 +15267,8 @@ var init_capture_policy = __esm(() => {
|
|
|
15193
15267
|
});
|
|
15194
15268
|
|
|
15195
15269
|
// ../../packages/core/dist/services/search/ignore-patterns.js
|
|
15196
|
-
import
|
|
15197
|
-
import
|
|
15270
|
+
import fs13 from "fs/promises";
|
|
15271
|
+
import path18 from "path";
|
|
15198
15272
|
function buildExtensionGlob(extensions2) {
|
|
15199
15273
|
return extensions2.map((ext2) => `**/*${ext2}`);
|
|
15200
15274
|
}
|
|
@@ -15217,8 +15291,8 @@ async function loadProjectIgnore(projectPath) {
|
|
|
15217
15291
|
const ig = ignore();
|
|
15218
15292
|
ig.add(DEFAULT_IGNORES);
|
|
15219
15293
|
try {
|
|
15220
|
-
const gitignorePath =
|
|
15221
|
-
const gitignoreContent = await
|
|
15294
|
+
const gitignorePath = path18.join(projectPath, ".gitignore");
|
|
15295
|
+
const gitignoreContent = await fs13.readFile(gitignorePath, "utf8");
|
|
15222
15296
|
const rules = gitignoreContent.split(`
|
|
15223
15297
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
15224
15298
|
ig.add(rules);
|
|
@@ -15472,8 +15546,8 @@ var init_alias_resolver = __esm(() => {
|
|
|
15472
15546
|
});
|
|
15473
15547
|
|
|
15474
15548
|
// ../../packages/core/dist/services/search/index-manager.js
|
|
15475
|
-
import
|
|
15476
|
-
import
|
|
15549
|
+
import fs14 from "fs";
|
|
15550
|
+
import path19 from "path";
|
|
15477
15551
|
|
|
15478
15552
|
class IndexManager {
|
|
15479
15553
|
metadataCache = new Map;
|
|
@@ -15566,9 +15640,9 @@ class IndexManager {
|
|
|
15566
15640
|
const fileMetadata = {};
|
|
15567
15641
|
let totalSize = 0;
|
|
15568
15642
|
for (const filePath of indexedFiles) {
|
|
15569
|
-
const fullPath =
|
|
15643
|
+
const fullPath = path19.join(projectPath, filePath);
|
|
15570
15644
|
try {
|
|
15571
|
-
const stat2 = await
|
|
15645
|
+
const stat2 = await fs14.promises.stat(fullPath);
|
|
15572
15646
|
fileMetadata[filePath] = {
|
|
15573
15647
|
path: filePath,
|
|
15574
15648
|
mtime: stat2.mtimeMs,
|
|
@@ -15619,9 +15693,9 @@ class IndexManager {
|
|
|
15619
15693
|
if (ig.ignores(match2)) {
|
|
15620
15694
|
continue;
|
|
15621
15695
|
}
|
|
15622
|
-
const fullPath =
|
|
15696
|
+
const fullPath = path19.join(projectPath, match2);
|
|
15623
15697
|
try {
|
|
15624
|
-
const stat2 = await
|
|
15698
|
+
const stat2 = await fs14.promises.stat(fullPath);
|
|
15625
15699
|
files.set(match2, {
|
|
15626
15700
|
path: match2,
|
|
15627
15701
|
mtime: stat2.mtimeMs,
|
|
@@ -16072,10 +16146,10 @@ function mergeDefs(...defs) {
|
|
|
16072
16146
|
function cloneDef(schema) {
|
|
16073
16147
|
return mergeDefs(schema._zod.def);
|
|
16074
16148
|
}
|
|
16075
|
-
function getElementAtPath(obj,
|
|
16076
|
-
if (!
|
|
16149
|
+
function getElementAtPath(obj, path20) {
|
|
16150
|
+
if (!path20)
|
|
16077
16151
|
return obj;
|
|
16078
|
-
return
|
|
16152
|
+
return path20.reduce((acc, key) => acc?.[key], obj);
|
|
16079
16153
|
}
|
|
16080
16154
|
function promiseAllObject(promisesObj) {
|
|
16081
16155
|
const keys = Object.keys(promisesObj);
|
|
@@ -16403,11 +16477,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
16403
16477
|
}
|
|
16404
16478
|
return false;
|
|
16405
16479
|
}
|
|
16406
|
-
function prefixIssues(
|
|
16480
|
+
function prefixIssues(path20, issues) {
|
|
16407
16481
|
return issues.map((iss) => {
|
|
16408
16482
|
var _a4;
|
|
16409
16483
|
(_a4 = iss).path ?? (_a4.path = []);
|
|
16410
|
-
iss.path.unshift(
|
|
16484
|
+
iss.path.unshift(path20);
|
|
16411
16485
|
return iss;
|
|
16412
16486
|
});
|
|
16413
16487
|
}
|
|
@@ -16620,16 +16694,16 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
16620
16694
|
}
|
|
16621
16695
|
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
16622
16696
|
const fieldErrors = { _errors: [] };
|
|
16623
|
-
const processError = (error2,
|
|
16697
|
+
const processError = (error2, path20 = []) => {
|
|
16624
16698
|
for (const issue2 of error2.issues) {
|
|
16625
16699
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16626
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16700
|
+
issue2.errors.map((issues) => processError({ issues }, [...path20, ...issue2.path]));
|
|
16627
16701
|
} else if (issue2.code === "invalid_key") {
|
|
16628
|
-
processError({ issues: issue2.issues }, [...
|
|
16702
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
16629
16703
|
} else if (issue2.code === "invalid_element") {
|
|
16630
|
-
processError({ issues: issue2.issues }, [...
|
|
16704
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
16631
16705
|
} else {
|
|
16632
|
-
const fullpath = [...
|
|
16706
|
+
const fullpath = [...path20, ...issue2.path];
|
|
16633
16707
|
if (fullpath.length === 0) {
|
|
16634
16708
|
fieldErrors._errors.push(mapper(issue2));
|
|
16635
16709
|
} else {
|
|
@@ -16656,17 +16730,17 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
16656
16730
|
}
|
|
16657
16731
|
function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
16658
16732
|
const result = { errors: [] };
|
|
16659
|
-
const processError = (error2,
|
|
16733
|
+
const processError = (error2, path20 = []) => {
|
|
16660
16734
|
var _a4, _b;
|
|
16661
16735
|
for (const issue2 of error2.issues) {
|
|
16662
16736
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
16663
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16737
|
+
issue2.errors.map((issues) => processError({ issues }, [...path20, ...issue2.path]));
|
|
16664
16738
|
} else if (issue2.code === "invalid_key") {
|
|
16665
|
-
processError({ issues: issue2.issues }, [...
|
|
16739
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
16666
16740
|
} else if (issue2.code === "invalid_element") {
|
|
16667
|
-
processError({ issues: issue2.issues }, [...
|
|
16741
|
+
processError({ issues: issue2.issues }, [...path20, ...issue2.path]);
|
|
16668
16742
|
} else {
|
|
16669
|
-
const fullpath = [...
|
|
16743
|
+
const fullpath = [...path20, ...issue2.path];
|
|
16670
16744
|
if (fullpath.length === 0) {
|
|
16671
16745
|
result.errors.push(mapper(issue2));
|
|
16672
16746
|
continue;
|
|
@@ -16698,8 +16772,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
|
16698
16772
|
}
|
|
16699
16773
|
function toDotPath(_path) {
|
|
16700
16774
|
const segs = [];
|
|
16701
|
-
const
|
|
16702
|
-
for (const seg of
|
|
16775
|
+
const path20 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16776
|
+
for (const seg of path20) {
|
|
16703
16777
|
if (typeof seg === "number")
|
|
16704
16778
|
segs.push(`[${seg}]`);
|
|
16705
16779
|
else if (typeof seg === "symbol")
|
|
@@ -29702,13 +29776,13 @@ function resolveRef(ref, ctx) {
|
|
|
29702
29776
|
if (!ref.startsWith("#")) {
|
|
29703
29777
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29704
29778
|
}
|
|
29705
|
-
const
|
|
29706
|
-
if (
|
|
29779
|
+
const path20 = ref.slice(1).split("/").filter(Boolean);
|
|
29780
|
+
if (path20.length === 0) {
|
|
29707
29781
|
return ctx.rootSchema;
|
|
29708
29782
|
}
|
|
29709
29783
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29710
|
-
if (
|
|
29711
|
-
const key =
|
|
29784
|
+
if (path20[0] === defsKey) {
|
|
29785
|
+
const key = path20[1];
|
|
29712
29786
|
if (!key || !ctx.defs[key]) {
|
|
29713
29787
|
throw new Error(`Reference not found: ${ref}`);
|
|
29714
29788
|
}
|
|
@@ -31197,8 +31271,8 @@ class ParseStatus2 {
|
|
|
31197
31271
|
}
|
|
31198
31272
|
}
|
|
31199
31273
|
var makeIssue2 = (params) => {
|
|
31200
|
-
const { data, path:
|
|
31201
|
-
const fullPath = [...
|
|
31274
|
+
const { data, path: path20, errorMaps, issueData } = params;
|
|
31275
|
+
const fullPath = [...path20, ...issueData.path || []];
|
|
31202
31276
|
const fullIssue = {
|
|
31203
31277
|
...issueData,
|
|
31204
31278
|
path: fullPath
|
|
@@ -31243,11 +31317,11 @@ var init_errorUtil = __esm(() => {
|
|
|
31243
31317
|
|
|
31244
31318
|
// ../../node_modules/zod/v3/types.js
|
|
31245
31319
|
class ParseInputLazyPath2 {
|
|
31246
|
-
constructor(parent, value,
|
|
31320
|
+
constructor(parent, value, path20, key) {
|
|
31247
31321
|
this._cachedPath = [];
|
|
31248
31322
|
this.parent = parent;
|
|
31249
31323
|
this.data = value;
|
|
31250
|
-
this._path =
|
|
31324
|
+
this._path = path20;
|
|
31251
31325
|
this._key = key;
|
|
31252
31326
|
}
|
|
31253
31327
|
get path() {
|
|
@@ -37312,23 +37386,23 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
37312
37386
|
writeAuthConfig: () => writeAuthConfig
|
|
37313
37387
|
});
|
|
37314
37388
|
module.exports = __toCommonJS2(auth_config_exports);
|
|
37315
|
-
var
|
|
37316
|
-
var
|
|
37389
|
+
var fs15 = __toESM2(__require("fs"));
|
|
37390
|
+
var path20 = __toESM2(__require("path"));
|
|
37317
37391
|
var import_token_util = require_token_util();
|
|
37318
37392
|
function getAuthConfigPath() {
|
|
37319
37393
|
const dataDir = (0, import_token_util.getVercelDataDir)();
|
|
37320
37394
|
if (!dataDir) {
|
|
37321
37395
|
throw new Error(`Unable to find Vercel CLI data directory. Your platform: ${process.platform}. Supported: darwin, linux, win32.`);
|
|
37322
37396
|
}
|
|
37323
|
-
return
|
|
37397
|
+
return path20.join(dataDir, "auth.json");
|
|
37324
37398
|
}
|
|
37325
37399
|
function readAuthConfig() {
|
|
37326
37400
|
try {
|
|
37327
37401
|
const authPath = getAuthConfigPath();
|
|
37328
|
-
if (!
|
|
37402
|
+
if (!fs15.existsSync(authPath)) {
|
|
37329
37403
|
return null;
|
|
37330
37404
|
}
|
|
37331
|
-
const content =
|
|
37405
|
+
const content = fs15.readFileSync(authPath, "utf8");
|
|
37332
37406
|
if (!content) {
|
|
37333
37407
|
return null;
|
|
37334
37408
|
}
|
|
@@ -37339,11 +37413,11 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
37339
37413
|
}
|
|
37340
37414
|
function writeAuthConfig(config3) {
|
|
37341
37415
|
const authPath = getAuthConfigPath();
|
|
37342
|
-
const authDir =
|
|
37343
|
-
if (!
|
|
37344
|
-
|
|
37416
|
+
const authDir = path20.dirname(authPath);
|
|
37417
|
+
if (!fs15.existsSync(authDir)) {
|
|
37418
|
+
fs15.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
37345
37419
|
}
|
|
37346
|
-
|
|
37420
|
+
fs15.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
37347
37421
|
}
|
|
37348
37422
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
37349
37423
|
if (!authConfig.token)
|
|
@@ -37518,8 +37592,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37518
37592
|
saveToken: () => saveToken
|
|
37519
37593
|
});
|
|
37520
37594
|
module.exports = __toCommonJS2(token_util_exports);
|
|
37521
|
-
var
|
|
37522
|
-
var
|
|
37595
|
+
var path20 = __toESM2(__require("path"));
|
|
37596
|
+
var fs15 = __toESM2(__require("fs"));
|
|
37523
37597
|
var import_token_error = require_token_error();
|
|
37524
37598
|
var import_token_io = require_token_io();
|
|
37525
37599
|
var import_auth_config = require_auth_config();
|
|
@@ -37531,7 +37605,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37531
37605
|
if (!dataDir) {
|
|
37532
37606
|
return null;
|
|
37533
37607
|
}
|
|
37534
|
-
return
|
|
37608
|
+
return path20.join(dataDir, vercelFolder);
|
|
37535
37609
|
}
|
|
37536
37610
|
async function getVercelToken2(options) {
|
|
37537
37611
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
@@ -37599,11 +37673,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37599
37673
|
if (!dir) {
|
|
37600
37674
|
throw new import_token_error.VercelOidcTokenError("Unable to find project root directory. Have you linked your project with `vc link?`");
|
|
37601
37675
|
}
|
|
37602
|
-
const prjPath =
|
|
37603
|
-
if (!
|
|
37676
|
+
const prjPath = path20.join(dir, ".vercel", "project.json");
|
|
37677
|
+
if (!fs15.existsSync(prjPath)) {
|
|
37604
37678
|
throw new import_token_error.VercelOidcTokenError("project.json not found, have you linked your project with `vc link?`");
|
|
37605
37679
|
}
|
|
37606
|
-
const prj = JSON.parse(
|
|
37680
|
+
const prj = JSON.parse(fs15.readFileSync(prjPath, "utf8"));
|
|
37607
37681
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
37608
37682
|
throw new TypeError("Expected a string-valued projectId property. Try running `vc link` to re-link your project.");
|
|
37609
37683
|
}
|
|
@@ -37614,11 +37688,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37614
37688
|
if (!dir) {
|
|
37615
37689
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37616
37690
|
}
|
|
37617
|
-
const tokenPath =
|
|
37691
|
+
const tokenPath = path20.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37618
37692
|
const tokenJson = JSON.stringify(token);
|
|
37619
|
-
|
|
37620
|
-
|
|
37621
|
-
|
|
37693
|
+
fs15.mkdirSync(path20.dirname(tokenPath), { mode: 504, recursive: true });
|
|
37694
|
+
fs15.writeFileSync(tokenPath, tokenJson);
|
|
37695
|
+
fs15.chmodSync(tokenPath, 432);
|
|
37622
37696
|
return;
|
|
37623
37697
|
}
|
|
37624
37698
|
function loadToken(projectId) {
|
|
@@ -37626,11 +37700,11 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
37626
37700
|
if (!dir) {
|
|
37627
37701
|
throw new import_token_error.VercelOidcTokenError("Unable to find user data directory. Please reach out to Vercel support.");
|
|
37628
37702
|
}
|
|
37629
|
-
const tokenPath =
|
|
37630
|
-
if (!
|
|
37703
|
+
const tokenPath = path20.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
37704
|
+
if (!fs15.existsSync(tokenPath)) {
|
|
37631
37705
|
return null;
|
|
37632
37706
|
}
|
|
37633
|
-
const token = JSON.parse(
|
|
37707
|
+
const token = JSON.parse(fs15.readFileSync(tokenPath, "utf8"));
|
|
37634
37708
|
assertVercelOidcTokenResponse(token);
|
|
37635
37709
|
return token;
|
|
37636
37710
|
}
|
|
@@ -48472,37 +48546,37 @@ function createOpenAI(options = {}) {
|
|
|
48472
48546
|
}, `ai-sdk/openai/${VERSION4}`);
|
|
48473
48547
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel(modelId, {
|
|
48474
48548
|
provider: `${providerName}.chat`,
|
|
48475
|
-
url: ({ path:
|
|
48549
|
+
url: ({ path: path20 }) => `${baseURL}${path20}`,
|
|
48476
48550
|
headers: getHeaders,
|
|
48477
48551
|
fetch: options.fetch
|
|
48478
48552
|
});
|
|
48479
48553
|
const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
|
|
48480
48554
|
provider: `${providerName}.completion`,
|
|
48481
|
-
url: ({ path:
|
|
48555
|
+
url: ({ path: path20 }) => `${baseURL}${path20}`,
|
|
48482
48556
|
headers: getHeaders,
|
|
48483
48557
|
fetch: options.fetch
|
|
48484
48558
|
});
|
|
48485
48559
|
const createEmbeddingModel = (modelId) => new OpenAIEmbeddingModel(modelId, {
|
|
48486
48560
|
provider: `${providerName}.embedding`,
|
|
48487
|
-
url: ({ path:
|
|
48561
|
+
url: ({ path: path20 }) => `${baseURL}${path20}`,
|
|
48488
48562
|
headers: getHeaders,
|
|
48489
48563
|
fetch: options.fetch
|
|
48490
48564
|
});
|
|
48491
48565
|
const createImageModel = (modelId) => new OpenAIImageModel(modelId, {
|
|
48492
48566
|
provider: `${providerName}.image`,
|
|
48493
|
-
url: ({ path:
|
|
48567
|
+
url: ({ path: path20 }) => `${baseURL}${path20}`,
|
|
48494
48568
|
headers: getHeaders,
|
|
48495
48569
|
fetch: options.fetch
|
|
48496
48570
|
});
|
|
48497
48571
|
const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
|
|
48498
48572
|
provider: `${providerName}.transcription`,
|
|
48499
|
-
url: ({ path:
|
|
48573
|
+
url: ({ path: path20 }) => `${baseURL}${path20}`,
|
|
48500
48574
|
headers: getHeaders,
|
|
48501
48575
|
fetch: options.fetch
|
|
48502
48576
|
});
|
|
48503
48577
|
const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
|
|
48504
48578
|
provider: `${providerName}.speech`,
|
|
48505
|
-
url: ({ path:
|
|
48579
|
+
url: ({ path: path20 }) => `${baseURL}${path20}`,
|
|
48506
48580
|
headers: getHeaders,
|
|
48507
48581
|
fetch: options.fetch
|
|
48508
48582
|
});
|
|
@@ -48515,7 +48589,7 @@ function createOpenAI(options = {}) {
|
|
|
48515
48589
|
const createResponsesModel = (modelId) => {
|
|
48516
48590
|
return new OpenAIResponsesLanguageModel(modelId, {
|
|
48517
48591
|
provider: `${providerName}.responses`,
|
|
48518
|
-
url: ({ path:
|
|
48592
|
+
url: ({ path: path20 }) => `${baseURL}${path20}`,
|
|
48519
48593
|
headers: getHeaders,
|
|
48520
48594
|
fetch: options.fetch,
|
|
48521
48595
|
fileIdPrefixes: ["file-"]
|
|
@@ -65170,26 +65244,26 @@ var require_process = __commonJS((exports, module) => {
|
|
|
65170
65244
|
|
|
65171
65245
|
// ../../node_modules/detect-libc/lib/filesystem.js
|
|
65172
65246
|
var require_filesystem = __commonJS((exports, module) => {
|
|
65173
|
-
var
|
|
65247
|
+
var fs15 = __require("fs");
|
|
65174
65248
|
var LDD_PATH = "/usr/bin/ldd";
|
|
65175
65249
|
var SELF_PATH = "/proc/self/exe";
|
|
65176
65250
|
var MAX_LENGTH = 2048;
|
|
65177
|
-
var readFileSync2 = (
|
|
65178
|
-
const fd =
|
|
65251
|
+
var readFileSync2 = (path20) => {
|
|
65252
|
+
const fd = fs15.openSync(path20, "r");
|
|
65179
65253
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
65180
|
-
const bytesRead =
|
|
65181
|
-
|
|
65254
|
+
const bytesRead = fs15.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
65255
|
+
fs15.close(fd, () => {});
|
|
65182
65256
|
return buffer.subarray(0, bytesRead);
|
|
65183
65257
|
};
|
|
65184
|
-
var readFile = (
|
|
65185
|
-
|
|
65258
|
+
var readFile = (path20) => new Promise((resolve4, reject) => {
|
|
65259
|
+
fs15.open(path20, "r", (err, fd) => {
|
|
65186
65260
|
if (err) {
|
|
65187
65261
|
reject(err);
|
|
65188
65262
|
} else {
|
|
65189
65263
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
65190
|
-
|
|
65264
|
+
fs15.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
65191
65265
|
resolve4(buffer.subarray(0, bytesRead));
|
|
65192
|
-
|
|
65266
|
+
fs15.close(fd, () => {});
|
|
65193
65267
|
});
|
|
65194
65268
|
}
|
|
65195
65269
|
});
|
|
@@ -65294,11 +65368,11 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
65294
65368
|
}
|
|
65295
65369
|
return null;
|
|
65296
65370
|
};
|
|
65297
|
-
var familyFromInterpreterPath = (
|
|
65298
|
-
if (
|
|
65299
|
-
if (
|
|
65371
|
+
var familyFromInterpreterPath = (path20) => {
|
|
65372
|
+
if (path20) {
|
|
65373
|
+
if (path20.includes("/ld-musl-")) {
|
|
65300
65374
|
return MUSL;
|
|
65301
|
-
} else if (
|
|
65375
|
+
} else if (path20.includes("/ld-linux-")) {
|
|
65302
65376
|
return GLIBC;
|
|
65303
65377
|
}
|
|
65304
65378
|
}
|
|
@@ -65343,8 +65417,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
65343
65417
|
cachedFamilyInterpreter = null;
|
|
65344
65418
|
try {
|
|
65345
65419
|
const selfContent = await readFile(SELF_PATH);
|
|
65346
|
-
const
|
|
65347
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65420
|
+
const path20 = interpreterPath(selfContent);
|
|
65421
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path20);
|
|
65348
65422
|
} catch (e) {}
|
|
65349
65423
|
return cachedFamilyInterpreter;
|
|
65350
65424
|
};
|
|
@@ -65355,8 +65429,8 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
65355
65429
|
cachedFamilyInterpreter = null;
|
|
65356
65430
|
try {
|
|
65357
65431
|
const selfContent = readFileSync2(SELF_PATH);
|
|
65358
|
-
const
|
|
65359
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
65432
|
+
const path20 = interpreterPath(selfContent);
|
|
65433
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path20);
|
|
65360
65434
|
} catch (e) {}
|
|
65361
65435
|
return cachedFamilyInterpreter;
|
|
65362
65436
|
};
|
|
@@ -67018,18 +67092,18 @@ var require_sharp = __commonJS((exports, module) => {
|
|
|
67018
67092
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
67019
67093
|
"@img/sharp-wasm32/sharp.node"
|
|
67020
67094
|
];
|
|
67021
|
-
var
|
|
67095
|
+
var path20;
|
|
67022
67096
|
var sharp;
|
|
67023
67097
|
var errors5 = [];
|
|
67024
|
-
for (
|
|
67098
|
+
for (path20 of paths) {
|
|
67025
67099
|
try {
|
|
67026
|
-
sharp = __require(
|
|
67100
|
+
sharp = __require(path20);
|
|
67027
67101
|
break;
|
|
67028
67102
|
} catch (err) {
|
|
67029
67103
|
errors5.push(err);
|
|
67030
67104
|
}
|
|
67031
67105
|
}
|
|
67032
|
-
if (sharp &&
|
|
67106
|
+
if (sharp && path20.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
67033
67107
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
67034
67108
|
err.code = "Unsupported CPU";
|
|
67035
67109
|
errors5.push(err);
|
|
@@ -69891,15 +69965,15 @@ var require_color = __commonJS((exports, module) => {
|
|
|
69891
69965
|
};
|
|
69892
69966
|
}
|
|
69893
69967
|
function wrapConversion(toModel, graph) {
|
|
69894
|
-
const
|
|
69968
|
+
const path20 = [graph[toModel].parent, toModel];
|
|
69895
69969
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
69896
69970
|
let cur = graph[toModel].parent;
|
|
69897
69971
|
while (graph[cur].parent) {
|
|
69898
|
-
|
|
69972
|
+
path20.unshift(graph[cur].parent);
|
|
69899
69973
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
69900
69974
|
cur = graph[cur].parent;
|
|
69901
69975
|
}
|
|
69902
|
-
fn.conversion =
|
|
69976
|
+
fn.conversion = path20;
|
|
69903
69977
|
return fn;
|
|
69904
69978
|
}
|
|
69905
69979
|
function route(fromModel) {
|
|
@@ -70504,7 +70578,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
70504
70578
|
Copyright 2013 Lovell Fuller and others.
|
|
70505
70579
|
SPDX-License-Identifier: Apache-2.0
|
|
70506
70580
|
*/
|
|
70507
|
-
var
|
|
70581
|
+
var path20 = __require("path");
|
|
70508
70582
|
var is = require_is();
|
|
70509
70583
|
var sharp = require_sharp();
|
|
70510
70584
|
var formats = new Map([
|
|
@@ -70535,9 +70609,9 @@ var require_output = __commonJS((exports, module) => {
|
|
|
70535
70609
|
let err;
|
|
70536
70610
|
if (!is.string(fileOut)) {
|
|
70537
70611
|
err = new Error("Missing output file path");
|
|
70538
|
-
} else if (is.string(this.options.input.file) &&
|
|
70612
|
+
} else if (is.string(this.options.input.file) && path20.resolve(this.options.input.file) === path20.resolve(fileOut)) {
|
|
70539
70613
|
err = new Error("Cannot use same file for input and output");
|
|
70540
|
-
} else if (jp2Regex.test(
|
|
70614
|
+
} else if (jp2Regex.test(path20.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
70541
70615
|
err = errJp2Save();
|
|
70542
70616
|
}
|
|
70543
70617
|
if (err) {
|
|
@@ -77784,11 +77858,11 @@ var init_transformers_node = __esm(() => {
|
|
|
77784
77858
|
throw new Error(`The number of external data chunks (${num_chunks}) exceeds the maximum allowed value (${_utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.MAX_EXTERNAL_DATA_CHUNKS}).`);
|
|
77785
77859
|
}
|
|
77786
77860
|
for (let i = 0;i < num_chunks; ++i) {
|
|
77787
|
-
const
|
|
77788
|
-
const fullPath = `${options.subfolder ?? ""}/${
|
|
77861
|
+
const path20 = `${baseName}_data${i === 0 ? "" : "_" + i}`;
|
|
77862
|
+
const fullPath = `${options.subfolder ?? ""}/${path20}`;
|
|
77789
77863
|
externalDataPromises.push(new Promise(async (resolve4, reject) => {
|
|
77790
77864
|
const data = await (0, _utils_hub_js__WEBPACK_IMPORTED_MODULE_5__.getModelFile)(pretrained_model_name_or_path, fullPath, true, options, return_path);
|
|
77791
|
-
resolve4(data instanceof Uint8Array ? { path:
|
|
77865
|
+
resolve4(data instanceof Uint8Array ? { path: path20, data } : path20);
|
|
77792
77866
|
}));
|
|
77793
77867
|
}
|
|
77794
77868
|
} else if (session_options.externalData !== undefined) {
|
|
@@ -90852,7 +90926,7 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90852
90926
|
const blob = new Blob([wav], { type: "audio/wav" });
|
|
90853
90927
|
return blob;
|
|
90854
90928
|
}
|
|
90855
|
-
async save(
|
|
90929
|
+
async save(path20) {
|
|
90856
90930
|
let fn;
|
|
90857
90931
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_BROWSER_ENV) {
|
|
90858
90932
|
if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_WEBWORKER_ENV) {
|
|
@@ -90860,14 +90934,14 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90860
90934
|
}
|
|
90861
90935
|
fn = _core_js__WEBPACK_IMPORTED_MODULE_2__.saveBlob;
|
|
90862
90936
|
} else if (_env_js__WEBPACK_IMPORTED_MODULE_3__.apis.IS_FS_AVAILABLE) {
|
|
90863
|
-
fn = async (
|
|
90937
|
+
fn = async (path21, blob) => {
|
|
90864
90938
|
let buffer = await blob.arrayBuffer();
|
|
90865
|
-
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(
|
|
90939
|
+
node_fs__WEBPACK_IMPORTED_MODULE_5__["default"].writeFileSync(path21, Buffer.from(buffer));
|
|
90866
90940
|
};
|
|
90867
90941
|
} else {
|
|
90868
90942
|
throw new Error("Unable to save because filesystem is disabled in this environment.");
|
|
90869
90943
|
}
|
|
90870
|
-
await fn(
|
|
90944
|
+
await fn(path20, this.toBlob());
|
|
90871
90945
|
}
|
|
90872
90946
|
}
|
|
90873
90947
|
},
|
|
@@ -90963,11 +91037,11 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
90963
91037
|
function calculateReflectOffset(i, w) {
|
|
90964
91038
|
return Math.abs((i + w) % (2 * w) - w);
|
|
90965
91039
|
}
|
|
90966
|
-
function saveBlob(
|
|
91040
|
+
function saveBlob(path20, blob) {
|
|
90967
91041
|
const dataURL = URL.createObjectURL(blob);
|
|
90968
91042
|
const downloadLink = document.createElement("a");
|
|
90969
91043
|
downloadLink.href = dataURL;
|
|
90970
|
-
downloadLink.download =
|
|
91044
|
+
downloadLink.download = path20;
|
|
90971
91045
|
downloadLink.click();
|
|
90972
91046
|
downloadLink.remove();
|
|
90973
91047
|
URL.revokeObjectURL(dataURL);
|
|
@@ -91568,8 +91642,8 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
91568
91642
|
}
|
|
91569
91643
|
|
|
91570
91644
|
class FileCache {
|
|
91571
|
-
constructor(
|
|
91572
|
-
this.path =
|
|
91645
|
+
constructor(path20) {
|
|
91646
|
+
this.path = path20;
|
|
91573
91647
|
}
|
|
91574
91648
|
async match(request) {
|
|
91575
91649
|
let filePath = node_path__WEBPACK_IMPORTED_MODULE_1__["default"].join(this.path, request);
|
|
@@ -92325,20 +92399,20 @@ ${fake_token_around_image}` + `${global_img_token}` + image_token.repeat(image_s
|
|
|
92325
92399
|
}
|
|
92326
92400
|
return this;
|
|
92327
92401
|
}
|
|
92328
|
-
async save(
|
|
92402
|
+
async save(path20) {
|
|
92329
92403
|
if (IS_BROWSER_OR_WEBWORKER) {
|
|
92330
92404
|
if (_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_WEBWORKER_ENV) {
|
|
92331
92405
|
throw new Error("Unable to save an image from a Web Worker.");
|
|
92332
92406
|
}
|
|
92333
|
-
const extension =
|
|
92407
|
+
const extension = path20.split(".").pop().toLowerCase();
|
|
92334
92408
|
const mime2 = CONTENT_TYPE_MAP.get(extension) ?? "image/png";
|
|
92335
92409
|
const blob = await this.toBlob(mime2);
|
|
92336
|
-
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(
|
|
92410
|
+
(0, _core_js__WEBPACK_IMPORTED_MODULE_0__.saveBlob)(path20, blob);
|
|
92337
92411
|
} else if (!_env_js__WEBPACK_IMPORTED_MODULE_2__.apis.IS_FS_AVAILABLE) {
|
|
92338
92412
|
throw new Error("Unable to save the image because filesystem is disabled in this environment.");
|
|
92339
92413
|
} else {
|
|
92340
92414
|
const img = this.toSharp();
|
|
92341
|
-
return await img.toFile(
|
|
92415
|
+
return await img.toFile(path20);
|
|
92342
92416
|
}
|
|
92343
92417
|
}
|
|
92344
92418
|
toSharp() {
|
|
@@ -101878,10 +101952,10 @@ Note that ${s.bold("include")} statements only accept relation fields.`, a12;
|
|
|
101878
101952
|
super(t2, "P2023", r2);
|
|
101879
101953
|
}
|
|
101880
101954
|
};
|
|
101881
|
-
var
|
|
101955
|
+
var fs15 = new WeakMap;
|
|
101882
101956
|
function Ep(e) {
|
|
101883
|
-
let t2 =
|
|
101884
|
-
return t2 || (t2 = Object.entries(e),
|
|
101957
|
+
let t2 = fs15.get(e);
|
|
101958
|
+
return t2 || (t2 = Object.entries(e), fs15.set(e, t2)), t2;
|
|
101885
101959
|
}
|
|
101886
101960
|
function hs(e, t2, r2) {
|
|
101887
101961
|
switch (t2.type) {
|
|
@@ -105849,7 +105923,7 @@ var require_prisma = __commonJS((exports) => {
|
|
|
105849
105923
|
Prisma.JsonNull = JsonNull2;
|
|
105850
105924
|
Prisma.AnyNull = AnyNull2;
|
|
105851
105925
|
Prisma.NullTypes = NullTypes2;
|
|
105852
|
-
var
|
|
105926
|
+
var path20 = __require("path");
|
|
105853
105927
|
exports.Prisma.TransactionIsolationLevel = makeStrictEnum2({
|
|
105854
105928
|
ReadUncommitted: "ReadUncommitted",
|
|
105855
105929
|
ReadCommitted: "ReadCommitted",
|
|
@@ -116206,10 +116280,10 @@ var init_chunker_code = __esm(() => {
|
|
|
116206
116280
|
});
|
|
116207
116281
|
|
|
116208
116282
|
// ../../packages/core/dist/services/search/smart-chunker.js
|
|
116209
|
-
import
|
|
116283
|
+
import path20 from "path";
|
|
116210
116284
|
function smartChunk(content, filePath, config3 = {}) {
|
|
116211
116285
|
const cfg = { ...DEFAULT_CONFIG, ...config3 };
|
|
116212
|
-
const ext2 =
|
|
116286
|
+
const ext2 = path20.extname(filePath).toLowerCase();
|
|
116213
116287
|
const relativePath = filePath;
|
|
116214
116288
|
const fileImports = isCodeFile(ext2) ? extractFileImports(content, ext2) : undefined;
|
|
116215
116289
|
let chunks;
|
|
@@ -116547,8 +116621,8 @@ var init_embedding_freshness = __esm(() => {
|
|
|
116547
116621
|
});
|
|
116548
116622
|
|
|
116549
116623
|
// ../../packages/core/dist/services/search/project-indexer.js
|
|
116550
|
-
import
|
|
116551
|
-
import
|
|
116624
|
+
import fs15 from "fs/promises";
|
|
116625
|
+
import path21 from "path";
|
|
116552
116626
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
116553
116627
|
async function runWithIndexLock(lockMap, projectId, work) {
|
|
116554
116628
|
const prevLock = lockMap.get(projectId);
|
|
@@ -116591,7 +116665,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
116591
116665
|
dot: false
|
|
116592
116666
|
});
|
|
116593
116667
|
const filteredFiles = files.filter((file3) => {
|
|
116594
|
-
const relativePath =
|
|
116668
|
+
const relativePath = path21.relative(projectPath, file3);
|
|
116595
116669
|
const shouldIgnore = ig.ignores(relativePath);
|
|
116596
116670
|
if (shouldIgnore) {
|
|
116597
116671
|
logger.debug("Ignoring file per .gitignore during indexing", {
|
|
@@ -116631,7 +116705,7 @@ async function indexProjectInternal(deps, projectPath, projectId, options = {})
|
|
|
116631
116705
|
});
|
|
116632
116706
|
}
|
|
116633
116707
|
}
|
|
116634
|
-
const indexedFilesList = filteredFiles.map((f) =>
|
|
116708
|
+
const indexedFilesList = filteredFiles.map((f) => path21.relative(projectPath, f));
|
|
116635
116709
|
await deps.indexManager.updateIndexMetadata(projectId, projectPath, indexedFilesList);
|
|
116636
116710
|
logger.info("Project indexing completed", {
|
|
116637
116711
|
projectId,
|
|
@@ -116761,7 +116835,7 @@ async function ensureFreshIndex(deps, projectId, projectPath, options = {}) {
|
|
|
116761
116835
|
let errors5 = 0;
|
|
116762
116836
|
for (const relativeFilePath of filesToReindex) {
|
|
116763
116837
|
try {
|
|
116764
|
-
const fullPath =
|
|
116838
|
+
const fullPath = path21.join(projectPath, relativeFilePath);
|
|
116765
116839
|
const result = await deps.indexFile(fullPath, projectId, projectPath, centralityMap);
|
|
116766
116840
|
filesIndexed++;
|
|
116767
116841
|
chunksIndexed += result.chunks;
|
|
@@ -116821,8 +116895,8 @@ async function checkSearchAdmission(deps, projectId, projectPath) {
|
|
|
116821
116895
|
}
|
|
116822
116896
|
async function indexFile(deps, filePath, projectId, projectRoot, centralityMap) {
|
|
116823
116897
|
projectId = await getProjectIdentityAliasResolver().resolve(projectId);
|
|
116824
|
-
const content = await
|
|
116825
|
-
const relativePath =
|
|
116898
|
+
const content = await fs15.readFile(filePath, "utf-8");
|
|
116899
|
+
const relativePath = path21.relative(projectRoot, filePath);
|
|
116826
116900
|
const maxFileSize = config.get("security").maxFileSize || 1024 * 1024;
|
|
116827
116901
|
if (content.length > maxFileSize) {
|
|
116828
116902
|
logger.warn("File too large, skipping", {
|
|
@@ -116842,7 +116916,7 @@ async function indexFile(deps, filePath, projectId, projectRoot, centralityMap)
|
|
|
116842
116916
|
chunkIndex: i,
|
|
116843
116917
|
totalChunks: chunks.length,
|
|
116844
116918
|
type: chunk.type,
|
|
116845
|
-
language:
|
|
116919
|
+
language: path21.extname(filePath).slice(1),
|
|
116846
116920
|
lineStart: chunk.lineStart,
|
|
116847
116921
|
lineEnd: chunk.lineEnd,
|
|
116848
116922
|
label: chunk.label,
|
|
@@ -118913,8 +118987,8 @@ function stripNul(content) {
|
|
|
118913
118987
|
}
|
|
118914
118988
|
|
|
118915
118989
|
// ../../packages/core/dist/services/etl/stages/discover.js
|
|
118916
|
-
import
|
|
118917
|
-
import
|
|
118990
|
+
import fs16 from "fs/promises";
|
|
118991
|
+
import path22 from "path";
|
|
118918
118992
|
import { createHash as createHash5 } from "crypto";
|
|
118919
118993
|
|
|
118920
118994
|
class DiscoverStage {
|
|
@@ -118940,7 +119014,7 @@ class DiscoverStage {
|
|
|
118940
119014
|
dot: false,
|
|
118941
119015
|
absolute: false
|
|
118942
119016
|
});
|
|
118943
|
-
relPaths = found.map((p) =>
|
|
119017
|
+
relPaths = found.map((p) => path22.isAbsolute(p) ? path22.relative(ctx.projectPath, p) : p).filter((p) => !ig.ignores(p) && applyPolicy(p, policy) !== "Drop");
|
|
118944
119018
|
}
|
|
118945
119019
|
if (ctx.resumeCursor?.path) {
|
|
118946
119020
|
const cursorPath = ctx.resumeCursor.path;
|
|
@@ -118999,10 +119073,10 @@ class DiscoverStage {
|
|
|
118999
119073
|
return discovered;
|
|
119000
119074
|
}
|
|
119001
119075
|
async processFile(ctx, relativePath, forceReindex) {
|
|
119002
|
-
const absolutePath =
|
|
119076
|
+
const absolutePath = path22.join(ctx.projectPath, relativePath);
|
|
119003
119077
|
try {
|
|
119004
|
-
const stat2 = await
|
|
119005
|
-
const content = stripNul(await
|
|
119078
|
+
const stat2 = await fs16.stat(absolutePath);
|
|
119079
|
+
const content = stripNul(await fs16.readFile(absolutePath, "utf-8"));
|
|
119006
119080
|
const contentHash = createHash5("sha256").update(content).digest("hex");
|
|
119007
119081
|
let needsReparse = forceReindex;
|
|
119008
119082
|
if (!forceReindex) {
|
|
@@ -119046,8 +119120,8 @@ class DiscoverStage {
|
|
|
119046
119120
|
ig.add(pattern);
|
|
119047
119121
|
}
|
|
119048
119122
|
try {
|
|
119049
|
-
const gitignorePath =
|
|
119050
|
-
const gitignoreContent = await
|
|
119123
|
+
const gitignorePath = path22.join(projectPath, ".gitignore");
|
|
119124
|
+
const gitignoreContent = await fs16.readFile(gitignorePath, "utf8");
|
|
119051
119125
|
const rules = gitignoreContent.split(`
|
|
119052
119126
|
`).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
119053
119127
|
ig.add(rules);
|
|
@@ -120402,8 +120476,8 @@ function rustUseLeaves(node2, source, prefix = []) {
|
|
|
120402
120476
|
}
|
|
120403
120477
|
if (node2.type === "use_wildcard")
|
|
120404
120478
|
return [{ path: [...prefix, "*"], glob: true }];
|
|
120405
|
-
const
|
|
120406
|
-
return
|
|
120479
|
+
const path23 = rustPathSegments(node2, source);
|
|
120480
|
+
return path23.length ? [{ path: [...prefix, ...path23] }] : [];
|
|
120407
120481
|
}
|
|
120408
120482
|
function functionalCaptures(captures, source, family) {
|
|
120409
120483
|
if (family !== "clojure")
|
|
@@ -121375,8 +121449,8 @@ var init_structural_runtime = __esm(() => {
|
|
|
121375
121449
|
});
|
|
121376
121450
|
|
|
121377
121451
|
// ../../packages/core/dist/services/etl/stages/parse.js
|
|
121378
|
-
import
|
|
121379
|
-
import
|
|
121452
|
+
import path23 from "path";
|
|
121453
|
+
import fs17 from "fs/promises";
|
|
121380
121454
|
function resolveChunkerMaxChars() {
|
|
121381
121455
|
const global2 = Number(process.env.EMBEDDING_MAX_CHARS);
|
|
121382
121456
|
if (Number.isFinite(global2) && global2 > 0)
|
|
@@ -121404,8 +121478,8 @@ class ParseStage {
|
|
|
121404
121478
|
const results = new Map;
|
|
121405
121479
|
let processed = 0;
|
|
121406
121480
|
const phases = [
|
|
121407
|
-
files.filter((file3) =>
|
|
121408
|
-
files.filter((file3) =>
|
|
121481
|
+
files.filter((file3) => path23.extname(file3.relativePath).toLowerCase() !== ".h"),
|
|
121482
|
+
files.filter((file3) => path23.extname(file3.relativePath).toLowerCase() === ".h")
|
|
121409
121483
|
];
|
|
121410
121484
|
const batches = phases.flatMap((phase) => Array.from({ length: Math.ceil(phase.length / BATCH_SIZE) }, (_2, index) => phase.slice(index * BATCH_SIZE, (index + 1) * BATCH_SIZE)));
|
|
121411
121485
|
for (const batch of batches) {
|
|
@@ -121443,19 +121517,19 @@ class ParseStage {
|
|
|
121443
121517
|
return files.map((file3) => results.get(file3.relativePath));
|
|
121444
121518
|
}
|
|
121445
121519
|
recordHeaderImporterEvidence(ctx, files, parsedFiles) {
|
|
121446
|
-
const knownHeaders = new Set(files.filter((file3) =>
|
|
121520
|
+
const knownHeaders = new Set(files.filter((file3) => path23.extname(file3.relativePath).toLowerCase() === ".h").map((file3) => path23.posix.normalize(file3.relativePath)));
|
|
121447
121521
|
const mutable = {
|
|
121448
121522
|
...ctx.structuralHeaderEvidenceByFile
|
|
121449
121523
|
};
|
|
121450
121524
|
for (const parsed of parsedFiles) {
|
|
121451
|
-
const extension =
|
|
121525
|
+
const extension = path23.extname(parsed.file.relativePath).toLowerCase();
|
|
121452
121526
|
const key = extension === ".c" ? "cImporters" : [".cpp", ".hpp"].includes(extension) ? "cppImporters" : undefined;
|
|
121453
121527
|
if (!key)
|
|
121454
121528
|
continue;
|
|
121455
121529
|
for (const imported of parsed.rawImports) {
|
|
121456
121530
|
if (!["c_include", "cpp_include"].includes(imported.form) || imported.specifier.startsWith("<"))
|
|
121457
121531
|
continue;
|
|
121458
|
-
const header =
|
|
121532
|
+
const header = path23.posix.normalize(path23.posix.join(path23.posix.dirname(parsed.file.relativePath), imported.specifier));
|
|
121459
121533
|
if (!knownHeaders.has(header))
|
|
121460
121534
|
continue;
|
|
121461
121535
|
const existing = mutable[header] ?? {};
|
|
@@ -121466,9 +121540,9 @@ class ParseStage {
|
|
|
121466
121540
|
}
|
|
121467
121541
|
async parseFile(ctx, file3) {
|
|
121468
121542
|
if (!file3.needsReparse) {
|
|
121469
|
-
const extension =
|
|
121543
|
+
const extension = path23.extname(file3.relativePath).toLowerCase();
|
|
121470
121544
|
if ([".c", ".cpp", ".hpp"].includes(extension)) {
|
|
121471
|
-
const content = file3.snapshotContent ?? await
|
|
121545
|
+
const content = file3.snapshotContent ?? await fs17.readFile(file3.absolutePath, "utf8");
|
|
121472
121546
|
const outcome = await this.runtime.parse({ extension, source: Buffer.from(content) });
|
|
121473
121547
|
if (outcome.status === "failed")
|
|
121474
121548
|
throw new StructuralEtlParseError(file3.relativePath, outcome.failureKind, `Structural evidence parse failed (${outcome.failureKind})`, outcome.diagnosticCount, outcome.diagnostics.slice(0, 10));
|
|
@@ -121480,8 +121554,8 @@ class ParseStage {
|
|
|
121480
121554
|
return { file: file3, chunks: [], symbols: [], rawImports: [], rawEdges: [] };
|
|
121481
121555
|
}
|
|
121482
121556
|
try {
|
|
121483
|
-
const content = file3.snapshotContent ?? await
|
|
121484
|
-
const ext2 =
|
|
121557
|
+
const content = file3.snapshotContent ?? await fs17.readFile(file3.absolutePath, "utf-8");
|
|
121558
|
+
const ext2 = path23.extname(file3.relativePath).toLowerCase();
|
|
121485
121559
|
const chunkerMaxChars = resolveChunkerMaxChars();
|
|
121486
121560
|
const chunks = smartChunk(content, file3.relativePath, chunkerMaxChars ? { maxChunkChars: chunkerMaxChars } : {});
|
|
121487
121561
|
let symbols;
|
|
@@ -122036,7 +122110,7 @@ var init_resolver = __esm(() => {
|
|
|
122036
122110
|
});
|
|
122037
122111
|
|
|
122038
122112
|
// ../../packages/core/dist/services/structural/resolvers/typescript.js
|
|
122039
|
-
import
|
|
122113
|
+
import path24 from "path";
|
|
122040
122114
|
function candidates(identities) {
|
|
122041
122115
|
return Object.freeze(identities.map((identity) => Object.freeze({
|
|
122042
122116
|
fqn: identity.fqn,
|
|
@@ -122131,7 +122205,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
122131
122205
|
const bases = /\.[cm]?jsx?$/u.test(base) ? [base.replace(/\.[cm]?jsx?$/u, ".ts"), base.replace(/\.[cm]?jsx?$/u, ".tsx"), base] : [base];
|
|
122132
122206
|
for (const candidateBase of bases)
|
|
122133
122207
|
for (const suffix of DIALECT_PROBES[dialect] ?? [""]) {
|
|
122134
|
-
const value =
|
|
122208
|
+
const value = path24.posix.normalize(`${candidateBase}${suffix}`);
|
|
122135
122209
|
if (!value.startsWith("../") && value !== ".." && known.has(value))
|
|
122136
122210
|
return value;
|
|
122137
122211
|
}
|
|
@@ -122140,7 +122214,7 @@ function probe(base, known, dialect = "typescript") {
|
|
|
122140
122214
|
function resolveStructuralSpecifier(specifier, fromFile, build, dialect = "typescript") {
|
|
122141
122215
|
const known = new Set(build.knownFiles.map(normalizeStructuralFile));
|
|
122142
122216
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
122143
|
-
return probe(
|
|
122217
|
+
return probe(path24.posix.join(path24.posix.dirname(fromFile), specifier), known, dialect);
|
|
122144
122218
|
}
|
|
122145
122219
|
const aliases = build.pathAliasesByFile?.[normalizeStructuralFile(fromFile)] ?? build.pathAliases ?? [];
|
|
122146
122220
|
for (const alias of aliases) {
|
|
@@ -122404,7 +122478,7 @@ var init_scripting2 = __esm(() => {
|
|
|
122404
122478
|
});
|
|
122405
122479
|
|
|
122406
122480
|
// ../../packages/core/dist/services/structural/resolvers/systems.js
|
|
122407
|
-
import
|
|
122481
|
+
import path25 from "path";
|
|
122408
122482
|
var DIALECTS, SYSTEMS_LANGUAGE_RESOLVER;
|
|
122409
122483
|
var init_systems2 = __esm(() => {
|
|
122410
122484
|
init_typescript2();
|
|
@@ -122423,7 +122497,7 @@ var init_systems2 = __esm(() => {
|
|
|
122423
122497
|
const bindings = item.bindings.map((binding) => binding.imported === "*" && binding.local === "*" && unresolvedTarget && !unresolvedTarget.qualifier ? { ...binding, imported: unresolvedTarget.name, local: unresolvedTarget.name } : binding);
|
|
122424
122498
|
if (item.specifier === "crate" || item.specifier.startsWith("crate/")) {
|
|
122425
122499
|
const crateRoot = file3.file.startsWith("src/") ? "src" : "";
|
|
122426
|
-
return { ...item, bindings, specifier: `./${
|
|
122500
|
+
return { ...item, bindings, specifier: `./${path25.posix.relative(path25.posix.dirname(file3.file), path25.posix.join(crateRoot, item.specifier.replace(/^crate\/?/u, "")))}` };
|
|
122427
122501
|
}
|
|
122428
122502
|
if (item.specifier === "self" || item.specifier.startsWith("self/"))
|
|
122429
122503
|
return { ...item, bindings, specifier: `./${item.specifier.replace(/^self\/?/u, "")}` };
|
|
@@ -122521,8 +122595,8 @@ var init_data_document2 = __esm(() => {
|
|
|
122521
122595
|
});
|
|
122522
122596
|
|
|
122523
122597
|
// ../../packages/core/dist/services/etl/stages/resolve.js
|
|
122524
|
-
import
|
|
122525
|
-
import
|
|
122598
|
+
import path26 from "path";
|
|
122599
|
+
import fs18 from "fs";
|
|
122526
122600
|
|
|
122527
122601
|
class ResolveStage {
|
|
122528
122602
|
symbolRepository;
|
|
@@ -122546,7 +122620,7 @@ class ResolveStage {
|
|
|
122546
122620
|
const structuralDocuments = files.flatMap((file3) => {
|
|
122547
122621
|
if (!file3.structure)
|
|
122548
122622
|
return [];
|
|
122549
|
-
const language = resolveStructuralLanguage(
|
|
122623
|
+
const language = resolveStructuralLanguage(path26.extname(file3.file.relativePath));
|
|
122550
122624
|
if (language.status !== "supported")
|
|
122551
122625
|
throw new Error(`structural_manifest_missing:${file3.file.relativePath}`);
|
|
122552
122626
|
return [{
|
|
@@ -122558,13 +122632,13 @@ class ResolveStage {
|
|
|
122558
122632
|
}];
|
|
122559
122633
|
});
|
|
122560
122634
|
const currentStructuralFiles = new Set(structuralDocuments.map((document2) => document2.file));
|
|
122561
|
-
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
122635
|
+
const skippedStructuralFiles = new Set(files.filter((item) => !item.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path26.extname(item.file.relativePath).toLowerCase())).map((item) => item.file.relativePath));
|
|
122562
122636
|
const pathAliasesByFile = Object.fromEntries([...knownRelPaths].map((file3) => [
|
|
122563
122637
|
file3,
|
|
122564
122638
|
this.structuralAliasesFor(file3, rootAliases, monorepoPackages)
|
|
122565
122639
|
]));
|
|
122566
122640
|
const buildMetadata = { knownFiles: [...knownRelPaths], pathAliasesByFile };
|
|
122567
|
-
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(
|
|
122641
|
+
const seedRows = repositoryDefinitions.filter((definition) => STRUCTURAL_SEED_EXTENSIONS.has(path26.extname(definition.file_path).toLowerCase())).filter((definition) => knownRelPaths.has(definition.file_path) && skippedStructuralFiles.has(definition.file_path)).filter((definition) => !currentStructuralFiles.has(definition.file_path));
|
|
122568
122642
|
const seedIds = new Set;
|
|
122569
122643
|
for (const definition of seedRows) {
|
|
122570
122644
|
if (seedIds.has(definition.id))
|
|
@@ -122657,7 +122731,7 @@ class ResolveStage {
|
|
|
122657
122731
|
if (parsed.file !== definition.file_path) {
|
|
122658
122732
|
throw new Error(`structural_repository_seed_file_mismatch:${definition.id}`);
|
|
122659
122733
|
}
|
|
122660
|
-
const language = resolveStructuralLanguage(
|
|
122734
|
+
const language = resolveStructuralLanguage(path26.extname(definition.file_path));
|
|
122661
122735
|
if (language.status !== "supported")
|
|
122662
122736
|
throw new Error(`structural_repository_seed_language:${definition.id}`);
|
|
122663
122737
|
let identity;
|
|
@@ -122709,7 +122783,7 @@ class ResolveStage {
|
|
|
122709
122783
|
});
|
|
122710
122784
|
}
|
|
122711
122785
|
resolveFile(parsed, projectPath, knownRelPaths, rootAliases, monorepoPackages, symbolIndex, knownFqns) {
|
|
122712
|
-
const fromDir =
|
|
122786
|
+
const fromDir = path26.dirname(path26.join(projectPath, parsed.file.relativePath));
|
|
122713
122787
|
const packageAliases = this.getPackageAliases(parsed.file.relativePath, monorepoPackages);
|
|
122714
122788
|
const allAliases = [...packageAliases, ...rootAliases];
|
|
122715
122789
|
const resolvedImports = parsed.rawImports.map((raw2) => {
|
|
@@ -122780,7 +122854,7 @@ class ResolveStage {
|
|
|
122780
122854
|
index.set(def.name, `${def.file_path}#${def.name}`);
|
|
122781
122855
|
}
|
|
122782
122856
|
} catch (err) {
|
|
122783
|
-
const skippedStructural = files.some((file3) => !file3.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(
|
|
122857
|
+
const skippedStructural = files.some((file3) => !file3.file.needsReparse && STRUCTURAL_SEED_EXTENSIONS.has(path26.extname(file3.file.relativePath).toLowerCase()));
|
|
122784
122858
|
if (skippedStructural)
|
|
122785
122859
|
throw new Error("structural_repository_seed_failed", { cause: err });
|
|
122786
122860
|
logger.warn("buildSymbolIndex: repo seed failed, in-batch only", {
|
|
@@ -122804,7 +122878,7 @@ class ResolveStage {
|
|
|
122804
122878
|
}
|
|
122805
122879
|
resolveSpecifier(specifier, fromDir, projectPath, knownRelPaths, aliases) {
|
|
122806
122880
|
if (specifier.startsWith("./") || specifier.startsWith("../")) {
|
|
122807
|
-
const resolved = this.probeExtensions(
|
|
122881
|
+
const resolved = this.probeExtensions(path26.resolve(fromDir, specifier), projectPath, knownRelPaths);
|
|
122808
122882
|
return { resolvedPath: resolved, external: false };
|
|
122809
122883
|
}
|
|
122810
122884
|
for (const alias of aliases) {
|
|
@@ -122812,8 +122886,8 @@ class ResolveStage {
|
|
|
122812
122886
|
const suffix = specifier.slice(alias.prefix.length);
|
|
122813
122887
|
for (const target of alias.targets) {
|
|
122814
122888
|
const cleanTarget = target.replace(/\/\*$/, "");
|
|
122815
|
-
const basePath = alias.packagePath ?
|
|
122816
|
-
const absPath =
|
|
122889
|
+
const basePath = alias.packagePath ? path26.join(projectPath, alias.packagePath) : projectPath;
|
|
122890
|
+
const absPath = path26.join(basePath, cleanTarget + suffix);
|
|
122817
122891
|
const resolved = this.probeExtensions(absPath, projectPath, knownRelPaths);
|
|
122818
122892
|
if (resolved)
|
|
122819
122893
|
return { resolvedPath: resolved, external: false };
|
|
@@ -122829,7 +122903,7 @@ class ResolveStage {
|
|
|
122829
122903
|
...TS_EXTENSIONS.map((ext2) => absPath.replace(/\.[^.]+$/, ext2))
|
|
122830
122904
|
];
|
|
122831
122905
|
for (const candidate2 of candidates2) {
|
|
122832
|
-
const rel =
|
|
122906
|
+
const rel = path26.relative(projectPath, candidate2).replace(/\\/g, "/");
|
|
122833
122907
|
if (knownRelPaths.has(rel))
|
|
122834
122908
|
return rel;
|
|
122835
122909
|
}
|
|
@@ -122837,9 +122911,9 @@ class ResolveStage {
|
|
|
122837
122911
|
}
|
|
122838
122912
|
loadTsConfigPaths(projectPath, packageBase) {
|
|
122839
122913
|
const aliases = [];
|
|
122840
|
-
const tsconfigPath =
|
|
122914
|
+
const tsconfigPath = path26.join(projectPath, "tsconfig.json");
|
|
122841
122915
|
try {
|
|
122842
|
-
const raw2 =
|
|
122916
|
+
const raw2 = fs18.readFileSync(tsconfigPath, "utf-8");
|
|
122843
122917
|
const stripped = raw2.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
122844
122918
|
const tsconfig = JSON.parse(stripped);
|
|
122845
122919
|
const paths = tsconfig?.compilerOptions?.paths ?? {};
|
|
@@ -122868,7 +122942,7 @@ class ResolveStage {
|
|
|
122868
122942
|
}
|
|
122869
122943
|
}
|
|
122870
122944
|
for (const packageRelPath of packagePaths) {
|
|
122871
|
-
const absPackagePath =
|
|
122945
|
+
const absPackagePath = path26.join(projectPath, packageRelPath);
|
|
122872
122946
|
const aliases = this.loadTsConfigPaths(absPackagePath, packageRelPath);
|
|
122873
122947
|
if (aliases.length > 0) {
|
|
122874
122948
|
packages.push({
|
|
@@ -122898,7 +122972,7 @@ class ResolveStage {
|
|
|
122898
122972
|
structuralAliasesFor(filePath, rootAliases, packages) {
|
|
122899
122973
|
return [...this.getPackageAliases(filePath, packages), ...rootAliases].map((alias) => ({
|
|
122900
122974
|
pattern: alias.prefix + (alias.targets.some((target) => target.includes("*")) ? "/*" : ""),
|
|
122901
|
-
targets: alias.targets.map((target) => alias.packagePath ?
|
|
122975
|
+
targets: alias.targets.map((target) => alias.packagePath ? path26.posix.join(alias.packagePath, target) : target)
|
|
122902
122976
|
}));
|
|
122903
122977
|
}
|
|
122904
122978
|
}
|
|
@@ -122962,7 +123036,7 @@ var init_with_deadlock_retry = __esm(() => {
|
|
|
122962
123036
|
});
|
|
122963
123037
|
|
|
122964
123038
|
// ../../packages/core/dist/services/etl/stages/load.js
|
|
122965
|
-
import
|
|
123039
|
+
import path27 from "path";
|
|
122966
123040
|
function formatDuration(ms) {
|
|
122967
123041
|
const totalSec = Math.max(0, Math.round(ms / 1000));
|
|
122968
123042
|
if (totalSec < 60)
|
|
@@ -123239,7 +123313,7 @@ class LoadStage {
|
|
|
123239
123313
|
const filePath = file3.file.relativePath;
|
|
123240
123314
|
const batch = buildSymbolPersistenceBatch(ctx.projectId, file3);
|
|
123241
123315
|
if (ctx.graphGenerationLease) {
|
|
123242
|
-
const manifest = getLanguageManifestEntry(
|
|
123316
|
+
const manifest = getLanguageManifestEntry(path27.extname(filePath));
|
|
123243
123317
|
const diagnostics2 = (file3.structuralDiagnostics ?? []).slice(0, 10).map((diagnostic2) => ({
|
|
123244
123318
|
code: diagnostic2.code,
|
|
123245
123319
|
severity: diagnostic2.severity,
|
|
@@ -123696,9 +123770,9 @@ var init_graph_generation_coordinator = __esm(() => {
|
|
|
123696
123770
|
// ../../packages/core/dist/services/etl/pipeline.js
|
|
123697
123771
|
import { createHash as createHash7 } from "crypto";
|
|
123698
123772
|
import { setTimeout as delay2 } from "timers/promises";
|
|
123699
|
-
import
|
|
123773
|
+
import path28 from "path";
|
|
123700
123774
|
function buildHeaderLanguageEvidence(files) {
|
|
123701
|
-
const headers = new Set(files.filter((file3) =>
|
|
123775
|
+
const headers = new Set(files.filter((file3) => path28.posix.extname(file3.relativePath).toLowerCase() === ".h").map((file3) => path28.posix.normalize(file3.relativePath)));
|
|
123702
123776
|
const mutable = new Map;
|
|
123703
123777
|
const entry2 = (header) => {
|
|
123704
123778
|
let value = mutable.get(header);
|
|
@@ -123709,7 +123783,7 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
123709
123783
|
return value;
|
|
123710
123784
|
};
|
|
123711
123785
|
for (const file3 of files) {
|
|
123712
|
-
if (
|
|
123786
|
+
if (path28.posix.basename(file3.relativePath) !== "compile_commands.json" || file3.snapshotContent === undefined)
|
|
123713
123787
|
continue;
|
|
123714
123788
|
let commands;
|
|
123715
123789
|
try {
|
|
@@ -123725,11 +123799,11 @@ function buildHeaderLanguageEvidence(files) {
|
|
|
123725
123799
|
const record2 = command;
|
|
123726
123800
|
if (typeof record2.file !== "string")
|
|
123727
123801
|
continue;
|
|
123728
|
-
const projectRoot =
|
|
123729
|
-
const commandDirectory = typeof record2.directory === "string" ?
|
|
123730
|
-
const absoluteInput =
|
|
123731
|
-
const relative2 =
|
|
123732
|
-
const header =
|
|
123802
|
+
const projectRoot = path28.resolve(file3.absolutePath, ...file3.relativePath.split("/").map(() => ".."));
|
|
123803
|
+
const commandDirectory = typeof record2.directory === "string" ? path28.resolve(projectRoot, record2.directory) : projectRoot;
|
|
123804
|
+
const absoluteInput = path28.resolve(commandDirectory, record2.file);
|
|
123805
|
+
const relative2 = path28.relative(projectRoot, absoluteInput);
|
|
123806
|
+
const header = path28.posix.normalize(relative2.replaceAll(path28.sep, "/"));
|
|
123733
123807
|
if (!headers.has(header))
|
|
123734
123808
|
continue;
|
|
123735
123809
|
const invocation = typeof record2.command === "string" ? record2.command : Array.isArray(record2.arguments) ? record2.arguments.join(" ") : "";
|
|
@@ -124904,16 +124978,16 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
124904
124978
|
const seen = new Set;
|
|
124905
124979
|
const out = [];
|
|
124906
124980
|
for (const e of httpEdges) {
|
|
124907
|
-
const
|
|
124908
|
-
if (!
|
|
124981
|
+
const path30 = e.route;
|
|
124982
|
+
if (!path30)
|
|
124909
124983
|
continue;
|
|
124910
124984
|
const method = (e.method ?? "ANY").toUpperCase();
|
|
124911
|
-
const key = method + " " +
|
|
124985
|
+
const key = method + " " + path30;
|
|
124912
124986
|
if (seen.has(key))
|
|
124913
124987
|
continue;
|
|
124914
124988
|
seen.add(key);
|
|
124915
124989
|
out.push({
|
|
124916
|
-
path:
|
|
124990
|
+
path: path30,
|
|
124917
124991
|
method: e.method,
|
|
124918
124992
|
file: e.fromFile,
|
|
124919
124993
|
handler: e.targetFqn ?? e.symbolName
|
|
@@ -124924,12 +124998,12 @@ function detectRoutes(httpEdges, defs, opts = {}) {
|
|
|
124924
124998
|
continue;
|
|
124925
124999
|
const parsed = parseRouteName(d.name);
|
|
124926
125000
|
const method = parsed?.method ?? "ANY";
|
|
124927
|
-
const
|
|
124928
|
-
const key = method + " " +
|
|
125001
|
+
const path30 = parsed?.path ?? d.name;
|
|
125002
|
+
const key = method + " " + path30;
|
|
124929
125003
|
if (seen.has(key))
|
|
124930
125004
|
continue;
|
|
124931
125005
|
seen.add(key);
|
|
124932
|
-
out.push({ path:
|
|
125006
|
+
out.push({ path: path30, method: parsed?.method, file: d.filePath, handler: d.name });
|
|
124933
125007
|
}
|
|
124934
125008
|
for (const d of defs) {
|
|
124935
125009
|
const parsed = parseRouteName(d.name);
|
|
@@ -125150,8 +125224,8 @@ __export(exports_symbol_graph_service, {
|
|
|
125150
125224
|
symbolGraphService: () => symbolGraphService,
|
|
125151
125225
|
SymbolGraphService: () => SymbolGraphService
|
|
125152
125226
|
});
|
|
125153
|
-
import
|
|
125154
|
-
import
|
|
125227
|
+
import path30 from "path";
|
|
125228
|
+
import fs19 from "fs/promises";
|
|
125155
125229
|
|
|
125156
125230
|
class SymbolGraphService {
|
|
125157
125231
|
identityLookup;
|
|
@@ -125479,7 +125553,7 @@ class SymbolGraphService {
|
|
|
125479
125553
|
async readSnippet(relativePath, lineStart, lineEnd, projectId) {
|
|
125480
125554
|
try {
|
|
125481
125555
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
125482
|
-
const content = await
|
|
125556
|
+
const content = await fs19.readFile(absolutePath, "utf-8");
|
|
125483
125557
|
const lines = content.split(`
|
|
125484
125558
|
`);
|
|
125485
125559
|
return lines.slice(Math.max(0, lineStart - 1), Math.min(lines.length, lineEnd)).join(`
|
|
@@ -125491,7 +125565,7 @@ class SymbolGraphService {
|
|
|
125491
125565
|
async readContext(relativePath, lineNumber, contextLines, projectId) {
|
|
125492
125566
|
try {
|
|
125493
125567
|
const absolutePath = await this.resolveToAbsolute(relativePath, projectId);
|
|
125494
|
-
const content = await
|
|
125568
|
+
const content = await fs19.readFile(absolutePath, "utf-8");
|
|
125495
125569
|
const lines = content.split(`
|
|
125496
125570
|
`);
|
|
125497
125571
|
const start = Math.max(0, lineNumber - contextLines - 1);
|
|
@@ -125504,7 +125578,7 @@ class SymbolGraphService {
|
|
|
125504
125578
|
}
|
|
125505
125579
|
async resolveToAbsolute(relativePath, projectId) {
|
|
125506
125580
|
const root = await this.getProjectRoot(projectId);
|
|
125507
|
-
return root ?
|
|
125581
|
+
return root ? path30.resolve(root, relativePath) : relativePath;
|
|
125508
125582
|
}
|
|
125509
125583
|
async getProjectRoot(projectId) {
|
|
125510
125584
|
const cached2 = this.projectRootCache.get(projectId);
|
|
@@ -128886,7 +128960,7 @@ var TOOL_NAME_NORMALIZE, classifyToolCall = (_source, payload) => {
|
|
|
128886
128960
|
if (lowerPrompt.includes("blocked on") || lowerPrompt.includes("waiting on") || lowerPrompt.includes("can't proceed") || lowerPrompt.includes("stuck on")) {
|
|
128887
128961
|
return "blocked-on";
|
|
128888
128962
|
}
|
|
128889
|
-
if (lowerPrompt.startsWith("
|
|
128963
|
+
if (lowerPrompt.startsWith("act as") || lowerPrompt.startsWith("you are a")) {
|
|
128890
128964
|
return "role";
|
|
128891
128965
|
}
|
|
128892
128966
|
return "user-prompts";
|
|
@@ -129519,31 +129593,31 @@ class TracePathService {
|
|
|
129519
129593
|
const chains = [];
|
|
129520
129594
|
const seen = new Set;
|
|
129521
129595
|
let walks = 0;
|
|
129522
|
-
const walk = (fqn,
|
|
129596
|
+
const walk = (fqn, path33) => {
|
|
129523
129597
|
if (chains.length >= CHAIN_CAP)
|
|
129524
129598
|
return;
|
|
129525
129599
|
if (walks >= MAX_WALKS)
|
|
129526
129600
|
return;
|
|
129527
129601
|
walks++;
|
|
129528
|
-
const key =
|
|
129602
|
+
const key = path33.join("\u2192");
|
|
129529
129603
|
if (seen.has(key))
|
|
129530
129604
|
return;
|
|
129531
129605
|
seen.add(key);
|
|
129532
129606
|
const next = adj.get(fqn);
|
|
129533
129607
|
if (!next || next.length === 0 || !whoHasChild.has(fqn)) {
|
|
129534
|
-
if (
|
|
129535
|
-
chains.push(
|
|
129608
|
+
if (path33.length > 1)
|
|
129609
|
+
chains.push(path33.map((n2) => this.fqnToName(n2)).join(" \u2192 "));
|
|
129536
129610
|
return;
|
|
129537
129611
|
}
|
|
129538
129612
|
for (const child of next) {
|
|
129539
129613
|
if (chains.length >= CHAIN_CAP || walks >= MAX_WALKS)
|
|
129540
129614
|
return;
|
|
129541
|
-
if (
|
|
129542
|
-
const cycled = [...
|
|
129615
|
+
if (path33.includes(child)) {
|
|
129616
|
+
const cycled = [...path33, `${this.fqnToName(child)}\u21BA`];
|
|
129543
129617
|
chains.push(cycled.map((n2) => n2).join(" \u2192 "));
|
|
129544
129618
|
continue;
|
|
129545
129619
|
}
|
|
129546
|
-
walk(child, [...
|
|
129620
|
+
walk(child, [...path33, child]);
|
|
129547
129621
|
}
|
|
129548
129622
|
};
|
|
129549
129623
|
for (const seed of seeds) {
|
|
@@ -132717,9 +132791,9 @@ var init_inference_probe = __esm(() => {
|
|
|
132717
132791
|
});
|
|
132718
132792
|
|
|
132719
132793
|
// ../../packages/core/dist/services/health/local-health-checker.js
|
|
132720
|
-
import
|
|
132794
|
+
import fs22 from "fs/promises";
|
|
132721
132795
|
import { existsSync as existsSync3 } from "fs";
|
|
132722
|
-
import
|
|
132796
|
+
import path35 from "path";
|
|
132723
132797
|
|
|
132724
132798
|
class LocalHealthChecker {
|
|
132725
132799
|
dataDir = config.get("dataDir");
|
|
@@ -132797,10 +132871,10 @@ class LocalHealthChecker {
|
|
|
132797
132871
|
const start = Date.now();
|
|
132798
132872
|
try {
|
|
132799
132873
|
if (!existsSync3(this.dataDir))
|
|
132800
|
-
await
|
|
132801
|
-
const probe2 =
|
|
132802
|
-
await
|
|
132803
|
-
await
|
|
132874
|
+
await fs22.mkdir(this.dataDir, { recursive: true });
|
|
132875
|
+
const probe2 = path35.join(this.dataDir, ".health-check-test");
|
|
132876
|
+
await fs22.writeFile(probe2, "ok");
|
|
132877
|
+
await fs22.unlink(probe2);
|
|
132804
132878
|
return { available: true, latency: Date.now() - start, details: { path: this.dataDir, writable: true } };
|
|
132805
132879
|
} catch (error51) {
|
|
132806
132880
|
return { available: false, latency: Date.now() - start, error: `Data directory error: ${error51.message}` };
|
|
@@ -134873,9 +134947,9 @@ var init_scheduler2 = __esm(() => {
|
|
|
134873
134947
|
});
|
|
134874
134948
|
|
|
134875
134949
|
// ../../packages/core/dist/services/pricing/models-dev-client.js
|
|
134876
|
-
import
|
|
134950
|
+
import fs23 from "fs/promises";
|
|
134877
134951
|
import { existsSync as existsSync4 } from "fs";
|
|
134878
|
-
import
|
|
134952
|
+
import path36 from "path";
|
|
134879
134953
|
function getModelsDevClient() {
|
|
134880
134954
|
if (!clientInstance) {
|
|
134881
134955
|
clientInstance = new ModelsDevClient;
|
|
@@ -134895,7 +134969,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134895
134969
|
memoryCacheTimestamp = 0;
|
|
134896
134970
|
getLocalCachePath() {
|
|
134897
134971
|
const dataDir = config.get("dataDir");
|
|
134898
|
-
return
|
|
134972
|
+
return path36.join(dataDir, ModelsDevClient.LOCAL_CACHE_FILE);
|
|
134899
134973
|
}
|
|
134900
134974
|
async loadLocalCache() {
|
|
134901
134975
|
const cachePath = this.getLocalCachePath();
|
|
@@ -134903,7 +134977,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
134903
134977
|
if (!existsSync4(cachePath)) {
|
|
134904
134978
|
return null;
|
|
134905
134979
|
}
|
|
134906
|
-
const content = await
|
|
134980
|
+
const content = await fs23.readFile(cachePath, "utf-8");
|
|
134907
134981
|
const data = JSON.parse(content);
|
|
134908
134982
|
const age = Date.now() - data.timestamp;
|
|
134909
134983
|
if (age > ModelsDevClient.LOCAL_CACHE_TTL) {
|
|
@@ -134930,14 +135004,14 @@ var init_models_dev_client = __esm(() => {
|
|
|
134930
135004
|
async saveLocalCache(models) {
|
|
134931
135005
|
const cachePath = this.getLocalCachePath();
|
|
134932
135006
|
try {
|
|
134933
|
-
const dir =
|
|
134934
|
-
await
|
|
135007
|
+
const dir = path36.dirname(cachePath);
|
|
135008
|
+
await fs23.mkdir(dir, { recursive: true });
|
|
134935
135009
|
const data = {
|
|
134936
135010
|
timestamp: Date.now(),
|
|
134937
135011
|
version: "1.0.0",
|
|
134938
135012
|
models: Object.fromEntries(models)
|
|
134939
135013
|
};
|
|
134940
|
-
await
|
|
135014
|
+
await fs23.writeFile(cachePath, JSON.stringify(data), "utf-8");
|
|
134941
135015
|
logger.debug("Saved pricing to local cache", {
|
|
134942
135016
|
models: models.size,
|
|
134943
135017
|
path: cachePath
|
|
@@ -135267,7 +135341,7 @@ var init_models_dev_client = __esm(() => {
|
|
|
135267
135341
|
const cachePath = this.getLocalCachePath();
|
|
135268
135342
|
try {
|
|
135269
135343
|
if (existsSync4(cachePath)) {
|
|
135270
|
-
await
|
|
135344
|
+
await fs23.unlink(cachePath);
|
|
135271
135345
|
logger.debug("Local pricing cache file deleted");
|
|
135272
135346
|
}
|
|
135273
135347
|
} catch (error51) {
|
|
@@ -140826,33 +140900,33 @@ var require_URL = __commonJS((exports, module) => {
|
|
|
140826
140900
|
else
|
|
140827
140901
|
return basepath.substring(0, lastslash + 1) + refpath;
|
|
140828
140902
|
}
|
|
140829
|
-
function remove_dot_segments(
|
|
140830
|
-
if (!
|
|
140831
|
-
return
|
|
140903
|
+
function remove_dot_segments(path37) {
|
|
140904
|
+
if (!path37)
|
|
140905
|
+
return path37;
|
|
140832
140906
|
var output = "";
|
|
140833
|
-
while (
|
|
140834
|
-
if (
|
|
140835
|
-
|
|
140907
|
+
while (path37.length > 0) {
|
|
140908
|
+
if (path37 === "." || path37 === "..") {
|
|
140909
|
+
path37 = "";
|
|
140836
140910
|
break;
|
|
140837
140911
|
}
|
|
140838
|
-
var twochars =
|
|
140839
|
-
var threechars =
|
|
140840
|
-
var fourchars =
|
|
140912
|
+
var twochars = path37.substring(0, 2);
|
|
140913
|
+
var threechars = path37.substring(0, 3);
|
|
140914
|
+
var fourchars = path37.substring(0, 4);
|
|
140841
140915
|
if (threechars === "../") {
|
|
140842
|
-
|
|
140916
|
+
path37 = path37.substring(3);
|
|
140843
140917
|
} else if (twochars === "./") {
|
|
140844
|
-
|
|
140918
|
+
path37 = path37.substring(2);
|
|
140845
140919
|
} else if (threechars === "/./") {
|
|
140846
|
-
|
|
140847
|
-
} else if (twochars === "/." &&
|
|
140848
|
-
|
|
140849
|
-
} else if (fourchars === "/../" || threechars === "/.." &&
|
|
140850
|
-
|
|
140920
|
+
path37 = "/" + path37.substring(3);
|
|
140921
|
+
} else if (twochars === "/." && path37.length === 2) {
|
|
140922
|
+
path37 = "/";
|
|
140923
|
+
} else if (fourchars === "/../" || threechars === "/.." && path37.length === 3) {
|
|
140924
|
+
path37 = "/" + path37.substring(4);
|
|
140851
140925
|
output = output.replace(/\/?[^\/]*$/, "");
|
|
140852
140926
|
} else {
|
|
140853
|
-
var segment =
|
|
140927
|
+
var segment = path37.match(/(\/?([^\/]*))/)[0];
|
|
140854
140928
|
output += segment;
|
|
140855
|
-
|
|
140929
|
+
path37 = path37.substring(segment.length);
|
|
140856
140930
|
}
|
|
140857
140931
|
}
|
|
140858
140932
|
return output;
|
|
@@ -152922,21 +152996,21 @@ function jsonToKeyPathChunks(value, label = "$") {
|
|
|
152922
152996
|
walk(value, label, out);
|
|
152923
152997
|
return out;
|
|
152924
152998
|
}
|
|
152925
|
-
function walk(val,
|
|
152999
|
+
function walk(val, path37, out) {
|
|
152926
153000
|
if (val === null || val === undefined)
|
|
152927
153001
|
return;
|
|
152928
153002
|
if (Array.isArray(val)) {
|
|
152929
153003
|
if (val.length === 0) {
|
|
152930
|
-
out.push({ path:
|
|
153004
|
+
out.push({ path: path37, content: `**${path37}** = _[]_` });
|
|
152931
153005
|
return;
|
|
152932
153006
|
}
|
|
152933
153007
|
if (val.every((v) => v !== null && typeof v === "object")) {
|
|
152934
|
-
val.forEach((v, i) => walk(v, `${
|
|
153008
|
+
val.forEach((v, i) => walk(v, `${path37}[${i}]`, out));
|
|
152935
153009
|
return;
|
|
152936
153010
|
}
|
|
152937
153011
|
const items = val.map((v) => `- \`${String(v)}\``).join(`
|
|
152938
153012
|
`);
|
|
152939
|
-
out.push({ path:
|
|
153013
|
+
out.push({ path: path37, content: `**${path37}**
|
|
152940
153014
|
|
|
152941
153015
|
${items}` });
|
|
152942
153016
|
return;
|
|
@@ -152944,16 +153018,16 @@ ${items}` });
|
|
|
152944
153018
|
if (typeof val === "object") {
|
|
152945
153019
|
const entries = Object.entries(val);
|
|
152946
153020
|
if (entries.length === 0) {
|
|
152947
|
-
out.push({ path:
|
|
153021
|
+
out.push({ path: path37, content: `**${path37}** = _{}_` });
|
|
152948
153022
|
return;
|
|
152949
153023
|
}
|
|
152950
153024
|
for (const [k2, v] of entries) {
|
|
152951
153025
|
const safeKey = /^[A-Za-z_$][\w$]*$/.test(k2) ? k2 : JSON.stringify(k2);
|
|
152952
|
-
walk(v, `${
|
|
153026
|
+
walk(v, `${path37}.${safeKey}`, out);
|
|
152953
153027
|
}
|
|
152954
153028
|
return;
|
|
152955
153029
|
}
|
|
152956
|
-
out.push({ path:
|
|
153030
|
+
out.push({ path: path37, content: `**${path37}** = \`${String(val)}\`` });
|
|
152957
153031
|
}
|
|
152958
153032
|
var gfm, STRIP_SELECTORS, tdCache = null;
|
|
152959
153033
|
var init_html_to_md = __esm(() => {
|
|
@@ -175946,9 +176020,9 @@ async function acquireIndexingLease(request) {
|
|
|
175946
176020
|
|
|
175947
176021
|
// ../../packages/core/dist/services/project-identity/project-root-identity.js
|
|
175948
176022
|
import { realpath as realpath2 } from "fs/promises";
|
|
175949
|
-
import
|
|
176023
|
+
import path29 from "path";
|
|
175950
176024
|
async function canonicalizeProjectRoot(projectPath, canonicalize = realpath2) {
|
|
175951
|
-
return canonicalize(
|
|
176025
|
+
return canonicalize(path29.resolve(projectPath));
|
|
175952
176026
|
}
|
|
175953
176027
|
async function assertProjectRootReuse(options) {
|
|
175954
176028
|
if (!options.storedProjectPath || options.forceReindex)
|
|
@@ -175956,9 +176030,9 @@ async function assertProjectRootReuse(options) {
|
|
|
175956
176030
|
const canonicalize = options.canonicalize ?? realpath2;
|
|
175957
176031
|
let storedCanonical;
|
|
175958
176032
|
try {
|
|
175959
|
-
storedCanonical = await canonicalize(
|
|
176033
|
+
storedCanonical = await canonicalize(path29.resolve(options.storedProjectPath));
|
|
175960
176034
|
} catch {
|
|
175961
|
-
storedCanonical =
|
|
176035
|
+
storedCanonical = path29.resolve(options.storedProjectPath);
|
|
175962
176036
|
}
|
|
175963
176037
|
if (storedCanonical !== options.canonicalProjectPath) {
|
|
175964
176038
|
throw new Error(`Project ID "${options.projectId}" already indexes canonical root ` + `"${storedCanonical}", not "${options.canonicalProjectPath}"; ` + "use forceReindex only after verifying ownership of the existing project");
|
|
@@ -175968,7 +176042,7 @@ async function assertProjectRootReuse(options) {
|
|
|
175968
176042
|
// ../../packages/core/dist/tools/index_project.js
|
|
175969
176043
|
init_workspace_manager();
|
|
175970
176044
|
init_parser_readiness();
|
|
175971
|
-
import
|
|
176045
|
+
import path31 from "path";
|
|
175972
176046
|
|
|
175973
176047
|
class IndexProjectTool {
|
|
175974
176048
|
name = "index_project";
|
|
@@ -176016,7 +176090,7 @@ class IndexProjectTool {
|
|
|
176016
176090
|
try {
|
|
176017
176091
|
await assertParserReadyForIndexing();
|
|
176018
176092
|
const canonicalProjectPath = await canonicalizeProjectRoot(projectPath);
|
|
176019
|
-
const finalProjectId = projectId ||
|
|
176093
|
+
const finalProjectId = projectId || path31.basename(canonicalProjectPath) || "default";
|
|
176020
176094
|
const existing = await workspaceManager.getWorkspace(finalProjectId);
|
|
176021
176095
|
await assertProjectRootReuse({
|
|
176022
176096
|
projectId: finalProjectId,
|
|
@@ -176570,17 +176644,17 @@ function applyReplacer(root, replacer) {
|
|
|
176570
176644
|
return transformChildren(root, replacer, []);
|
|
176571
176645
|
return transformChildren(normalizeValue(replacedRoot), replacer, []);
|
|
176572
176646
|
}
|
|
176573
|
-
function transformChildren(value, replacer,
|
|
176647
|
+
function transformChildren(value, replacer, path32) {
|
|
176574
176648
|
if (isJsonObject(value))
|
|
176575
|
-
return transformObject(value, replacer,
|
|
176649
|
+
return transformObject(value, replacer, path32);
|
|
176576
176650
|
if (isJsonArray(value))
|
|
176577
|
-
return transformArray(value, replacer,
|
|
176651
|
+
return transformArray(value, replacer, path32);
|
|
176578
176652
|
return value;
|
|
176579
176653
|
}
|
|
176580
|
-
function transformObject(obj, replacer,
|
|
176654
|
+
function transformObject(obj, replacer, path32) {
|
|
176581
176655
|
const result = {};
|
|
176582
176656
|
for (const [key, value] of Object.entries(obj)) {
|
|
176583
|
-
const childPath = [...
|
|
176657
|
+
const childPath = [...path32, key];
|
|
176584
176658
|
const replacedValue = replacer(key, value, childPath);
|
|
176585
176659
|
if (replacedValue === undefined)
|
|
176586
176660
|
continue;
|
|
@@ -176588,11 +176662,11 @@ function transformObject(obj, replacer, path31) {
|
|
|
176588
176662
|
}
|
|
176589
176663
|
return result;
|
|
176590
176664
|
}
|
|
176591
|
-
function transformArray(arr, replacer,
|
|
176665
|
+
function transformArray(arr, replacer, path32) {
|
|
176592
176666
|
const result = [];
|
|
176593
176667
|
for (let i = 0;i < arr.length; i++) {
|
|
176594
176668
|
const value = arr[i];
|
|
176595
|
-
const childPath = [...
|
|
176669
|
+
const childPath = [...path32, i];
|
|
176596
176670
|
const replacedValue = replacer(String(i), value, childPath);
|
|
176597
176671
|
if (replacedValue === undefined)
|
|
176598
176672
|
continue;
|
|
@@ -177973,9 +178047,9 @@ init_dist();
|
|
|
177973
178047
|
init_db_connection();
|
|
177974
178048
|
init_alias_resolver();
|
|
177975
178049
|
init_safe_error_summary();
|
|
177976
|
-
import
|
|
178050
|
+
import fs20 from "fs";
|
|
177977
178051
|
import os9 from "os";
|
|
177978
|
-
import
|
|
178052
|
+
import path32 from "path";
|
|
177979
178053
|
|
|
177980
178054
|
// ../../packages/core/dist/services/hooks/session-pin-store.js
|
|
177981
178055
|
var DEFAULT_MAX_SIZE = 1000;
|
|
@@ -178075,7 +178149,7 @@ class AttributionResolver {
|
|
|
178075
178149
|
this.pins = options.pins ?? new SessionPinStore;
|
|
178076
178150
|
this.canonicalize = options.canonicalize ?? defaultCanonicalize;
|
|
178077
178151
|
this.homedir = options.homedir ?? os9.homedir;
|
|
178078
|
-
this.fsRoot = options.fsRoot ?? (() =>
|
|
178152
|
+
this.fsRoot = options.fsRoot ?? (() => path32.parse(path32.sep).root);
|
|
178079
178153
|
}
|
|
178080
178154
|
async resolve(input) {
|
|
178081
178155
|
const caller = input.callerProjectId;
|
|
@@ -178126,7 +178200,7 @@ class AttributionResolver {
|
|
|
178126
178200
|
}
|
|
178127
178201
|
let bestPath = null;
|
|
178128
178202
|
for (const candidate2 of byPath.keys()) {
|
|
178129
|
-
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(
|
|
178203
|
+
if (canonicalCwd === candidate2 || canonicalCwd.startsWith(candidate2.endsWith(path32.sep) ? candidate2 : candidate2 + path32.sep)) {
|
|
178130
178204
|
if (bestPath === null || candidate2.length > bestPath.length) {
|
|
178131
178205
|
bestPath = candidate2;
|
|
178132
178206
|
}
|
|
@@ -178149,7 +178223,7 @@ class AttributionResolver {
|
|
|
178149
178223
|
return projectPath2;
|
|
178150
178224
|
const fsRoot = this.fsRoot();
|
|
178151
178225
|
let normalized = projectPath2;
|
|
178152
|
-
while (normalized.length > fsRoot.length && normalized.endsWith(
|
|
178226
|
+
while (normalized.length > fsRoot.length && normalized.endsWith(path32.sep)) {
|
|
178153
178227
|
normalized = normalized.slice(0, -1);
|
|
178154
178228
|
}
|
|
178155
178229
|
return normalized;
|
|
@@ -178157,10 +178231,10 @@ class AttributionResolver {
|
|
|
178157
178231
|
}
|
|
178158
178232
|
function defaultCanonicalize(cwd) {
|
|
178159
178233
|
try {
|
|
178160
|
-
return
|
|
178234
|
+
return fs20.realpathSync(cwd);
|
|
178161
178235
|
} catch {
|
|
178162
178236
|
try {
|
|
178163
|
-
return
|
|
178237
|
+
return path32.resolve(cwd);
|
|
178164
178238
|
} catch {
|
|
178165
178239
|
return;
|
|
178166
178240
|
}
|
|
@@ -178698,7 +178772,7 @@ init_code_compressor();
|
|
|
178698
178772
|
|
|
178699
178773
|
// ../../packages/core/dist/services/file-read/file-content-cache.js
|
|
178700
178774
|
init_dist();
|
|
178701
|
-
import
|
|
178775
|
+
import fs21 from "fs/promises";
|
|
178702
178776
|
|
|
178703
178777
|
class FileContentCache {
|
|
178704
178778
|
extractMetadata;
|
|
@@ -178731,7 +178805,7 @@ class FileContentCache {
|
|
|
178731
178805
|
metadata: cached2.metadata
|
|
178732
178806
|
};
|
|
178733
178807
|
}
|
|
178734
|
-
const content = await
|
|
178808
|
+
const content = await fs21.readFile(filePath, "utf-8");
|
|
178735
178809
|
const metadata = await this.extractMetadata(content, filePath, options);
|
|
178736
178810
|
evictOldest(this.fileCache, this.FILE_CACHE_MAX_ENTRIES - 1);
|
|
178737
178811
|
this.fileCache.set(cacheKey, {
|
|
@@ -178746,7 +178820,7 @@ class FileContentCache {
|
|
|
178746
178820
|
|
|
178747
178821
|
// ../../packages/core/dist/services/file-read/file-metadata.js
|
|
178748
178822
|
init_dist();
|
|
178749
|
-
import
|
|
178823
|
+
import path33 from "path";
|
|
178750
178824
|
|
|
178751
178825
|
class FileMetadataExtractor {
|
|
178752
178826
|
symbolGraph;
|
|
@@ -178782,7 +178856,7 @@ class FileMetadataExtractor {
|
|
|
178782
178856
|
return metadata;
|
|
178783
178857
|
}
|
|
178784
178858
|
detectLanguage(filePath) {
|
|
178785
|
-
const ext2 =
|
|
178859
|
+
const ext2 = path33.extname(filePath).toLowerCase();
|
|
178786
178860
|
const languageMap2 = {
|
|
178787
178861
|
".ts": "TypeScript",
|
|
178788
178862
|
".tsx": "TypeScript",
|
|
@@ -178899,7 +178973,7 @@ function selectLines(lines, range) {
|
|
|
178899
178973
|
|
|
178900
178974
|
// ../../packages/core/dist/services/file-read/path-containment.js
|
|
178901
178975
|
init_dist();
|
|
178902
|
-
import
|
|
178976
|
+
import path34 from "path";
|
|
178903
178977
|
|
|
178904
178978
|
class PathContainment {
|
|
178905
178979
|
projectRoots;
|
|
@@ -178907,14 +178981,14 @@ class PathContainment {
|
|
|
178907
178981
|
this.projectRoots = projectRoots;
|
|
178908
178982
|
}
|
|
178909
178983
|
async resolveFilePath(filePath, projectId) {
|
|
178910
|
-
if (
|
|
178911
|
-
return
|
|
178984
|
+
if (path34.isAbsolute(filePath)) {
|
|
178985
|
+
return path34.resolve(filePath);
|
|
178912
178986
|
}
|
|
178913
178987
|
if (projectId) {
|
|
178914
178988
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
178915
178989
|
if (root) {
|
|
178916
178990
|
const cleaned = sanitizeFilePath(filePath);
|
|
178917
|
-
return
|
|
178991
|
+
return path34.resolve(root, cleaned);
|
|
178918
178992
|
}
|
|
178919
178993
|
return null;
|
|
178920
178994
|
}
|
|
@@ -178925,17 +178999,17 @@ class PathContainment {
|
|
|
178925
178999
|
if (projectId) {
|
|
178926
179000
|
const root = await this.projectRoots.getProjectRoot(projectId);
|
|
178927
179001
|
if (root)
|
|
178928
|
-
roots.push(
|
|
179002
|
+
roots.push(path34.resolve(root));
|
|
178929
179003
|
}
|
|
178930
|
-
roots.push(
|
|
179004
|
+
roots.push(path34.resolve(process.cwd()));
|
|
178931
179005
|
const envRoots = (process.env.MASSA_AI_READ_FILE_ROOTS ?? "").split(":").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
178932
179006
|
for (const extra of envRoots) {
|
|
178933
|
-
roots.push(
|
|
179007
|
+
roots.push(path34.resolve(extra));
|
|
178934
179008
|
}
|
|
178935
|
-
const target =
|
|
179009
|
+
const target = path34.resolve(absoluteFilePath);
|
|
178936
179010
|
for (const root of roots) {
|
|
178937
|
-
const rel =
|
|
178938
|
-
if (rel !== "" && !rel.startsWith("..") && !
|
|
179011
|
+
const rel = path34.relative(root, target);
|
|
179012
|
+
if (rel !== "" && !rel.startsWith("..") && !path34.isAbsolute(rel)) {
|
|
178939
179013
|
return { allowed: true };
|
|
178940
179014
|
}
|
|
178941
179015
|
if (rel === "")
|
|
@@ -179774,8 +179848,8 @@ init_event_bus();
|
|
|
179774
179848
|
init_llm_client();
|
|
179775
179849
|
init_symbol_graph_service();
|
|
179776
179850
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
179777
|
-
import
|
|
179778
|
-
import
|
|
179851
|
+
import fs24 from "fs";
|
|
179852
|
+
import path37 from "path";
|
|
179779
179853
|
import { spawn as spawn2 } from "child_process";
|
|
179780
179854
|
var FALLBACK_BOOTSTRAP = {
|
|
179781
179855
|
enabled: true,
|
|
@@ -179959,9 +180033,9 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179959
180033
|
}
|
|
179960
180034
|
try {
|
|
179961
180035
|
for (const name26 of README_CANDIDATES) {
|
|
179962
|
-
const p =
|
|
179963
|
-
if (
|
|
179964
|
-
const buf =
|
|
180036
|
+
const p = path37.join(projectRoot, name26);
|
|
180037
|
+
if (fs24.existsSync(p) && fs24.statSync(p).isFile()) {
|
|
180038
|
+
const buf = fs24.readFileSync(p);
|
|
179965
180039
|
signals.readme = buf.slice(0, MAX_README_BYTES).toString("utf8");
|
|
179966
180040
|
break;
|
|
179967
180041
|
}
|
|
@@ -179970,14 +180044,14 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179970
180044
|
logger.debug("bootstrap scan: README read failed", { error: e.message });
|
|
179971
180045
|
}
|
|
179972
180046
|
try {
|
|
179973
|
-
const docsDir =
|
|
179974
|
-
if (
|
|
180047
|
+
const docsDir = path37.join(projectRoot, "docs");
|
|
180048
|
+
if (fs24.existsSync(docsDir) && fs24.statSync(docsDir).isDirectory()) {
|
|
179975
180049
|
const entries = walkMarkdown(docsDir).slice(0, MAX_DOCS);
|
|
179976
180050
|
for (const rel of entries) {
|
|
179977
180051
|
try {
|
|
179978
|
-
const buf =
|
|
180052
|
+
const buf = fs24.readFileSync(rel);
|
|
179979
180053
|
signals.docs.push({
|
|
179980
|
-
path:
|
|
180054
|
+
path: path37.relative(projectRoot, rel),
|
|
179981
180055
|
snippet: buf.slice(0, MAX_DOC_BYTES).toString("utf8")
|
|
179982
180056
|
});
|
|
179983
180057
|
} catch {}
|
|
@@ -179988,10 +180062,10 @@ async function scanSignals(_projectId, projectRoot, caps, symbolGraph, gitRunner
|
|
|
179988
180062
|
}
|
|
179989
180063
|
try {
|
|
179990
180064
|
for (const name26 of MANIFEST_FILES) {
|
|
179991
|
-
const p =
|
|
179992
|
-
if (!
|
|
180065
|
+
const p = path37.join(projectRoot, name26);
|
|
180066
|
+
if (!fs24.existsSync(p) || !fs24.statSync(p).isFile())
|
|
179993
180067
|
continue;
|
|
179994
|
-
const raw2 =
|
|
180068
|
+
const raw2 = fs24.readFileSync(p).slice(0, MAX_MANIFEST_BYTES).toString("utf8");
|
|
179995
180069
|
const kind = name26;
|
|
179996
180070
|
if (name26 === "package.json") {
|
|
179997
180071
|
try {
|
|
@@ -180031,12 +180105,12 @@ function walkMarkdown(dir) {
|
|
|
180031
180105
|
const cur = stack.pop();
|
|
180032
180106
|
let entries;
|
|
180033
180107
|
try {
|
|
180034
|
-
entries =
|
|
180108
|
+
entries = fs24.readdirSync(cur, { withFileTypes: true });
|
|
180035
180109
|
} catch {
|
|
180036
180110
|
continue;
|
|
180037
180111
|
}
|
|
180038
180112
|
for (const e of entries) {
|
|
180039
|
-
const full =
|
|
180113
|
+
const full = path37.join(cur, e.name);
|
|
180040
180114
|
if (e.isDirectory()) {
|
|
180041
180115
|
if (e.name === "node_modules" || e.name.startsWith("."))
|
|
180042
180116
|
continue;
|
|
@@ -181221,8 +181295,8 @@ var checkpointRoutes = new Elysia({ prefix: "/api/v1/checkpoints" }).post("/list
|
|
|
181221
181295
|
|
|
181222
181296
|
// src/routes/project.ts
|
|
181223
181297
|
init_dist();
|
|
181224
|
-
import
|
|
181225
|
-
import
|
|
181298
|
+
import fs25 from "fs/promises";
|
|
181299
|
+
import path38 from "path";
|
|
181226
181300
|
function isDimensionMismatchError(error51) {
|
|
181227
181301
|
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
181228
181302
|
return /dimension mismatch/i.test(message);
|
|
@@ -181442,22 +181516,22 @@ var projectRoutes = new Elysia({ prefix: "/api/v1/project" }).get("/list", async
|
|
|
181442
181516
|
}).post("/upload-and-index", async ({ body }) => {
|
|
181443
181517
|
const rawBase = body.projectId || body.projectPath.replace(/\\/g, "/").split("/").filter(Boolean).pop() || "default";
|
|
181444
181518
|
const finalProjectId = rawBase.replace(/[^a-zA-Z0-9_.-]/g, "_").slice(0, 128);
|
|
181445
|
-
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR ||
|
|
181446
|
-
const stagingDir =
|
|
181447
|
-
await
|
|
181448
|
-
await
|
|
181519
|
+
const uploadRoot = process.env.MASSA_AI_UPLOAD_DIR || path38.join(getGlobalDataDir(), "uploads");
|
|
181520
|
+
const stagingDir = path38.resolve(uploadRoot, finalProjectId);
|
|
181521
|
+
await fs25.rm(stagingDir, { recursive: true, force: true });
|
|
181522
|
+
await fs25.mkdir(stagingDir, { recursive: true });
|
|
181449
181523
|
const WRITE_BATCH = 20;
|
|
181450
181524
|
for (let i = 0;i < body.files.length; i += WRITE_BATCH) {
|
|
181451
181525
|
await Promise.all(body.files.slice(i, i + WRITE_BATCH).map(async (file3) => {
|
|
181452
|
-
if (
|
|
181526
|
+
if (path38.isAbsolute(file3.relativePath) || file3.relativePath.includes("..")) {
|
|
181453
181527
|
throw new Error(`Invalid file path: ${file3.relativePath}`);
|
|
181454
181528
|
}
|
|
181455
|
-
const dest =
|
|
181456
|
-
if (!dest.startsWith(stagingDir +
|
|
181529
|
+
const dest = path38.resolve(stagingDir, file3.relativePath.replace(/\//g, path38.sep));
|
|
181530
|
+
if (!dest.startsWith(stagingDir + path38.sep)) {
|
|
181457
181531
|
throw new Error(`Path escapes staging directory: ${file3.relativePath}`);
|
|
181458
181532
|
}
|
|
181459
|
-
await
|
|
181460
|
-
await
|
|
181533
|
+
await fs25.mkdir(path38.dirname(dest), { recursive: true });
|
|
181534
|
+
await fs25.writeFile(dest, file3.content, "utf-8");
|
|
181461
181535
|
}));
|
|
181462
181536
|
}
|
|
181463
181537
|
return await getIndexProjectTool().handle({
|
|
@@ -181613,8 +181687,8 @@ var analyticsRoutes = new Elysia({ prefix: "/api/v1/analytics" }).post("/", asyn
|
|
|
181613
181687
|
init_dist();
|
|
181614
181688
|
init_config();
|
|
181615
181689
|
init_inference_providers();
|
|
181616
|
-
import
|
|
181617
|
-
import
|
|
181690
|
+
import path39 from "path";
|
|
181691
|
+
import fs26 from "fs";
|
|
181618
181692
|
import os10 from "os";
|
|
181619
181693
|
function resolveConfiguredOllamaEmbeddingModel() {
|
|
181620
181694
|
return process.env.OLLAMA_EMBEDDING_MODEL || loadRawUserConfig().embedding?.model || INFERENCE_PROVIDERS.ollama.defaultModels.embedding;
|
|
@@ -181691,11 +181765,11 @@ var systemRoutes = new Elysia({ prefix: "/api/v1/system" }).get("/info", async (
|
|
|
181691
181765
|
description: "Check PostgreSQL, pgvector, Ollama, and local artifact directory health"
|
|
181692
181766
|
}
|
|
181693
181767
|
}).get("/metrics", async () => {
|
|
181694
|
-
const metricsPath =
|
|
181768
|
+
const metricsPath = path39.join(process.cwd(), "data", "metrics.json");
|
|
181695
181769
|
let metrics2 = {};
|
|
181696
|
-
if (
|
|
181770
|
+
if (fs26.existsSync(metricsPath)) {
|
|
181697
181771
|
try {
|
|
181698
|
-
metrics2 = JSON.parse(
|
|
181772
|
+
metrics2 = JSON.parse(fs26.readFileSync(metricsPath, "utf-8"));
|
|
181699
181773
|
} catch {}
|
|
181700
181774
|
}
|
|
181701
181775
|
const database = await getDatabaseInfo();
|
|
@@ -181889,8 +181963,8 @@ var eventsRoutes = new Elysia({ prefix: "/api/v1" }).get("/events", async ({ que
|
|
|
181889
181963
|
});
|
|
181890
181964
|
|
|
181891
181965
|
// src/routes/workspace.ts
|
|
181892
|
-
import
|
|
181893
|
-
import
|
|
181966
|
+
import fs27 from "fs/promises";
|
|
181967
|
+
import path40 from "path";
|
|
181894
181968
|
import { realpathSync as realpathSync4 } from "fs";
|
|
181895
181969
|
var indexProjectTool2 = null;
|
|
181896
181970
|
function getIndexProjectTool2() {
|
|
@@ -181932,7 +182006,7 @@ function realpathSafe(p) {
|
|
|
181932
182006
|
try {
|
|
181933
182007
|
return realpathSync4(p);
|
|
181934
182008
|
} catch {
|
|
181935
|
-
return
|
|
182009
|
+
return path40.resolve(p);
|
|
181936
182010
|
}
|
|
181937
182011
|
}
|
|
181938
182012
|
var graphController = null;
|
|
@@ -182283,8 +182357,8 @@ var workspaceRoutes = new Elysia({ prefix: "/api/v1" }).get("/workspace/list", a
|
|
|
182283
182357
|
}
|
|
182284
182358
|
const registeredRoot = realpathSafe(workspace.project_path);
|
|
182285
182359
|
const callerRoot = realpathSafe(projectPath2);
|
|
182286
|
-
const rel =
|
|
182287
|
-
const escapes = rel.startsWith("..") ||
|
|
182360
|
+
const rel = path40.relative(registeredRoot, callerRoot);
|
|
182361
|
+
const escapes = rel.startsWith("..") || path40.isAbsolute(rel);
|
|
182288
182362
|
if (registeredRoot !== callerRoot && escapes) {
|
|
182289
182363
|
return {
|
|
182290
182364
|
success: false,
|
|
@@ -182414,8 +182488,8 @@ var workspaceRoutes = new Elysia({ prefix: "/api/v1" }).get("/workspace/list", a
|
|
|
182414
182488
|
} else {
|
|
182415
182489
|
end = start + 20;
|
|
182416
182490
|
}
|
|
182417
|
-
const absolutePath =
|
|
182418
|
-
const content = await
|
|
182491
|
+
const absolutePath = path40.join(workspace.project_path, file3);
|
|
182492
|
+
const content = await fs27.readFile(absolutePath, "utf-8");
|
|
182419
182493
|
const lines = content.split(/\r?\n/);
|
|
182420
182494
|
const slice = lines.slice(start - 1, Math.min(lines.length, end));
|
|
182421
182495
|
const formatted = slice.map((text3, idx) => ({
|
|
@@ -183671,8 +183745,8 @@ var webRoutes = new Elysia({ prefix: "/api/v1/web" }).post("/fetch_and_index", a
|
|
|
183671
183745
|
});
|
|
183672
183746
|
|
|
183673
183747
|
// src/routes/web-ui.ts
|
|
183674
|
-
import
|
|
183675
|
-
import
|
|
183748
|
+
import fs28 from "fs/promises";
|
|
183749
|
+
import path41 from "path";
|
|
183676
183750
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
183677
183751
|
|
|
183678
183752
|
// src/web-ui-trust.ts
|
|
@@ -183716,9 +183790,9 @@ function buildStaticDirCandidates(moduleDir, cwd) {
|
|
|
183716
183790
|
for (const root2 of [moduleDir, cwd]) {
|
|
183717
183791
|
let dir = root2;
|
|
183718
183792
|
for (let i = 0;i < 10; i++) {
|
|
183719
|
-
candidates2.push(
|
|
183720
|
-
candidates2.push(
|
|
183721
|
-
const parent =
|
|
183793
|
+
candidates2.push(path41.resolve(dir, "apps/web-ui/dist/static"));
|
|
183794
|
+
candidates2.push(path41.resolve(dir, "web-ui/dist/static"));
|
|
183795
|
+
const parent = path41.dirname(dir);
|
|
183722
183796
|
if (parent === dir)
|
|
183723
183797
|
break;
|
|
183724
183798
|
dir = parent;
|
|
@@ -183726,11 +183800,11 @@ function buildStaticDirCandidates(moduleDir, cwd) {
|
|
|
183726
183800
|
}
|
|
183727
183801
|
return [...new Set(candidates2)];
|
|
183728
183802
|
}
|
|
183729
|
-
var STATIC_DIR_CANDIDATES = buildStaticDirCandidates(
|
|
183803
|
+
var STATIC_DIR_CANDIDATES = buildStaticDirCandidates(path41.dirname(fileURLToPath3(import.meta.url)), process.cwd());
|
|
183730
183804
|
async function resolveStaticDir() {
|
|
183731
183805
|
for (const dir of STATIC_DIR_CANDIDATES) {
|
|
183732
183806
|
try {
|
|
183733
|
-
const st = await
|
|
183807
|
+
const st = await fs28.stat(dir);
|
|
183734
183808
|
if (st.isDirectory())
|
|
183735
183809
|
return dir;
|
|
183736
183810
|
} catch {}
|
|
@@ -183751,7 +183825,7 @@ var CONTENT_TYPES = {
|
|
|
183751
183825
|
".woff2": "font/woff2"
|
|
183752
183826
|
};
|
|
183753
183827
|
function contentTypeFor(filePath) {
|
|
183754
|
-
const ext2 =
|
|
183828
|
+
const ext2 = path41.extname(filePath).toLowerCase();
|
|
183755
183829
|
return CONTENT_TYPES[ext2] ?? "application/octet-stream";
|
|
183756
183830
|
}
|
|
183757
183831
|
function webUiDisabled() {
|
|
@@ -183762,13 +183836,13 @@ function webUiDisabled() {
|
|
|
183762
183836
|
}
|
|
183763
183837
|
async function resolveSafePath(staticDir, sub) {
|
|
183764
183838
|
const cleaned = sub.replace(/^\/+/, "");
|
|
183765
|
-
const abs =
|
|
183766
|
-
const rel =
|
|
183767
|
-
if (rel.startsWith("..") ||
|
|
183839
|
+
const abs = path41.resolve(staticDir, cleaned);
|
|
183840
|
+
const rel = path41.relative(staticDir, abs);
|
|
183841
|
+
if (rel.startsWith("..") || path41.isAbsolute(rel)) {
|
|
183768
183842
|
return null;
|
|
183769
183843
|
}
|
|
183770
183844
|
try {
|
|
183771
|
-
await
|
|
183845
|
+
await fs28.stat(abs);
|
|
183772
183846
|
return { abs, exists: true };
|
|
183773
183847
|
} catch {
|
|
183774
183848
|
return { abs, exists: false };
|
|
@@ -183791,7 +183865,7 @@ function injectAccessMarkup(html, apiKey, trusted) {
|
|
|
183791
183865
|
return out;
|
|
183792
183866
|
}
|
|
183793
183867
|
async function readShell(indexPath, remoteAddress) {
|
|
183794
|
-
const raw2 = await
|
|
183868
|
+
const raw2 = await fs28.readFile(indexPath, "utf-8");
|
|
183795
183869
|
const trusted = isTrustedWebUiCaller(remoteAddress);
|
|
183796
183870
|
return Buffer.from(injectAccessMarkup(raw2, getConfiguredApiKey(), trusted), "utf-8");
|
|
183797
183871
|
}
|
|
@@ -183808,7 +183882,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183808
183882
|
set3.status = 500;
|
|
183809
183883
|
return { status: 500, error: "web ui static dir not found" };
|
|
183810
183884
|
}
|
|
183811
|
-
const indexPath =
|
|
183885
|
+
const indexPath = path41.join(dir, "index.html");
|
|
183812
183886
|
try {
|
|
183813
183887
|
const body = await readShell(indexPath, remoteAddressOf(request));
|
|
183814
183888
|
set3.headers["content-type"] = contentTypeFor(indexPath);
|
|
@@ -183841,7 +183915,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183841
183915
|
}
|
|
183842
183916
|
if (resolved.exists) {
|
|
183843
183917
|
try {
|
|
183844
|
-
const body = await
|
|
183918
|
+
const body = await fs28.readFile(resolved.abs);
|
|
183845
183919
|
set3.headers["content-type"] = contentTypeFor(resolved.abs);
|
|
183846
183920
|
return body;
|
|
183847
183921
|
} catch {
|
|
@@ -183850,7 +183924,7 @@ var webUiRoutes = new Elysia().get("/ui", async ({ set: set3, request }) => {
|
|
|
183850
183924
|
}
|
|
183851
183925
|
}
|
|
183852
183926
|
try {
|
|
183853
|
-
const body = await readShell(
|
|
183927
|
+
const body = await readShell(path41.join(dir, "index.html"), remoteAddressOf(request));
|
|
183854
183928
|
set3.headers["content-type"] = "text/html; charset=utf-8";
|
|
183855
183929
|
return body;
|
|
183856
183930
|
} catch {
|
|
@@ -183998,8 +184072,8 @@ init_dist();
|
|
|
183998
184072
|
|
|
183999
184073
|
// src/routes/model-registry-deployment.ts
|
|
184000
184074
|
init_dist();
|
|
184001
|
-
import
|
|
184002
|
-
var MARKER =
|
|
184075
|
+
import path42 from "path";
|
|
184076
|
+
var MARKER = path42.join("scripts", "generate-subagent-artifacts.ts");
|
|
184003
184077
|
var MAX_LEVELS2 = 6;
|
|
184004
184078
|
var cachedRoot;
|
|
184005
184079
|
function findDeploymentRoot(startDir) {
|
|
@@ -184209,8 +184283,8 @@ var configRoutes = new Elysia({ prefix: "/api/v1/config" }).get("/", ({ set: set
|
|
|
184209
184283
|
|
|
184210
184284
|
// src/routes/model-registry.ts
|
|
184211
184285
|
init_config();
|
|
184212
|
-
import
|
|
184213
|
-
import
|
|
184286
|
+
import fs29 from "fs";
|
|
184287
|
+
import path43 from "path";
|
|
184214
184288
|
import { spawnSync } from "child_process";
|
|
184215
184289
|
var _profilesLib = null;
|
|
184216
184290
|
function profilesLib() {
|
|
@@ -184219,7 +184293,7 @@ function profilesLib() {
|
|
|
184219
184293
|
if (!root2) {
|
|
184220
184294
|
throw new Error(deploymentUnavailableMessage("scripts/lib/model-profiles.ts"));
|
|
184221
184295
|
}
|
|
184222
|
-
const libPath =
|
|
184296
|
+
const libPath = path43.join(root2, "scripts", "lib", "model-profiles.ts");
|
|
184223
184297
|
_profilesLib = __require(libPath);
|
|
184224
184298
|
}
|
|
184225
184299
|
return _profilesLib;
|
|
@@ -184231,7 +184305,7 @@ function generatorLib() {
|
|
|
184231
184305
|
if (!root2) {
|
|
184232
184306
|
throw new Error(deploymentUnavailableMessage("scripts/generate-subagent-artifacts.ts"));
|
|
184233
184307
|
}
|
|
184234
|
-
const libPath =
|
|
184308
|
+
const libPath = path43.join(root2, "scripts", "generate-subagent-artifacts.ts");
|
|
184235
184309
|
_generatorLib = __require(libPath);
|
|
184236
184310
|
}
|
|
184237
184311
|
return _generatorLib;
|
|
@@ -184276,7 +184350,7 @@ function overlayShapeViolations(overlay) {
|
|
|
184276
184350
|
var REGISTRY_DETAIL = {
|
|
184277
184351
|
tags: ["model-registry"]
|
|
184278
184352
|
};
|
|
184279
|
-
var OVERLAY_PATH =
|
|
184353
|
+
var OVERLAY_PATH = path43.join(configDir("massa-ai"), "model-profiles.json");
|
|
184280
184354
|
var ZERO_OVERLAY_OVERRIDE_BREAKDOWN = {
|
|
184281
184355
|
models: 0,
|
|
184282
184356
|
profiles: 0
|
|
@@ -184375,7 +184449,7 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
184375
184449
|
set3.status = 501;
|
|
184376
184450
|
return { success: false, error: deploymentUnavailableMessage("scripts/generate-subagent-artifacts.ts") };
|
|
184377
184451
|
}
|
|
184378
|
-
const generateScript =
|
|
184452
|
+
const generateScript = path43.join(root2, "scripts", "generate-subagent-artifacts.ts");
|
|
184379
184453
|
try {
|
|
184380
184454
|
const child = spawnSync("bun", [generateScript], {
|
|
184381
184455
|
env: { ...process.env },
|
|
@@ -184414,8 +184488,8 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
184414
184488
|
}
|
|
184415
184489
|
const lib = profilesLib();
|
|
184416
184490
|
try {
|
|
184417
|
-
if (
|
|
184418
|
-
|
|
184491
|
+
if (fs29.existsSync(OVERLAY_PATH)) {
|
|
184492
|
+
fs29.unlinkSync(OVERLAY_PATH);
|
|
184419
184493
|
}
|
|
184420
184494
|
const builtin = lib.loadRegistry(lib.DEFAULT_REGISTRY_PATH);
|
|
184421
184495
|
set3.status = 200;
|
|
@@ -184441,17 +184515,17 @@ var modelRegistryRoutes = new Elysia({ prefix: "/api/v1/model-registry" }).get("
|
|
|
184441
184515
|
}
|
|
184442
184516
|
});
|
|
184443
184517
|
function writeOverlayAtomically(overlayPath, data) {
|
|
184444
|
-
const dir =
|
|
184445
|
-
if (!
|
|
184446
|
-
|
|
184518
|
+
const dir = path43.dirname(overlayPath);
|
|
184519
|
+
if (!fs29.existsSync(dir)) {
|
|
184520
|
+
fs29.mkdirSync(dir, { recursive: true });
|
|
184447
184521
|
}
|
|
184448
184522
|
const tmp = `${overlayPath}.${process.pid}.${Date.now()}.tmp`;
|
|
184449
184523
|
try {
|
|
184450
|
-
|
|
184451
|
-
|
|
184524
|
+
fs29.writeFileSync(tmp, JSON.stringify(data, null, 2));
|
|
184525
|
+
fs29.renameSync(tmp, overlayPath);
|
|
184452
184526
|
} catch (e) {
|
|
184453
184527
|
try {
|
|
184454
|
-
|
|
184528
|
+
fs29.unlinkSync(tmp);
|
|
184455
184529
|
} catch {}
|
|
184456
184530
|
throw e;
|
|
184457
184531
|
}
|
|
@@ -184460,8 +184534,8 @@ function writeOverlayAtomically(overlayPath, data) {
|
|
|
184460
184534
|
// src/routes/model-registry-stream.ts
|
|
184461
184535
|
init_config();
|
|
184462
184536
|
init_dist();
|
|
184463
|
-
import
|
|
184464
|
-
import
|
|
184537
|
+
import fs30 from "fs";
|
|
184538
|
+
import path44 from "path";
|
|
184465
184539
|
import { spawn as spawn3 } from "child_process";
|
|
184466
184540
|
var encoder3 = new TextEncoder;
|
|
184467
184541
|
function sseFrame(data) {
|
|
@@ -184473,10 +184547,10 @@ var KNOWN_GENERATOR_FILENAMES = ["generate-skill-artifacts.ts", "generate-subage
|
|
|
184473
184547
|
var SH_C_WRAPPER = /^sh -c '(.*)' --$/;
|
|
184474
184548
|
var GENERATOR_SEGMENT = /^bun\s+(\S+\.ts)(?:\s+"\$@")?$/;
|
|
184475
184549
|
function deriveGeneratorScripts(root2) {
|
|
184476
|
-
const pkgPath =
|
|
184550
|
+
const pkgPath = path44.join(root2, "package.json");
|
|
184477
184551
|
let raw2;
|
|
184478
184552
|
try {
|
|
184479
|
-
raw2 =
|
|
184553
|
+
raw2 = fs30.readFileSync(pkgPath, "utf-8");
|
|
184480
184554
|
} catch (e) {
|
|
184481
184555
|
throw new Error(`cannot read ${pkgPath}: ${e.message}`);
|
|
184482
184556
|
}
|
|
@@ -184503,7 +184577,7 @@ function deriveGeneratorScripts(root2) {
|
|
|
184503
184577
|
throw new Error(`"generate:artifacts" segment does not match the expected "bun <script.ts>" shape: ${JSON.stringify(segment)}`);
|
|
184504
184578
|
}
|
|
184505
184579
|
const relPath = match2[1];
|
|
184506
|
-
return { relPath, name:
|
|
184580
|
+
return { relPath, name: path44.basename(relPath) };
|
|
184507
184581
|
});
|
|
184508
184582
|
}
|
|
184509
184583
|
function assertGeneratorBackstop(scripts) {
|
|
@@ -184655,7 +184729,7 @@ function createRegenerateStreamHandler() {
|
|
|
184655
184729
|
return;
|
|
184656
184730
|
}
|
|
184657
184731
|
const generator = generatorScripts[index];
|
|
184658
|
-
const scriptPath =
|
|
184732
|
+
const scriptPath = path44.join(root2, generator.relPath);
|
|
184659
184733
|
try {
|
|
184660
184734
|
child = spawn3("bun", [scriptPath], {
|
|
184661
184735
|
env: { ...process.env },
|
|
@@ -184813,7 +184887,7 @@ var restartRoutes = new Elysia({ prefix: "/api/v1/system" }).onAfterResponse(()
|
|
|
184813
184887
|
|
|
184814
184888
|
// src/routes/logs.ts
|
|
184815
184889
|
init_dist();
|
|
184816
|
-
import
|
|
184890
|
+
import fs31 from "fs";
|
|
184817
184891
|
var LOGS_DETAIL = { tags: ["logs"] };
|
|
184818
184892
|
var MAX_SCAN_BYTES = 64 * 1024 * 1024;
|
|
184819
184893
|
var MAX_LIMIT = 1000;
|
|
@@ -184893,7 +184967,7 @@ function parseLine(line, prevTs) {
|
|
|
184893
184967
|
function realReadTail(filePath, maxBytes) {
|
|
184894
184968
|
let size;
|
|
184895
184969
|
try {
|
|
184896
|
-
size =
|
|
184970
|
+
size = fs31.statSync(filePath).size;
|
|
184897
184971
|
} catch {
|
|
184898
184972
|
return { content: "", truncated: false };
|
|
184899
184973
|
}
|
|
@@ -184901,24 +184975,24 @@ function realReadTail(filePath, maxBytes) {
|
|
|
184901
184975
|
return { content: "", truncated: false };
|
|
184902
184976
|
if (size <= maxBytes) {
|
|
184903
184977
|
try {
|
|
184904
|
-
return { content:
|
|
184978
|
+
return { content: fs31.readFileSync(filePath, "utf8"), truncated: false };
|
|
184905
184979
|
} catch {
|
|
184906
184980
|
return { content: "", truncated: false };
|
|
184907
184981
|
}
|
|
184908
184982
|
}
|
|
184909
184983
|
try {
|
|
184910
|
-
const fd =
|
|
184984
|
+
const fd = fs31.openSync(filePath, "r");
|
|
184911
184985
|
try {
|
|
184912
184986
|
const start = size - maxBytes;
|
|
184913
184987
|
const buf = Buffer.alloc(maxBytes);
|
|
184914
|
-
|
|
184988
|
+
fs31.readSync(fd, buf, 0, maxBytes, start);
|
|
184915
184989
|
let text3 = buf.toString("utf8");
|
|
184916
184990
|
const firstNewline = text3.indexOf(`
|
|
184917
184991
|
`);
|
|
184918
184992
|
text3 = firstNewline !== -1 ? text3.slice(firstNewline + 1) : "";
|
|
184919
184993
|
return { content: text3, truncated: true };
|
|
184920
184994
|
} finally {
|
|
184921
|
-
|
|
184995
|
+
fs31.closeSync(fd);
|
|
184922
184996
|
}
|
|
184923
184997
|
} catch {
|
|
184924
184998
|
return { content: "", truncated: true };
|
|
@@ -184928,7 +185002,7 @@ var realReader = {
|
|
|
184928
185002
|
listFiles(filePath, maxFiles) {
|
|
184929
185003
|
return sinkFiles(filePath, maxFiles).filter((f) => {
|
|
184930
185004
|
try {
|
|
184931
|
-
|
|
185005
|
+
fs31.accessSync(f, fs31.constants.R_OK);
|
|
184932
185006
|
return true;
|
|
184933
185007
|
} catch {
|
|
184934
185008
|
return false;
|
|
@@ -185017,7 +185091,7 @@ function startSinkTail(enqueue) {
|
|
|
185017
185091
|
let currentFile = initial[0];
|
|
185018
185092
|
let offset;
|
|
185019
185093
|
try {
|
|
185020
|
-
offset =
|
|
185094
|
+
offset = fs31.statSync(currentFile).size;
|
|
185021
185095
|
} catch {
|
|
185022
185096
|
return;
|
|
185023
185097
|
}
|
|
@@ -185033,7 +185107,7 @@ function startSinkTail(enqueue) {
|
|
|
185033
185107
|
offset = 0;
|
|
185034
185108
|
carry = "";
|
|
185035
185109
|
}
|
|
185036
|
-
const size =
|
|
185110
|
+
const size = fs31.statSync(currentFile).size;
|
|
185037
185111
|
if (size < offset) {
|
|
185038
185112
|
offset = 0;
|
|
185039
185113
|
carry = "";
|
|
@@ -185042,11 +185116,11 @@ function startSinkTail(enqueue) {
|
|
|
185042
185116
|
return;
|
|
185043
185117
|
const length = Math.min(size - offset, SINK_POLL_MAX_BYTES);
|
|
185044
185118
|
const buf = Buffer.alloc(length);
|
|
185045
|
-
const fd =
|
|
185119
|
+
const fd = fs31.openSync(currentFile, "r");
|
|
185046
185120
|
try {
|
|
185047
|
-
|
|
185121
|
+
fs31.readSync(fd, buf, 0, length, offset);
|
|
185048
185122
|
} finally {
|
|
185049
|
-
|
|
185123
|
+
fs31.closeSync(fd);
|
|
185050
185124
|
}
|
|
185051
185125
|
offset += length;
|
|
185052
185126
|
const text3 = carry + buf.toString("utf8");
|
|
@@ -185246,12 +185320,12 @@ var READ_ONLY_ROUTES = [
|
|
|
185246
185320
|
justification: "Clean. apps/tools-api/src/routes/workspace.ts:542-673 calls " + "`getGraphController().analyzeImpact(...)`, which " + "(packages/core/src/services/symbol/graph-controller.ts:189-232) delegates to " + "`impactAnalysisService.analyze(...)` " + "(packages/core/src/services/symbol/impact-analysis.ts). Every git invocation there " + "runs through `execFileSync` for `rev-parse`/`diff`/`status`-class read commands, " + "plus one `hash-object -t tree --stdin` with no `-w` flag (so nothing is written to " + "the git object database) \u2014 no `git commit`, `git add`, or `-w` flag anywhere in " + "the module."
|
|
185247
185321
|
}
|
|
185248
185322
|
];
|
|
185249
|
-
function normalizeRoutePath(
|
|
185250
|
-
return
|
|
185323
|
+
function normalizeRoutePath(path45) {
|
|
185324
|
+
return path45.length > 1 && path45.endsWith("/") ? path45.slice(0, -1) : path45;
|
|
185251
185325
|
}
|
|
185252
185326
|
var READ_ONLY_INDEX = new Map(READ_ONLY_ROUTES.map((entry2) => [`${entry2.method} ${entry2.path}`, entry2]));
|
|
185253
|
-
function findReadOnlyRoute(method,
|
|
185254
|
-
return READ_ONLY_INDEX.get(`${method.toUpperCase()} ${normalizeRoutePath(
|
|
185327
|
+
function findReadOnlyRoute(method, path45) {
|
|
185328
|
+
return READ_ONLY_INDEX.get(`${method.toUpperCase()} ${normalizeRoutePath(path45)}`);
|
|
185255
185329
|
}
|
|
185256
185330
|
|
|
185257
185331
|
// src/middleware/write-mode.ts
|
|
@@ -185270,14 +185344,14 @@ var WRITE_REFUSED = {
|
|
|
185270
185344
|
success: false,
|
|
185271
185345
|
error: "Write refused: read-only mode is active"
|
|
185272
185346
|
};
|
|
185273
|
-
var writeModeMiddleware = new Elysia({ name: "write-mode" }).onBeforeHandle({ as: "global" }, ({ request, path:
|
|
185347
|
+
var writeModeMiddleware = new Elysia({ name: "write-mode" }).onBeforeHandle({ as: "global" }, ({ request, path: path45, set: set3, body }) => {
|
|
185274
185348
|
if (request.method.toUpperCase() === "GET")
|
|
185275
185349
|
return;
|
|
185276
|
-
if (isPublicPath(
|
|
185350
|
+
if (isPublicPath(path45))
|
|
185277
185351
|
return;
|
|
185278
185352
|
if (!isReadOnlyModeActive())
|
|
185279
185353
|
return;
|
|
185280
|
-
const entry2 = findReadOnlyRoute(request.method,
|
|
185354
|
+
const entry2 = findReadOnlyRoute(request.method, path45);
|
|
185281
185355
|
if (entry2) {
|
|
185282
185356
|
if (entry2.sanitizeBody && body && typeof body === "object") {
|
|
185283
185357
|
entry2.sanitizeBody(body);
|
|
@@ -185290,11 +185364,11 @@ var writeModeMiddleware = new Elysia({ name: "write-mode" }).onBeforeHandle({ as
|
|
|
185290
185364
|
|
|
185291
185365
|
// src/middleware/error.ts
|
|
185292
185366
|
init_dist();
|
|
185293
|
-
var errorHandler = new Elysia({ name: "error-handler" }).onError(({ code, error: error51, set: set3, path:
|
|
185367
|
+
var errorHandler = new Elysia({ name: "error-handler" }).onError(({ code, error: error51, set: set3, path: path45, request }) => {
|
|
185294
185368
|
logger.error("[massa-ai-api] Request failed", undefined, {
|
|
185295
185369
|
...safeErrorSummary(error51),
|
|
185296
185370
|
code,
|
|
185297
|
-
path:
|
|
185371
|
+
path: path45,
|
|
185298
185372
|
method: request.method
|
|
185299
185373
|
});
|
|
185300
185374
|
if (error51 instanceof SearchServiceError) {
|