omnifocus_mcp 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4eb86aa8048f5b98edf61273ab7936b859663199e2ad6c73bb11ec55605550d8
4
- data.tar.gz: 7dc7b4f11e986aa96d8b9d746d75a16e7222f13627577ca3e3c420ee4df21bb1
3
+ metadata.gz: e41a69180f0d9273204d7c1768eebccad3d62c0378608e2d5f8d7af2a1e0efc9
4
+ data.tar.gz: a1ead1aa0c0a8c7080c9701a89507d662ab58d76311445f1c53d90a0446578b1
5
5
  SHA512:
6
- metadata.gz: d7886bb913d144e269a8d9605a7e09ac18a9cab49742a62b9bd4f8b835fd034e6f4984ed33dbc38df2709f6ea748b0902b69b6e823da5b7cd58548c645e195ef
7
- data.tar.gz: 033366a6ead47fccfb29bdb0e0df36a1817a124ecea767977bd7c397d26252884fc4e57a3f3e4d6e8b41dc397ad9e6bd2265bf532f3f55ee127d796a300ab00c
6
+ metadata.gz: d07d104a5f1a0d49cef8668099f785fee962ec0cdcf6cf2a23a6899c3bddba4fb184d04cf45094aeb2500f5a32a4cf783ec751b79ca86e1888f1dcd76a99dea6
7
+ data.tar.gz: e99de7a835a14187683b719ac5b876684ebda26cb2f0334ac05c04d20ee5b7d2a404d0f7c9e589de8756d2c9b53803f8635eafb327f55f4d0615bf0048ae1dce
data/bin/omnifocus-mcp CHANGED
@@ -1,7 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ # Keep in sync with OmnifocusMcp::VERSION_ARGS in lib/omnifocus_mcp/version.rb.
5
+ VERSION_ARGS = %w[--version -v version].freeze
6
+
7
+ if ARGV.intersect?(VERSION_ARGS)
8
+ require "omnifocus_mcp/version"
9
+ puts OmnifocusMcp::VERSION
10
+ exit 0
11
+ end
12
+
4
13
  require "bundler/setup"
5
14
  require "omnifocus_mcp"
6
-
7
- OmnifocusMcp::Mcp.start
15
+ OmnifocusMcp::Cli.run
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmnifocusMcp
4
+ # Command-line entry point for the `omnifocus-mcp` executable.
5
+ module Cli
6
+ module_function
7
+
8
+ def run(argv = ARGV)
9
+ if version_requested?(argv)
10
+ print_version
11
+ exit 0
12
+ end
13
+
14
+ Mcp.start
15
+ end
16
+
17
+ def version_requested?(argv)
18
+ argv.intersect?(OmnifocusMcp::VERSION_ARGS)
19
+ end
20
+
21
+ def print_version
22
+ puts VERSION
23
+ end
24
+ end
25
+ end
@@ -10,12 +10,17 @@ module OmnifocusMcp
10
10
  module_function
11
11
 
12
12
  def apply!
13
+ $stdin.set_encoding(Encoding::UTF_8) if $stdin.respond_to?(:set_encoding)
13
14
  patch_server_send_error!
14
15
  patch_stdio_transport!
15
16
  end
16
17
 
17
18
  def normalize_id(id) = id.nil? ? UNKNOWN_REQUEST_ID : id
18
19
 
20
+ # MCP clients send UTF-8 JSON, but stdio may be US-ASCII-labelled (same as
21
+ # osascript stdout in ScriptRunner). Re-label before strip/parse.
22
+ def normalize_line(line) = line.to_s.dup.force_encoding(Encoding::UTF_8).strip
23
+
19
24
  def patch_server_send_error!
20
25
  return if server_send_error_patched?
21
26
 
@@ -29,6 +34,7 @@ module OmnifocusMcp
29
34
  end
30
35
  private_class_method :patch_server_send_error!
31
36
 
37
+ # rubocop:disable Metrics
32
38
  def patch_stdio_transport!
33
39
  return if stdio_transport_patched?
34
40
 
@@ -40,7 +46,7 @@ module OmnifocusMcp
40
46
  @running = true
41
47
 
42
48
  while @running && (line = $stdin.gets)
