@snap/valdi 1.0.8 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/.bootstrap/apps/cli_application/BUILD.bazel.template +7 -0
  2. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +11 -0
  3. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/src/index.ts +1 -0
  4. package/.bootstrap/apps/ui_application/.eslint.rc +27 -0
  5. package/.bootstrap/apps/ui_application/BUILD.bazel.template +19 -0
  6. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +21 -0
  7. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/res/valdi@3x.png +0 -0
  8. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/src/App.tsx +133 -0
  9. package/.bootstrap/apps/ui_application/package.json +24 -0
  10. package/.bootstrap/modules/polyglot_bridge_module/BUILD.bazel.template +54 -0
  11. package/.bootstrap/modules/polyglot_bridge_module/android/CalculatorModuleFactory.kt.template +18 -0
  12. package/.bootstrap/modules/polyglot_bridge_module/ios/SCCCalculatorModuleFactory.m.template +31 -0
  13. package/.bootstrap/modules/polyglot_bridge_module/src/Calculator.d.ts +4 -0
  14. package/.bootstrap/modules/polyglot_bridge_module/web/Calculator.ts +11 -0
  15. package/.bootstrap/modules/polyglot_bridge_module/web/tsconfig.json +16 -0
  16. package/.bootstrap/modules/polyglot_view_module/BUILD.bazel.template +75 -0
  17. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeView.kt.template +41 -0
  18. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeViewAttributesBinder.kt.template +17 -0
  19. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.h +8 -0
  20. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.m +23 -0
  21. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.h +8 -0
  22. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.m +23 -0
  23. package/.bootstrap/modules/polyglot_view_module/src/PolyglotCustomView.tsx.template +23 -0
  24. package/.bootstrap/modules/polyglot_view_module/web/PolyglotWeb.ts.template +30 -0
  25. package/.bootstrap/modules/polyglot_view_module/web/tsconfig.json +16 -0
  26. package/.bootstrap/modules/ui_component/BUILD.bazel.template +34 -0
  27. package/.bootstrap/modules/ui_component/src/NewModuleComponent.tsx +45 -0
  28. package/.metadata/.bazelrc.template +92 -0
  29. package/.metadata/.bazelversion.template +1 -0
  30. package/.metadata/.editorconfig.template +37 -0
  31. package/.metadata/.eslintrc.js.template +27 -0
  32. package/.metadata/.gitignore.template +4 -0
  33. package/.metadata/.prettierrc.json.template +7 -0
  34. package/.metadata/.watchmanconfig.template +8 -0
  35. package/.metadata/AGENTS.md.template +16 -0
  36. package/.metadata/MODULE.bazel.template +62 -0
  37. package/.metadata/README.md.template +31 -0
  38. package/.metadata/config.yaml.template +1 -0
  39. package/.metadata/package.json.template +23 -0
  40. package/.metadata/skill-reference.tsx.template +8 -0
  41. package/.metadata/skill-tests-BUILD.bazel.template +21 -0
  42. package/.metadata/skill-tests-README.md.template +17 -0
  43. package/.metadata/skill.md.template +27 -0
  44. package/bundled-skills/registry.json +14 -2
  45. package/bundled-skills/skills/valdi-animations/skill.md +197 -0
  46. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +1 -1
  47. package/bundled-skills/skills/valdi-bazel/skill.md +21 -2
  48. package/bundled-skills/skills/valdi-component-dedup/skill.md +263 -0
  49. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +1 -1
  50. package/bundled-skills/skills/valdi-custom-view/skill.md +49 -5
  51. package/bundled-skills/skills/valdi-error-handling/skill.md +238 -0
  52. package/bundled-skills/skills/valdi-gestures/skill.md +198 -0
  53. package/bundled-skills/skills/valdi-inspect/skill.md +217 -0
  54. package/bundled-skills/skills/valdi-localization/skill.md +142 -0
  55. package/bundled-skills/skills/valdi-mock-breakdown/skill.md +327 -0
  56. package/bundled-skills/skills/valdi-mock-iterate/skill.md +216 -0
  57. package/bundled-skills/skills/valdi-mock-to-module/scripts/diff.py +392 -0
  58. package/bundled-skills/skills/valdi-mock-to-module/scripts/extract_colors.py +277 -0
  59. package/bundled-skills/skills/valdi-mock-to-module/scripts/find_icon.py +303 -0
  60. package/bundled-skills/skills/valdi-mock-to-module/scripts/snapshot-and-diff.sh +53 -0
  61. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_diff.py +207 -0
  62. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_extract_colors.py +167 -0
  63. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_find_icon.py +188 -0
  64. package/bundled-skills/skills/valdi-mock-to-module/scripts/watch-and-diff.sh +181 -0
  65. package/bundled-skills/skills/valdi-mock-to-module/skill.md +451 -0
  66. package/bundled-skills/skills/valdi-navigation/skill.md +187 -0
  67. package/bundled-skills/skills/valdi-overview/skill.md +7 -4
  68. package/bundled-skills/skills/valdi-perf/skill.md +223 -0
  69. package/bundled-skills/skills/valdi-polyglot-module/skill.md +131 -12
  70. package/bundled-skills/skills/valdi-preview/skill.md +303 -0
  71. package/bundled-skills/skills/valdi-profile/skill.md +126 -0
  72. package/bundled-skills/skills/valdi-setup/skill.md +55 -5
  73. package/bundled-skills/skills/valdi-testing/skill.md +23 -7
  74. package/bundled-skills/skills/valdi-tsx/skill.md +69 -5
  75. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +29 -5
  76. package/dist/commands/agentCheck.js +184 -0
  77. package/dist/commands/analyze.js +16 -0
  78. package/dist/commands/analyze_commands/duplicates.js +134 -0
  79. package/dist/commands/bootstrap.js +57 -73
  80. package/dist/commands/doctor.js +40 -203
  81. package/dist/commands/hotreload.js +15 -0
  82. package/dist/commands/inspect.js +16 -0
  83. package/dist/commands/inspect_commands/contexts.js +55 -0
  84. package/dist/commands/inspect_commands/devices.js +53 -0
  85. package/dist/commands/inspect_commands/heap.js +59 -0
  86. package/dist/commands/inspect_commands/select.js +43 -0
  87. package/dist/commands/inspect_commands/snapshot.js +129 -0
  88. package/dist/commands/inspect_commands/snapshot.spec.js +105 -0
  89. package/dist/commands/inspect_commands/status.js +68 -0
  90. package/dist/commands/inspect_commands/tree.js +86 -0
  91. package/dist/commands/preview.js +81 -0
  92. package/dist/commands/profile.js +16 -0
  93. package/dist/commands/profile_commands/capture.js +106 -0
  94. package/dist/commands/projectsync.js +9 -7
  95. package/dist/commands/skills_commands/install.js +6 -1
  96. package/dist/commands/skills_commands/update.js +2 -1
  97. package/dist/core/analyze/clusterer.js +150 -0
  98. package/dist/core/analyze/fingerprint.js +2 -0
  99. package/dist/core/analyze/knownPatterns.js +76 -0
  100. package/dist/core/analyze/parser.js +177 -0
  101. package/dist/core/analyze/reporter.js +83 -0
  102. package/dist/core/analyze/scanner.js +172 -0
  103. package/dist/core/analyze/similarity.js +56 -0
  104. package/dist/core/constants.js +1 -1
  105. package/dist/core/packageFiles.spec.js +29 -0
  106. package/dist/preview/previewGenerator.js +240 -0
  107. package/dist/preview/previewGenerator.spec.js +203 -0
  108. package/dist/preview/viewModelParser.js +86 -0
  109. package/dist/preview/viewModelParser.spec.js +171 -0
  110. package/dist/setup/DevSetupHelper.js +0 -51
  111. package/dist/setup/linuxSetup.js +0 -2
  112. package/dist/setup/macOSSetup.js +1 -4
  113. package/dist/utils/BazelClient.js +15 -0
  114. package/dist/utils/daemonClient.js +344 -0
  115. package/dist/utils/hermesClient.js +252 -0
  116. package/dist/utils/skillsAdapters.js +86 -5
  117. package/dist/utils/skillsAdapters.spec.js +60 -0
  118. package/dist/utils/skillsRegistry.js +8 -0
  119. package/dist/utils/stringUtils.spec.js +1 -1
  120. package/package.json +30 -12
  121. package/dist/setup/versions.js +0 -8
