claude-smart 0.1.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.
- package/LICENSE +202 -0
- package/README.md +436 -0
- package/bin/claude-smart.js +142 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<br>
|
|
3
|
+
claude-smart
|
|
4
|
+
<br>
|
|
5
|
+
</h1>
|
|
6
|
+
|
|
7
|
+
<h4 align="center">Self-improving <a href="https://claude.com/claude-code" target="_blank">Claude Code</a> plugin — learns from your corrections, not just remembers them.</h4>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="LICENSE">
|
|
11
|
+
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="pyproject.toml">
|
|
14
|
+
<img src="https://img.shields.io/badge/version-0.1.0-green.svg" alt="Version">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="pyproject.toml">
|
|
17
|
+
<img src="https://img.shields.io/badge/python-%3E%3D3.12-brightgreen.svg" alt="Python">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="#installation">
|
|
20
|
+
<img src="https://img.shields.io/badge/llm-claude%20code%20cli-purple.svg" alt="LLM">
|
|
21
|
+
</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<p align="center">
|
|
25
|
+
<a href="#quick-start">Quick Start</a> •
|
|
26
|
+
<a href="#how-it-works">How It Works</a> •
|
|
27
|
+
<a href="#installation">Installation</a> •
|
|
28
|
+
<a href="#slash-commands">Slash Commands</a> •
|
|
29
|
+
<a href="#configuration">Configuration</a> •
|
|
30
|
+
<a href="#troubleshooting">Troubleshooting</a> •
|
|
31
|
+
<a href="#license">License</a>
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
claude-smart turns your Claude Code corrections into durable rules that shape <i>future</i> sessions. Instead of replaying past observations as context, it distils them into a project playbook and per-session preferences — so Claude stops repeating the same mistakes and adapts to how your codebase actually wants to be written.
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Why Learning, Not Memory
|
|
41
|
+
|
|
42
|
+
Plain memory solutions preserve *what happened* — they re-inject transcripts, summaries, or observations from prior sessions. That works for continuity, but it has two real limits:
|
|
43
|
+
|
|
44
|
+
- **It grows with every session.** More memory means more tokens, more context dilution, and diminishing returns as Claude has to re-read a history it can't fully use.
|
|
45
|
+
- **It doesn't change behavior.** If you corrected Claude yesterday about a library choice, a test framework, a deployment region — a memory system *remembers the correction happened*, but Claude may still make the same default choice today because nothing updated its decision-making.
|
|
46
|
+
|
|
47
|
+
claude-smart takes a different approach: **extract, don't accumulate**. Each session's corrections and successful patterns are distilled by an LLM into two small, structured artifacts:
|
|
48
|
+
|
|
49
|
+
- **User profile** — short, session-scoped preferences Claude should respect right now.
|
|
50
|
+
- **Project playbook** — cross-session behavioral rules keyed to your project, with an explicit `trigger` (when the rule applies) and `rationale` (why). Rules are deduplicated, updated, and archived as they evolve.
|
|
51
|
+
|
|
52
|
+
The result is a compact, always-up-to-date set of instructions Claude reads at the start of every session — measured in *dozens* of tokens rather than thousands, and actually capable of changing behavior.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 1. Clone with the reflexio backend submodule
|
|
60
|
+
git clone --recurse-submodules https://github.com/ReflexioAI/claude-smart.git
|
|
61
|
+
cd claude-smart
|
|
62
|
+
|
|
63
|
+
# 2. Install dependencies (creates a uv-managed venv, pulls reflexio as a path dep)
|
|
64
|
+
uv sync
|
|
65
|
+
|
|
66
|
+
# 3. Turn on the local providers inside reflexio — no API key required at all
|
|
67
|
+
mkdir -p ~/.reflexio
|
|
68
|
+
grep -q '^CLAUDE_SMART_USE_LOCAL_CLI=' ~/.reflexio/.env 2>/dev/null \
|
|
69
|
+
|| echo 'CLAUDE_SMART_USE_LOCAL_CLI=1' >> ~/.reflexio/.env
|
|
70
|
+
grep -q '^CLAUDE_SMART_USE_LOCAL_EMBEDDING=' ~/.reflexio/.env 2>/dev/null \
|
|
71
|
+
|| echo 'CLAUDE_SMART_USE_LOCAL_EMBEDDING=1' >> ~/.reflexio/.env
|
|
72
|
+
|
|
73
|
+
# 4. Start the local reflexio backend (storage + search + extraction orchestrator)
|
|
74
|
+
uv run reflexio services start --only backend --no-reload
|
|
75
|
+
|
|
76
|
+
# 5. Install the plugin into Claude Code (project-level)
|
|
77
|
+
mkdir -p .claude && cat > .claude/settings.local.json <<'JSON'
|
|
78
|
+
{
|
|
79
|
+
"extraKnownMarketplaces": {
|
|
80
|
+
"claude-smart-local": {
|
|
81
|
+
"source": { "source": "directory", "path": "." }
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"enabledPlugins": { "claude-smart@claude-smart-local": true }
|
|
85
|
+
}
|
|
86
|
+
JSON
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Restart Claude Code in this workspace. The first time you correct Claude on something project-specific (*"no, don't use pytest-asyncio — use anyio with trio"*), a playbook rule will be extracted. Every subsequent session in the project starts with that rule injected — automatically, without you asking.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Key Features
|
|
94
|
+
|
|
95
|
+
- 🧠 **Learn, don't just remember** — Corrections become structured, deduplicated rules, not transcript replays.
|
|
96
|
+
- 🎯 **Two-tier scope** — Per-session profiles for the current conversation; cross-session playbooks for the whole project.
|
|
97
|
+
- 🔌 **Fully local — no external API keys needed** — Generation runs through your local `claude` CLI; semantic search runs on an in-process ONNX embedder (all-MiniLM-L6-v2). The whole stack works offline.
|
|
98
|
+
- 🔎 **Hybrid search** — Playbooks and profiles are indexed with vector + BM25 search for fast, robust retrieval.
|
|
99
|
+
- 📥 **Automatic hook ingestion** — `SessionStart`, `UserPromptSubmit`, `PostToolUse`, `Stop`, `SessionEnd` all wired up; you don't run anything manually.
|
|
100
|
+
- 🏷️ **Correction-aware** — Corrective phrasings (`"no, don't"`, `"actually"`, `"stop"`, `"wrong"`) are detected and weighted during extraction.
|
|
101
|
+
- 🧪 **Offline resilience** — If the reflexio backend is down, hooks buffer to disk; the next successful publish drains them.
|
|
102
|
+
- 🧰 **Three slash commands** — `/show`, `/learn`, `/tag` for on-demand control.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## How It Works
|
|
107
|
+
|
|
108
|
+
**Core components:**
|
|
109
|
+
|
|
110
|
+
1. **5 lifecycle hooks** (`plugin/hooks/hooks.json`)
|
|
111
|
+
- `SessionStart` — fetches the project playbook from reflexio and injects it as `additionalContext`.
|
|
112
|
+
- `UserPromptSubmit` — buffers each user turn, heuristically flags corrections.
|
|
113
|
+
- `PostToolUse` — records tool invocations for later extraction.
|
|
114
|
+
- `Stop` — finalizes the assistant turn from the transcript, publishes to reflexio.
|
|
115
|
+
- `SessionEnd` — flushes the remaining buffer with `force_extraction=True`.
|
|
116
|
+
2. **Local state buffer** — JSONL per session at `~/.claude-smart/sessions/{session_id}.jsonl`. Offline-safe.
|
|
117
|
+
3. **Reflexio backend** (submodule at `reflexio/`) — SQLite storage, hybrid search, profile/playbook extraction, dedup, status lifecycle (`CURRENT` → `ARCHIVED`). Runs on `localhost:8081`.
|
|
118
|
+
4. **Claude Code LLM provider** — a LiteLLM custom provider registered inside reflexio. Every generation call (extraction, update, dedup, evaluation) subprocesses `claude -p --output-format json`, so no OpenAI/Anthropic key is needed for the learning loop.
|
|
119
|
+
5. **Three slash commands** — `/show`, `/learn`, `/tag`.
|
|
120
|
+
|
|
121
|
+
**Data flow:**
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Claude Code session
|
|
125
|
+
├─ UserPromptSubmit ─┐
|
|
126
|
+
├─ PostToolUse ─────┤ → JSONL buffer ─→ Stop ─→ reflexio publish_interaction
|
|
127
|
+
└─ Stop ─────┘ │
|
|
128
|
+
▼
|
|
129
|
+
┌─────────────────────────┐
|
|
130
|
+
│ reflexio extractors │
|
|
131
|
+
│ (run via claude -p) │
|
|
132
|
+
│ → profiles + playbooks │
|
|
133
|
+
└────────────┬────────────┘
|
|
134
|
+
│
|
|
135
|
+
▼
|
|
136
|
+
Next session → SessionStart → search_user_playbooks(agent_version=project_id)
|
|
137
|
+
→ additionalContext injected into Claude's system prompt
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Mapping to reflexio:**
|
|
141
|
+
|
|
142
|
+
| Reflexio field | claude-smart value |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `user_id` | Claude Code `session_id` — scopes profiles to the current conversation |
|
|
145
|
+
| `agent_version` | `project_id` (git-toplevel basename) — stable across sessions, so playbooks accumulate project-wide |
|
|
146
|
+
| `session_id` | Claude Code `session_id` — for reflexio's deferred success evaluation |
|
|
147
|
+
|
|
148
|
+
Cross-session playbook retrieval uses `search_user_playbooks(agent_version=project_id, user_id=None)` — playbooks written from any prior session in this project surface for every future session.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Installation
|
|
153
|
+
|
|
154
|
+
### One-command install
|
|
155
|
+
|
|
156
|
+
If you just want the plugin wired into Claude Code (marketplace added, plugin installed, `~/.reflexio/.env` seeded with the local-provider flags), run **one** of:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# uvx — pulls the Python package straight from git, no clone required
|
|
160
|
+
uvx --from git+https://github.com/ReflexioAI/claude-smart claude-smart install
|
|
161
|
+
|
|
162
|
+
# npx — same thing via the published npm wrapper
|
|
163
|
+
npx claude-smart install
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Both do the same three things:
|
|
167
|
+
|
|
168
|
+
1. `claude plugin marketplace add ReflexioAI/claude-smart`
|
|
169
|
+
2. `claude plugin install claude-smart@yilu`
|
|
170
|
+
3. Append `CLAUDE_SMART_USE_LOCAL_CLI=1` and `CLAUDE_SMART_USE_LOCAL_EMBEDDING=1` to `~/.reflexio/.env` (idempotent).
|
|
171
|
+
|
|
172
|
+
You still need to start the reflexio backend yourself the first time (`uv run reflexio services start --only backend --no-reload` from a clone of this repo). Everything else — submodule init, `uv sync` — runs inside Claude Code's `Setup` hook on first session.
|
|
173
|
+
|
|
174
|
+
For a manual, step-by-step walkthrough, see below.
|
|
175
|
+
|
|
176
|
+
### Prerequisites
|
|
177
|
+
|
|
178
|
+
| Tool | Purpose |
|
|
179
|
+
| --- | --- |
|
|
180
|
+
| [Claude Code](https://claude.com/claude-code) | The host CLI — also used as the LLM backend for extraction |
|
|
181
|
+
| [uv](https://docs.astral.sh/uv/) | Python package manager (Python 3.12+) |
|
|
182
|
+
| `git` | Needed to clone with submodules and to derive the project id |
|
|
183
|
+
|
|
184
|
+
> **No external API keys needed.** Generation runs through your local `claude` CLI (via a LiteLLM custom provider). Embeddings run through an in-process ONNX model (`all-MiniLM-L6-v2`, bundled by `chromadb`). Both are opt-in; when enabled, reflexio refuses to fall back to paid APIs.
|
|
185
|
+
|
|
186
|
+
### Step 1 — Clone the repository (with the reflexio submodule)
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
git clone --recurse-submodules https://github.com/ReflexioAI/claude-smart.git
|
|
190
|
+
cd claude-smart
|
|
191
|
+
|
|
192
|
+
# If you forgot --recurse-submodules
|
|
193
|
+
git submodule update --init --recursive
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Step 2 — Install Python dependencies
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv sync
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
This creates `.venv/`, pulls `reflexio-ai` as a path dependency from the `reflexio/` submodule, and registers the `claude-smart` and `claude-smart-hook` console scripts.
|
|
203
|
+
|
|
204
|
+
### Step 3 — Enable the local providers in reflexio
|
|
205
|
+
|
|
206
|
+
Two env flags turn on the local generation backend (Claude Code CLI) and the local embedder (in-process ONNX). Both live in `~/.reflexio/.env`:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
mkdir -p ~/.reflexio
|
|
210
|
+
grep -q '^CLAUDE_SMART_USE_LOCAL_CLI=' ~/.reflexio/.env 2>/dev/null \
|
|
211
|
+
|| echo 'CLAUDE_SMART_USE_LOCAL_CLI=1' >> ~/.reflexio/.env
|
|
212
|
+
grep -q '^CLAUDE_SMART_USE_LOCAL_EMBEDDING=' ~/.reflexio/.env 2>/dev/null \
|
|
213
|
+
|| echo 'CLAUDE_SMART_USE_LOCAL_EMBEDDING=1' >> ~/.reflexio/.env
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
On first use, the embedder downloads the ~80 MB ONNX model once and caches it at `~/.cache/chroma/onnx_models/`. Subsequent starts reuse the cache and stay offline.
|
|
217
|
+
|
|
218
|
+
### Step 4 — Start the reflexio backend
|
|
219
|
+
|
|
220
|
+
Run this from the **claude-smart repo root** (not the `reflexio/` subdir) so that `uv run` uses the claude-smart venv — which already has `chromadb` installed for the local embedder and `reflexio-ai` available as a path dep with the `reflexio` CLI script registered:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
uv run reflexio services start --only backend --no-reload
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
You should see a log line like:
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
Registered claude-code LiteLLM provider (cli=/path/to/claude)
|
|
230
|
+
Local embedding provider enabled (model=local/minilm-l6-v2)
|
|
231
|
+
Auto-detected LLM providers (priority order): ['claude-code', 'local']
|
|
232
|
+
Primary provider for generation: claude-code
|
|
233
|
+
Embedding provider: local
|
|
234
|
+
Application startup complete.
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Health check:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
curl http://localhost:8081/health
|
|
241
|
+
# {"status":"healthy"}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Leave this running in a separate terminal. Stop it later with:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
uv run reflexio services stop
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Step 5 — Install the plugin into Claude Code
|
|
251
|
+
|
|
252
|
+
**Project-level (recommended while you evaluate):**
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
mkdir -p .claude
|
|
256
|
+
cat > .claude/settings.local.json <<JSON
|
|
257
|
+
{
|
|
258
|
+
"extraKnownMarketplaces": {
|
|
259
|
+
"claude-smart-local": {
|
|
260
|
+
"source": { "source": "directory", "path": "$PWD" }
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
"enabledPlugins": { "claude-smart@claude-smart-local": true }
|
|
264
|
+
}
|
|
265
|
+
JSON
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**User-level (all projects):**
|
|
269
|
+
|
|
270
|
+
Put the same JSON into `~/.claude/settings.json`, using an absolute path for the marketplace `path`.
|
|
271
|
+
|
|
272
|
+
Restart Claude Code. On the next session start you should see reflexio logs show a `search_user_playbooks` call — that's the SessionStart hook fetching the (currently empty) playbook.
|
|
273
|
+
|
|
274
|
+
### Step 6 — Sanity check
|
|
275
|
+
|
|
276
|
+
Inside Claude Code:
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
/show
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
On a fresh project you'll see `_No playbook or profiles yet for project `<name>`._` — correct. Have a conversation, include at least one genuine correction (`"no, don't use X — use Y"`), then:
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
/learn
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
That forces immediate extraction. Run `/show` again after ~20–30 seconds; the extracted rule should appear.
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Slash Commands
|
|
293
|
+
|
|
294
|
+
| Command | What it does |
|
|
295
|
+
| --- | --- |
|
|
296
|
+
| `/show` | Print the current project playbook plus the current session's user profiles (same markdown that `SessionStart` injects). Use it to audit what rules and preferences Claude is being told to follow. |
|
|
297
|
+
| `/learn` | Force reflexio to run extraction *now* on the current session's unpublished interactions. Without this, extraction runs at the end of the session or on reflexio's batch interval. |
|
|
298
|
+
| `/tag [note]` | Tag the most recent turn as a correction, for cases the automatic heuristic missed. The note becomes the correction description the extractor sees. |
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Configuration
|
|
303
|
+
|
|
304
|
+
### Environment variables
|
|
305
|
+
|
|
306
|
+
| Variable | Default | Purpose |
|
|
307
|
+
| --- | --- | --- |
|
|
308
|
+
| `CLAUDE_SMART_USE_LOCAL_CLI` | `0` | Set to `1` in `~/.reflexio/.env` to route generation through the local `claude` CLI. |
|
|
309
|
+
| `CLAUDE_SMART_USE_LOCAL_EMBEDDING` | `0` | Set to `1` to use the in-process ONNX embedder (requires `chromadb`). |
|
|
310
|
+
| `CLAUDE_SMART_CLI_PATH` | `shutil.which("claude")` | Override the path to the `claude` binary. |
|
|
311
|
+
| `CLAUDE_SMART_CLI_TIMEOUT` | `120` | Per-call subprocess timeout (seconds). Raise for slow prompts. |
|
|
312
|
+
| `CLAUDE_SMART_STATE_DIR` | `~/.claude-smart/sessions/` | Where the per-session JSONL buffer lives. |
|
|
313
|
+
| `REFLEXIO_URL` | `http://localhost:8081/` | Point the plugin at a non-local reflexio backend. |
|
|
314
|
+
|
|
315
|
+
### Where data lives
|
|
316
|
+
|
|
317
|
+
| Path | What |
|
|
318
|
+
| --- | --- |
|
|
319
|
+
| `~/.reflexio/data/reflexio.db` | Source of truth — profiles, user_playbooks, interactions, FTS5 indexes, and vec0 embedding tables (plus `.db-shm` / `.db-wal` WAL sidecars). Inspect with `sqlite3`. |
|
|
320
|
+
| `~/.reflexio/.env` | Provider config — `CLAUDE_SMART_USE_LOCAL_CLI`, `CLAUDE_SMART_USE_LOCAL_EMBEDDING`, any optional API keys. |
|
|
321
|
+
| `~/.claude-smart/sessions/{session_id}.jsonl` | Per-session buffer. User turns, assistant turns, tool invocations, `{"published_up_to": N}` watermarks. Safe to inspect and safe to delete — everything past the latest watermark has already been written to reflexio's DB. |
|
|
322
|
+
| `~/.cache/chroma/onnx_models/all-MiniLM-L6-v2/` | Cached ONNX weights (~86 MB, downloaded once). Delete to force a re-download. |
|
|
323
|
+
|
|
324
|
+
### Scope: profile vs. playbook
|
|
325
|
+
|
|
326
|
+
- **Profile** (`user_id = session_id`) — session-scoped preferences. Does not persist across sessions, but *is* reinjected if you resume the same session (`/resume`, `/clear`, `/compact`).
|
|
327
|
+
- **Playbook** (`agent_version = project_id`) — cross-session. Every session in the same project — identified by git-toplevel basename — sees the accumulated playbook.
|
|
328
|
+
|
|
329
|
+
### Embeddings
|
|
330
|
+
|
|
331
|
+
claude-smart uses an in-process ONNX embedder (Chroma's `all-MiniLM-L6-v2`, 384-dim, zero-padded to reflexio's 512-dim schema). The model weights are downloaded on first use (~80 MB, cached under `~/.cache/chroma/onnx_models/`) — after that, no network calls for embedding. Runtime cost is a few milliseconds per short document on CPU.
|
|
332
|
+
|
|
333
|
+
If you still want to use a cloud embedding provider (OpenAI, Gemini, etc.), omit `CLAUDE_SMART_USE_LOCAL_EMBEDDING` and set the corresponding API key in `~/.reflexio/.env` — reflexio will fall back to its standard provider-priority chain.
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## How the Claude Code Provider Works
|
|
338
|
+
|
|
339
|
+
claude-smart ships a small patch to reflexio (`reflexio/server/llm/providers/claude_code_provider.py`) that registers a LiteLLM `CustomLLM` named `claude-code`. Every time reflexio wants to generate, evaluate, or dedup, it ends up in `litellm.completion(model="claude-code/default", ...)` — which routes to our handler. The handler:
|
|
340
|
+
|
|
341
|
+
1. Splits LiteLLM's messages into `(system_prompt, dialogue)`.
|
|
342
|
+
2. Subprocesses `claude -p --output-format json --append-system-prompt "<system>"` with the dialogue on stdin.
|
|
343
|
+
3. Parses the JSON stdout into a LiteLLM `ModelResponse` with populated usage tokens.
|
|
344
|
+
|
|
345
|
+
Registration is opt-in (`CLAUDE_SMART_USE_LOCAL_CLI=1`) and idempotent, so enabling it does not affect users who still want OpenAI/Anthropic — reflexio's normal provider-priority chain stays intact.
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Troubleshooting
|
|
350
|
+
|
|
351
|
+
**SessionStart injects nothing after a correction.**
|
|
352
|
+
Extraction is async by default. Run `/learn` to force it, wait ~20–30s, then run `/show` — no new session needed. `/show` shows whether the rule was actually extracted.
|
|
353
|
+
|
|
354
|
+
**Reflexio refuses to boot with "no embedding-capable provider".**
|
|
355
|
+
Check that `CLAUDE_SMART_USE_LOCAL_EMBEDDING=1` is in `~/.reflexio/.env` *and* that `chromadb` is installed in the venv (`uv run python -c "import chromadb"` should print nothing). If you'd rather use a cloud embedder instead, drop the env flag and set `OPENAI_API_KEY` or `GEMINI_API_KEY` in the same file.
|
|
356
|
+
|
|
357
|
+
**`claude-smart` doesn't see my interactions.**
|
|
358
|
+
Check `~/.claude-smart/sessions/`. If your current session's JSONL has no `User`/`Assistant` rows, the plugin isn't receiving hook events — verify `.claude/settings.local.json` has the right path and that `enabledPlugins` is `true`.
|
|
359
|
+
|
|
360
|
+
**Hooks appear to time out.**
|
|
361
|
+
Each hook is capped at 15–60s. If you see long pauses, check `uv` is on PATH (hooks shell out to `uv run`). Set `CLAUDE_SMART_CLI_TIMEOUT=180` to give the LLM provider more headroom.
|
|
362
|
+
|
|
363
|
+
**A different LLM is being used.**
|
|
364
|
+
Reflexio's provider priority is `claude-code > local > anthropic > gemini > ... > openai`. If you have `CLAUDE_SMART_USE_LOCAL_CLI=1` *and* an Anthropic key set, claude-code still wins for generation; `local` sits above openai/gemini for embeddings. Check the startup log line `Primary provider for generation: <name>` and `Embedding provider: <name>` to confirm.
|
|
365
|
+
|
|
366
|
+
**I want to wipe everything and start over.**
|
|
367
|
+
```bash
|
|
368
|
+
rm -rf ~/.claude-smart/sessions/
|
|
369
|
+
rm -rf ~/.reflexio/data/ # reflexio SQLite store
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Dashboard (web UI)
|
|
375
|
+
|
|
376
|
+
A Next.js management UI lives in [`dashboard/`](dashboard/). Use it to browse
|
|
377
|
+
local session buffers, inspect extracted user profiles, edit and archive
|
|
378
|
+
project playbooks, and tweak the claude-smart environment. It connects to the
|
|
379
|
+
same reflexio backend the plugin uses, so run that first.
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# 1. reflexio backend on :8081 (see Step 4 above)
|
|
383
|
+
uv run reflexio services start --only backend --no-reload
|
|
384
|
+
|
|
385
|
+
# 2. install and run the dashboard
|
|
386
|
+
cd dashboard
|
|
387
|
+
npm install
|
|
388
|
+
npm run dev # http://localhost:3001
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
The dashboard reads `~/.claude-smart/sessions/*.jsonl` directly (server-side)
|
|
392
|
+
for in-flight session transcripts and proxies everything else through reflexio.
|
|
393
|
+
All state lives where the CLI already keeps it — the dashboard does not
|
|
394
|
+
introduce a second source of truth.
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Development
|
|
399
|
+
|
|
400
|
+
Run the test suite:
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
# reflexio patch unit tests
|
|
404
|
+
cd reflexio
|
|
405
|
+
uv run pytest tests/server/llm/ -q -o 'addopts='
|
|
406
|
+
|
|
407
|
+
# claude-smart package tests
|
|
408
|
+
cd ..
|
|
409
|
+
uv run pytest tests/ -q
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Exercise a hook handler directly (useful for debugging without a live Claude Code session):
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
echo '{"session_id":"dev-1","source":"startup","cwd":"'"$PWD"'"}' \
|
|
416
|
+
| uv run python -m claude_smart.hook session-start
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## License
|
|
422
|
+
|
|
423
|
+
This project is licensed under the **Apache License 2.0**. The bundled `reflexio/` submodule is also Apache 2.0. Claude Code is Anthropic's and not covered by this license.
|
|
424
|
+
|
|
425
|
+
See the [LICENSE](LICENSE) file for details.
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## Support
|
|
430
|
+
|
|
431
|
+
- **Issues**: open one on GitHub describing the symptom and include the reflexio startup log (stdout of `uv run reflexio services start`) and the relevant lines of `~/.claude-smart/sessions/{session_id}.jsonl`.
|
|
432
|
+
- **Architecture notes**: see the plan file in `.claude/plans/` (if present), which walks through each design decision and the rationale.
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
**Built on** [reflexio](https://github.com/ReflexioAI/reflexio) · **Runs on** [Claude Code](https://claude.com/claude-code) · **Written in** Python 3.12+
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* npx claude-smart install — thin wrapper around the native Claude Code
|
|
4
|
+
* plugin CLI. Registers the GitHub marketplace, installs the plugin, and
|
|
5
|
+
* seeds ~/.reflexio/.env with the two local-provider flags so reflexio
|
|
6
|
+
* can route generation through the local `claude` CLI with no API key.
|
|
7
|
+
*
|
|
8
|
+
* Keep this file dependency-free — it runs via `npx` with no install step.
|
|
9
|
+
*/
|
|
10
|
+
"use strict";
|
|
11
|
+
|
|
12
|
+
const { execFileSync, execSync } = require("child_process");
|
|
13
|
+
const { appendFileSync, existsSync, mkdirSync, readFileSync } = require("fs");
|
|
14
|
+
const { homedir } = require("os");
|
|
15
|
+
const { dirname, join } = require("path");
|
|
16
|
+
|
|
17
|
+
const DEFAULT_MARKETPLACE_SOURCE = "ReflexioAI/claude-smart";
|
|
18
|
+
const PLUGIN_SPEC = "claude-smart@yilu";
|
|
19
|
+
const REFLEXIO_ENV_PATH = join(homedir(), ".reflexio", ".env");
|
|
20
|
+
|
|
21
|
+
function hasClaudeCli() {
|
|
22
|
+
const probe = process.platform === "win32" ? "where claude" : "command -v claude";
|
|
23
|
+
try {
|
|
24
|
+
execSync(probe, { stdio: "ignore" });
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function seedReflexioEnv() {
|
|
32
|
+
mkdirSync(dirname(REFLEXIO_ENV_PATH), { recursive: true });
|
|
33
|
+
const existing = existsSync(REFLEXIO_ENV_PATH)
|
|
34
|
+
? readFileSync(REFLEXIO_ENV_PATH, "utf8")
|
|
35
|
+
: "";
|
|
36
|
+
const flags = ["CLAUDE_SMART_USE_LOCAL_CLI", "CLAUDE_SMART_USE_LOCAL_EMBEDDING"];
|
|
37
|
+
const missing = flags.filter((f) => !new RegExp(`^${f}=`, "m").test(existing));
|
|
38
|
+
if (missing.length === 0) return [];
|
|
39
|
+
const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
|
|
40
|
+
const body = missing.map((f) => `${f}=1`).join("\n") + "\n";
|
|
41
|
+
appendFileSync(REFLEXIO_ENV_PATH, prefix + body);
|
|
42
|
+
return missing;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function printHelp() {
|
|
46
|
+
process.stdout.write(
|
|
47
|
+
[
|
|
48
|
+
"claude-smart — install helper for the Claude Code plugin",
|
|
49
|
+
"",
|
|
50
|
+
"Usage:",
|
|
51
|
+
" npx claude-smart install Install the plugin into Claude Code",
|
|
52
|
+
" npx claude-smart install --source <owner/repo> Override the marketplace source",
|
|
53
|
+
" npx claude-smart --help Show this help",
|
|
54
|
+
"",
|
|
55
|
+
"What it does:",
|
|
56
|
+
" 1. claude plugin marketplace add <source>",
|
|
57
|
+
` 2. claude plugin install ${PLUGIN_SPEC}`,
|
|
58
|
+
" 3. Appends CLAUDE_SMART_USE_LOCAL_CLI=1 and CLAUDE_SMART_USE_LOCAL_EMBEDDING=1",
|
|
59
|
+
" to ~/.reflexio/.env (idempotent).",
|
|
60
|
+
"",
|
|
61
|
+
].join("\n"),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function parseSource(args) {
|
|
66
|
+
const idx = args.indexOf("--source");
|
|
67
|
+
if (idx === -1) return DEFAULT_MARKETPLACE_SOURCE;
|
|
68
|
+
const value = args[idx + 1];
|
|
69
|
+
if (!value) {
|
|
70
|
+
process.stderr.write("error: --source requires a value (e.g. owner/repo)\n");
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function runInstall(args) {
|
|
77
|
+
if (!hasClaudeCli()) {
|
|
78
|
+
process.stderr.write(
|
|
79
|
+
"error: 'claude' CLI not found on PATH. " +
|
|
80
|
+
"Install Claude Code first: https://claude.com/claude-code\n",
|
|
81
|
+
);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const source = parseSource(args);
|
|
86
|
+
const steps = [
|
|
87
|
+
["plugin", "marketplace", "add", source],
|
|
88
|
+
["plugin", "install", PLUGIN_SPEC],
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
for (const stepArgs of steps) {
|
|
92
|
+
try {
|
|
93
|
+
execFileSync("claude", stepArgs, { stdio: "inherit" });
|
|
94
|
+
} catch (err) {
|
|
95
|
+
const code = typeof err.status === "number" ? err.status : 1;
|
|
96
|
+
process.stderr.write(
|
|
97
|
+
`error: \`claude ${stepArgs.join(" ")}\` failed (exit ${code})\n`,
|
|
98
|
+
);
|
|
99
|
+
process.exit(code);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const added = seedReflexioEnv();
|
|
104
|
+
if (added.length > 0) {
|
|
105
|
+
process.stdout.write(
|
|
106
|
+
`Seeded ${REFLEXIO_ENV_PATH} with ${added.join(", ")}.\n`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
process.stdout.write(
|
|
111
|
+
[
|
|
112
|
+
"",
|
|
113
|
+
"claude-smart installed. Next steps:",
|
|
114
|
+
" 1. Start the reflexio backend (leave it running in another terminal):",
|
|
115
|
+
" uv run reflexio services start --only backend --no-reload",
|
|
116
|
+
" 2. Restart Claude Code in your project.",
|
|
117
|
+
"",
|
|
118
|
+
].join("\n"),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function main() {
|
|
123
|
+
const args = process.argv.slice(2);
|
|
124
|
+
const cmd = args[0] || "install";
|
|
125
|
+
|
|
126
|
+
if (cmd === "help" || cmd === "--help" || cmd === "-h") {
|
|
127
|
+
printHelp();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (cmd === "install") {
|
|
132
|
+
runInstall(args.slice(1));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
process.stderr.write(
|
|
137
|
+
`claude-smart: unknown command '${cmd}'. Try 'npx claude-smart --help'.\n`,
|
|
138
|
+
);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-smart",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Self-improving Claude Code plugin — learns from corrections via reflexio",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude",
|
|
7
|
+
"claude-code",
|
|
8
|
+
"plugin",
|
|
9
|
+
"reflexio",
|
|
10
|
+
"self-improvement",
|
|
11
|
+
"playbook",
|
|
12
|
+
"learning"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/ReflexioAI/claude-smart#readme",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/ReflexioAI/claude-smart.git"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/ReflexioAI/claude-smart/issues"
|
|
21
|
+
},
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"author": "Yi Lu",
|
|
24
|
+
"type": "commonjs",
|
|
25
|
+
"bin": {
|
|
26
|
+
"claude-smart": "bin/claude-smart.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|