expressible 0.1.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 (93) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +261 -0
  3. package/dist/commands/add.d.ts +9 -0
  4. package/dist/commands/add.d.ts.map +1 -0
  5. package/dist/commands/add.js +175 -0
  6. package/dist/commands/add.js.map +1 -0
  7. package/dist/commands/doctor.d.ts +2 -0
  8. package/dist/commands/doctor.d.ts.map +1 -0
  9. package/dist/commands/doctor.js +126 -0
  10. package/dist/commands/doctor.js.map +1 -0
  11. package/dist/commands/export.d.ts +2 -0
  12. package/dist/commands/export.d.ts.map +1 -0
  13. package/dist/commands/export.js +108 -0
  14. package/dist/commands/export.js.map +1 -0
  15. package/dist/commands/init.d.ts +2 -0
  16. package/dist/commands/init.d.ts.map +1 -0
  17. package/dist/commands/init.js +37 -0
  18. package/dist/commands/init.js.map +1 -0
  19. package/dist/commands/retrain.d.ts +2 -0
  20. package/dist/commands/retrain.d.ts.map +1 -0
  21. package/dist/commands/retrain.js +139 -0
  22. package/dist/commands/retrain.js.map +1 -0
  23. package/dist/commands/review.d.ts +2 -0
  24. package/dist/commands/review.d.ts.map +1 -0
  25. package/dist/commands/review.js +44 -0
  26. package/dist/commands/review.js.map +1 -0
  27. package/dist/commands/run.d.ts +2 -0
  28. package/dist/commands/run.d.ts.map +1 -0
  29. package/dist/commands/run.js +83 -0
  30. package/dist/commands/run.js.map +1 -0
  31. package/dist/commands/setup.d.ts +2 -0
  32. package/dist/commands/setup.d.ts.map +1 -0
  33. package/dist/commands/setup.js +15 -0
  34. package/dist/commands/setup.js.map +1 -0
  35. package/dist/commands/stats.d.ts +2 -0
  36. package/dist/commands/stats.d.ts.map +1 -0
  37. package/dist/commands/stats.js +52 -0
  38. package/dist/commands/stats.js.map +1 -0
  39. package/dist/commands/train.d.ts +2 -0
  40. package/dist/commands/train.d.ts.map +1 -0
  41. package/dist/commands/train.js +63 -0
  42. package/dist/commands/train.js.map +1 -0
  43. package/dist/core/classifier.d.ts +18 -0
  44. package/dist/core/classifier.d.ts.map +1 -0
  45. package/dist/core/classifier.js +220 -0
  46. package/dist/core/classifier.js.map +1 -0
  47. package/dist/core/config.d.ts +11 -0
  48. package/dist/core/config.d.ts.map +1 -0
  49. package/dist/core/config.js +15 -0
  50. package/dist/core/config.js.map +1 -0
  51. package/dist/core/data.d.ts +23 -0
  52. package/dist/core/data.d.ts.map +1 -0
  53. package/dist/core/data.js +66 -0
  54. package/dist/core/data.js.map +1 -0
  55. package/dist/core/embeddings.d.ts +4 -0
  56. package/dist/core/embeddings.d.ts.map +1 -0
  57. package/dist/core/embeddings.js +80 -0
  58. package/dist/core/embeddings.js.map +1 -0
  59. package/dist/core/model-io.d.ts +11 -0
  60. package/dist/core/model-io.d.ts.map +1 -0
  61. package/dist/core/model-io.js +76 -0
  62. package/dist/core/model-io.js.map +1 -0
  63. package/dist/core/tf.d.ts +4 -0
  64. package/dist/core/tf.d.ts.map +1 -0
  65. package/dist/core/tf.js +21 -0
  66. package/dist/core/tf.js.map +1 -0
  67. package/dist/index.d.ts +3 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +161 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/ui/server.d.ts +3 -0
  72. package/dist/ui/server.d.ts.map +1 -0
  73. package/dist/ui/server.js +107 -0
  74. package/dist/ui/server.js.map +1 -0
  75. package/dist/ui/static/index.html +486 -0
  76. package/dist/ui/static/static/index.html +486 -0
  77. package/dist/utils/display.d.ts +9 -0
  78. package/dist/utils/display.d.ts.map +1 -0
  79. package/dist/utils/display.js +34 -0
  80. package/dist/utils/display.js.map +1 -0
  81. package/dist/utils/fs.d.ts +3 -0
  82. package/dist/utils/fs.d.ts.map +1 -0
  83. package/dist/utils/fs.js +31 -0
  84. package/dist/utils/fs.js.map +1 -0
  85. package/dist/utils/paths.d.ts +13 -0
  86. package/dist/utils/paths.d.ts.map +1 -0
  87. package/dist/utils/paths.js +55 -0
  88. package/dist/utils/paths.js.map +1 -0
  89. package/dist/utils/similarity.d.ts +6 -0
  90. package/dist/utils/similarity.d.ts.map +1 -0
  91. package/dist/utils/similarity.js +23 -0
  92. package/dist/utils/similarity.js.map +1 -0
  93. package/package.json +45 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Expressible AI, Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,261 @@