@@ -6,7 +6,6 @@ const fs = tslib_1.__importStar(require("fs"));
6
6
  const os = tslib_1.__importStar(require("os"));
7
7
  const path_1 = tslib_1.__importDefault(require("path"));
8
8
  const constants_1 = require("../core/constants");
9
- const versions_1 = require("../setup/versions");
10
9
  const BazelClient_1 = require("../utils/BazelClient");
11
10
  const cliUtils_1 = require("../utils/cliUtils");
12
11
  const errorUtils_1 = require("../utils/errorUtils");
@@ -48,7 +47,6 @@ class ValdiDoctor {
48
47
  }
49
48
  await this.checkEssentialPlatformTools();
50
49
  await this.checkJavaInstallation();
51
- this.checkAndroidSDKBasics();
52
50
  await this.checkCoreDependencies();
53
51
  await this.checkGitLfsInitialization();
54
52
  this.checkShellAutoComplete();
@@ -281,23 +279,41 @@ class ValdiDoctor {
281
279
  }
282
280
  }
283
281
  async checkEssentialPlatformTools() {
284
- const androidHome = process.env['ANDROID_HOME'] || process.env['ANDROID_SDK_ROOT'];
285
- if (androidHome && fs.existsSync(androidHome)) {
286
- this.addResult({
287
- name: 'Android SDK',
288
- status: 'pass',
289
- message: `Android SDK found at ${androidHome}`,
290
- category: 'Android installation',
291
- });
282
+ this.addResult({
283
+ name: 'Android SDK',
284
+ status: 'pass',
285
+ message: 'Android SDK, NDK, and build tools are managed hermetically by Bazel',
286
+ details: 'See bzl/hermetic_android_sdk.bzl and bzl/hermetic_ndk.bzl',
287
+ category: 'Android installation',
288
+ });
289
+ if ((0, cliUtils_1.checkCommandExists)('adb')) {
290
+ try {
291
+ const { stdout } = await (0, cliUtils_1.runCliCommand)('adb --version');
292
+ const versionLine = stdout.split('\n')[0] || 'Unknown version';
293
+ this.addResult({
294
+ name: 'adb (Android Debug Bridge)',
295
+ status: 'pass',
296
+ message: `adb is installed: ${versionLine}`,
297
+ category: 'Android installation',
298
+ });
299
+ }
300
+ catch {
301
+ this.addResult({
302
+ name: 'adb (Android Debug Bridge)',
303
+ status: 'pass',
304
+ message: 'adb is installed',
305
+ category: 'Android installation',
306
+ });
307
+ }
292
308
  }
293
309
  else {
310
+ const fixCommand = this.getFixCommandForDependency('adb');
294
311
  this.addResult({
295
- name: 'Android SDK',
312
+ name: 'adb (Android Debug Bridge)',
296
313
  status: 'warn',
297
- message: 'Android SDK not found',
298
- details: 'Required for Android app development. Set ANDROID_HOME environment variable.',
314
+ message: 'adb is not installed — needed for device interaction (push, logcat, etc.)',
299
315
  fixable: true,
300
- fixCommand: 'Install Android Studio and set ANDROID_HOME',
316
+ fixCommand,
301
317
  category: 'Android installation',
302
318
  });
303
319
  }
@@ -516,86 +532,6 @@ class ValdiDoctor {
516
532
  }
517
533
  }
518
534
  }
