trucontext 0.9.1 → 0.9.2

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 CHANGED
@@ -13,7 +13,7 @@ import { ingestCommand } from '../src/commands/ingest.js';
13
13
  import { queryCommand } from '../src/commands/query.js';
14
14
  import { recallCommand } from '../src/commands/recall.js';
15
15
  import { schemaShowCommand, schemaGenerateCommand, schemaSetAuthorshipCommand } from '../src/commands/schema.js';
16
- import { entitiesListCommand, entitiesGetCommand, entitiesCreateCommand, entitiesUpdateCommand, entitiesDeleteCommand, entitiesEdgesCommand } from '../src/commands/entities.js';
16
+ import { entitiesListCommand, entitiesGetCommand, entitiesCreateCommand, entitiesUpdateCommand, entitiesDeleteCommand, entitiesEdgesCommand, edgesCreateCommand, edgesDeleteCommand } from '../src/commands/entities.js';
17
17
  import { recipesListCommand, recipesGetCommand, recipesCreateCommand, recipesUpdateCommand, recipesDeleteCommand } from '../src/commands/recipes.js';
18
18
  import { relationshipTypesListCommand, relationshipTypesCreateCommand, relationshipTypesDeleteCommand } from '../src/commands/relationship-types.js';
19
19
  import { docsListCommand, docsShowCommand } from '../src/commands/docs.js';
@@ -129,6 +129,19 @@ entities.command('delete <entityId>')
129
129
  entities.command('edges <entityId>')
130
130
  .description('List edges for an entity')
131
131
  .action(entitiesEdgesCommand);
132
+ entities.command('edges-create')
133
+ .description('Create an edge between two entities')
134
+ .requiredOption('--type <type>', 'Edge type (UPPER_SNAKE_CASE)')
135
+ .requiredOption('--from <entityId>', 'Source entity ID')
136
+ .requiredOption('--to <entityId>', 'Target entity ID')
137
+ .option('--properties <json>', 'Edge properties as JSON')
138
+ .action(edgesCreateCommand);
139
+ entities.command('edges-delete')
140
+ .description('Delete an edge between two entities')
141
+ .requiredOption('--type <type>', 'Edge type')
142
+ .requiredOption('--from <entityId>', 'Source entity ID')
143
+ .requiredOption('--to <entityId>', 'Target entity ID')
144
+ .action(edgesDeleteCommand);
132
145
 
133
146
  // Recipes
134
147
  const recipes = program.command('recipes').description('Manage recipes').action(function() { this.help(); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucontext",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "TruContext CLI — contextual memory for AI applications",
5
5
  "type": "module",
6
6
  "bin": {
@@ -197,6 +197,64 @@ export async function entitiesDeleteCommand(entityId) {
197
197
  }
198
198
  }
199
199
 
200
+ export async function edgesCreateCommand(options) {
201
+ try {
202
+ const body = {
203
+ type: options.type,
204
+ from: {},
205
+ to: {},
206
+ };
207
+
208
+ // From reference
209
+ if (options.from) body.from.entityId = options.from;
210
+ if (options.fromType && options.fromKey) {
211
+ body.from = { nodeType: options.fromType, key: JSON.parse(options.fromKey) };
212
+ }
213
+
214
+ // To reference
215
+ if (options.to) body.to.entityId = options.to;
216
+ if (options.toType && options.toKey) {
217
+ body.to = { nodeType: options.toType, key: JSON.parse(options.toKey) };
218
+ }
219
+
220
+ // Properties
221
+ if (options.properties) {
222
+ try {
223
+ body.properties = JSON.parse(options.properties);
224
+ } catch {
225
+ console.error(chalk.red('Invalid properties JSON'));
226
+ process.exit(1);
227
+ }
228
+ }
229
+
230
+ const res = await dataPlane('POST', '/v1/entities/edges', body);
231
+ const edge = res.data;
232
+ console.log(chalk.green(`Edge created: ${edge.source || options.from} -[${chalk.cyan(options.type)}]-> ${edge.target || options.to}`));
233
+ } catch (err) {
234
+ console.error(chalk.red(`Failed: ${err.message}`));
235
+ process.exit(1);
236
+ }
237
+ }
238
+
239
+ export async function edgesDeleteCommand(options) {
240
+ try {
241
+ const body = {
242
+ type: options.type,
243
+ from: {},
244
+ to: {},
245
+ };
246
+
247
+ if (options.from) body.from.entityId = options.from;
248
+ if (options.to) body.to.entityId = options.to;
249
+
250
+ await dataPlane('DELETE', '/v1/entities/edges', body);
251
+ console.log(chalk.green(`Edge deleted: ${options.from} -[${options.type}]-> ${options.to}`));
252
+ } catch (err) {
253
+ console.error(chalk.red(`Failed: ${err.message}`));
254
+ process.exit(1);
255
+ }
256
+ }
257
+
200
258
  export async function entitiesEdgesCommand(entityId) {
201
259
  try {
202
260
  const appId = getActiveApp();