space-architect 8.0.0 → 9.0.0

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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -0
  3. data/README.md +53 -243
  4. data/lib/space_architect/bug_report.rb +2 -1
  5. data/lib/space_architect/cli/architect.rb +20 -7
  6. data/lib/space_architect/cli.rb +9 -14
  7. data/lib/space_architect/session_sync/bin_path.rb +1 -1
  8. data/lib/space_architect/session_sync/cursor.rb +1 -1
  9. data/lib/space_architect/session_sync/plist.rb +1 -1
  10. data/lib/{space_core → space_architect}/version.rb +2 -2
  11. data/lib/space_architect.rb +1 -1
  12. data/skill/architect/SKILL.md +3 -2
  13. data/skill/architect-vocabulary/SKILL.md +2 -2
  14. metadata +18 -177
  15. data/exe/space +0 -13
  16. data/exe/src +0 -13
  17. data/lib/space_architect/cli/space.rb +0 -29
  18. data/lib/space_architect/cli/src.rb +0 -38
  19. data/lib/space_core/atomic_write.rb +0 -21
  20. data/lib/space_core/cli/base_command.rb +0 -19
  21. data/lib/space_core/cli/build.rb +0 -27
  22. data/lib/space_core/cli/config.rb +0 -49
  23. data/lib/space_core/cli/current.rb +0 -16
  24. data/lib/space_core/cli/help.rb +0 -195
  25. data/lib/space_core/cli/helpers.rb +0 -115
  26. data/lib/space_core/cli/init.rb +0 -29
  27. data/lib/space_core/cli/list.rb +0 -24
  28. data/lib/space_core/cli/loop_status.rb +0 -47
  29. data/lib/space_core/cli/new.rb +0 -38
  30. data/lib/space_core/cli/pack.rb +0 -29
  31. data/lib/space_core/cli/path.rb +0 -16
  32. data/lib/space_core/cli/repeatable_options.rb +0 -84
  33. data/lib/space_core/cli/repo.rb +0 -76
  34. data/lib/space_core/cli/run.rb +0 -44
  35. data/lib/space_core/cli/shell.rb +0 -125
  36. data/lib/space_core/cli/show.rb +0 -21
  37. data/lib/space_core/cli/status.rb +0 -74
  38. data/lib/space_core/cli/use.rb +0 -17
  39. data/lib/space_core/cli.rb +0 -177
  40. data/lib/space_core/commands.rb +0 -51
  41. data/lib/space_core/config.rb +0 -152
  42. data/lib/space_core/errors.rb +0 -14
  43. data/lib/space_core/git_client.rb +0 -49
  44. data/lib/space_core/mise_client.rb +0 -37
  45. data/lib/space_core/oci_builder.rb +0 -56
  46. data/lib/space_core/oci_packer.rb +0 -103
  47. data/lib/space_core/oci_runner.rb +0 -89
  48. data/lib/space_core/paths.rb +0 -58
  49. data/lib/space_core/repo_reference.rb +0 -19
  50. data/lib/space_core/repo_resolver.rb +0 -167
  51. data/lib/space_core/shell_integration.rb +0 -438
  52. data/lib/space_core/slugger.rb +0 -16
  53. data/lib/space_core/space.rb +0 -174
  54. data/lib/space_core/space_store.rb +0 -319
  55. data/lib/space_core/state.rb +0 -86
  56. data/lib/space_core/templates/oci/dockerfile.erb +0 -73
  57. data/lib/space_core/templates/oci/dockerignore.erb +0 -17
  58. data/lib/space_core/templates/oci/entrypoint.sh.erb +0 -16
  59. data/lib/space_core/terminal.rb +0 -161
  60. data/lib/space_core/warnings.rb +0 -13
  61. data/lib/space_core/xdg.rb +0 -33
  62. data/lib/space_core.rb +0 -26
  63. data/lib/space_src/cli/clone.rb +0 -54
  64. data/lib/space_src/cli/config.rb +0 -65
  65. data/lib/space_src/cli/daemon.rb +0 -362
  66. data/lib/space_src/cli/options.rb +0 -21
  67. data/lib/space_src/cli/org.rb +0 -199
  68. data/lib/space_src/cli/repo.rb +0 -169
  69. data/lib/space_src/cli/shell.rb +0 -121
  70. data/lib/space_src/cli/status.rb +0 -75
  71. data/lib/space_src/cli/sync.rb +0 -161
  72. data/lib/space_src/cli.rb +0 -159
  73. data/lib/space_src/cloner.rb +0 -77
  74. data/lib/space_src/config/contract.rb +0 -54
  75. data/lib/space_src/config/duration.rb +0 -79
  76. data/lib/space_src/config/model.rb +0 -49
  77. data/lib/space_src/config/store.rb +0 -156
  78. data/lib/space_src/forge/client.rb +0 -31
  79. data/lib/space_src/forge/github.rb +0 -98
  80. data/lib/space_src/launchd/agent.rb +0 -195
  81. data/lib/space_src/launchd/plist.rb +0 -129
  82. data/lib/space_src/log_rotator.rb +0 -46
  83. data/lib/space_src/migration.rb +0 -43
  84. data/lib/space_src/nav.rb +0 -99
  85. data/lib/space_src/paths.rb +0 -72
  86. data/lib/space_src/scm/client.rb +0 -87
  87. data/lib/space_src/scm/git.rb +0 -232
  88. data/lib/space_src/scm/status.rb +0 -24
  89. data/lib/space_src/shell.rb +0 -90
  90. data/lib/space_src/shell_integration.rb +0 -321
  91. data/lib/space_src/state/lock.rb +0 -59
  92. data/lib/space_src/state/store.rb +0 -140
  93. data/lib/space_src/sync/engine.rb +0 -503
  94. data/lib/space_src/sync/repo_plan.rb +0 -215
  95. data/lib/space_src/sync/report.rb +0 -18
  96. data/lib/space_src/ui/interactive_reporter.rb +0 -280
  97. data/lib/space_src/ui/json_reporter.rb +0 -39
  98. data/lib/space_src/ui/mode.rb +0 -68
  99. data/lib/space_src/ui/plain_reporter.rb +0 -53
  100. data/lib/space_src/ui/reporter.rb +0 -48
  101. data/lib/space_src/version.rb +0 -7
  102. data/lib/space_src.rb +0 -38
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
-
5
- module Space::Core
6
- module XDG
7
- module_function
8
-
9
- def config_home(env: ENV)
10
- Pathname.new(env.fetch("XDG_CONFIG_HOME", File.join(home(env: env), ".config")))
11
- end
12
-
13
- def state_home(env: ENV)
14
- Pathname.new(env.fetch("XDG_STATE_HOME", File.join(home(env: env), ".local", "state")))
15
- end
16
-
17
- def home(env: ENV)
18
- env.fetch("HOME", Dir.home)
19
- end
20
-
21
- def expand_user(path, env: ENV)
22
- value = path.to_s
23
-
24
- if value == "~"
25
- home(env: env)
26
- elsif value.start_with?("~/")
27
- File.join(home(env: env), value[2..])
28
- else
29
- File.expand_path(value)
30
- end
31
- end
32
- end
33
- end
data/lib/space_core.rb DELETED
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "space_core/version"
4
-
5
- module Space::Core
6
- end
7
-
8
- require "space_core/errors"
9
- require "space_core/warnings"
10
- Space::Core::Warnings.disable_experimental!
11
- require "space_core/atomic_write"
12
- require "space_core/xdg"
13
- require "space_core/paths"
14
- require "space_core/commands"
15
- require "space_core/config"
16
- require "space_core/state"
17
- require "space_core/slugger"
18
- require "space_core/space"
19
- require "space_core/repo_reference"
20
- require "space_core/repo_resolver"
21
- require "space_core/git_client"
22
- require "space_core/mise_client"
23
- require "space_core/space_store"
24
- require "space_core/shell_integration"
25
- require "space_core/terminal"
26
- require "space_core/cli"
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pastel"
4
- require "dry/monads"
5
- require "space_src/cli/options"
6
- require "space_src/cloner"
7
-
8
- module Space::Src
9
- module CLI
10
- # `clone` command: APFS COW copy of an evergreen repo into a working dir.
11
- # Resolves each NAME against config.base_dir and copies via cp -Rc.
12
- # Multiple names are processed independently; a per-name failure is
13
- # reported on err and does not abort the others. Exit code is 1 if any
14
- # name failed, else 0.
15
- class Clone < Dry::CLI::Command
16
- include GlobalOptions
17
-
18
- desc "Clone evergreen repo(s) into a working directory (APFS COW copy)"
19
- argument :names, type: :array, required: true,
20
- desc: "Repo name(s): bare name, owner/name, or host/owner/name"
21
- option :into, default: ".",
22
- desc: "Destination parent directory (default: current working directory)"
23
-
24
- def call(names:, into: ".", plain: nil, json: nil, no_color: nil, quiet: nil, **)
25
- mode = UI::Mode.resolve(
26
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
27
- env: CLI.env,
28
- out: out
29
- )
30
- pastel = Pastel.new(enabled: mode.color)
31
-
32
- paths = CLI.make_paths
33
- config = Config::Store.load(paths.config_file).success
34
- cloner = Cloner.new(base_dir: config.base_dir)
35
-
36
- any_failure = false
37
- names.each do |name|
38
- result = cloner.call(name: name, into: into)
39
- if result.success?
40
- dest = result.success
41
- out.puts pastel.green("cloned: #{name} → #{dest}")
42
- else
43
- err.puts result.failure
44
- any_failure = true
45
- end
46
- end
47
-
48
- CLI.record_outcome(Outcome.new(exit_code: any_failure ? 1 : 0))
49
- end
50
- end
51
- end
52
- end
53
-
54
- Space::Src::CLI::Registry.register "clone", Space::Src::CLI::Clone
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pastel"
4
- require "yaml"
5
- require "space_src/ui/mode"
6
- require "space_src/cli/options"
7
-
8
- module Space::Src
9
- module CLI
10
- # `config` command group: path / show.
11
- module ConfigCmd
12
- class Path < Dry::CLI::Command
13
- include GlobalOptions
14
-
15
- desc "Print the resolved config file path (honors $XDG_CONFIG_HOME)"
16
-
17
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
18
- mode = UI::Mode.resolve(
19
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
20
- env: CLI.env,
21
- out: out
22
- )
23
- pastel = Pastel.new(enabled: mode.color)
24
-
25
- paths = CLI.make_paths
26
- out.puts pastel.cyan(paths.config_file)
27
- CLI.record_outcome(Outcome.new(exit_code: 0))
28
- end
29
- end
30
-
31
- class Show < Dry::CLI::Command
32
- include GlobalOptions
33
-
34
- desc "Print the effective (validated, defaults-applied) config as YAML"
35
-
36
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
37
- mode = UI::Mode.resolve(
38
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
39
- env: CLI.env,
40
- out: out
41
- )
42
- pastel = Pastel.new(enabled: mode.color)
43
-
44
- paths = CLI.make_paths
45
- config = Config::Store.load(paths.config_file).success
46
- # Emit via the store's own emit() so the format matches
47
- # what `config.yaml` looks like on disk (stable key order
48
- # per Slice 1's emit implementation). This makes
49
- # `config show` a faithful round-trip preview.
50
- out.puts pastel.cyan(Config::Store.emit(config.to_h).chomp)
51
- CLI.record_outcome(Outcome.new(exit_code: 0))
52
- end
53
- end
54
- end
55
- end
56
- end
57
-
58
- # `config` is the name of both our config-store module (Config) and
59
- # the CLI command group. We register under a different module name
60
- # (ConfigCmd) to avoid the constant clash, then alias the
61
- # registration key as "config".
62
- Space::Src::CLI::Registry.register "config" do |prefix|
63
- prefix.register "path", Space::Src::CLI::ConfigCmd::Path
64
- prefix.register "show", Space::Src::CLI::ConfigCmd::Show
65
- end
@@ -1,362 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pastel"
4
- require "fileutils"
5
- require "dry/monads"
6
- require "space_src/ui/mode"
7
- require "space_src/cli/options"
8
- require "space_src/launchd/agent"
9
- require "space_src/launchd/plist"
10
- require "space_src/migration"
11
-
12
- module Space::Src
13
- module CLI
14
- # `daemon` command group: install / uninstall / start / stop
15
- # / restart / status. Installs a per-user launchd agent
16
- # (`gui/<UID>`) that fires `src sync` on a
17
- # `StartInterval`. The launchctl side is exercised ONLY
18
- # through an injected command runner (slice-4 gates G2–G4);
19
- # the live domain is proven by the manual real-Mac checklist
20
- # in docs/gates/slice-4.md, not by these tests.
21
- module Daemon
22
- module Helpers
23
- module_function
24
-
25
- # Build a `Launchd::Agent` wired against the CLI's env
26
- # seam (`CLI.env`). Tests inject a temp HOME (so
27
- # `paths.launch_agents_dir` is under the temp HOME, not
28
- # the real one) and a `runner:` via `Launchd::Agent.new`
29
- # — the daemon commands don't accept a runner flag, so
30
- # tests must use a real `Agent` (whose default `runner`
31
- # only fires in an ambient Async::Task) OR stub the
32
- # `Launchd::Agent` class.
33
- def make_agent(uid: Process.uid, label: Launchd::Agent::DEFAULT_LABEL, runner: nil)
34
- if runner
35
- Launchd::Agent.new(runner: runner, uid: uid, label: label)
36
- else
37
- Launchd::Agent.new(uid: uid, label: label)
38
- end
39
- end
40
-
41
- # Resolve the on-disk plist path for the agent label,
42
- # rooted at the env's HOME-resolved `LaunchAgents/`
43
- # (per slice-4 gate G3).
44
- def plist_path(paths, label)
45
- File.join(paths.launch_agents_dir, "#{label}.plist")
46
- end
47
-
48
- # Build the plist XML by looking up the absolute paths
49
- # the launchd runtime needs (mise, ruby, the bin
50
- # script, the repo root, the mise.toml). These come
51
- # from a few places:
52
- # * `mise_bin` — `which mise` (we shell out at
53
- # install-time; the result is baked into the plist
54
- # as an absolute path so launchd's empty PATH
55
- # doesn't matter).
56
- # * `ruby_bin` — `mise exec -- which ruby` (the
57
- # toolchain-resolved ruby; pinned via mise.toml).
58
- # * `bin_path` — `RbConfig.ruby` + the script path
59
- # (we use `__dir__` of this file's caller; for the
60
- # gem install, this is `<gem>/exe/src`).
61
- #
62
- # In tests, we inject these via the `Resolve` object
63
- # (see below) — never call out to the shell.
64
- def build_plist(resolve:, config:, paths:, label:)
65
- Launchd::Plist.call(
66
- label: label,
67
- refresh_interval: config.refresh_interval,
68
- log_dir: paths.log_dir,
69
- repo_root: resolve.repo_root,
70
- mise_toml: resolve.mise_toml,
71
- mise_bin: resolve.mise_bin,
72
- ruby_bin: resolve.ruby_bin,
73
- bin_path: resolve.bin_path
74
- )
75
- end
76
-
77
- def format_failure(f) = f.is_a?(Hash) ? f.inspect : f.to_s
78
-
79
- def fail_with(cmd, msg)
80
- cmd.send(:err).puts msg
81
- Space::Src::CLI.record_outcome(Outcome.new(exit_code: 1, message: msg))
82
- end
83
-
84
- # Bundle of resolved absolute paths the plist needs.
85
- # Production code resolves these via the shell (see
86
- # `Resolve.detect`); tests construct one directly with
87
- # known absolute paths.
88
- Resolve = Data.define(:repo_root, :mise_toml, :mise_bin, :ruby_bin, :bin_path) do
89
- def initialize(repo_root:, mise_toml:, mise_bin:, ruby_bin:, bin_path:)
90
- super
91
- end
92
- end
93
- end
94
-
95
- class Install < Dry::CLI::Command
96
- include Helpers
97
- include GlobalOptions
98
-
99
- desc "Install the per-user launchd agent (writes the plist + bootstrap)"
100
-
101
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
102
- paths = CLI.make_paths
103
- paths.ensure!
104
- config = Config::Store.load(paths.config_file).success
105
-
106
- mode = UI::Mode.resolve(
107
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
108
- env: CLI.env,
109
- out: out
110
- )
111
- pastel = Pastel.new(enabled: mode.color)
112
-
113
- label = Launchd::Agent::DEFAULT_LABEL
114
- pp = plist_path(paths, label)
115
-
116
- # Relabel: if old-identity plist exists, bootout (benign-failure-tolerant)
117
- # and remove it before bootstrapping the new-label plist.
118
- old_pp = plist_path(paths, Migration::OLD_LABEL)
119
- if File.exist?(old_pp)
120
- old_agent = make_agent(label: Migration::OLD_LABEL)
121
- old_agent.uninstall
122
- File.delete(old_pp) if File.exist?(old_pp)
123
- end
124
-
125
- resolve = Resolve.detect(repo_root: Dir.pwd)
126
- xml = build_plist(resolve: resolve, config: config, paths: paths, label: label)
127
- FileUtils.mkdir_p(File.dirname(pp))
128
- File.write(pp, xml)
129
-
130
- agent = make_agent
131
- result = agent.install(pp)
132
- if result.failure?
133
- return fail_with(self, "bootstrap failed: #{format_failure(result.failure)}")
134
- end
135
-
136
- out.puts pastel.green("installed: #{pp}")
137
- CLI.record_outcome(Outcome.new(exit_code: 0))
138
- end
139
- end
140
-
141
- class Uninstall < Dry::CLI::Command
142
- include Helpers
143
- include GlobalOptions
144
-
145
- desc "Uninstall the per-user launchd agent (bootout + remove the plist)"
146
-
147
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
148
- mode = UI::Mode.resolve(
149
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
150
- env: CLI.env,
151
- out: out
152
- )
153
- pastel = Pastel.new(enabled: mode.color)
154
-
155
- paths = CLI.make_paths
156
- label = Launchd::Agent::DEFAULT_LABEL
157
- pp = plist_path(paths, label)
158
-
159
- agent = make_agent
160
- result = agent.uninstall
161
- # CF5 (Slice 5): the Agent maps a not-loaded bootout
162
- # (status 3 / "No such process") to Success — the
163
- # common case at a 6h refresh interval. A non-benign
164
- # bootout Failure (e.g. status 1 "Operation not
165
- # permitted") still surfaces here as a real failure
166
- # the operator needs to see. We still remove the
167
- # plist regardless (idempotent uninstall, Slice-4
168
- # gate G3): the bootout is the only best-effort step.
169
- if result.failure?
170
- err.puts "bootout reported: #{format_failure(result.failure)}"
171
- end
172
-
173
- if File.exist?(pp)
174
- File.delete(pp)
175
- out.puts pastel.green("removed plist: #{pp}")
176
- else
177
- out.puts pastel.yellow("plist not present: #{pp}")
178
- end
179
-
180
- CLI.record_outcome(Outcome.new(exit_code: 0))
181
- end
182
- end
183
-
184
- class Start < Dry::CLI::Command
185
- include Helpers
186
- include GlobalOptions
187
-
188
- desc "Start the agent (bootstrap + enable)"
189
-
190
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
191
- mode = UI::Mode.resolve(
192
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
193
- env: CLI.env,
194
- out: out
195
- )
196
- pastel = Pastel.new(enabled: mode.color)
197
-
198
- paths = CLI.make_paths
199
- label = Launchd::Agent::DEFAULT_LABEL
200
- pp = plist_path(paths, label)
201
-
202
- agent = make_agent
203
- result = agent.start(pp)
204
- if result.failure?
205
- return fail_with(self, "start failed: #{format_failure(result.failure)}")
206
- end
207
- out.puts pastel.green("started: #{label}")
208
- CLI.record_outcome(Outcome.new(exit_code: 0))
209
- end
210
- end
211
-
212
- class Stop < Dry::CLI::Command
213
- include Helpers
214
- include GlobalOptions
215
-
216
- desc "Stop the agent (bootout + disable)"
217
-
218
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
219
- mode = UI::Mode.resolve(
220
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
221
- env: CLI.env,
222
- out: out
223
- )
224
- pastel = Pastel.new(enabled: mode.color)
225
-
226
- label = Launchd::Agent::DEFAULT_LABEL
227
- agent = make_agent
228
- result = agent.stop
229
- if result.failure?
230
- return fail_with(self, "stop failed: #{format_failure(result.failure)}")
231
- end
232
- out.puts pastel.green("stopped: #{label}")
233
- CLI.record_outcome(Outcome.new(exit_code: 0))
234
- end
235
- end
236
-
237
- class Restart < Dry::CLI::Command
238
- include Helpers
239
- include GlobalOptions
240
-
241
- desc "Restart the agent (kickstart -k)"
242
-
243
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
244
- mode = UI::Mode.resolve(
245
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
246
- env: CLI.env,
247
- out: out
248
- )
249
- pastel = Pastel.new(enabled: mode.color)
250
-
251
- label = Launchd::Agent::DEFAULT_LABEL
252
- agent = make_agent
253
- result = agent.restart
254
- if result.failure?
255
- return fail_with(self, "restart failed: #{format_failure(result.failure)}")
256
- end
257
- out.puts pastel.green("restarted: #{label}")
258
- CLI.record_outcome(Outcome.new(exit_code: 0))
259
- end
260
- end
261
-
262
- class Status < Dry::CLI::Command
263
- include Helpers
264
- include GlobalOptions
265
-
266
- desc "Print the agent's loaded/running/last-exit state"
267
-
268
- def call(plain: nil, json: nil, no_color: nil, quiet: nil, **)
269
- mode = UI::Mode.resolve(
270
- flags: {plain: plain, json: json, no_color: no_color, quiet: quiet},
271
- env: CLI.env,
272
- out: out
273
- )
274
- pastel = Pastel.new(enabled: mode.color)
275
-
276
- paths = CLI.make_paths
277
- old_pp = plist_path(paths, Migration::OLD_LABEL)
278
- if File.exist?(old_pp)
279
- err.puts pastel.yellow("warning: stale agent #{Migration::OLD_LABEL} detected; run `src daemon install` to upgrade")
280
- end
281
-
282
- label = Launchd::Agent::DEFAULT_LABEL
283
- agent = make_agent
284
- result = agent.status
285
- if result.failure?
286
- return fail_with(self, "status failed: #{format_failure(result.failure)}")
287
- end
288
- s = result.success
289
- out.puts pastel.cyan("label: #{label}")
290
- out.puts pastel.cyan("loaded: #{s[:loaded]}")
291
- out.puts pastel.cyan("running: #{s[:running]}")
292
- out.puts pastel.cyan("pid: #{s[:pid].inspect}")
293
- out.puts pastel.cyan("last_exit: #{s[:last_exit].inspect}")
294
- CLI.record_outcome(Outcome.new(exit_code: 0))
295
- end
296
- end
297
- end
298
- end
299
- end
300
-
301
- # Detect the runtime paths the plist needs. The src install path
302
- # matters because the plist stores an absolute `bin_path` — that
303
- # is the script launchd invokes. We resolve `bin_path` from the
304
- # on-disk gem layout if we can, else fall back to the directory
305
- # the daemon command was run from.
306
- class Space::Src::CLI::Daemon::Helpers::Resolve
307
- # @param repo_root [String] absolute path of the working directory (where mise.toml is expected)
308
- # @return [Resolve]
309
- def self.detect(repo_root:)
310
- mise_bin = detect_mise_bin
311
- ruby_bin = detect_ruby_bin(repo_root, mise_bin)
312
- bin_path = detect_bin_path(repo_root)
313
- mise_toml = File.join(repo_root, "mise.toml")
314
- new(repo_root: repo_root, mise_toml: mise_toml, mise_bin: mise_bin, ruby_bin: ruby_bin, bin_path: bin_path)
315
- end
316
-
317
- def self.detect_mise_bin
318
- path = ENV["SPACE_SRC_MISE_BIN"]
319
- return path if path && !path.empty?
320
- require "open3"
321
- out, _e, st = Open3.capture3("which", "mise")
322
- st.success? ? out.strip : "/opt/homebrew/bin/mise"
323
- end
324
-
325
- def self.detect_ruby_bin(repo_root, mise_bin)
326
- path = ENV["SPACE_SRC_RUBY_BIN"]
327
- return path if path && !path.empty?
328
- # `mise exec -- which ruby` — but we avoid spawning in tests;
329
- # production path goes through here.
330
- require "open3"
331
- out, _e, st = Open3.capture3(mise_bin, "exec", "--", "which", "ruby", chdir: repo_root)
332
- return out.strip if st.success? && !out.strip.empty?
333
- # Fall back to the system ruby (last resort).
334
- out, _e, st = Open3.capture3("which", "ruby")
335
- st.success? ? out.strip : "/usr/bin/ruby"
336
- end
337
-
338
- def self.detect_bin_path(repo_root)
339
- path = ENV["SPACE_SRC_BIN_PATH"]
340
- return path if path && !path.empty?
341
- # Prefer the on-disk dev bin at `<repo_root>/exe/src`
342
- # — it's what the human runs during testing, and the gem is
343
- # typically not `gem install`ed in a source checkout.
344
- dev = File.join(repo_root, "exe", "src")
345
- return dev if File.exist?(dev)
346
- # Next, an installed binary on PATH.
347
- require "open3"
348
- out, _e, st = Open3.capture3("which", "src")
349
- return out.strip if st.success? && !out.strip.empty?
350
- # Last resort: the installed gem's bin (raises if not installed).
351
- Gem.bin_path("space-architect", "src")
352
- end
353
- end
354
-
355
- Space::Src::CLI::Registry.register "daemon" do |prefix|
356
- prefix.register "install", Space::Src::CLI::Daemon::Install
357
- prefix.register "uninstall", Space::Src::CLI::Daemon::Uninstall
358
- prefix.register "start", Space::Src::CLI::Daemon::Start
359
- prefix.register "stop", Space::Src::CLI::Daemon::Stop
360
- prefix.register "restart", Space::Src::CLI::Daemon::Restart
361
- prefix.register "status", Space::Src::CLI::Daemon::Status
362
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Space::Src
4
- module CLI
5
- # Shared output mode flags. Include in any command class to add:
6
- # --plain force plain text output (one line per event, ANSI-free)
7
- # --json force JSON output (one object per event line, 12-factor)
8
- # --no-color disable ANSI color
9
- # --quiet/-q suppress non-essential human output
10
- #
11
- # Resolved via UI::Mode.resolve in the command's #call.
12
- module GlobalOptions
13
- def self.included(base)
14
- base.option :plain, type: :flag, desc: "Plain text output (one line per event, no color)"
15
- base.option :json, type: :flag, desc: "JSON output (one object per event line, 12-factor)"
16
- base.option :no_color, type: :flag, desc: "Disable color output"
17
- base.option :quiet, type: :flag, aliases: ["-q"], desc: "Suppress non-essential output"
18
- end
19
- end
20
- end
21
- end