519
- checkAndroidSDKBasics() {
520
- const androidHome = process.env['ANDROID_HOME'] || process.env['ANDROID_SDK_ROOT'];
521
- if (!androidHome || !fs.existsSync(androidHome)) {
522
- this.addResult({
523
- name: 'Android SDK Components',
524
- status: 'warn',
525
- message: 'Cannot check Android SDK components - ANDROID_HOME not set',
526
- details: 'Set ANDROID_HOME environment variable for Android development',
527
- fixable: true,
528
- fixCommand: 'Install Android Studio and set ANDROID_HOME',
529
- category: 'Android installation',
530
- });
531
- return;
532
- }
533
- const platformsDir = path_1.default.join(androidHome, 'platforms');
534
- if (fs.existsSync(platformsDir)) {
535
- const platforms = fs.readdirSync(platformsDir).filter(dir => dir.startsWith('android-'));
536
- if (platforms.length > 0) {
537
- this.addResult({
538
- name: 'Android Platform',
539
- status: 'pass',
540
- message: `Android Platform installed (${platforms.length} version${platforms.length > 1 ? 's' : ''})`,
541
- category: 'Android installation',
542
- });
543
- }
544
- else {
545
- this.addResult({
546
- name: 'Android Platform',
547
- status: 'warn',
548
- message: 'No Android Platform found',
549
- details: 'Install an Android Platform via Android Studio SDK Manager',
550
- fixable: true,
551
- fixCommand: 'Open Android Studio > SDK Manager > Install an Android Platform',
552
- category: 'Android installation',
553
- });
554
- }
555
- }
556
- else {
557
- this.addResult({
558
- name: 'Android Platform',
559
- status: 'warn',
560
- message: 'Android platforms directory not found',
561
- fixable: true,
562
- fixCommand: 'Install Android Studio and configure SDK',
563
- category: 'Android installation',
564
- });
565
- }
566
- const buildToolsDir = path_1.default.join(androidHome, 'build-tools');
567
- if (fs.existsSync(buildToolsDir)) {
568
- const buildTools = fs.readdirSync(buildToolsDir);
569
- if (buildTools.length > 0) {
570
- this.addResult({
571
- name: 'Android Build Tools',
572
- status: 'pass',
573
- message: `Android Build Tools installed (${buildTools.length} version${buildTools.length > 1 ? 's' : ''})`,
574
- category: 'Android installation',
575
- });
576
- }
577
- else {
578
- this.addResult({
579
- name: 'Android Build Tools',
580
- status: 'warn',
581
- message: 'No Android Build Tools found',
582
- fixable: true,
583
- fixCommand: 'Install Build Tools via Android Studio SDK Manager',
584
- category: 'Android installation',
585
- });
586
- }
587
- }
588
- else {
589
- this.addResult({
590
- name: 'Android Build Tools',
591
- status: 'warn',
592
- message: 'Build tools directory not found',
593
- fixable: true,
594
- fixCommand: 'Install Android Studio and configure SDK',
595
- category: 'Android installation',
596
- });
597
- }
598
- }
599
535
  async checkCoreDependencies() {
600
536
  const coreDeps = ['git', 'npm', 'watchman'];
601
537
  for (const dep of coreDeps) {
@@ -815,50 +751,13 @@ class ValdiDoctor {
815
751
  }
816
752
  }
817
753
  checkAdvancedAndroidSDK() {
818
- const androidHome = process.env['ANDROID_HOME'] || process.env['ANDROID_SDK_ROOT'];
819
- if (!androidHome || !fs.existsSync(androidHome)) {
820
- return;
821
- }
822
- const platformPath = path_1.default.join(androidHome, 'platforms', versions_1.ANDROID_PLATFORM_VERSION);
823
- if (fs.existsSync(platformPath)) {
824
- this.addResult({
825
- name: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION}`,
826
- status: 'pass',
827
- message: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION} installed`,
828
- category: 'Android installation',
829
- });
830
- }
831
- else {
832
- this.addResult({
833
- name: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION}`,
834
- status: 'warn',
835
- message: `Android Platform ${versions_1.ANDROID_PLATFORM_VERSION} not found`,
836
- details: 'Specific platform version for framework development',
837
- fixable: true,
838
- fixCommand: `sdkmanager --install 'platforms;${versions_1.ANDROID_PLATFORM_VERSION}'`,
839
- category: 'Android installation',
840
- });
841
- }
842
- const ndkPath = path_1.default.join(androidHome, 'ndk', versions_1.ANDROID_NDK_VERSION);
843
- if (fs.existsSync(ndkPath)) {
844
- this.addResult({
845
- name: 'Android NDK',
846
- status: 'pass',
847
- message: `Android NDK ${versions_1.ANDROID_NDK_VERSION} installed`,
848
- category: 'Android installation',
849
- });
850
- }
851
- else {
852
- this.addResult({
853
- name: 'Android NDK',
854
- status: 'warn',
855
- message: `Android NDK ${versions_1.ANDROID_NDK_VERSION} not found`,
856
- details: 'Required for native development in framework',
857
- fixable: true,
858
- fixCommand: `sdkmanager --install 'ndk;${versions_1.ANDROID_NDK_VERSION}'`,
859
- category: 'Android installation',
860
- });
861
- }
754
+ this.addResult({
755
+ name: 'Android SDK',
756
+ status: 'pass',
757
+ message: 'Android SDK, NDK, and build tools are managed hermetically by Bazel',
758
+ details: 'See bzl/hermetic_android_sdk.bzl and bzl/hermetic_ndk.bzl',
759
+ category: 'Android installation',
760
+ });
862
761
  }
863
762
  async checkSingleDependency(dep, failureLevel) {
864
763
  let category;
@@ -907,71 +806,6 @@ class ValdiDoctor {
907
806
  }
908
807
  }
909
808
  checkEnvironmentVariables() {
910
- const androidHome = process.env['ANDROID_HOME'];
911
- if (androidHome && fs.existsSync(androidHome)) {
912
- this.addResult({
913
- name: 'ANDROID_HOME',
914
- status: 'pass',
915
- message: `ANDROID_HOME set to ${androidHome}`,
916
- category: 'Android installation',
917
- });
918
- }
919
- else {
920
- this.addResult({
921
- name: 'ANDROID_HOME',
922
- status: 'fail',
923
- message: 'ANDROID_HOME not set or invalid',
924
- details: 'dev_setup configures ANDROID_HOME for Android development',
925
- fixable: true,
926
- fixCommand: 'valdi dev_setup',
927
- category: 'Android installation',
928
- });
929
- }
930
- const androidNdkHome = process.env['ANDROID_NDK_HOME'];
931
- if (androidNdkHome && fs.existsSync(androidNdkHome)) {
932
- this.addResult({
933
- name: 'ANDROID_NDK_HOME',
934
- status: 'pass',
935
- message: `ANDROID_NDK_HOME set to ${androidNdkHome}`,
936
- category: 'Android installation',
937
- });
938
- }
939
- else {
940
- this.addResult({
941
- name: 'ANDROID_NDK_HOME',
942
- status: 'warn',
943
- message: 'ANDROID_NDK_HOME not set or invalid',
944
- details: 'dev_setup configures ANDROID_NDK_HOME for native development',
945
- fixable: true,
946
- fixCommand: 'valdi dev_setup',
947
- category: 'Android installation',
948
- });
949
- }
950
- const pathEnvAndroid = process.env['PATH'] || '';
951
- const androidHomeForPath = process.env['ANDROID_HOME'];
952
- if (androidHomeForPath) {
953
- const platformToolsInPath = pathEnvAndroid.includes(`${androidHomeForPath}/platform-tools`) ||
954
- pathEnvAndroid.includes('platform-tools');
955
- if (platformToolsInPath) {
956
- this.addResult({
957
- name: 'Android platform-tools PATH',
958
- status: 'pass',
959
- message: 'Android platform-tools in PATH',
960
- category: 'Android installation',
961
- });
962
- }
963
- else {
964
- this.addResult({
965
- name: 'Android platform-tools PATH',
966
- status: 'warn',
967
- message: 'Android platform-tools not in PATH',
968
- details: 'dev_setup adds platform-tools (containing adb) to PATH',
969
- fixable: true,
970
- fixCommand: 'export PATH="$ANDROID_HOME/platform-tools:$PATH"',
971
- category: 'Android installation',
972
- });
973
- }
974
- }
975
809
  const pathEnv = process.env['PATH'] || '';
976
810
  if (os.platform() === 'linux') {
977
811
  if (pathEnv.includes('/.valdi/bin')) {
@@ -1029,6 +863,9 @@ class ValdiDoctor {
1029
863
  case 'ios_webkit_debug_proxy': {
1030
864
  return 'brew install ios-webkit-debug-proxy';
1031
865
  }
866
+ case 'adb': {
867
+ return 'brew install android-platform-tools';
868
+ }
1032
869
  default: {
1033
870
  return `brew install ${dep}`;
1034
871
  }
@@ -1,13 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const child_process_1 = require("child_process");
4
5
  const constants_1 = require("../core/constants");
5
6
  const errors_1 = require("../core/errors");
6
7
  const BazelClient_1 = require("../utils/BazelClient");
7
8
  const cliUtils_1 = require("../utils/cliUtils");
8
9
  const errorUtils_1 = require("../utils/errorUtils");
9
10
  const logUtils_1 = require("../utils/logUtils");
11
+ function killExistingHotreloaders() {
12
+ const commands = [
13
+ 'pkill -f valdi_companion',
14
+ 'pkill -f run_hotreloader',
15
+ ];
16
+ for (const cmd of commands) {
17
+ try {
18
+ (0, child_process_1.execSync)(cmd, { stdio: 'ignore' });
19
+ }
20
+ catch {
21
+ }
22
+ }
23
+ }
10
24
  async function hotreloadResolvedTarget(client, resolvedTarget) {
25
+ killExistingHotreloaders();
11
26
  await client.buildTarget(resolvedTarget);
12
27
  const workspaceRoot = await client.getWorkspaceRoot();
13
28
  const buildOutputs = await client.queryBuildOutputs([resolvedTarget]);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ exports.command = 'inspect <command>';
5
+ exports.describe = 'Inspect a running Valdi app — component trees, contexts, screenshots, heap';
6
+ const builder = (yargs) => {
7
+ return yargs
8
+ .commandDir('inspect_commands', { extensions: ['js', 'ts'] })
9
+ .demandCommand(1, 'Use devices, select, status, contexts, tree, snapshot, or heap')
10
+ .recommendCommands()
11
+ .wrap(yargs.terminalWidth())
12
+ .help();
13
+ };
14
+ exports.builder = builder;
15
+ const handler = () => { };
16
+ exports.handler = handler;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const constants_1 = require("../../core/constants");
7
+ const logUtils_1 = require("../../utils/logUtils");
8
+ async function inspectContexts(argv) {
9
+ const port = argv.getArgument('port');
10
+ const clientOverride = argv.getArgument('client');
11
+ const pretty = argv.getArgument('pretty');
12
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
13
+ try {
14
+ await conn.configure();
15
+ const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
16
+ const contexts = await conn.listContexts(clientId);
17
+ if (pretty) {
18
+ if (contexts.length === 0) {
19
+ console.log((0, logUtils_1.wrapInColor)('No active contexts found.', constants_1.ANSI_COLORS.YELLOW_COLOR));
20
+ return;
21
+ }
22
+ console.log((0, logUtils_1.wrapInColor)(`${contexts.length} context(s) on device ${clientId}:\n`, constants_1.ANSI_COLORS.GRAY_COLOR));
23
+ for (const ctx of contexts) {
24
+ console.log(` ${(0, logUtils_1.wrapInColor)(ctx.id, constants_1.ANSI_COLORS.BLUE_COLOR)} ${ctx.rootComponentName}`);
25
+ }
26
+ }
27
+ else {
28
+ console.log(JSON.stringify(contexts));
29
+ }
30
+ }
31
+ finally {
32
+ conn.close();
33
+ }
34
+ }
35
+ exports.command = 'contexts';
36
+ exports.describe = 'List active Valdi root contexts (components) on the device';
37
+ const builder = (yargs) => {
38
+ yargs
39
+ .option('port', {
40
+ describe: 'Daemon TCP port',
41
+ type: 'number',
42
+ default: daemonClient_1.DEFAULT_PORT,
43
+ })
44
+ .option('client', {
45
+ describe: 'Client ID to target (from "valdi inspect devices")',
46
+ type: 'string',
47
+ })
48
+ .option('pretty', {
49
+ describe: 'Human-readable output instead of JSON',
50
+ type: 'boolean',
51
+ default: false,
52
+ });
53
+ };
54
+ exports.builder = builder;
55
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectContexts);
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const constants_1 = require("../../core/constants");
7
+ const logUtils_1 = require("../../utils/logUtils");
8
+ async function inspectDevices(argv) {
9
+ const port = argv.getArgument('port');
10
+ const pretty = argv.getArgument('pretty');
11
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
12
+ try {
13
+ await conn.configure();
14
+ const clients = await conn.listConnectedClients();
15
+ if (pretty) {
16
+ if (clients.length === 0) {
17
+ console.log((0, logUtils_1.wrapInColor)('No devices connected to the Valdi daemon.', constants_1.ANSI_COLORS.YELLOW_COLOR));
18
+ return;
19
+ }
20
+ const nameWidth = 30;
21
+ const platWidth = 12;
22
+ console.log((0, logUtils_1.wrapInColor)(['CLIENT ID'.padEnd(36), 'PLATFORM'.padEnd(platWidth), 'APPLICATION ID'.padEnd(nameWidth)].join(' '), constants_1.ANSI_COLORS.GRAY_COLOR));
23
+ console.log((0, logUtils_1.wrapInColor)('-'.repeat(36 + platWidth + nameWidth + 4), constants_1.ANSI_COLORS.GRAY_COLOR));
24
+ for (const c of clients) {
25
+ console.log([c.client_id.padEnd(36), c.platform.padEnd(platWidth), c.application_id.padEnd(nameWidth)].join(' '));
26
+ }
27
+ console.log((0, logUtils_1.wrapInColor)(`\n${clients.length} device(s) connected`, constants_1.ANSI_COLORS.GRAY_COLOR));
28
+ }
29
+ else {
30
+ console.log(JSON.stringify(clients));
31
+ }
32
+ }
33
+ finally {
34
+ conn.close();
35
+ }
36
+ }
37
+ exports.command = 'devices';
38
+ exports.describe = 'List devices connected to the Valdi daemon';
39
+ const builder = (yargs) => {
40
+ yargs
41
+ .option('port', {
42
+ describe: 'Daemon TCP port',
43
+ type: 'number',
44
+ default: daemonClient_1.DEFAULT_PORT,
45
+ })
46
+ .option('pretty', {
47
+ describe: 'Human-readable output instead of JSON',
48
+ type: 'boolean',
49
+ default: false,
50
+ });
51
+ };
52
+ exports.builder = builder;
53
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectDevices);
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const constants_1 = require("../../core/constants");
7
+ const logUtils_1 = require("../../utils/logUtils");
8
+ async function inspectHeap(argv) {
9
+ const gc = argv.getArgument('gc');
10
+ const port = argv.getArgument('port');
11
+ const clientOverride = argv.getArgument('client');
12
+ const pretty = argv.getArgument('pretty');
13
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
14
+ try {
15
+ await conn.configure();
16
+ const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
17
+ const result = await conn.dumpHeap(clientId, gc);
18
+ if (pretty) {
19
+ const heap = result;
20
+ if (heap?.memoryUsageBytes !== undefined) {
21
+ const mb = (heap.memoryUsageBytes / 1024 / 1024).toFixed(2);
22
+ console.log(`Memory usage: ${(0, logUtils_1.wrapInColor)(`${mb} MB`, constants_1.ANSI_COLORS.YELLOW_COLOR)} (${heap.memoryUsageBytes} bytes)`);
23
+ }
24
+ console.log(JSON.stringify(result, null, 2));
25
+ }
26
+ else {
27
+ console.log(JSON.stringify(result));
28
+ }
29
+ }
30
+ finally {
31
+ conn.close();
32
+ }
33
+ }
34
+ exports.command = 'heap';
35
+ exports.describe = 'Dump JS heap stats for the connected device';
36
+ const builder = (yargs) => {
37
+ yargs
38
+ .option('gc', {
39
+ describe: 'Run garbage collection before dumping heap',
40
+ type: 'boolean',
41
+ default: false,
42
+ })
43
+ .option('port', {
44
+ describe: 'Daemon TCP port',
45
+ type: 'number',
46
+ default: daemonClient_1.DEFAULT_PORT,
47
+ })
48
+ .option('client', {
49
+ describe: 'Client ID to target (from "valdi inspect devices")',
50
+ type: 'string',
51
+ })
52
+ .option('pretty', {
53
+ describe: 'Human-readable output instead of JSON',
54
+ type: 'boolean',
55
+ default: false,
56
+ });
57
+ };
58
+ exports.builder = builder;
59
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectHeap);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const cliUtils_1 = require("../../utils/cliUtils");
7
+ const errors_1 = require("../../core/errors");
8
+ const constants_1 = require("../../core/constants");
9
+ const logUtils_1 = require("../../utils/logUtils");
10
+ async function inspectSelect(argv) {
11
+ const port = argv.getArgument('port');
12
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
13
+ try {
14
+ await conn.configure();
15
+ const clients = await conn.listConnectedClients();
16
+ if (clients.length === 0) {
17
+ throw new errors_1.CliError('No devices connected to the Valdi daemon.');
18
+ }
19
+ const clientId = await (0, cliUtils_1.getUserChoice)(clients.map((c) => ({
20
+ name: `${c.application_id} (${c.platform}) [${c.client_id}]`,
21
+ value: c.client_id,
22
+ })), 'Select a device to use for inspect commands:');
23
+ const config = (0, daemonClient_1.loadInspectConfig)();
24
+ (0, daemonClient_1.saveInspectConfig)({ ...config, selectedClientId: clientId });
25
+ const chosen = clients.find((c) => c.client_id === clientId);
26
+ console.log(`Selected: ${(0, logUtils_1.wrapInColor)(chosen.application_id, constants_1.ANSI_COLORS.GREEN_COLOR)} (${chosen.platform})`);
27
+ console.log((0, logUtils_1.wrapInColor)(`Saved to ~/.valdi-inspect.json`, constants_1.ANSI_COLORS.GRAY_COLOR));
28
+ }
29
+ finally {
30
+ conn.close();
31
+ }
32
+ }
33
+ exports.command = 'select';
34
+ exports.describe = 'Interactively select a device and save it for subsequent inspect commands';
35
+ const builder = (yargs) => {
36
+ yargs.option('port', {
37
+ describe: 'Daemon TCP port',
38
+ type: 'number',
39
+ default: daemonClient_1.DEFAULT_PORT,
40
+ });
41
+ };
42
+ exports.builder = builder;
43
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectSelect);