@hasna/brains 0.0.20 → 0.0.21

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/dist/cli/index.js CHANGED
@@ -24077,6 +24077,17 @@ function getPackageVersion() {
24077
24077
  return cachedVersion;
24078
24078
  }
24079
24079
 
24080
+ // src/cli/remove.ts
24081
+ function parseRemoveType(rawType) {
24082
+ if (!rawType)
24083
+ return;
24084
+ const normalized = rawType.trim().toLowerCase();
24085
+ if (normalized === "model" || normalized === "job") {
24086
+ return normalized;
24087
+ }
24088
+ throw new Error(`Invalid --type value: ${rawType}. Use model or job.`);
24089
+ }
24090
+
24080
24091
  // src/cli/index.ts
24081
24092
  var program2 = new Command;
24082
24093
  program2.name("brains").description("Fine-tuned model tracker and trainer").version(getPackageVersion());
@@ -24084,34 +24095,63 @@ registerModelsCommands(program2);
24084
24095
  registerFinetuneCommands(program2);
24085
24096
  registerDataCommands(program2);
24086
24097
  registerCollectionsCommands(program2);
24087
- program2.command("remove <id>").alias("rm").alias("uninstall").description("Remove a fine-tuned model or training job by ID").option("--type <type>", "Type: model | job (default: auto-detect)").action(async (id, opts) => {
24098
+ program2.command("remove <id>").alias("rm").alias("uninstall").description("Remove a fine-tuned model or training job by ID").option("--type <type>", "Type: model | job (default: auto-detect)").option("--json", "Output as JSON").action(async (id, opts) => {
24088
24099
  const db = getDb();
24089
24100
  try {
24090
- const type = opts.type?.toLowerCase();
24091
- if (type === "job" || !type && !type) {
24101
+ const type = parseRemoveType(opts.type);
24102
+ if (!type || type === "job") {
24092
24103
  const job = db.select().from(trainingJobs).where(eq(trainingJobs.id, id)).get();
24093
- if (job || type === "job") {
24094
- if (!job) {
24095
- printError(`Job not found: ${id}`);
24096
- process.exit(1);
24097
- }
24104
+ if (job) {
24098
24105
  db.delete(trainingJobs).where(eq(trainingJobs.id, id)).run();
24106
+ if (opts.json) {
24107
+ printJson({ deleted: "job", id });
24108
+ return;
24109
+ }
24099
24110
  printSuccess(`Training job ${id} removed`);
24100
24111
  return;
24101
24112
  }
24113
+ if (type === "job") {
24114
+ if (opts.json) {
24115
+ printJson({ error: `Job not found: ${id}` });
24116
+ } else {
24117
+ printError(`Job not found: ${id}`);
24118
+ }
24119
+ process.exit(1);
24120
+ }
24102
24121
  }
24103
- if (type === "model" || !type) {
24122
+ if (!type || type === "model") {
24104
24123
  const model = db.select().from(fineTunedModels).where(eq(fineTunedModels.id, id)).get();
24105
24124
  if (model) {
24106
24125
  db.delete(fineTunedModels).where(eq(fineTunedModels.id, id)).run();
24126
+ if (opts.json) {
24127
+ printJson({ deleted: "model", id });
24128
+ return;
24129
+ }
24107
24130
  printSuccess(`Model ${id} removed`);
24108
24131
  return;
24109
24132
  }
24133
+ if (type === "model") {
24134
+ if (opts.json) {
24135
+ printJson({ error: `Model not found: ${id}` });
24136
+ } else {
24137
+ printError(`Model not found: ${id}`);
24138
+ }
24139
+ process.exit(1);
24140
+ }
24141
+ }
24142
+ const message = `Not found: ${id}. Use --type model|job to target a specific entity.`;
24143
+ if (opts.json) {
24144
+ printJson({ error: message });
24145
+ } else {
24146
+ printError(message);
24110
24147
  }
24111
- printError(`Not found: ${id}. Use --type model|job`);
24112
24148
  process.exit(1);
24113
24149
  } catch (err) {
24114
- printError(err instanceof Error ? err.message : String(err));
24150
+ if (opts.json) {
24151
+ printJson({ error: err instanceof Error ? err.message : String(err) });
24152
+ } else {
24153
+ printError(err instanceof Error ? err.message : String(err));
24154
+ }
24115
24155
  process.exit(1);
24116
24156
  }
24117
24157
  });
@@ -0,0 +1,3 @@
1
+ export type RemoveEntityType = "model" | "job";
2
+ export declare function parseRemoveType(rawType?: string): RemoveEntityType | undefined;
3
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/cli/remove.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AAE/C,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAO9E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/brains",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "Fine-tuned model tracker and trainer — wraps OpenAI + Thinker Labs, gathers training data from todos/mementos/conversations/sessions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",