trucontext 0.5.0 → 0.5.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/bin/cli.js +5 -4
- package/package.json +1 -1
- package/src/commands/recipes.js +24 -7
package/bin/cli.js
CHANGED
|
@@ -139,10 +139,11 @@ recipes.command('get <recipeId>')
|
|
|
139
139
|
.description('Get recipe details')
|
|
140
140
|
.action(recipesGetCommand);
|
|
141
141
|
recipes.command('create')
|
|
142
|
-
.description('Create a recipe')
|
|
143
|
-
.requiredOption('--id <recipeId>', 'Recipe ID')
|
|
144
|
-
.requiredOption('--name <name>', 'Recipe name')
|
|
145
|
-
.
|
|
142
|
+
.description('Create a custom recipe. --id and --name are always required. Provide the interpretation via --file (JSON) or inline flags.')
|
|
143
|
+
.requiredOption('--id <recipeId>', 'Recipe ID (e.g., my-health-score)')
|
|
144
|
+
.requiredOption('--name <name>', 'Recipe display name')
|
|
145
|
+
.option('--file <path>', 'JSON file containing the interpretation block (the WHY)')
|
|
146
|
+
.option('--purpose <text>', 'Recipe purpose (inline alternative to --file)')
|
|
146
147
|
.option('--decay-profile <text>', 'Decay profile description')
|
|
147
148
|
.option('--confidence-bias <text>', 'Confidence bias description')
|
|
148
149
|
.action(recipesCreateCommand);
|
package/package.json
CHANGED
package/src/commands/recipes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
1
2
|
import chalk from 'chalk';
|
|
2
3
|
import { controlPlane } from '../client.js';
|
|
3
4
|
import { getActiveApp } from '../config.js';
|
|
@@ -107,19 +108,35 @@ export async function recipesCreateCommand(options) {
|
|
|
107
108
|
console.error(chalk.red('--name is required'));
|
|
108
109
|
process.exit(1);
|
|
109
110
|
}
|
|
110
|
-
if (!options.purpose) {
|
|
111
|
-
console.error(chalk.red('--purpose is required'));
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
111
|
|
|
115
112
|
const body = {
|
|
116
113
|
recipeId: options.id,
|
|
117
114
|
name: options.name,
|
|
118
|
-
purpose: options.purpose,
|
|
119
115
|
};
|
|
120
116
|
|
|
121
|
-
|
|
122
|
-
if (options.
|
|
117
|
+
// --file provides the full interpretation block as JSON
|
|
118
|
+
if (options.file) {
|
|
119
|
+
try {
|
|
120
|
+
const raw = readFileSync(options.file, 'utf8');
|
|
121
|
+
body.interpretation = JSON.parse(raw);
|
|
122
|
+
if (!body.interpretation.purpose) {
|
|
123
|
+
console.error(chalk.red('File must contain a "purpose" field'));
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.error(chalk.red(`Failed to read --file: ${e.message}`));
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
// Inline flags → build interpretation object
|
|
132
|
+
if (!options.purpose) {
|
|
133
|
+
console.error(chalk.red('--purpose is required (or use --file to provide the full interpretation)'));
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
body.interpretation = { purpose: options.purpose };
|
|
137
|
+
if (options.decayProfile) body.interpretation.decay_profile = options.decayProfile;
|
|
138
|
+
if (options.confidenceBias) body.interpretation.confidence_bias = options.confidenceBias;
|
|
139
|
+
}
|
|
123
140
|
|
|
124
141
|
const res = await controlPlane('POST', `/apps/${appId}/recipes`, body);
|
|
125
142
|
const r = res.data || res;
|