1
+ # Expressible CLI
2
+
3
+ Open-source developer tools by [Expressible AI, Inc.](https://expressible.ai)
4
+
5
+ The Expressible CLI provides local-first tooling for AI workflows where data sovereignty matters. It is part of the [Expressible platform](https://gen.expressible.ai) for secure, end-to-end software delivery.
6
+
7
+ ---
8
+
9
+ ## Distill
10
+
11
+ Train small, task-specific ML models from input/output examples. Runs entirely on your machine. Your data never leaves your environment.
12
+
13
+ ```
14
+ $ expressible distill run "The Vendor shall indemnify and hold harmless the Client
15
+ from all claims, damages, and expenses arising from breach of this Agreement"
16
+
17
+ {
18
+ "output": "indemnification",
19
+ "confidence": 0.96
20
+ }
21
+
22
+ Classified locally. No API call. Model is ~230KB on disk.
23
+ ```
24
+
25
+ No cloud. No API keys. No external calls. No ML expertise required.
26
+
27
+ ---
28
+
29
+ ### Get to this in 5 minutes
30
+
31
+ ```bash
32
+ npm install -g expressible
33
+ ```
34
+
35
+ **1. Create a project**
36
+
37
+ ```bash
38
+ expressible distill init clause-detector
39
+ cd clause-detector
40
+ ```
41
+
42
+ **2. Add labeled examples**
43
+
44
+ Provide contract clauses labeled by type — from your own review history, from past LLM outputs, or hand-labeled by your legal team:
45
+
46
+ ```bash
47
+ # Import from a JSON file
48
+ expressible distill add --file ./labeled-clauses.json
49
+
50
+ # Bulk import from a directory of labeled pairs
51
+ expressible distill add --dir ./labeled-clauses/
52
+
53
+ # Or add one at a time
54
+ expressible distill add
55
+ # Paste: "For 24 months after closing, Seller shall not own or operate
56
+ # any business competitive with the Business in the Territory."
57
+ # Label: non-compete
58
+ ```
59
+
60
+ The JSON file should contain an array of `{ "input": "...", "output": "..." }` objects.
61
+
62
+ You need at least 10 labeled examples. 50+ gives strong results.
63
+
64
+ **3. Train**
65
+
66
+ ```bash
67
+ expressible distill train
68
+ ```
69
+
70
+ ```
71
+ Training classify model "clause-detector"
72
+ ℹ 87 training samples loaded
73
+ ℹ Categories: non-compete, indemnification, limitation-of-liability,
74
+ change-of-control, termination-for-convenience
75
+ ℹ Training classifier with 78 samples, validating on 9...
76
+ ℹ Early stopping at epoch 34
77
+
78
+ Training Complete
79
+ Samples 87
80
+ Validation accuracy 93.2%
81
+ Time elapsed 2.8s
82
+
83
+ ✓ Model saved to model/
84
+ ```
85
+
86
+ **4. Run**
87
+
88
+ ```bash
89
+ expressible distill run "Either party may terminate this Agreement at any time
90
+ for any reason by providing 90 days written notice"
91
+ ```
92
+
93
+ ```json
94
+ {
95
+ "output": "termination-for-convenience",
96
+ "confidence": 0.94
97
+ }
98
+ ```
99
+
100
+ That ran locally. No network call. The contract text never left your machine.
101
+
102
+ **5. Review and improve**
103
+
104
+ ```bash
105
+ expressible distill review
106
+ ```
107
+
108
+ Opens a local web UI where you review predictions, correct mistakes, and approve results. Then:
109
+
110
+ ```bash
111
+ expressible distill retrain
112
+ # → Previous accuracy: 89% → New accuracy: 94% (improved by 5%)
113
+ ```
114
+
115
+ **6. Export for production**
116
+
117
+ ```bash
118
+ expressible distill export ./deploy/
119
+ # Generates standalone inference.js + model files
120
+ # No expressible CLI needed — just Node.js and the model
121
+ ```
122
+
123
+ ---
124
+
125
+ ### What Stays on Your Machine
126
+
127
+ Everything.
128
+
129
+ - Training data never leaves your filesystem
130
+ - The embedding model runs locally — no API calls, ever
131
+ - Trained models are files you own and control
132
+ - The review UI runs on localhost
133
+ - Zero telemetry. Zero analytics. Zero phone-home.
134
+
135
+ ---
136
+
137
+ ### Use Cases
138
+
139
+ **Legal document review** — Classify contract clauses by type across thousands of agreements. Privileged documents stay within your perimeter.
140
+
141
+ **Log analysis and alerting** — Classify application logs as normal, warning, error, security event, or performance degradation. Thousands per hour, entirely local.
142
+
143
+ **Content moderation** — Classify user-generated content against your community guidelines. Consistent categories, high volume.
144
+
145
+ **Support ticket routing** — Route incoming tickets to the right team by category. Same classification task, repeated thousands of times.
146
+
147
+ ---
148
+
149
+ ### Benchmarks
150
+
151
+ With 50 labeled examples (~30 minutes of work), no API keys, and no ML expertise:
152
+
153
+ | Scenario | Accuracy | Data Source |
154
+ |---|---|---|
155
+ | Support ticket routing (4 categories) | 95.0% | Synthetic |
156
+ | Content moderation (3 categories) | 90.0% | Synthetic |
157
+ | News categorization (5 categories) | 88.0% | Synthetic |
158
+ | 20 Newsgroups (5 categories) | 80.0% | [Public dataset](https://huggingface.co/datasets/SetFit/20_newsgroups) |
159
+ | AG News (4 categories) | 64.0% | [Public dataset](https://huggingface.co/datasets/fancyzhx/ag_news) |
160
+
161
+ AG News improves to 80% with 100 training samples. More data helps — see [benchmarks](docs/benchmarks.md) for scaling details.
162
+
163
+ Public dataset results use real-world text from established ML benchmarks — 50 samples drawn from datasets containing 120,000+ entries. All samples and the test harness are included in the repo so you can reproduce these results:
164
+
165
+ ```bash
166
+ npx tsx tests/harness/run.ts
167
+ ```
168
+
169
+ Accuracy improves as you add more examples through the review-retrain loop. Full results, methodology, and known limitations: **[docs/benchmarks.md](docs/benchmarks.md)**
170
+
171
+ ---
172
+
173
+ ### Built for Environments Where Data Stays Internal
174
+
175
+ - Healthcare teams handling patient records
176
+ - Financial services processing sensitive transactions
177
+ - Government contractors with data residency requirements
178
+ - Legal teams working with privileged documents
179
+ - Any organization with data sovereignty obligations
180
+
181
+ ---
182
+
183
+ ### Task Type
184
+
185
+ Distill trains **classification** models: text in, one of N categories out.
186
+
187
+ | Type | Input → Output | Example |
188
+ |------|---------------|---------|
189
+ | **classify** | Text → one of N categories | Contract clause → `indemnification` |
190
+
191
+ ### Commands
192
+
193
+ ```
194
+ expressible distill init <name> Create a new project
195
+ expressible distill add Add training examples (interactive, file, or bulk)
196
+ expressible distill train Train a model from your samples
197
+ expressible distill run <input> Run inference on text or files
198
+ expressible distill review Open web UI to review and correct predictions
199
+ expressible distill retrain Retrain using review feedback
200
+ expressible distill stats Show project statistics
201
+ expressible distill export <dir> Export model for standalone use
202
+ expressible distill doctor Check system requirements and project health
203
+ expressible distill setup Pre-download embedding model for offline use
204
+ ```
205
+
206
+ ### What You Need
207
+
208
+ - Node.js 18+
209
+ - ~200MB disk space (embedding model + trained model)
210
+ - No Python, no GPU, no Docker
211
+
212
+ ---
213
+
214
+ ### FAQ
215
+
216
+ **Is this a replacement for LLMs?**
217
+ No. This replaces the *repetitive, pattern-based* subset of LLM calls — the ones where the same prompt structure processes different data every time. For tasks that require reasoning, creativity, or open-ended generation, you still want an LLM.
218
+
219
+ **How many examples do I need?**
220
+ 10 minimum. In practice, 50–100 examples with good coverage of your categories will give you strong results.
221
+
222
+ **How accurate is it?**
223
+ For well-defined classification tasks with clear categories and 50+ examples, 85–95% accuracy is typical. The review → retrain loop lets you improve iteratively.
224
+
225
+ **Does it work with non-English text?**
226
+ The underlying embedding model supports 100+ languages but is strongest in English. Performance varies by language. Test with your data.
227
+
228
+ **Can I use this in CI/CD?**
229
+ Yes. `expressible distill run` accepts file paths, globs, and piped stdin. Outputs JSON to stdout.
230
+
231
+ **Where does the language understanding come from?**
232
+ Distill uses a pre-trained sentence embedding model ([all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)) that runs locally. It converts text into numerical vectors that capture meaning. A small neural network trained on your examples learns to map those vectors to your labels. The embedding model downloads once (~80MB) and is cached. Everything after that is offline.
233
+
234
+ ---
235
+
236
+ ### Project Structure
237
+
238
+ ```
239
+ my-task/
240
+ distill.config.json # Task configuration
241
+ samples/ # Training data (input/output pairs)
242
+ model/ # Trained model files
243
+ validation/ # Review results
244
+ .distill/ # Embedding cache
245
+ ```
246
+
247
+ ---
248
+
249
+ ### Expressible Platform
250
+
251
+ The CLI is the open-source, local-first layer of the Expressible platform. For teams that need governance, traceability, and managed deployment across AI-generated workloads, see [expressible.ai](https://expressible.ai).
252
+
253
+ ### Contributing
254
+
255
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
256
+
257
+ ### License
258
+
259
+ Apache 2.0 — See [LICENSE](LICENSE)
260
+
261
+ Copyright 2026 Expressible AI, Inc.
@@ -0,0 +1,9 @@
1
+ interface AddOptions {
2
+ input?: string;
3
+ output?: string;
4
+ dir?: string;
5
+ file?: string;
6
+ }
7
+ export declare function addCommand(options: AddOptions): Promise<void>;
8
+ export {};
9
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAQA,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBnE"}
@@ -0,0 +1,175 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import readline from 'node:readline';
4
+ import inquirer from 'inquirer';
5
+ import { findTaskDir } from '../utils/paths.js';
6
+ import { getNextSampleId, saveSample, loadSamples } from '../core/data.js';
7
+ import { success, error, info } from '../utils/display.js';
8
+ export async function addCommand(options) {
9
+ const taskDir = findTaskDir();
10
+ if (options.file) {
11
+ await importFromFile(taskDir, options.file);
12
+ return;
13
+ }
14
+ if (options.dir) {
15
+ await bulkImport(taskDir, options.dir);
16
+ return;
17
+ }
18
+ if (options.input && options.output) {
19
+ await addFromFiles(taskDir, options.input, options.output);
20
+ return;
21
+ }
22
+ await addInteractive(taskDir);
23
+ }
24
+ function readMultilineInput(prompt) {
25
+ return new Promise((resolve) => {
26
+ process.stdout.write(prompt);
27
+ const rl = readline.createInterface({
28
+ input: process.stdin,
29
+ output: process.stdout,
30
+ terminal: false,
31
+ });
32
+ const lines = [];
33
+ rl.on('line', (line) => {
34
+ if (line === '' && lines.length > 0) {
35
+ rl.close();
36
+ resolve(lines.join('\n'));
37
+ }
38
+ else if (line === '' && lines.length === 0) {
39
+ rl.close();
40
+ resolve('');
41
+ }
42
+ else {
43
+ lines.push(line);
44
+ }
45
+ });
46
+ rl.on('close', () => {
47
+ resolve(lines.join('\n'));
48
+ });
49
+ });
50
+ }
51
+ async function addInteractive(taskDir) {
52
+ while (true) {
53
+ const samples = loadSamples(taskDir);
54
+ info(`Current samples: ${samples.length}`);
55
+ const input = (await readMultilineInput('? Paste input text (blank line to end, empty to quit):\n')).trim();
56
+ if (!input) {
57
+ break;
58
+ }
59
+ const { output: rawOutput } = await inquirer.prompt([
60
+ { type: 'input', name: 'output', message: 'Label:' },
61
+ ]);
62
+ const output = rawOutput.trim();
63
+ if (!output) {
64
+ error('Output is required. Skipping this sample.');
65
+ continue;
66
+ }
67
+ const id = getNextSampleId(taskDir);
68
+ saveSample(taskDir, id, input, output, false);
69
+ success(`Saved sample ${id}`);
70
+ }
71
+ }
72
+ async function addFromFiles(taskDir, inputPath, outputPath) {
73
+ const resolvedInput = path.resolve(inputPath);
74
+ const resolvedOutput = path.resolve(outputPath);
75
+ if (!fs.existsSync(resolvedInput)) {
76
+ error(`Input file not found: ${resolvedInput}`);
77
+ process.exit(1);
78
+ }
79
+ if (!fs.existsSync(resolvedOutput)) {
80
+ error(`Output file not found: ${resolvedOutput}`);
81
+ process.exit(1);
82
+ }
83
+ const input = fs.readFileSync(resolvedInput, 'utf-8').trim();
84
+ const output = fs.readFileSync(resolvedOutput, 'utf-8').trim();
85
+ const id = getNextSampleId(taskDir);
86
+ const isJson = resolvedOutput.endsWith('.json');
87
+ saveSample(taskDir, id, input, output, isJson);
88
+ success(`Saved sample ${id} from files`);
89
+ }
90
+ async function importFromFile(taskDir, filePath) {
91
+ const resolvedPath = path.resolve(filePath);
92
+ if (!fs.existsSync(resolvedPath)) {
93
+ error(`File not found: ${resolvedPath}`);
94
+ process.exit(1);
95
+ }
96
+ if (!resolvedPath.endsWith('.json')) {
97
+ error('Only JSON files are supported. Expected a .json file.');
98
+ process.exit(1);
99
+ }
100
+ let raw;
101
+ try {
102
+ raw = fs.readFileSync(resolvedPath, 'utf-8');
103
+ }
104
+ catch (err) {
105
+ error(`Could not read file: ${resolvedPath}`);
106
+ process.exit(1);
107
+ }
108
+ let data;
109
+ try {
110
+ data = JSON.parse(raw);
111
+ }
112
+ catch {
113
+ error('Invalid JSON. Expected an array of { "input": "...", "output": "..." } objects.');
114
+ process.exit(1);
115
+ }
116
+ if (!Array.isArray(data)) {
117
+ error('Expected a JSON array of { "input": "...", "output": "..." } objects.');
118
+ process.exit(1);
119
+ }
120
+ let imported = 0;
121
+ let skipped = 0;
122
+ for (let i = 0; i < data.length; i++) {
123
+ const item = data[i];
124
+ if (!item || typeof item.input !== 'string' || typeof item.output !== 'string') {
125
+ info(`Skipping row ${i + 1} — missing or invalid "input"/"output" fields.`);
126
+ skipped++;
127
+ continue;
128
+ }
129
+ const input = item.input.trim();
130
+ const output = item.output.trim();
131
+ if (!input || !output) {
132
+ info(`Skipping row ${i + 1} — empty input or output.`);
133
+ skipped++;
134
+ continue;
135
+ }
136
+ const id = getNextSampleId(taskDir);
137
+ saveSample(taskDir, id, input, output, false);
138
+ imported++;
139
+ }
140
+ if (skipped > 0) {
141
+ info(`${skipped} row(s) skipped due to missing or empty fields.`);
142
+ }
143
+ success(`Imported ${imported} sample(s) from ${path.basename(resolvedPath)}`);
144
+ }
145
+ async function bulkImport(taskDir, dirPath) {
146
+ const resolvedDir = path.resolve(dirPath);
147
+ if (!fs.existsSync(resolvedDir)) {
148
+ error(`Directory not found: ${resolvedDir}`);
149
+ process.exit(1);
150
+ }
151
+ const files = fs.readdirSync(resolvedDir);
152
+ const inputFiles = files.filter((f) => f.includes('.input.')).sort();
153
+ if (inputFiles.length === 0) {
154
+ error('No files matching *.input.* found in the directory.');
155
+ info('Expected file naming: 001.input.txt / 001.output.txt');
156
+ process.exit(1);
157
+ }
158
+ let imported = 0;
159
+ for (const inputFile of inputFiles) {
160
+ const baseName = inputFile.split('.input.')[0];
161
+ const outputFile = files.find((f) => f.startsWith(baseName + '.output.'));
162
+ if (!outputFile) {
163
+ info(`Skipping ${inputFile} — no matching output file found.`);
164
+ continue;
165
+ }
166
+ const input = fs.readFileSync(path.join(resolvedDir, inputFile), 'utf-8').trim();
167
+ const output = fs.readFileSync(path.join(resolvedDir, outputFile), 'utf-8').trim();
168
+ const id = getNextSampleId(taskDir);
169
+ const isJson = outputFile.endsWith('.json');
170
+ saveSample(taskDir, id, input, output, isJson);
171
+ imported++;
172
+ }
173
+ success(`Imported ${imported} sample pair(s)`);
174
+ }
175
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,WAAW,EAA4B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAS3D,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAmB;IAClD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAE9B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QACvC,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,E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AS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,IAAI,CAAC,YAAY,SAAS,mCAAmC,CAAC,CAAC;YAC/D,SAAS;QACX,CAAC;QAED,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QACjF,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;QAEnF,MAAM,EAAE,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5C,UAAU,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,QAAQ,EAAE,CAAC;IACb,CAAC;IAED,OAAO,CAAC,YAAY,QAAQ,iBAAiB,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function doctorCommand(): Promise<void>;
2
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAaA,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAkHnD"}