43
- stripped = line.strip
49
+ stripped = OmnifocusMcp::JsonRpcCompat.normalize_line(line)
44
50
  next if stripped.empty?
45
51
 
46
52
  begin
@@ -60,6 +66,7 @@ module OmnifocusMcp
60
66
  end
61
67
  end
62
68
  end
69
+ # rubocop:enable Metrics
63
70
  private_class_method :patch_stdio_transport!
64
71
 
65
72
  def server_send_error_patched?
@@ -41,7 +41,10 @@ module OmnifocusMcp
41
41
  end
42
42
  end
43
43
 
44
- def start = build_server.start
44
+ def start
45
+ OmnifocusMcp.logger.warn("Starting #{server_name} v#{server_version}")
46
+ build_server.start
47
+ end
45
48
 
46
49
  private
47
50
 
@@ -49,15 +49,15 @@ module OmnifocusMcp
49
49
  parts << "has note: #{f["hasNote"]}" unless f["hasNote"].nil?
50
50
  parts << "inbox: #{f["inbox"]}" unless f["inbox"].nil?
51
51
 
52
- parts << format_on(label: "due", value: f["dueOn"]) unless f["dueOn"].nil?
53
- parts << format_on(label: "defer", value: f["deferOn"]) unless f["deferOn"].nil?
54
- parts << format_on(label: "planned", value: f["plannedOn"]) unless f["plannedOn"].nil?
52
+ parts << format_on(label: "due", value: f["dueOn"]) if f["dueOn"]
53
+ parts << format_on(label: "defer", value: f["deferOn"]) if f["deferOn"]
54
+ parts << format_on(label: "planned", value: f["plannedOn"]) if f["plannedOn"]
55
55
 
56
- parts << "added within #{f["addedWithin"]} days" unless f["addedWithin"].nil?
57
- parts << "added on day #{f["addedOn"]}" unless f["addedOn"].nil?
56
+ parts << "added within #{f["addedWithin"]} days" if f["addedWithin"]
57
+ parts << "added on day #{f["addedOn"]}" if f["addedOn"]
58
58
  parts << "repeating: #{f["isRepeating"]}" unless f["isRepeating"].nil?
59
- parts << "completed within #{f["completedWithin"]} days" unless f["completedWithin"].nil?
60
- parts << "completed on day #{f["completedOn"]}" unless f["completedOn"].nil?
59
+ parts << "completed within #{f["completedWithin"]} days" if f["completedWithin"]
60
+ parts << "completed on day #{f["completedOn"]}" if f["completedOn"]
61
61
 
62
62
  parts.join(", ")
63
63
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmnifocusMcp
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
+ VERSION_ARGS = %w[--version -v version].freeze
5
6
  end
data/lib/omnifocus_mcp.rb CHANGED
@@ -100,3 +100,4 @@ require_relative "omnifocus_mcp/resources/today_resource"
100
100
 
101
101
  # MCP bootstrap depends on everything above.
102
102
  require_relative "omnifocus_mcp/mcp"
103
+ require_relative "omnifocus_mcp/cli"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnifocus_mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Maddocks
@@ -40,9 +40,9 @@ files:
40
40
  - Rakefile
41
41
  - bin/omnifocus-mcp
42
42
  - lib/omnifocus_mcp.rb
43
+ - lib/omnifocus_mcp/cli.rb
43
44
  - lib/omnifocus_mcp/config.rb
44
45
  - lib/omnifocus_mcp/infrastructure.rb
45
- - lib/omnifocus_mcp/infrastructure/.keep
46
46
  - lib/omnifocus_mcp/infrastructure/apple_script.rb
47
47
  - lib/omnifocus_mcp/infrastructure/apple_script_date_builder.rb
48
48
  - lib/omnifocus_mcp/infrastructure/js_embed.rb
@@ -51,7 +51,6 @@ files:
51
51
  - lib/omnifocus_mcp/logger.rb
52
52
  - lib/omnifocus_mcp/mcp.rb
53
53
  - lib/omnifocus_mcp/parsers.rb
54
- - lib/omnifocus_mcp/parsers/.keep
55
54
  - lib/omnifocus_mcp/parsers/apple_script_envelope.rb
56
55
  - lib/omnifocus_mcp/resources/base.rb
57
56
  - lib/omnifocus_mcp/resources/flagged_resource.rb
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-