kiro-mobile-bridge 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiro-mobile-bridge",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A simple mobile web interface for monitoring Kiro IDE agent sessions from your phone over LAN",
5
5
  "type": "module",
6
6
  "main": "src/server.js",
@@ -435,6 +435,7 @@
435
435
  function selectCascade(cascadeId) {
436
436
  selectedCascadeId = cascadeId;
437
437
  currentStyles = null;
438
+ workspaceFiles = []; // Clear file cache when switching cascades
438
439
 
439
440
  if (cascadeId) {
440
441
  fetchStyles(cascadeId).then(() => {
package/src/server.js CHANGED
@@ -1848,8 +1848,6 @@ app.get('/files/:id', async (req, res) => {
1848
1848
  return res.status(404).json({ error: 'Cascade not found' });
1849
1849
  }
1850
1850
 
1851
- console.log(`[Files] Listing workspace files`);
1852
-
1853
1851
  try {
1854
1852
  const fs = await import('fs/promises');
1855
1853
  const path = await import('path');
@@ -1885,9 +1883,72 @@ app.get('/files/:id', async (req, res) => {
1885
1883
  '.cob': 'cobol', '.cbl': 'cobol'
1886
1884
  };
1887
1885
 
1886
+ // Try to get workspace root from Kiro/VS Code window title
1887
+ let workspaceRoot = null;
1888
+
1889
+ // Method 1: Try to extract from main window CDP (VS Code window title contains workspace path)
1890
+ if (mainWindowCDP.connection && mainWindowCDP.connection.rootContextId) {
1891
+ try {
1892
+ const titleScript = `document.title`;
1893
+ const titleResult = await mainWindowCDP.connection.call('Runtime.evaluate', {
1894
+ expression: titleScript,
1895
+ contextId: mainWindowCDP.connection.rootContextId,
1896
+ returnByValue: true
1897
+ });
1898
+
1899
+ const windowTitle = titleResult.result?.value || '';
1900
+ // VS Code/Kiro title format: "filename - foldername - Kiro" or "foldername - Kiro"
1901
+ // Extract the workspace folder name from title
1902
+ const titleParts = windowTitle.split(' - ');
1903
+ if (titleParts.length >= 2) {
1904
+ // The folder name is usually the second-to-last part before "Kiro"
1905
+ const folderName = titleParts[titleParts.length - 2].trim();
1906
+
1907
+ // Try to find this folder in common locations
1908
+ const possibleRoots = [
1909
+ process.cwd(),
1910
+ path.join(process.env.HOME || process.env.USERPROFILE || '', folderName),
1911
+ path.join(process.env.HOME || process.env.USERPROFILE || '', 'projects', folderName),
1912
+ path.join(process.env.HOME || process.env.USERPROFILE || '', 'dev', folderName),
1913
+ path.join(process.env.HOME || process.env.USERPROFILE || '', 'code', folderName),
1914
+ path.join(process.env.HOME || process.env.USERPROFILE || '', 'workspace', folderName),
1915
+ // Windows common paths
1916
+ path.join('C:', 'Users', process.env.USERNAME || '', folderName),
1917
+ path.join('C:', 'gab', folderName),
1918
+ path.join('C:', 'dev', folderName),
1919
+ path.join('C:', 'projects', folderName),
1920
+ ];
1921
+
1922
+ for (const root of possibleRoots) {
1923
+ try {
1924
+ const stat = await fs.stat(root);
1925
+ if (stat.isDirectory()) {
1926
+ // Verify it looks like a project (has package.json, .git, or src folder)
1927
+ const hasPackageJson = await fs.access(path.join(root, 'package.json')).then(() => true).catch(() => false);
1928
+ const hasGit = await fs.access(path.join(root, '.git')).then(() => true).catch(() => false);
1929
+ const hasSrc = await fs.access(path.join(root, 'src')).then(() => true).catch(() => false);
1930
+
1931
+ if (hasPackageJson || hasGit || hasSrc) {
1932
+ workspaceRoot = root;
1933
+ break;
1934
+ }
1935
+ }
1936
+ } catch (e) {
1937
+ // Path doesn't exist, try next
1938
+ }
1939
+ }
1940
+ }
1941
+ } catch (e) {
1942
+ // CDP call failed, continue with fallback
1943
+ }
1944
+ }
1945
+
1946
+ // Method 2: Fallback to current working directory
1947
+ if (!workspaceRoot) {
1948
+ workspaceRoot = process.cwd();
1949
+ }
1950
+
1888
1951
  const files = [];
1889
- // Use parent directory as workspace root (kiro-mobile-bridge is inside the workspace)
1890
- const workspaceRoot = path.dirname(__dirname);
1891
1952
 
1892
1953
  // Recursive function to collect files
1893
1954
  async function collectFiles(dir, relativePath = '', depth = 0) {
@@ -1897,8 +1958,8 @@ app.get('/files/:id', async (req, res) => {
1897
1958
  const entries = await fs.readdir(dir, { withFileTypes: true });
1898
1959
 
1899
1960
  for (const entry of entries) {
1900
- // Skip hidden files/folders EXCEPT .kiro, and common non-code directories
1901
- if ((entry.name.startsWith('.') && entry.name !== '.kiro') ||
1961
+ // Skip hidden files/folders EXCEPT .kiro and .github, and common non-code directories
1962
+ if ((entry.name.startsWith('.') && entry.name !== '.kiro' && entry.name !== '.github') ||
1902
1963
  entry.name === 'node_modules' ||
1903
1964
  entry.name === 'dist' ||
1904
1965
  entry.name === 'build' ||
@@ -1935,7 +1996,7 @@ app.get('/files/:id', async (req, res) => {
1935
1996
  // Sort files: by path for easier browsing
1936
1997
  files.sort((a, b) => a.path.localeCompare(b.path));
1937
1998
 
1938
- console.log(`[Files] Found ${files.length} code files`);
1999
+ console.log(`[Files] Found ${files.length} files in ${workspaceRoot}`);
1939
2000
  res.json({ files, workspaceRoot });
1940
2001
 
1941
2002
  } catch (err) {