claude-smart 0.2.23 → 0.2.24
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/.agents/plugins/marketplace.json +20 -0
- package/README.md +69 -27
- package/bin/claude-smart.js +296 -11
- package/package.json +11 -1
- package/plugin/.claude-plugin/plugin.json +17 -0
- package/plugin/.codex-plugin/plugin.json +35 -0
- package/plugin/LICENSE +202 -0
- package/plugin/README.md +37 -0
- package/plugin/bin/cs-cite +77 -0
- package/plugin/commands/clear-all.md +8 -0
- package/plugin/commands/dashboard.md +8 -0
- package/plugin/commands/learn.md +12 -0
- package/plugin/commands/restart.md +8 -0
- package/plugin/commands/show.md +8 -0
- package/plugin/dashboard/AGENTS.md +6 -0
- package/plugin/dashboard/app/api/claude-settings/route.ts +19 -0
- package/plugin/dashboard/app/api/config/route.ts +16 -0
- package/plugin/dashboard/app/api/health/route.ts +10 -0
- package/plugin/dashboard/app/api/reflexio/[...path]/route.ts +63 -0
- package/plugin/dashboard/app/api/sessions/[id]/route.ts +28 -0
- package/plugin/dashboard/app/api/sessions/route.ts +14 -0
- package/plugin/dashboard/app/configure/env/page.tsx +318 -0
- package/plugin/dashboard/app/configure/layout.tsx +47 -0
- package/plugin/dashboard/app/configure/page.tsx +5 -0
- package/plugin/dashboard/app/configure/server/page.tsx +258 -0
- package/plugin/dashboard/app/dashboard/page.tsx +227 -0
- package/plugin/dashboard/app/globals.css +129 -0
- package/plugin/dashboard/app/icon.png +0 -0
- package/plugin/dashboard/app/layout.tsx +40 -0
- package/plugin/dashboard/app/page.tsx +5 -0
- package/plugin/dashboard/app/preferences/[id]/page.tsx +531 -0
- package/plugin/dashboard/app/preferences/page.tsx +126 -0
- package/plugin/dashboard/app/providers.tsx +12 -0
- package/plugin/dashboard/app/sessions/[sessionId]/page.tsx +321 -0
- package/plugin/dashboard/app/sessions/page.tsx +186 -0
- package/plugin/dashboard/app/skills/page.tsx +362 -0
- package/plugin/dashboard/app/skills/project/[id]/page.tsx +597 -0
- package/plugin/dashboard/app/skills/shared/[id]/page.tsx +830 -0
- package/plugin/dashboard/components/common/delete-all-button.tsx +45 -0
- package/plugin/dashboard/components/common/empty-state.tsx +34 -0
- package/plugin/dashboard/components/common/learnings-badge.tsx +34 -0
- package/plugin/dashboard/components/common/page-header.tsx +34 -0
- package/plugin/dashboard/components/common/page-tabs.tsx +115 -0
- package/plugin/dashboard/components/common/stat-card.tsx +38 -0
- package/plugin/dashboard/components/layout/nav-items.ts +22 -0
- package/plugin/dashboard/components/layout/sidebar.tsx +45 -0
- package/plugin/dashboard/components/layout/top-bar.tsx +64 -0
- package/plugin/dashboard/components/stall-banner.tsx +53 -0
- package/plugin/dashboard/components/ui/badge.tsx +52 -0
- package/plugin/dashboard/components/ui/button.tsx +60 -0
- package/plugin/dashboard/components/ui/collapsible.tsx +21 -0
- package/plugin/dashboard/components/ui/input.tsx +20 -0
- package/plugin/dashboard/components/ui/label.tsx +20 -0
- package/plugin/dashboard/components/ui/scroll-area.tsx +55 -0
- package/plugin/dashboard/components/ui/select.tsx +201 -0
- package/plugin/dashboard/components/ui/separator.tsx +25 -0
- package/plugin/dashboard/components/ui/sheet.tsx +135 -0
- package/plugin/dashboard/components/ui/switch.tsx +32 -0
- package/plugin/dashboard/components.json +25 -0
- package/plugin/dashboard/eslint.config.mjs +16 -0
- package/plugin/dashboard/hooks/use-settings.tsx +88 -0
- package/plugin/dashboard/hooks/use-stall-state.ts +59 -0
- package/plugin/dashboard/lib/claude-settings-file.ts +114 -0
- package/plugin/dashboard/lib/config-file.ts +131 -0
- package/plugin/dashboard/lib/format.ts +58 -0
- package/plugin/dashboard/lib/reflexio-client.ts +238 -0
- package/plugin/dashboard/lib/reflexio-url.ts +17 -0
- package/plugin/dashboard/lib/session-reader.ts +245 -0
- package/plugin/dashboard/lib/status.ts +24 -0
- package/plugin/dashboard/lib/types.ts +145 -0
- package/plugin/dashboard/lib/utils.ts +6 -0
- package/plugin/dashboard/next.config.ts +7 -0
- package/plugin/dashboard/package-lock.json +10275 -0
- package/plugin/dashboard/package.json +37 -0
- package/plugin/dashboard/postcss.config.mjs +7 -0
- package/plugin/dashboard/public/claude-smart-icon.png +0 -0
- package/plugin/dashboard/tsconfig.json +34 -0
- package/plugin/hooks/codex-hooks.json +67 -0
- package/plugin/hooks/hooks.json +111 -0
- package/plugin/pyproject.toml +49 -0
- package/plugin/scripts/_codex_env.sh +27 -0
- package/plugin/scripts/_lib.sh +325 -0
- package/plugin/scripts/backend-service.sh +208 -0
- package/plugin/scripts/cli.sh +40 -0
- package/plugin/scripts/dashboard-build.sh +139 -0
- package/plugin/scripts/dashboard-open.sh +107 -0
- package/plugin/scripts/dashboard-service.sh +195 -0
- package/plugin/scripts/ensure-plugin-root.sh +84 -0
- package/plugin/scripts/hook_entry.sh +70 -0
- package/plugin/scripts/smart-install.sh +411 -0
- package/plugin/src/claude_smart/__init__.py +3 -0
- package/plugin/src/claude_smart/cli.py +1273 -0
- package/plugin/src/claude_smart/context_format.py +277 -0
- package/plugin/src/claude_smart/context_inject.py +92 -0
- package/plugin/src/claude_smart/cs_cite.py +236 -0
- package/plugin/src/claude_smart/events/__init__.py +1 -0
- package/plugin/src/claude_smart/events/post_tool.py +148 -0
- package/plugin/src/claude_smart/events/pre_tool.py +52 -0
- package/plugin/src/claude_smart/events/session_end.py +20 -0
- package/plugin/src/claude_smart/events/session_start.py +119 -0
- package/plugin/src/claude_smart/events/stop.py +393 -0
- package/plugin/src/claude_smart/events/user_prompt.py +73 -0
- package/plugin/src/claude_smart/hook.py +114 -0
- package/plugin/src/claude_smart/ids.py +56 -0
- package/plugin/src/claude_smart/internal_call.py +89 -0
- package/plugin/src/claude_smart/optimizer_assistant.py +203 -0
- package/plugin/src/claude_smart/publish.py +71 -0
- package/plugin/src/claude_smart/query_compose.py +51 -0
- package/plugin/src/claude_smart/reflexio_adapter.py +403 -0
- package/plugin/src/claude_smart/runtime.py +52 -0
- package/plugin/src/claude_smart/stall_banner.py +61 -0
- package/plugin/src/claude_smart/state.py +276 -0
- package/plugin/uv.lock +3720 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-smart",
|
|
3
|
+
"version": "0.2.24",
|
|
4
|
+
"description": "Self-improving coding assistant plugin — learns from corrections across sessions via reflexio",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Yi Lu"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/ReflexioAI/claude-smart#readme",
|
|
9
|
+
"repository": "https://github.com/ReflexioAI/claude-smart",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"claude",
|
|
13
|
+
"codex",
|
|
14
|
+
"plugin",
|
|
15
|
+
"reflexio",
|
|
16
|
+
"self-improvement",
|
|
17
|
+
"playbook",
|
|
18
|
+
"learning"
|
|
19
|
+
],
|
|
20
|
+
"hooks": "./hooks/codex-hooks.json",
|
|
21
|
+
"interface": {
|
|
22
|
+
"displayName": "claude-smart",
|
|
23
|
+
"shortDescription": "Persistent learning across coding sessions",
|
|
24
|
+
"longDescription": "claude-smart captures user preferences and project-specific skills into a local reflexio backend, then injects relevant learnings back into future Claude Code and Codex sessions.",
|
|
25
|
+
"developerName": "ReflexioAI",
|
|
26
|
+
"category": "Productivity",
|
|
27
|
+
"capabilities": [
|
|
28
|
+
"Interactive",
|
|
29
|
+
"Write"
|
|
30
|
+
],
|
|
31
|
+
"websiteURL": "https://github.com/ReflexioAI/claude-smart",
|
|
32
|
+
"brandColor": "#2563EB",
|
|
33
|
+
"screenshots": []
|
|
34
|
+
}
|
|
35
|
+
}
|
package/plugin/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/plugin/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# claude-smart
|
|
2
|
+
|
|
3
|
+
Self-improving [Claude Code](https://claude.com/claude-code) plugin — turns your corrections into durable rules that Claude Code follows in future sessions, via [reflexio](https://github.com/ReflexioAI/reflexio).
|
|
4
|
+
|
|
5
|
+
This directory is the published Python package (`claude-smart` on PyPI) and the Claude Code plugin payload shipped through the marketplace. For the project overview, install instructions, benchmarks, and feature walkthrough, see the [top-level README](https://github.com/ReflexioAI/claude-smart#readme).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
claude plugin marketplace add ReflexioAI/claude-smart
|
|
11
|
+
claude plugin install claude-smart@reflexioai
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The Setup hook bootstraps `uv`, Python 3.12, and a private Node.js/npm runtime
|
|
15
|
+
under `~/.claude-smart/` when they are missing. If Node.js is already installed,
|
|
16
|
+
`npx claude-smart install` is equivalent; if uv is already installed,
|
|
17
|
+
`uvx claude-smart install` is equivalent.
|
|
18
|
+
|
|
19
|
+
Then restart Claude Code.
|
|
20
|
+
|
|
21
|
+
## Uninstall
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
claude plugin uninstall claude-smart@reflexioai
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or, if Node.js or uv is already installed:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx claude-smart uninstall # or: uvx claude-smart uninstall
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Local data under `~/.reflexio/` and `~/.claude-smart/` is left in place — remove manually if desired.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""cs-cite — claude-smart citation tool.
|
|
3
|
+
|
|
4
|
+
Claude invokes this via Bash at the end of a reply when an injected
|
|
5
|
+
skill or preference materially shaped the response. The script silently
|
|
6
|
+
validates the id tokens and exits; the Stop hook reads the citation IDs
|
|
7
|
+
off the Bash ``tool_use`` block when it scans the session transcript —
|
|
8
|
+
no session_id, no sidecar file, no state. The confirmation line
|
|
9
|
+
("✨ N claude-smart learnings applied") is emitted by Claude itself as
|
|
10
|
+
the trailing content of the same assistant message, not by this script,
|
|
11
|
+
so the model has a natural, bounded turn-closer after the tool returns.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
cs-cite <id> [<id>...] # space- or comma-separated
|
|
15
|
+
|
|
16
|
+
Accepts one or more rank ids: ``p<N>[-<fp>]`` for preferences
|
|
17
|
+
and ``s<N>[-<fp>]`` for skills, as emitted in ``[cs:p1-ab12]``
|
|
18
|
+
/ ``[cs:s2-cd34]`` tags. The optional ``-<fp>`` suffix is a 1–4 char
|
|
19
|
+
alphanumeric fingerprint of the underlying real id. Tokens may be
|
|
20
|
+
separated by commas and/or whitespace. An optional ``cs:`` prefix is
|
|
21
|
+
stripped for convenience since the model often copies the tag
|
|
22
|
+
verbatim. Case is normalized to lowercase.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import re
|
|
28
|
+
import sys
|
|
29
|
+
|
|
30
|
+
_TOKEN_RE = re.compile(r"^(?:cs:)?([ps]\d+(?:-[a-z0-9]{1,4})?)$", re.IGNORECASE)
|
|
31
|
+
_SPLIT_RE = re.compile(r"[,\s]+")
|
|
32
|
+
_USAGE = (
|
|
33
|
+
"cs-cite: expected one or more rank ids "
|
|
34
|
+
"(e.g. `cs-cite p1-ab12,s2-cd34` or `cs-cite cs:p1-ab12`)\n"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def main() -> int:
|
|
39
|
+
"""Parse ids from argv and exit silently on success.
|
|
40
|
+
|
|
41
|
+
The confirmation line is emitted by Claude as the trailing content of
|
|
42
|
+
the same assistant message (see ``CITATION_INSTRUCTION``), not here —
|
|
43
|
+
keeping this script silent gives the model a natural, bounded thing
|
|
44
|
+
to say after the tool returns instead of leaving a "must emit
|
|
45
|
+
something" gap that tends to hallucinate role markers.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
int: ``0`` on success, ``1`` when no valid ids were found.
|
|
49
|
+
"""
|
|
50
|
+
argv = sys.argv[1:]
|
|
51
|
+
if not argv:
|
|
52
|
+
sys.stderr.write(_USAGE)
|
|
53
|
+
return 1
|
|
54
|
+
tokens = [t for t in _SPLIT_RE.split(" ".join(argv).strip()) if t]
|
|
55
|
+
if not tokens:
|
|
56
|
+
sys.stderr.write(_USAGE)
|
|
57
|
+
return 1
|
|
58
|
+
ids: list[str] = []
|
|
59
|
+
bad: list[str] = []
|
|
60
|
+
for tok in tokens:
|
|
61
|
+
if match := _TOKEN_RE.match(tok):
|
|
62
|
+
ids.append(match.group(1).lower())
|
|
63
|
+
else:
|
|
64
|
+
bad.append(tok)
|
|
65
|
+
if bad:
|
|
66
|
+
sys.stderr.write(
|
|
67
|
+
"cs-cite: ignoring invalid tokens (expected rank ids like "
|
|
68
|
+
f"`p1` or `s2`, optionally 'cs:'-prefixed): {', '.join(bad)}\n"
|
|
69
|
+
)
|
|
70
|
+
if not ids:
|
|
71
|
+
sys.stderr.write(_USAGE)
|
|
72
|
+
return 1
|
|
73
|
+
return 0
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if __name__ == "__main__":
|
|
77
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Open the claude-smart dashboard (http://localhost:3001) in the browser, starting the backend and dashboard if they aren't running
|
|
3
|
+
allowed-tools: Bash(bash:*)
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Run this bash command and show its output verbatim:
|
|
7
|
+
|
|
8
|
+
!`bash "$HOME/.reflexio/plugin-root/scripts/dashboard-open.sh"`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Force claude-smart to extract learnings from this session now
|
|
3
|
+
argument-hint: [optional note to capture]
|
|
4
|
+
allowed-tools: Bash(bash:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Force claude-smart to run extraction on this session's interactions now. If a
|
|
8
|
+
note is provided after the command, it is appended as a neutral User turn
|
|
9
|
+
before extraction so claude-smart can learn from it directly.
|
|
10
|
+
Run the bash command below and show its output verbatim.
|
|
11
|
+
|
|
12
|
+
!`bash "$HOME/.reflexio/plugin-root/scripts/cli.sh" learn --note "$ARGUMENTS"`
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# This is NOT the Next.js you know
|
|
2
|
+
|
|
3
|
+
Next.js 16 has breaking changes from anything older than `next@16`. APIs,
|
|
4
|
+
conventions, and file structure may differ from training data. Before writing
|
|
5
|
+
route handlers, RSC code, dynamic params, or config, read the relevant guide
|
|
6
|
+
in `node_modules/next/dist/docs/`. Heed deprecation notices.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import {
|
|
3
|
+
readClaudeCodeHookConfig,
|
|
4
|
+
writeClaudeCodeHookConfig,
|
|
5
|
+
} from "@/lib/claude-settings-file";
|
|
6
|
+
|
|
7
|
+
export const dynamic = "force-dynamic";
|
|
8
|
+
|
|
9
|
+
export async function GET() {
|
|
10
|
+
const config = await readClaudeCodeHookConfig();
|
|
11
|
+
return NextResponse.json(config);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function PUT(req: Request) {
|
|
15
|
+
const body = await req.json();
|
|
16
|
+
await writeClaudeCodeHookConfig(body);
|
|
17
|
+
const config = await readClaudeCodeHookConfig();
|
|
18
|
+
return NextResponse.json(config);
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { readConfig, writeConfig } from "@/lib/config-file";
|
|
3
|
+
|
|
4
|
+
export const dynamic = "force-dynamic";
|
|
5
|
+
|
|
6
|
+
export async function GET() {
|
|
7
|
+
const config = await readConfig();
|
|
8
|
+
return NextResponse.json(config);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function PUT(req: Request) {
|
|
12
|
+
const body = await req.json();
|
|
13
|
+
await writeConfig(body);
|
|
14
|
+
const config = await readConfig();
|
|
15
|
+
return NextResponse.json(config);
|
|
16
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { originOnly } from "@/lib/reflexio-url";
|
|
3
|
+
|
|
4
|
+
export const dynamic = "force-dynamic";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_URL = "http://localhost:8071";
|
|
7
|
+
|
|
8
|
+
function reflexioBase(req: Request): string {
|
|
9
|
+
const header = req.headers.get("x-reflexio-url");
|
|
10
|
+
const fromHeader = header ? originOnly(header) : null;
|
|
11
|
+
if (fromHeader) return fromHeader;
|
|
12
|
+
const fromEnv = originOnly(process.env.REFLEXIO_URL ?? "");
|
|
13
|
+
return fromEnv ?? DEFAULT_URL;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function proxy(
|
|
17
|
+
req: Request,
|
|
18
|
+
context: { params: Promise<{ path: string[] }> },
|
|
19
|
+
): Promise<Response> {
|
|
20
|
+
const { path } = await context.params;
|
|
21
|
+
const targetPath = path.join("/");
|
|
22
|
+
const url = new URL(req.url);
|
|
23
|
+
const target = `${reflexioBase(req)}/${targetPath}${url.search}`;
|
|
24
|
+
|
|
25
|
+
const headers = new Headers(req.headers);
|
|
26
|
+
headers.delete("host");
|
|
27
|
+
headers.delete("x-reflexio-url");
|
|
28
|
+
headers.delete("connection");
|
|
29
|
+
|
|
30
|
+
const init: RequestInit = {
|
|
31
|
+
method: req.method,
|
|
32
|
+
headers,
|
|
33
|
+
cache: "no-store",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
37
|
+
init.body = await req.arrayBuffer();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const upstream = await fetch(target, init);
|
|
42
|
+
const buf = await upstream.arrayBuffer();
|
|
43
|
+
return new NextResponse(buf, {
|
|
44
|
+
status: upstream.status,
|
|
45
|
+
headers: {
|
|
46
|
+
"content-type":
|
|
47
|
+
upstream.headers.get("content-type") ?? "application/octet-stream",
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
52
|
+
return NextResponse.json(
|
|
53
|
+
{ error: "reflexio unreachable", detail: message, target },
|
|
54
|
+
{ status: 502 },
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const GET = proxy;
|
|
60
|
+
export const POST = proxy;
|
|
61
|
+
export const PUT = proxy;
|
|
62
|
+
export const PATCH = proxy;
|
|
63
|
+
export const DELETE = proxy;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { deleteSession, readSession } from "@/lib/session-reader";
|
|
3
|
+
|
|
4
|
+
export const dynamic = "force-dynamic";
|
|
5
|
+
|
|
6
|
+
export async function GET(
|
|
7
|
+
_req: Request,
|
|
8
|
+
context: { params: Promise<{ id: string }> },
|
|
9
|
+
) {
|
|
10
|
+
const { id } = await context.params;
|
|
11
|
+
const detail = await readSession(id);
|
|
12
|
+
if (!detail) {
|
|
13
|
+
return NextResponse.json({ error: "not found" }, { status: 404 });
|
|
14
|
+
}
|
|
15
|
+
return NextResponse.json(detail);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function DELETE(
|
|
19
|
+
_req: Request,
|
|
20
|
+
context: { params: Promise<{ id: string }> },
|
|
21
|
+
) {
|
|
22
|
+
const { id } = await context.params;
|
|
23
|
+
const ok = await deleteSession(id);
|
|
24
|
+
if (!ok) {
|
|
25
|
+
return NextResponse.json({ error: "not found" }, { status: 404 });
|
|
26
|
+
}
|
|
27
|
+
return NextResponse.json({ deleted: id });
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { deleteAllSessions, listSessions } from "@/lib/session-reader";
|
|
3
|
+
|
|
4
|
+
export const dynamic = "force-dynamic";
|
|
5
|
+
|
|
6
|
+
export async function GET() {
|
|
7
|
+
const sessions = await listSessions();
|
|
8
|
+
return NextResponse.json({ sessions });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function DELETE() {
|
|
12
|
+
const deleted = await deleteAllSessions();
|
|
13
|
+
return NextResponse.json({ deleted });
|
|
14
|
+
}
|