Skip to content

Commit 5ed0837

Browse files
carlye0304charliewwdev
authored andcommitted
fix: Windows lock file - use USERPROFILE fallback when HOME is not set
Co-authored-by: guxiyuesi <339558YYmy>
1 parent cf37e9a commit 5ed0837

20 files changed

Lines changed: 100 additions & 37 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ Then batch multiple actions in one call:
440440

441441
```yaml
442442
dependencies:
443-
flutter_skill: ^0.9.25
443+
flutter_skill: ^0.9.26
444444
```
445445
446446
```dart

intellij-plugin/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "com.aidashboad"
8-
version = "0.9.25"
8+
version = "0.9.26"
99

1010
repositories {
1111
mavenCentral()

intellij-plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin>
22
<id>com.aidashboad.flutterskill</id>
33
<name>Flutter Skill - AI App Automation</name>
4-
<version>0.9.25</version>
4+
<version>0.9.26</version>
55
<vendor email="support@ai-dashboad.com" url="https://github.com/ai-dashboad/flutter-skill">ai-dashboad</vendor>
66

77
<description><![CDATA[

lib/src/bridge/web_bridge_proxy.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,14 @@ class WebBridgeProxy {
156156

157157
// Read the SDK script — try common locations
158158
String? sdkSource;
159+
final home = Platform.environment['HOME'] ??
160+
Platform.environment['USERPROFILE'];
159161
final candidates = [
160162
// Relative to the flutter-skill package
161163
'sdks/web/flutter-skill.js',
162164
// npm global install
163-
'${Platform.environment['HOME']}/.pub-cache/hosted/pub.dev/flutter_skill-latest/sdks/web/flutter-skill.js',
165+
if (home != null)
166+
'$home/.pub-cache/hosted/pub.dev/flutter_skill-latest/sdks/web/flutter-skill.js',
164167
];
165168

166169
for (final path in candidates) {

lib/src/cli/init.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,12 @@ Future<void> _configureMCP() async {
470470
print('');
471471
print('🤖 Configuring AI agent MCP...');
472472

473-
final home = Platform.environment['HOME'] ?? '';
473+
final home = Platform.environment['HOME'] ??
474+
Platform.environment['USERPROFILE'];
475+
if (home == null) {
476+
print(' Warning: Could not determine home directory');
477+
return;
478+
}
474479

475480
// Claude Code
476481
final claudeSettings = File('$home/.claude/settings.json');

lib/src/cli/quickstart.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,14 +773,17 @@ Future<String?> _findFlutter() async {
773773
if (inPath != null) return 'flutter';
774774

775775
// Check common locations
776-
final home = Platform.environment['HOME'] ?? '';
776+
final home = Platform.environment['HOME'] ??
777+
Platform.environment['USERPROFILE'];
777778
final candidates = [
778-
'$home/development/flutter/bin/flutter',
779-
'$home/flutter/bin/flutter',
780-
'$home/.flutter/bin/flutter',
779+
if (home != null) ...[
780+
'$home/development/flutter/bin/flutter',
781+
'$home/flutter/bin/flutter',
782+
'$home/.flutter/bin/flutter',
783+
'$home/snap/flutter/common/flutter/bin/flutter',
784+
'$home/fvm/default/bin/flutter',
785+
],
781786
'/opt/flutter/bin/flutter',
782-
'$home/snap/flutter/common/flutter/bin/flutter',
783-
'$home/fvm/default/bin/flutter',
784787
];
785788
for (final path in candidates) {
786789
if (await File(path).exists()) {

lib/src/cli/server.dart

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ part 'tool_handlers/bug_report_handlers.dart';
6868
part 'tool_handlers/fixture_handlers.dart';
6969
part 'tool_handlers/explore_handlers.dart';
7070

71-
const String currentVersion = '0.9.25';
71+
const String currentVersion = '0.9.26';
7272

7373
/// Session information for multi-session support
7474
class SessionInfo {
@@ -108,9 +108,18 @@ Future<void> runServer(List<String> args) async {
108108
// Acquire lock to prevent multiple instances
109109
final lockFile = await _acquireLock();
110110
if (lockFile == null) {
111-
stderr.writeln('ERROR: Another flutter-skill server is already running.');
112-
stderr.writeln(
113-
'If you believe this is an error, delete: ~/.flutter_skill.lock');
111+
final home = Platform.environment['HOME'] ??
112+
Platform.environment['USERPROFILE'] ??
113+
'~';
114+
_printCliError(
115+
'Another flutter-skill server is already running',
116+
'A lock file prevents starting a second instance.',
117+
fixes: [
118+
'Stop the existing server first',
119+
'Or delete the stale lock: rm "$home/.flutter_skill.lock"',
120+
'On Windows: del "%USERPROFILE%\\.flutter_skill.lock"',
121+
],
122+
);
114123
exit(1);
115124
}
116125

@@ -331,7 +340,25 @@ class FlutterMcpServer {
331340
listener.onClientDisconnected = () {
332341
stderr.writeln('Browser client disconnected from bridge listener');
333342
};
334-
await listener.start(port);
343+
try {
344+
await listener.start(port);
345+
} on SocketException catch (e) {
346+
if (e.message.contains('Address already in use') ||
347+
e.osError?.errorCode == 98 ||
348+
e.osError?.errorCode == 48) {
349+
_printCliError(
350+
'Port $port is already in use',
351+
'Another process is already using this port.',
352+
fixes: [
353+
'Run: lsof -i :$port',
354+
'Kill the process using that port',
355+
'Or start with a different port: flutter-skill --bridge-port=9090',
356+
],
357+
);
358+
exit(1);
359+
}
360+
rethrow;
361+
}
335362
_webBridgeListener = listener;
336363
stderr.writeln('Bridge listener started on ws://127.0.0.1:$port');
337364
}
@@ -1037,11 +1064,30 @@ class FlutterMcpServer {
10371064
/// Export recorded steps as Jest test
10381065
}
10391066

1067+
// ==================== CLI Error Formatting ====================
1068+
1069+
/// Print a structured, actionable CLI error to stderr.
1070+
void _printCliError(String title, String detail, {List<String> fixes = const []}) {
1071+
stderr.writeln('');
1072+
stderr.writeln('❌ $title');
1073+
stderr.writeln('');
1074+
stderr.writeln(' $detail');
1075+
if (fixes.isNotEmpty) {
1076+
stderr.writeln('');
1077+
stderr.writeln('🔧 Suggested Fixes:');
1078+
for (final fix in fixes) {
1079+
stderr.writeln(' • $fix');
1080+
}
1081+
}
1082+
stderr.writeln('');
1083+
}
1084+
10401085
// ==================== Lock Management ====================
10411086

10421087
/// Acquire a lock file to prevent multiple server instances
10431088
Future<File?> _acquireLock() async {
1044-
final home = Platform.environment['HOME'];
1089+
final home = Platform.environment['HOME'] ??
1090+
Platform.environment['USERPROFILE'];
10451091
if (home == null) return null;
10461092

10471093
final lockFile = File('$home/.flutter_skill.lock');

lib/src/cli/tool_handlers/discovery_helpers.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ extension _DiscoveryHelpers on FlutterMcpServer {
4343
}
4444

4545
String _findAdb() {
46+
final home = Platform.environment['HOME'] ??
47+
Platform.environment['USERPROFILE'];
4648
final androidHome = Platform.environment['ANDROID_HOME'] ??
4749
Platform.environment['ANDROID_SDK_ROOT'] ??
48-
'${Platform.environment['HOME']}/Library/Android/sdk';
49-
final adbPath = '$androidHome/platform-tools/adb';
50-
if (File(adbPath).existsSync()) return adbPath;
50+
(home != null ? '$home/Library/Android/sdk' : null);
51+
if (androidHome != null) {
52+
final adbPath = '$androidHome/platform-tools/adb';
53+
if (File(adbPath).existsSync()) return adbPath;
54+
}
5155
return 'adb'; // fallback to PATH
5256
}
5357

packaging/homebrew/flutter-skill.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
class FlutterSkill < Formula
22
desc "MCP Server for Flutter app automation - AI Agent control for Flutter apps"
33
homepage "https://github.com/ai-dashboad/flutter-skill"
4-
version "0.9.25"
4+
version "0.9.26"
55
license "MIT"
66

77
# Platform-specific native binaries
88
on_macos do
99
on_arm do
10-
url "https://github.com/ai-dashboad/flutter-skill/releases/download/v0.9.25/flutter-skill-macos-arm64"
10+
url "https://github.com/ai-dashboad/flutter-skill/releases/download/v0.9.26/flutter-skill-macos-arm64"
1111
sha256 "PLACEHOLDER_ARM64_SHA256"
1212
end
1313
on_intel do
14-
url "https://github.com/ai-dashboad/flutter-skill/releases/download/v0.9.25/flutter-skill-macos-x64"
14+
url "https://github.com/ai-dashboad/flutter-skill/releases/download/v0.9.26/flutter-skill-macos-x64"
1515
sha256 "PLACEHOLDER_X64_SHA256"
1616
end
1717
end
1818

1919
on_linux do
20-
url "https://github.com/ai-dashboad/flutter-skill/releases/download/v0.9.25/flutter-skill-linux-x64"
20+
url "https://github.com/ai-dashboad/flutter-skill/releases/download/v0.9.26/flutter-skill-linux-x64"
2121
sha256 "PLACEHOLDER_LINUX_SHA256"
2222
end
2323

@@ -48,7 +48,7 @@ def caveats
4848
Note: Your Flutter app needs to include the flutter_skill package.
4949
Add to pubspec.yaml:
5050
dependencies:
51-
flutter_skill: ^0.9.25
51+
flutter_skill: ^0.9.26
5252
EOS
5353
end
5454

packaging/npm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "flutter-skill",
33
"mcpName": "io.github.ai-dashboad/flutter-skill",
4-
"version": "0.9.25",
4+
"version": "0.9.26",
55
"description": "MCP Server for app automation - Give your AI Agent eyes and hands inside any app (Flutter, React, Web, Native)",
66
"main": "index.js",
77
"bin": {

0 commit comments

Comments
 (0)