rosett-ai 1.8.0 → 1.11.9
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 +4 -4
- data/CHANGELOG.md +277 -0
- data/README.md +2 -2
- data/conf/schemas/rai_config_schema.json +10 -0
- data/lib/rosett_ai/compiler/backends/agents_md_backend.rb +10 -3
- data/lib/rosett_ai/compiler/backends/claude_backend.rb +11 -1
- data/lib/rosett_ai/compiler/compilation_pipeline.rb +25 -0
- data/lib/rosett_ai/compiler/lean_bundle.rb +150 -0
- data/lib/rosett_ai/compiler/lean_emitter.rb +76 -0
- data/lib/rosett_ai/desktop/gui_logger.rb +1 -1
- data/lib/rosett_ai/exit_codes.rb +2 -1
- data/lib/rosett_ai/init/mcp_registrar.rb +56 -19
- data/lib/rosett_ai/mcp/enforcement/hook_generator.rb +6 -2
- data/lib/rosett_ai/mcp/governance.rb +1 -0
- data/lib/rosett_ai/mcp/tools/compile_status_tool.rb +58 -13
- data/lib/rosett_ai/mcp/tools/config_compile_tool.rb +40 -7
- data/lib/rosett_ai/mcp/tools/hook_install_tool.rb +14 -0
- data/lib/rosett_ai/mcp/tools/optimize_tool.rb +73 -0
- data/lib/rosett_ai/optimize/corpus.rb +79 -0
- data/lib/rosett_ai/optimize/detector.rb +27 -0
- data/lib/rosett_ai/optimize/detectors/conflict.rb +50 -0
- data/lib/rosett_ai/optimize/detectors/overlap.rb +74 -0
- data/lib/rosett_ai/optimize/detectors/staleness.rb +61 -0
- data/lib/rosett_ai/optimize/detectors/token_cost.rb +44 -0
- data/lib/rosett_ai/optimize/finding.rb +36 -0
- data/lib/rosett_ai/optimize/proposal_writer.rb +54 -0
- data/lib/rosett_ai/optimize/report_writer.rb +72 -0
- data/lib/rosett_ai/optimize/runner.rb +38 -0
- data/lib/rosett_ai/optimize/thresholds.rb +52 -0
- data/lib/rosett_ai/optimize.rb +33 -0
- data/lib/rosett_ai/path_resolver.rb +25 -0
- data/lib/rosett_ai/plugins/registry.rb +45 -15
- data/lib/rosett_ai/provenance/entry.rb +1 -2
- data/lib/rosett_ai/rai_config.rb +3 -0
- data/lib/rosett_ai/rules/status_checker.rb +144 -0
- data/lib/rosett_ai/telemetry/json_lines_writer.rb +1 -1
- data/lib/rosett_ai/thor/cli.rb +7 -61
- data/lib/rosett_ai/thor/command_tree.rb +79 -0
- data/lib/rosett_ai/thor/tasks/compile.rb +137 -2
- data/lib/rosett_ai/thor/tasks/optimize.rb +103 -0
- data/lib/rosett_ai/thor/tasks/rules.rb +125 -0
- data/lib/rosett_ai/version.rb +1 -1
- data/lib/rosett_ai.rb +2 -0
- data/locales/en.yml +15 -0
- metadata +22 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-License-Identifier: GPL-3.0-only
|
|
4
|
+
# Copyright (C) 2026 Hugo Antonio Sepulveda Manriquez / NeatNerds
|
|
5
|
+
|
|
6
|
+
require 'terminal-table'
|
|
7
|
+
|
|
8
|
+
module RosettAi
|
|
9
|
+
module Thor
|
|
10
|
+
module Tasks
|
|
11
|
+
# Thor CLI for behaviour-rule LIVE/MIRROR drift reporting.
|
|
12
|
+
#
|
|
13
|
+
# Provides the read-only status subcommand. Write paths (push/pull)
|
|
14
|
+
# are intentionally not implemented here — they are blocked on
|
|
15
|
+
# unresolved conflict-semantics design questions.
|
|
16
|
+
#
|
|
17
|
+
# @author claude
|
|
18
|
+
class Rules < ::Thor
|
|
19
|
+
# @return [Hash{Symbol => Symbol}] display color per drift state.
|
|
20
|
+
STATE_COLORS = {
|
|
21
|
+
identical: :green,
|
|
22
|
+
live_only: :yellow,
|
|
23
|
+
live_newer: :yellow,
|
|
24
|
+
mirror_only: :cyan,
|
|
25
|
+
mirror_newer: :cyan
|
|
26
|
+
}.freeze
|
|
27
|
+
|
|
28
|
+
desc 'status', 'Report drift between LIVE behaviour rules and their git-tracked MIRROR'
|
|
29
|
+
long_desc <<~LONGDESC
|
|
30
|
+
Compares every behaviour-rule YAML file in the LIVE source directory
|
|
31
|
+
(~/.config/rosett-ai/conf/behaviour/) against its counterpart in a
|
|
32
|
+
git-tracked MIRROR repository, by content hash.
|
|
33
|
+
|
|
34
|
+
Reports drift in both directions distinctly — a file present or
|
|
35
|
+
changed only in LIVE is not the same problem as one present or
|
|
36
|
+
changed only in MIRROR. Direction for files that differ on both
|
|
37
|
+
sides is derived from the MIRROR's git history (does LIVE's
|
|
38
|
+
current content match a past MIRROR commit?): it reflects which
|
|
39
|
+
side has moved, not which side is correct. Inspect the diff
|
|
40
|
+
before acting on it.
|
|
41
|
+
|
|
42
|
+
Read-only: makes no changes to either tree, and performs no
|
|
43
|
+
network operations.
|
|
44
|
+
|
|
45
|
+
The MIRROR path must be configured via --mirror-dir or
|
|
46
|
+
rules.mirror_dir in ~/.config/rosett-ai/config.yml — rosett-ai
|
|
47
|
+
does not assume a mirror location.
|
|
48
|
+
|
|
49
|
+
Exit codes: 0 fully in sync, 1 drift detected, 3 mirror not configured.
|
|
50
|
+
|
|
51
|
+
EXAMPLES
|
|
52
|
+
|
|
53
|
+
raictl rules status
|
|
54
|
+
raictl rules status --format json
|
|
55
|
+
raictl rules status --mirror-dir ~/git/example/rosett-ai-mirror/global
|
|
56
|
+
LONGDESC
|
|
57
|
+
method_option :format, type: :string, default: 'table', enum: ['table', 'json'], desc: 'Output format'
|
|
58
|
+
method_option :live_dir, type: :string, default: nil, desc: 'Override the LIVE behaviour directory'
|
|
59
|
+
method_option :mirror_dir, type: :string, default: nil, desc: 'Path to the git-tracked MIRROR directory'
|
|
60
|
+
# Report drift between the LIVE and MIRROR trees.
|
|
61
|
+
# @return [void]
|
|
62
|
+
def status
|
|
63
|
+
mirror_dir = resolve_mirror_dir
|
|
64
|
+
return exit_with_error(t('mirror_not_configured')) unless mirror_dir
|
|
65
|
+
|
|
66
|
+
entries = RosettAi::Rules::StatusChecker.new(live_dir: live_dir, mirror_dir: mirror_dir).check
|
|
67
|
+
render_status(entries)
|
|
68
|
+
exit(entries.any? { |e| e[:state] != :identical } ? 1 : 0)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def t(key, **args)
|
|
74
|
+
::I18n.t("rosett_ai.rules.#{key}", **args)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def live_dir
|
|
78
|
+
options[:live_dir] || RosettAi.paths.rai_conf_dir.join('behaviour').to_s
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def resolve_mirror_dir
|
|
82
|
+
options[:mirror_dir] || RosettAi.rai_config.rules_mirror_dir
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def exit_with_error(message)
|
|
86
|
+
warn(Rainbow(message).red)
|
|
87
|
+
exit(3)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def render_status(entries)
|
|
91
|
+
if options[:format] == 'json'
|
|
92
|
+
say(JSON.pretty_generate(entries))
|
|
93
|
+
return
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
render_status_table(entries)
|
|
97
|
+
render_status_summary(entries)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def render_status_table(entries)
|
|
101
|
+
table = ::Terminal::Table.new(
|
|
102
|
+
headings: ['File', 'State'],
|
|
103
|
+
rows: entries.map { |e| [e[:name], colorize_state(e[:state])] }
|
|
104
|
+
)
|
|
105
|
+
say(table)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def colorize_state(state)
|
|
109
|
+
color = STATE_COLORS.fetch(state, :white)
|
|
110
|
+
Rainbow(state.to_s).color(color)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def render_status_summary(entries)
|
|
114
|
+
drifted = entries.reject { |e| e[:state] == :identical }
|
|
115
|
+
|
|
116
|
+
if drifted.empty?
|
|
117
|
+
say(t('no_drift', count: entries.size))
|
|
118
|
+
else
|
|
119
|
+
say(Rainbow(t('drift_detected', count: drifted.size)).red)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
data/lib/rosett_ai/version.rb
CHANGED
data/lib/rosett_ai.rb
CHANGED
|
@@ -77,6 +77,8 @@ module RosettAi
|
|
|
77
77
|
class McpError < Error; end
|
|
78
78
|
# Raised when Claude Code session hook installation fails.
|
|
79
79
|
class SessionHooksError < Error; end
|
|
80
|
+
# Raised when behaviour-rule LIVE/MIRROR drift operations fail.
|
|
81
|
+
class RulesError < Error; end
|
|
80
82
|
|
|
81
83
|
# @!endgroup
|
|
82
84
|
|
data/locales/en.yml
CHANGED
|
@@ -34,6 +34,17 @@ en:
|
|
|
34
34
|
deduplicated: "Deduplicated"
|
|
35
35
|
deduplicated_detail: "Deduplicated: %{filename} (identical to global)"
|
|
36
36
|
scope_project_no_project: "Cannot use --scope project: no project detected (no .rosett-ai/ directory found)"
|
|
37
|
+
scope_project_source_repo_hint: "Cannot use --scope project: no .rosett-ai/ directory found. This looks like the rosett-ai source repository itself, not a consuming project — did you mean --scope global?"
|
|
38
|
+
lean_would_write: "Would write lean bundle: %{filename}"
|
|
39
|
+
lean_wrote: "Wrote lean bundle: %{filename} (%{chars} chars)"
|
|
40
|
+
lean_summary_title: "Lean Context Bundles"
|
|
41
|
+
lean_bundle: "Bundle"
|
|
42
|
+
lean_rules: "Rules"
|
|
43
|
+
lean_chars: "Chars"
|
|
44
|
+
lean_tokens: "Tokens (approx)"
|
|
45
|
+
lean_delta: "Delta vs full"
|
|
46
|
+
lean_reference: "full behaviour rules (reference)"
|
|
47
|
+
lean_dir: "Lean bundles written to %{path}"
|
|
37
48
|
config:
|
|
38
49
|
scope_not_found: "Scope file not found: %{path}. Valid scopes: %{scopes}"
|
|
39
50
|
no_scopes: "No scope files found in conf/claude_code/"
|
|
@@ -534,6 +545,10 @@ en:
|
|
|
534
545
|
detected_managers: "Detected hook managers: %{managers}"
|
|
535
546
|
install_summary: "Installed %{count} hook(s)."
|
|
536
547
|
uninstall_summary: "Removed %{count} hook(s)."
|
|
548
|
+
rules:
|
|
549
|
+
mirror_not_configured: "MIRROR directory not configured. Set --mirror-dir or rules.mirror_dir in ~/.config/rosett-ai/config.yml."
|
|
550
|
+
no_drift: "No drift detected — LIVE and MIRROR are in sync (%{count} file(s))."
|
|
551
|
+
drift_detected: "%{count} file(s) with drift detected."
|
|
537
552
|
mcp:
|
|
538
553
|
no_servers: "No MCP servers configured."
|
|
539
554
|
serve_started: "MCP server started on stdio transport."
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rosett-ai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.11.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hugo Antonio Sepulveda Manriquez
|
|
@@ -155,14 +155,14 @@ dependencies:
|
|
|
155
155
|
requirements:
|
|
156
156
|
- - "~>"
|
|
157
157
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: '
|
|
158
|
+
version: '3.6'
|
|
159
159
|
type: :runtime
|
|
160
160
|
prerelease: false
|
|
161
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
162
162
|
requirements:
|
|
163
163
|
- - "~>"
|
|
164
164
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: '
|
|
165
|
+
version: '3.6'
|
|
166
166
|
- !ruby/object:Gem::Dependency
|
|
167
167
|
name: terminal-table
|
|
168
168
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -324,6 +324,8 @@ files:
|
|
|
324
324
|
- lib/rosett_ai/compiler/capability_checker.rb
|
|
325
325
|
- lib/rosett_ai/compiler/compilation_pipeline.rb
|
|
326
326
|
- lib/rosett_ai/compiler/compiled_output.rb
|
|
327
|
+
- lib/rosett_ai/compiler/lean_bundle.rb
|
|
328
|
+
- lib/rosett_ai/compiler/lean_emitter.rb
|
|
327
329
|
- lib/rosett_ai/compiler/locale_compiler.rb
|
|
328
330
|
- lib/rosett_ai/compiler/target_profile.rb
|
|
329
331
|
- lib/rosett_ai/completion/generator.rb
|
|
@@ -468,6 +470,7 @@ files:
|
|
|
468
470
|
- lib/rosett_ai/mcp/tools/hooks_status_tool.rb
|
|
469
471
|
- lib/rosett_ai/mcp/tools/init_tool.rb
|
|
470
472
|
- lib/rosett_ai/mcp/tools/license_status_tool.rb
|
|
473
|
+
- lib/rosett_ai/mcp/tools/optimize_tool.rb
|
|
471
474
|
- lib/rosett_ai/mcp/tools/project_tool.rb
|
|
472
475
|
- lib/rosett_ai/mcp/tools/provenance_tool.rb
|
|
473
476
|
- lib/rosett_ai/mcp/tools/provenance_write_tool.rb
|
|
@@ -482,6 +485,18 @@ files:
|
|
|
482
485
|
- lib/rosett_ai/migration/nncc_config_migrator.rb
|
|
483
486
|
- lib/rosett_ai/migration/nncc_project_migrator.rb
|
|
484
487
|
- lib/rosett_ai/migration/xdg_migrator.rb
|
|
488
|
+
- lib/rosett_ai/optimize.rb
|
|
489
|
+
- lib/rosett_ai/optimize/corpus.rb
|
|
490
|
+
- lib/rosett_ai/optimize/detector.rb
|
|
491
|
+
- lib/rosett_ai/optimize/detectors/conflict.rb
|
|
492
|
+
- lib/rosett_ai/optimize/detectors/overlap.rb
|
|
493
|
+
- lib/rosett_ai/optimize/detectors/staleness.rb
|
|
494
|
+
- lib/rosett_ai/optimize/detectors/token_cost.rb
|
|
495
|
+
- lib/rosett_ai/optimize/finding.rb
|
|
496
|
+
- lib/rosett_ai/optimize/proposal_writer.rb
|
|
497
|
+
- lib/rosett_ai/optimize/report_writer.rb
|
|
498
|
+
- lib/rosett_ai/optimize/runner.rb
|
|
499
|
+
- lib/rosett_ai/optimize/thresholds.rb
|
|
485
500
|
- lib/rosett_ai/package_manager/apt.rb
|
|
486
501
|
- lib/rosett_ai/package_manager/base.rb
|
|
487
502
|
- lib/rosett_ai/package_manager/gem_backend.rb
|
|
@@ -525,6 +540,7 @@ files:
|
|
|
525
540
|
- lib/rosett_ai/retrofit/round_trip_validator.rb
|
|
526
541
|
- lib/rosett_ai/retrofit/scanner.rb
|
|
527
542
|
- lib/rosett_ai/retrofit/secret_detector.rb
|
|
543
|
+
- lib/rosett_ai/rules/status_checker.rb
|
|
528
544
|
- lib/rosett_ai/secrets_resolver.rb
|
|
529
545
|
- lib/rosett_ai/session_hooks/installer.rb
|
|
530
546
|
- lib/rosett_ai/smart_feedback/suggester.rb
|
|
@@ -537,6 +553,7 @@ files:
|
|
|
537
553
|
- lib/rosett_ai/telemetry/reporter.rb
|
|
538
554
|
- lib/rosett_ai/text_sanitizer.rb
|
|
539
555
|
- lib/rosett_ai/thor/cli.rb
|
|
556
|
+
- lib/rosett_ai/thor/command_tree.rb
|
|
540
557
|
- lib/rosett_ai/thor/tasks/adopt.rb
|
|
541
558
|
- lib/rosett_ai/thor/tasks/backfill_user_yml.rb
|
|
542
559
|
- lib/rosett_ai/thor/tasks/backup.rb
|
|
@@ -558,11 +575,13 @@ files:
|
|
|
558
575
|
- lib/rosett_ai/thor/tasks/license.rb
|
|
559
576
|
- lib/rosett_ai/thor/tasks/mcp.rb
|
|
560
577
|
- lib/rosett_ai/thor/tasks/migrate.rb
|
|
578
|
+
- lib/rosett_ai/thor/tasks/optimize.rb
|
|
561
579
|
- lib/rosett_ai/thor/tasks/plugins.rb
|
|
562
580
|
- lib/rosett_ai/thor/tasks/project.rb
|
|
563
581
|
- lib/rosett_ai/thor/tasks/provenance.rb
|
|
564
582
|
- lib/rosett_ai/thor/tasks/release.rb
|
|
565
583
|
- lib/rosett_ai/thor/tasks/retrofit.rb
|
|
584
|
+
- lib/rosett_ai/thor/tasks/rules.rb
|
|
566
585
|
- lib/rosett_ai/thor/tasks/tooling.rb
|
|
567
586
|
- lib/rosett_ai/thor/tasks/validate.rb
|
|
568
587
|
- lib/rosett_ai/thor/tasks/workflow.rb
|