@hasna/machines 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/cli/index.js +231 -15
- package/dist/consumer.d.ts +1 -1
- package/dist/consumer.d.ts.map +1 -1
- package/dist/consumer.js +201 -10
- package/dist/index.js +205 -14
- package/dist/mcp/index.js +205 -14
- package/dist/topology.d.ts +21 -0
- package/dist/topology.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/consumer.js
CHANGED
|
@@ -4317,7 +4317,8 @@ var MACHINES_CONSUMER_CAPABILITIES = {
|
|
|
4317
4317
|
compatibility: true,
|
|
4318
4318
|
route_resolution: true,
|
|
4319
4319
|
cli_json_fallback: true,
|
|
4320
|
-
workspace_path_mapping: true
|
|
4320
|
+
workspace_path_mapping: true,
|
|
4321
|
+
workspace_diagnostics: true
|
|
4321
4322
|
};
|
|
4322
4323
|
var MACHINES_CONSUMER_CONTRACT = {
|
|
4323
4324
|
schema_version: MACHINES_CONSUMER_CONTRACT_VERSION,
|
|
@@ -4731,6 +4732,170 @@ function inferRepoRoot(workspaceRoot, repoName) {
|
|
|
4731
4732
|
}
|
|
4732
4733
|
return joinPath(root, repoName);
|
|
4733
4734
|
}
|
|
4735
|
+
function shellQuote(value) {
|
|
4736
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
4737
|
+
}
|
|
4738
|
+
function shellCommand(command) {
|
|
4739
|
+
return command.map(shellQuote).join(" ");
|
|
4740
|
+
}
|
|
4741
|
+
function canCheckPathForMachine(machine, localMachineId) {
|
|
4742
|
+
if (!machine)
|
|
4743
|
+
return false;
|
|
4744
|
+
if (machine.machine_id === localMachineId)
|
|
4745
|
+
return true;
|
|
4746
|
+
return machine.route_hints.some((hint) => hint.kind === "local");
|
|
4747
|
+
}
|
|
4748
|
+
function checkedPathExists(path, check) {
|
|
4749
|
+
if (!path || !check)
|
|
4750
|
+
return null;
|
|
4751
|
+
return existsSync4(path);
|
|
4752
|
+
}
|
|
4753
|
+
function repairHint(input) {
|
|
4754
|
+
const command = [
|
|
4755
|
+
"machines",
|
|
4756
|
+
"workspace",
|
|
4757
|
+
"repair",
|
|
4758
|
+
"--machine",
|
|
4759
|
+
input.machineId,
|
|
4760
|
+
"--project",
|
|
4761
|
+
input.projectId
|
|
4762
|
+
];
|
|
4763
|
+
if (input.repoName)
|
|
4764
|
+
command.push("--repo", input.repoName);
|
|
4765
|
+
if (input.openFilesRepoName)
|
|
4766
|
+
command.push("--open-files-repo", input.openFilesRepoName);
|
|
4767
|
+
command.push("--json");
|
|
4768
|
+
const applyCommand = [...command.slice(0, -1), "--apply", "--json"];
|
|
4769
|
+
return {
|
|
4770
|
+
id: `repair:${input.machineId}:${input.projectId}`,
|
|
4771
|
+
reason: input.reason,
|
|
4772
|
+
command,
|
|
4773
|
+
shell_command: shellCommand(command),
|
|
4774
|
+
apply_command: applyCommand,
|
|
4775
|
+
apply_shell_command: shellCommand(applyCommand)
|
|
4776
|
+
};
|
|
4777
|
+
}
|
|
4778
|
+
function pathDiagnostic(input) {
|
|
4779
|
+
if (!input.path.path) {
|
|
4780
|
+
return {
|
|
4781
|
+
id: input.id,
|
|
4782
|
+
status: "missing",
|
|
4783
|
+
severity: input.required ? "fail" : "warn",
|
|
4784
|
+
message: `${input.label} is unresolved.`,
|
|
4785
|
+
path: null,
|
|
4786
|
+
source: input.path.source,
|
|
4787
|
+
path_exists: null
|
|
4788
|
+
};
|
|
4789
|
+
}
|
|
4790
|
+
if (input.pathExists === false) {
|
|
4791
|
+
return {
|
|
4792
|
+
id: input.id,
|
|
4793
|
+
status: "stale",
|
|
4794
|
+
severity: "fail",
|
|
4795
|
+
message: `${input.label} points to a path that does not exist on this machine.`,
|
|
4796
|
+
path: input.path.path,
|
|
4797
|
+
source: input.path.source,
|
|
4798
|
+
path_exists: false
|
|
4799
|
+
};
|
|
4800
|
+
}
|
|
4801
|
+
if (input.path.source === "inferred") {
|
|
4802
|
+
return {
|
|
4803
|
+
id: input.id,
|
|
4804
|
+
status: "inferred",
|
|
4805
|
+
severity: "warn",
|
|
4806
|
+
message: `${input.label} was inferred from the workspace root; write an explicit manifest mapping for repeatable downstream sync.`,
|
|
4807
|
+
path: input.path.path,
|
|
4808
|
+
source: input.path.source,
|
|
4809
|
+
path_exists: input.pathExists
|
|
4810
|
+
};
|
|
4811
|
+
}
|
|
4812
|
+
return {
|
|
4813
|
+
id: input.id,
|
|
4814
|
+
status: "ok",
|
|
4815
|
+
severity: "ok",
|
|
4816
|
+
message: `${input.label} is explicit enough for downstream sync.`,
|
|
4817
|
+
path: input.path.path,
|
|
4818
|
+
source: input.path.source,
|
|
4819
|
+
path_exists: input.pathExists
|
|
4820
|
+
};
|
|
4821
|
+
}
|
|
4822
|
+
function workspaceDiagnostics(input) {
|
|
4823
|
+
const checkPaths = canCheckPathForMachine(input.machine, input.localMachineId);
|
|
4824
|
+
const diagnostics = [];
|
|
4825
|
+
if (!input.machine) {
|
|
4826
|
+
diagnostics.push({
|
|
4827
|
+
id: "manifest",
|
|
4828
|
+
status: "missing_manifest",
|
|
4829
|
+
severity: "fail",
|
|
4830
|
+
message: "Machine is not present in topology or manifest.",
|
|
4831
|
+
path: null,
|
|
4832
|
+
source: "manifest",
|
|
4833
|
+
path_exists: null
|
|
4834
|
+
});
|
|
4835
|
+
} else if (!input.resolution.evidence.manifest_declared) {
|
|
4836
|
+
diagnostics.push({
|
|
4837
|
+
id: "manifest",
|
|
4838
|
+
status: "missing_manifest",
|
|
4839
|
+
severity: "warn",
|
|
4840
|
+
message: "Machine came from live topology but is not declared in the manifest.",
|
|
4841
|
+
path: null,
|
|
4842
|
+
source: "manifest",
|
|
4843
|
+
path_exists: null
|
|
4844
|
+
});
|
|
4845
|
+
}
|
|
4846
|
+
diagnostics.push(pathDiagnostic({
|
|
4847
|
+
id: "workspace_root",
|
|
4848
|
+
label: "Workspace root",
|
|
4849
|
+
path: input.resolution.paths.workspace_root,
|
|
4850
|
+
pathExists: checkedPathExists(input.resolution.paths.workspace_root.path, checkPaths),
|
|
4851
|
+
required: false
|
|
4852
|
+
}));
|
|
4853
|
+
diagnostics.push(pathDiagnostic({
|
|
4854
|
+
id: "project_root",
|
|
4855
|
+
label: "Project root",
|
|
4856
|
+
path: input.resolution.paths.project_root,
|
|
4857
|
+
pathExists: checkedPathExists(input.resolution.paths.project_root.path, checkPaths),
|
|
4858
|
+
required: true
|
|
4859
|
+
}));
|
|
4860
|
+
diagnostics.push(pathDiagnostic({
|
|
4861
|
+
id: "open_files_root",
|
|
4862
|
+
label: "Open-files root",
|
|
4863
|
+
path: input.resolution.paths.open_files_root,
|
|
4864
|
+
pathExists: checkedPathExists(input.resolution.paths.open_files_root.path, checkPaths),
|
|
4865
|
+
required: false
|
|
4866
|
+
}));
|
|
4867
|
+
if (input.resolution.machine.trust_status !== "trusted") {
|
|
4868
|
+
diagnostics.push({
|
|
4869
|
+
id: "trust",
|
|
4870
|
+
status: "untrusted",
|
|
4871
|
+
severity: "warn",
|
|
4872
|
+
message: `Machine trust status is ${input.resolution.machine.trust_status}; manifest repair apply requires trust or --allow-untrusted.`,
|
|
4873
|
+
path: null,
|
|
4874
|
+
source: "trust",
|
|
4875
|
+
path_exists: null
|
|
4876
|
+
});
|
|
4877
|
+
}
|
|
4878
|
+
if (input.resolution.machine.auth_status !== "authenticated") {
|
|
4879
|
+
diagnostics.push({
|
|
4880
|
+
id: "auth",
|
|
4881
|
+
status: "unknown_auth",
|
|
4882
|
+
severity: "warn",
|
|
4883
|
+
message: `Machine auth status is ${input.resolution.machine.auth_status}; remote sync may still fail if SSH is unavailable.`,
|
|
4884
|
+
path: null,
|
|
4885
|
+
source: "auth",
|
|
4886
|
+
path_exists: null
|
|
4887
|
+
});
|
|
4888
|
+
}
|
|
4889
|
+
const needsRepair = diagnostics.some((entry) => (entry.id === "project_root" || entry.id === "open_files_root") && (entry.status === "missing" || entry.status === "inferred" || entry.status === "stale"));
|
|
4890
|
+
const repairHints = needsRepair ? [repairHint({
|
|
4891
|
+
machineId: input.resolution.machine_id ?? input.resolution.requested_machine_id,
|
|
4892
|
+
projectId: input.resolution.project.project_id,
|
|
4893
|
+
repoName: input.resolution.project.repo_name,
|
|
4894
|
+
openFilesRepoName: input.openFilesRepoName,
|
|
4895
|
+
reason: "Write explicit workspace_paths and open_files_roots manifest metadata."
|
|
4896
|
+
})] : [];
|
|
4897
|
+
return { diagnostics, repairHints };
|
|
4898
|
+
}
|
|
4734
4899
|
function projectPathFromMetadata(metadata, projectId, repoName) {
|
|
4735
4900
|
const keys = [projectId, repoName].filter((value) => Boolean(value));
|
|
4736
4901
|
return readMappedPath({
|
|
@@ -4806,7 +4971,7 @@ function resolveMachineWorkspace(options) {
|
|
|
4806
4971
|
const openFilesRepoName = options.openFilesRepoName ?? "open-files";
|
|
4807
4972
|
if (!machine) {
|
|
4808
4973
|
warnings.push(`machine_not_found:${options.machineId}`);
|
|
4809
|
-
|
|
4974
|
+
const resolution2 = {
|
|
4810
4975
|
schema_version: MACHINES_CONSUMER_CONTRACT_VERSION,
|
|
4811
4976
|
package: topology.package,
|
|
4812
4977
|
ok: false,
|
|
@@ -4820,6 +4985,8 @@ function resolveMachineWorkspace(options) {
|
|
|
4820
4985
|
project_root: { path: null, source: "unresolved" },
|
|
4821
4986
|
open_files_root: { path: null, source: "unresolved" }
|
|
4822
4987
|
},
|
|
4988
|
+
diagnostics: [],
|
|
4989
|
+
repair_hints: [],
|
|
4823
4990
|
evidence: {
|
|
4824
4991
|
topology: true,
|
|
4825
4992
|
matched_by: matchedBy,
|
|
@@ -4828,6 +4995,17 @@ function resolveMachineWorkspace(options) {
|
|
|
4828
4995
|
},
|
|
4829
4996
|
warnings
|
|
4830
4997
|
};
|
|
4998
|
+
const diagnostics2 = workspaceDiagnostics({
|
|
4999
|
+
machine,
|
|
5000
|
+
localMachineId: topology.local_machine_id,
|
|
5001
|
+
resolution: resolution2,
|
|
5002
|
+
openFilesRepoName
|
|
5003
|
+
});
|
|
5004
|
+
return {
|
|
5005
|
+
...resolution2,
|
|
5006
|
+
diagnostics: diagnostics2.diagnostics,
|
|
5007
|
+
repair_hints: diagnostics2.repairHints
|
|
5008
|
+
};
|
|
4831
5009
|
}
|
|
4832
5010
|
const metadata = machine.metadata;
|
|
4833
5011
|
const workspaceRootPath = options.workspaceRoot ?? machine.workspace_path;
|
|
@@ -4846,7 +5024,7 @@ function resolveMachineWorkspace(options) {
|
|
|
4846
5024
|
warnings.push(`open_files_root_inferred:${options.projectId}`);
|
|
4847
5025
|
if (!projectRootPath)
|
|
4848
5026
|
warnings.push(`project_root_unresolved:${options.projectId}`);
|
|
4849
|
-
|
|
5027
|
+
const resolution = {
|
|
4850
5028
|
schema_version: MACHINES_CONSUMER_CONTRACT_VERSION,
|
|
4851
5029
|
package: topology.package,
|
|
4852
5030
|
ok: Boolean(projectRootPath),
|
|
@@ -4869,6 +5047,8 @@ function resolveMachineWorkspace(options) {
|
|
|
4869
5047
|
project_root: { path: projectRootPath, source: projectRootSource },
|
|
4870
5048
|
open_files_root: { path: openFilesRootPath, source: openFilesRootSource }
|
|
4871
5049
|
},
|
|
5050
|
+
diagnostics: [],
|
|
5051
|
+
repair_hints: [],
|
|
4872
5052
|
evidence: {
|
|
4873
5053
|
topology: true,
|
|
4874
5054
|
matched_by: matchedBy,
|
|
@@ -4877,6 +5057,17 @@ function resolveMachineWorkspace(options) {
|
|
|
4877
5057
|
},
|
|
4878
5058
|
warnings
|
|
4879
5059
|
};
|
|
5060
|
+
const diagnostics = workspaceDiagnostics({
|
|
5061
|
+
machine,
|
|
5062
|
+
localMachineId: topology.local_machine_id,
|
|
5063
|
+
resolution,
|
|
5064
|
+
openFilesRepoName
|
|
5065
|
+
});
|
|
5066
|
+
return {
|
|
5067
|
+
...resolution,
|
|
5068
|
+
diagnostics: diagnostics.diagnostics,
|
|
5069
|
+
repair_hints: diagnostics.repairHints
|
|
5070
|
+
};
|
|
4880
5071
|
}
|
|
4881
5072
|
function getLocalMachineTopology(options = {}) {
|
|
4882
5073
|
const topology = discoverMachineTopology(options);
|
|
@@ -4902,7 +5093,7 @@ import { spawnSync as spawnSync2 } from "child_process";
|
|
|
4902
5093
|
import { hostname as hostname4 } from "os";
|
|
4903
5094
|
|
|
4904
5095
|
// src/commands/ssh.ts
|
|
4905
|
-
function
|
|
5096
|
+
function shellQuote2(value) {
|
|
4906
5097
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
4907
5098
|
}
|
|
4908
5099
|
function resolveSshTarget(machineId, options = {}) {
|
|
@@ -4923,11 +5114,11 @@ function resolveSshTarget(machineId, options = {}) {
|
|
|
4923
5114
|
}
|
|
4924
5115
|
function buildSshCommand(machineId, remoteCommand, options = {}) {
|
|
4925
5116
|
const resolved = resolveSshTarget(machineId, options);
|
|
4926
|
-
return remoteCommand ? `ssh ${resolved.target} ${
|
|
5117
|
+
return remoteCommand ? `ssh ${resolved.target} ${shellQuote2(remoteCommand)}` : `ssh ${resolved.target}`;
|
|
4927
5118
|
}
|
|
4928
5119
|
|
|
4929
5120
|
// src/remote.ts
|
|
4930
|
-
function
|
|
5121
|
+
function shellQuote3(value) {
|
|
4931
5122
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
4932
5123
|
}
|
|
4933
5124
|
function machineIsLocal(machineId, localMachineId) {
|
|
@@ -4945,7 +5136,7 @@ function resolveMachineCommand(machineId, command, localMachineId = getLocalMach
|
|
|
4945
5136
|
} catch (error) {
|
|
4946
5137
|
const message = String(error.message ?? error);
|
|
4947
5138
|
if (message.includes("Machine route not found") || message.includes("Machine not found in manifest")) {
|
|
4948
|
-
return { source: "ssh", shellCommand: `ssh ${
|
|
5139
|
+
return { source: "ssh", shellCommand: `ssh ${shellQuote3(machineId)} ${shellQuote3(command)}` };
|
|
4949
5140
|
}
|
|
4950
5141
|
throw error;
|
|
4951
5142
|
}
|
|
@@ -4973,7 +5164,7 @@ var DEFAULT_COMMANDS = [
|
|
|
4973
5164
|
function defaultPackages() {
|
|
4974
5165
|
return [{ name: "@hasna/machines", command: "machines", expectedVersion: getPackageVersion(), required: true }];
|
|
4975
5166
|
}
|
|
4976
|
-
function
|
|
5167
|
+
function shellQuote4(value) {
|
|
4977
5168
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
4978
5169
|
}
|
|
4979
5170
|
function commandId(value) {
|
|
@@ -5024,7 +5215,7 @@ function defaultRunner2(machineId, command) {
|
|
|
5024
5215
|
return runMachineCommand(machineId, command);
|
|
5025
5216
|
}
|
|
5026
5217
|
function inspectCommand(machineId, spec, runner) {
|
|
5027
|
-
const command =
|
|
5218
|
+
const command = shellQuote4(spec.command);
|
|
5028
5219
|
const versionArgs = spec.versionArgs ?? "--version";
|
|
5029
5220
|
const script = [
|
|
5030
5221
|
`cmd=${command}`,
|
|
@@ -5053,7 +5244,7 @@ function fieldCommand(field) {
|
|
|
5053
5244
|
}
|
|
5054
5245
|
function inspectWorkspace(machineId, spec, runner) {
|
|
5055
5246
|
const script = [
|
|
5056
|
-
`path=${
|
|
5247
|
+
`path=${shellQuote4(spec.path)}`,
|
|
5057
5248
|
'printf "exists=%s\\n" "$(test -d "$path" && printf yes || printf no)"',
|
|
5058
5249
|
'pkg="$path/package.json"',
|
|
5059
5250
|
'printf "package_json=%s\\n" "$(test -f "$pkg" && printf yes || printf no)"',
|
package/dist/index.js
CHANGED
|
@@ -11117,7 +11117,8 @@ var MACHINES_CONSUMER_CAPABILITIES = {
|
|
|
11117
11117
|
compatibility: true,
|
|
11118
11118
|
route_resolution: true,
|
|
11119
11119
|
cli_json_fallback: true,
|
|
11120
|
-
workspace_path_mapping: true
|
|
11120
|
+
workspace_path_mapping: true,
|
|
11121
|
+
workspace_diagnostics: true
|
|
11121
11122
|
};
|
|
11122
11123
|
var MACHINES_CONSUMER_CONTRACT = {
|
|
11123
11124
|
schema_version: MACHINES_CONSUMER_CONTRACT_VERSION,
|
|
@@ -11531,6 +11532,170 @@ function inferRepoRoot(workspaceRoot, repoName) {
|
|
|
11531
11532
|
}
|
|
11532
11533
|
return joinPath(root, repoName);
|
|
11533
11534
|
}
|
|
11535
|
+
function shellQuote(value) {
|
|
11536
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
11537
|
+
}
|
|
11538
|
+
function shellCommand(command) {
|
|
11539
|
+
return command.map(shellQuote).join(" ");
|
|
11540
|
+
}
|
|
11541
|
+
function canCheckPathForMachine(machine, localMachineId) {
|
|
11542
|
+
if (!machine)
|
|
11543
|
+
return false;
|
|
11544
|
+
if (machine.machine_id === localMachineId)
|
|
11545
|
+
return true;
|
|
11546
|
+
return machine.route_hints.some((hint) => hint.kind === "local");
|
|
11547
|
+
}
|
|
11548
|
+
function checkedPathExists(path, check) {
|
|
11549
|
+
if (!path || !check)
|
|
11550
|
+
return null;
|
|
11551
|
+
return existsSync4(path);
|
|
11552
|
+
}
|
|
11553
|
+
function repairHint(input) {
|
|
11554
|
+
const command = [
|
|
11555
|
+
"machines",
|
|
11556
|
+
"workspace",
|
|
11557
|
+
"repair",
|
|
11558
|
+
"--machine",
|
|
11559
|
+
input.machineId,
|
|
11560
|
+
"--project",
|
|
11561
|
+
input.projectId
|
|
11562
|
+
];
|
|
11563
|
+
if (input.repoName)
|
|
11564
|
+
command.push("--repo", input.repoName);
|
|
11565
|
+
if (input.openFilesRepoName)
|
|
11566
|
+
command.push("--open-files-repo", input.openFilesRepoName);
|
|
11567
|
+
command.push("--json");
|
|
11568
|
+
const applyCommand = [...command.slice(0, -1), "--apply", "--json"];
|
|
11569
|
+
return {
|
|
11570
|
+
id: `repair:${input.machineId}:${input.projectId}`,
|
|
11571
|
+
reason: input.reason,
|
|
11572
|
+
command,
|
|
11573
|
+
shell_command: shellCommand(command),
|
|
11574
|
+
apply_command: applyCommand,
|
|
11575
|
+
apply_shell_command: shellCommand(applyCommand)
|
|
11576
|
+
};
|
|
11577
|
+
}
|
|
11578
|
+
function pathDiagnostic(input) {
|
|
11579
|
+
if (!input.path.path) {
|
|
11580
|
+
return {
|
|
11581
|
+
id: input.id,
|
|
11582
|
+
status: "missing",
|
|
11583
|
+
severity: input.required ? "fail" : "warn",
|
|
11584
|
+
message: `${input.label} is unresolved.`,
|
|
11585
|
+
path: null,
|
|
11586
|
+
source: input.path.source,
|
|
11587
|
+
path_exists: null
|
|
11588
|
+
};
|
|
11589
|
+
}
|
|
11590
|
+
if (input.pathExists === false) {
|
|
11591
|
+
return {
|
|
11592
|
+
id: input.id,
|
|
11593
|
+
status: "stale",
|
|
11594
|
+
severity: "fail",
|
|
11595
|
+
message: `${input.label} points to a path that does not exist on this machine.`,
|
|
11596
|
+
path: input.path.path,
|
|
11597
|
+
source: input.path.source,
|
|
11598
|
+
path_exists: false
|
|
11599
|
+
};
|
|
11600
|
+
}
|
|
11601
|
+
if (input.path.source === "inferred") {
|
|
11602
|
+
return {
|
|
11603
|
+
id: input.id,
|
|
11604
|
+
status: "inferred",
|
|
11605
|
+
severity: "warn",
|
|
11606
|
+
message: `${input.label} was inferred from the workspace root; write an explicit manifest mapping for repeatable downstream sync.`,
|
|
11607
|
+
path: input.path.path,
|
|
11608
|
+
source: input.path.source,
|
|
11609
|
+
path_exists: input.pathExists
|
|
11610
|
+
};
|
|
11611
|
+
}
|
|
11612
|
+
return {
|
|
11613
|
+
id: input.id,
|
|
11614
|
+
status: "ok",
|
|
11615
|
+
severity: "ok",
|
|
11616
|
+
message: `${input.label} is explicit enough for downstream sync.`,
|
|
11617
|
+
path: input.path.path,
|
|
11618
|
+
source: input.path.source,
|
|
11619
|
+
path_exists: input.pathExists
|
|
11620
|
+
};
|
|
11621
|
+
}
|
|
11622
|
+
function workspaceDiagnostics(input) {
|
|
11623
|
+
const checkPaths = canCheckPathForMachine(input.machine, input.localMachineId);
|
|
11624
|
+
const diagnostics = [];
|
|
11625
|
+
if (!input.machine) {
|
|
11626
|
+
diagnostics.push({
|
|
11627
|
+
id: "manifest",
|
|
11628
|
+
status: "missing_manifest",
|
|
11629
|
+
severity: "fail",
|
|
11630
|
+
message: "Machine is not present in topology or manifest.",
|
|
11631
|
+
path: null,
|
|
11632
|
+
source: "manifest",
|
|
11633
|
+
path_exists: null
|
|
11634
|
+
});
|
|
11635
|
+
} else if (!input.resolution.evidence.manifest_declared) {
|
|
11636
|
+
diagnostics.push({
|
|
11637
|
+
id: "manifest",
|
|
11638
|
+
status: "missing_manifest",
|
|
11639
|
+
severity: "warn",
|
|
11640
|
+
message: "Machine came from live topology but is not declared in the manifest.",
|
|
11641
|
+
path: null,
|
|
11642
|
+
source: "manifest",
|
|
11643
|
+
path_exists: null
|
|
11644
|
+
});
|
|
11645
|
+
}
|
|
11646
|
+
diagnostics.push(pathDiagnostic({
|
|
11647
|
+
id: "workspace_root",
|
|
11648
|
+
label: "Workspace root",
|
|
11649
|
+
path: input.resolution.paths.workspace_root,
|
|
11650
|
+
pathExists: checkedPathExists(input.resolution.paths.workspace_root.path, checkPaths),
|
|
11651
|
+
required: false
|
|
11652
|
+
}));
|
|
11653
|
+
diagnostics.push(pathDiagnostic({
|
|
11654
|
+
id: "project_root",
|
|
11655
|
+
label: "Project root",
|
|
11656
|
+
path: input.resolution.paths.project_root,
|
|
11657
|
+
pathExists: checkedPathExists(input.resolution.paths.project_root.path, checkPaths),
|
|
11658
|
+
required: true
|
|
11659
|
+
}));
|
|
11660
|
+
diagnostics.push(pathDiagnostic({
|
|
11661
|
+
id: "open_files_root",
|
|
11662
|
+
label: "Open-files root",
|
|
11663
|
+
path: input.resolution.paths.open_files_root,
|
|
11664
|
+
pathExists: checkedPathExists(input.resolution.paths.open_files_root.path, checkPaths),
|
|
11665
|
+
required: false
|
|
11666
|
+
}));
|
|
11667
|
+
if (input.resolution.machine.trust_status !== "trusted") {
|
|
11668
|
+
diagnostics.push({
|
|
11669
|
+
id: "trust",
|
|
11670
|
+
status: "untrusted",
|
|
11671
|
+
severity: "warn",
|
|
11672
|
+
message: `Machine trust status is ${input.resolution.machine.trust_status}; manifest repair apply requires trust or --allow-untrusted.`,
|
|
11673
|
+
path: null,
|
|
11674
|
+
source: "trust",
|
|
11675
|
+
path_exists: null
|
|
11676
|
+
});
|
|
11677
|
+
}
|
|
11678
|
+
if (input.resolution.machine.auth_status !== "authenticated") {
|
|
11679
|
+
diagnostics.push({
|
|
11680
|
+
id: "auth",
|
|
11681
|
+
status: "unknown_auth",
|
|
11682
|
+
severity: "warn",
|
|
11683
|
+
message: `Machine auth status is ${input.resolution.machine.auth_status}; remote sync may still fail if SSH is unavailable.`,
|
|
11684
|
+
path: null,
|
|
11685
|
+
source: "auth",
|
|
11686
|
+
path_exists: null
|
|
11687
|
+
});
|
|
11688
|
+
}
|
|
11689
|
+
const needsRepair = diagnostics.some((entry) => (entry.id === "project_root" || entry.id === "open_files_root") && (entry.status === "missing" || entry.status === "inferred" || entry.status === "stale"));
|
|
11690
|
+
const repairHints = needsRepair ? [repairHint({
|
|
11691
|
+
machineId: input.resolution.machine_id ?? input.resolution.requested_machine_id,
|
|
11692
|
+
projectId: input.resolution.project.project_id,
|
|
11693
|
+
repoName: input.resolution.project.repo_name,
|
|
11694
|
+
openFilesRepoName: input.openFilesRepoName,
|
|
11695
|
+
reason: "Write explicit workspace_paths and open_files_roots manifest metadata."
|
|
11696
|
+
})] : [];
|
|
11697
|
+
return { diagnostics, repairHints };
|
|
11698
|
+
}
|
|
11534
11699
|
function projectPathFromMetadata(metadata, projectId, repoName) {
|
|
11535
11700
|
const keys = [projectId, repoName].filter((value) => Boolean(value));
|
|
11536
11701
|
return readMappedPath({
|
|
@@ -11606,7 +11771,7 @@ function resolveMachineWorkspace(options) {
|
|
|
11606
11771
|
const openFilesRepoName = options.openFilesRepoName ?? "open-files";
|
|
11607
11772
|
if (!machine) {
|
|
11608
11773
|
warnings.push(`machine_not_found:${options.machineId}`);
|
|
11609
|
-
|
|
11774
|
+
const resolution2 = {
|
|
11610
11775
|
schema_version: MACHINES_CONSUMER_CONTRACT_VERSION,
|
|
11611
11776
|
package: topology.package,
|
|
11612
11777
|
ok: false,
|
|
@@ -11620,6 +11785,8 @@ function resolveMachineWorkspace(options) {
|
|
|
11620
11785
|
project_root: { path: null, source: "unresolved" },
|
|
11621
11786
|
open_files_root: { path: null, source: "unresolved" }
|
|
11622
11787
|
},
|
|
11788
|
+
diagnostics: [],
|
|
11789
|
+
repair_hints: [],
|
|
11623
11790
|
evidence: {
|
|
11624
11791
|
topology: true,
|
|
11625
11792
|
matched_by: matchedBy,
|
|
@@ -11628,6 +11795,17 @@ function resolveMachineWorkspace(options) {
|
|
|
11628
11795
|
},
|
|
11629
11796
|
warnings
|
|
11630
11797
|
};
|
|
11798
|
+
const diagnostics2 = workspaceDiagnostics({
|
|
11799
|
+
machine,
|
|
11800
|
+
localMachineId: topology.local_machine_id,
|
|
11801
|
+
resolution: resolution2,
|
|
11802
|
+
openFilesRepoName
|
|
11803
|
+
});
|
|
11804
|
+
return {
|
|
11805
|
+
...resolution2,
|
|
11806
|
+
diagnostics: diagnostics2.diagnostics,
|
|
11807
|
+
repair_hints: diagnostics2.repairHints
|
|
11808
|
+
};
|
|
11631
11809
|
}
|
|
11632
11810
|
const metadata = machine.metadata;
|
|
11633
11811
|
const workspaceRootPath = options.workspaceRoot ?? machine.workspace_path;
|
|
@@ -11646,7 +11824,7 @@ function resolveMachineWorkspace(options) {
|
|
|
11646
11824
|
warnings.push(`open_files_root_inferred:${options.projectId}`);
|
|
11647
11825
|
if (!projectRootPath)
|
|
11648
11826
|
warnings.push(`project_root_unresolved:${options.projectId}`);
|
|
11649
|
-
|
|
11827
|
+
const resolution = {
|
|
11650
11828
|
schema_version: MACHINES_CONSUMER_CONTRACT_VERSION,
|
|
11651
11829
|
package: topology.package,
|
|
11652
11830
|
ok: Boolean(projectRootPath),
|
|
@@ -11669,6 +11847,8 @@ function resolveMachineWorkspace(options) {
|
|
|
11669
11847
|
project_root: { path: projectRootPath, source: projectRootSource },
|
|
11670
11848
|
open_files_root: { path: openFilesRootPath, source: openFilesRootSource }
|
|
11671
11849
|
},
|
|
11850
|
+
diagnostics: [],
|
|
11851
|
+
repair_hints: [],
|
|
11672
11852
|
evidence: {
|
|
11673
11853
|
topology: true,
|
|
11674
11854
|
matched_by: matchedBy,
|
|
@@ -11677,6 +11857,17 @@ function resolveMachineWorkspace(options) {
|
|
|
11677
11857
|
},
|
|
11678
11858
|
warnings
|
|
11679
11859
|
};
|
|
11860
|
+
const diagnostics = workspaceDiagnostics({
|
|
11861
|
+
machine,
|
|
11862
|
+
localMachineId: topology.local_machine_id,
|
|
11863
|
+
resolution,
|
|
11864
|
+
openFilesRepoName
|
|
11865
|
+
});
|
|
11866
|
+
return {
|
|
11867
|
+
...resolution,
|
|
11868
|
+
diagnostics: diagnostics.diagnostics,
|
|
11869
|
+
repair_hints: diagnostics.repairHints
|
|
11870
|
+
};
|
|
11680
11871
|
}
|
|
11681
11872
|
function getLocalMachineTopology(options = {}) {
|
|
11682
11873
|
const topology = discoverMachineTopology(options);
|
|
@@ -11702,7 +11893,7 @@ import { spawnSync as spawnSync2 } from "child_process";
|
|
|
11702
11893
|
import { hostname as hostname4 } from "os";
|
|
11703
11894
|
|
|
11704
11895
|
// src/commands/ssh.ts
|
|
11705
|
-
function
|
|
11896
|
+
function shellQuote2(value) {
|
|
11706
11897
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
11707
11898
|
}
|
|
11708
11899
|
function resolveSshTarget(machineId, options = {}) {
|
|
@@ -11723,11 +11914,11 @@ function resolveSshTarget(machineId, options = {}) {
|
|
|
11723
11914
|
}
|
|
11724
11915
|
function buildSshCommand(machineId, remoteCommand, options = {}) {
|
|
11725
11916
|
const resolved = resolveSshTarget(machineId, options);
|
|
11726
|
-
return remoteCommand ? `ssh ${resolved.target} ${
|
|
11917
|
+
return remoteCommand ? `ssh ${resolved.target} ${shellQuote2(remoteCommand)}` : `ssh ${resolved.target}`;
|
|
11727
11918
|
}
|
|
11728
11919
|
|
|
11729
11920
|
// src/remote.ts
|
|
11730
|
-
function
|
|
11921
|
+
function shellQuote3(value) {
|
|
11731
11922
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
11732
11923
|
}
|
|
11733
11924
|
function machineIsLocal(machineId, localMachineId) {
|
|
@@ -11745,7 +11936,7 @@ function resolveMachineCommand(machineId, command, localMachineId = getLocalMach
|
|
|
11745
11936
|
} catch (error) {
|
|
11746
11937
|
const message = String(error.message ?? error);
|
|
11747
11938
|
if (message.includes("Machine route not found") || message.includes("Machine not found in manifest")) {
|
|
11748
|
-
return { source: "ssh", shellCommand: `ssh ${
|
|
11939
|
+
return { source: "ssh", shellCommand: `ssh ${shellQuote3(machineId)} ${shellQuote3(command)}` };
|
|
11749
11940
|
}
|
|
11750
11941
|
throw error;
|
|
11751
11942
|
}
|
|
@@ -11773,7 +11964,7 @@ var DEFAULT_COMMANDS = [
|
|
|
11773
11964
|
function defaultPackages() {
|
|
11774
11965
|
return [{ name: "@hasna/machines", command: "machines", expectedVersion: getPackageVersion(), required: true }];
|
|
11775
11966
|
}
|
|
11776
|
-
function
|
|
11967
|
+
function shellQuote4(value) {
|
|
11777
11968
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
11778
11969
|
}
|
|
11779
11970
|
function commandId(value) {
|
|
@@ -11824,7 +12015,7 @@ function defaultRunner2(machineId, command) {
|
|
|
11824
12015
|
return runMachineCommand(machineId, command);
|
|
11825
12016
|
}
|
|
11826
12017
|
function inspectCommand(machineId, spec, runner) {
|
|
11827
|
-
const command =
|
|
12018
|
+
const command = shellQuote4(spec.command);
|
|
11828
12019
|
const versionArgs = spec.versionArgs ?? "--version";
|
|
11829
12020
|
const script = [
|
|
11830
12021
|
`cmd=${command}`,
|
|
@@ -11853,7 +12044,7 @@ function fieldCommand(field) {
|
|
|
11853
12044
|
}
|
|
11854
12045
|
function inspectWorkspace(machineId, spec, runner) {
|
|
11855
12046
|
const script = [
|
|
11856
|
-
`path=${
|
|
12047
|
+
`path=${shellQuote4(spec.path)}`,
|
|
11857
12048
|
'printf "exists=%s\\n" "$(test -d "$path" && printf yes || printf no)"',
|
|
11858
12049
|
'pkg="$path/package.json"',
|
|
11859
12050
|
'printf "package_json=%s\\n" "$(test -f "$pkg" && printf yes || printf no)"',
|
|
@@ -12148,7 +12339,7 @@ function getAppManager(machine, app) {
|
|
|
12148
12339
|
return "winget";
|
|
12149
12340
|
return "apt";
|
|
12150
12341
|
}
|
|
12151
|
-
function
|
|
12342
|
+
function shellQuote5(value) {
|
|
12152
12343
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
12153
12344
|
}
|
|
12154
12345
|
function buildAppCommand(machine, app) {
|
|
@@ -12169,7 +12360,7 @@ function buildAppCommand(machine, app) {
|
|
|
12169
12360
|
return `sudo apt-get install -y ${packageName}`;
|
|
12170
12361
|
}
|
|
12171
12362
|
function buildAppProbeCommand(machine, app) {
|
|
12172
|
-
const packageName =
|
|
12363
|
+
const packageName = shellQuote5(getPackageName(app));
|
|
12173
12364
|
const manager = getAppManager(machine, app);
|
|
12174
12365
|
if (manager === "custom") {
|
|
12175
12366
|
return `if command -v ${packageName} >/dev/null 2>&1; then printf 'installed=1\\nversion=custom\\n'; else printf 'installed=0\\n'; fi`;
|
|
@@ -12705,7 +12896,7 @@ var notificationConfigSchema = exports_external.object({
|
|
|
12705
12896
|
function sortChannels(channels) {
|
|
12706
12897
|
return [...channels].sort((left, right) => left.id.localeCompare(right.id));
|
|
12707
12898
|
}
|
|
12708
|
-
function
|
|
12899
|
+
function shellQuote6(value) {
|
|
12709
12900
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
12710
12901
|
}
|
|
12711
12902
|
function hasCommand2(binary) {
|
|
@@ -12752,7 +12943,7 @@ ${message}
|
|
|
12752
12943
|
};
|
|
12753
12944
|
}
|
|
12754
12945
|
if (hasCommand2("mail")) {
|
|
12755
|
-
const command = `printf %s ${
|
|
12946
|
+
const command = `printf %s ${shellQuote6(message)} | mail -s ${shellQuote6(subject)} ${shellQuote6(channel.target)}`;
|
|
12756
12947
|
const result = Bun.spawnSync(["bash", "-lc", command], {
|
|
12757
12948
|
stdout: "pipe",
|
|
12758
12949
|
stderr: "pipe",
|