trucontext 0.1.3 → 0.2.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 CHANGED
@@ -10,7 +10,7 @@ import { ingestCommand } from '../src/commands/ingest.js';
10
10
  import { queryCommand } from '../src/commands/query.js';
11
11
  import { recallCommand } from '../src/commands/recall.js';
12
12
  import { contextsListCommand, contextsCreateCommand, contextsDeleteCommand } from '../src/commands/contexts.js';
13
- import { schemaShowCommand, schemaGenerateCommand } from '../src/commands/schema.js';
13
+ import { schemaShowCommand, schemaGenerateCommand, schemaSetAuthorshipCommand } from '../src/commands/schema.js';
14
14
  import { entitiesListCommand, entitiesGetCommand, entitiesCreateCommand, entitiesUpdateCommand, entitiesDeleteCommand } from '../src/commands/entities.js';
15
15
  import { recipesListCommand, recipesGetCommand, recipesCreateCommand, recipesDeleteCommand } from '../src/commands/recipes.js';
16
16
  import { relationshipTypesListCommand } from '../src/commands/relationship-types.js';
@@ -18,7 +18,7 @@ import { relationshipTypesListCommand } from '../src/commands/relationship-types
18
18
  program
19
19
  .name('trucontext')
20
20
  .description('TruContext CLI — contextual memory for AI applications')
21
- .version('0.1.2');
21
+ .version('0.2.1');
22
22
 
23
23
  // Auth
24
24
  program.command('login')
@@ -74,8 +74,8 @@ program.command('recall <query>')
74
74
  .option('-d, --depth <n>', 'Graph expansion depth', '2')
75
75
  .action(recallCommand);
76
76
 
77
- // Contexts
78
- const contexts = program.command('contexts').description('Manage contexts').action(function() { this.help(); });
77
+ // Contexts (deprecated — use entities with contexts array)
78
+ const contexts = program.command('contexts').description('Manage contexts (deprecated — use entities)').action(function() { this.help(); });
79
79
  contexts.command('list').description('List contexts').action(contextsListCommand);
80
80
  contexts.command('create <name>')
81
81
  .description('Create a context')
@@ -152,6 +152,10 @@ schema.command('generate')
152
152
  .description('AI-generate a schema')
153
153
  .requiredOption('-d, --description <text>', 'App description for schema generation')
154
154
  .option('-n, --name <name>', 'App name')
155
+ .option('-a, --authorship-model <model>', 'Authorship model (single_author, multi_author, anonymous)')
155
156
  .action(schemaGenerateCommand);
157
+ schema.command('set-authorship <model>')
158
+ .description('Set authorship model (single_author, multi_author, anonymous)')
159
+ .action(schemaSetAuthorshipCommand);
156
160
 
157
161
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucontext",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "TruContext CLI — contextual memory for AI applications",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,7 +4,7 @@ import { dataPlane } from '../client.js';
4
4
  export async function contextsListCommand() {
5
5
  try {
6
6
  const res = await dataPlane('GET', '/v1/contexts');
7
- const contexts = res.data?.contexts || [];
7
+ const contexts = Array.isArray(res.data) ? res.data : (res.data?.contexts || []);
8
8
 
9
9
  if (contexts.length === 0) {
10
10
  console.log(chalk.yellow('No contexts. Create one with: trucontext contexts create <name>'));
@@ -10,7 +10,7 @@ export async function entitiesListCommand(options) {
10
10
  const path = `/v1/entities${qs ? `?${qs}` : ''}`;
11
11
 
12
12
  const res = await dataPlane('GET', path);
13
- const entities = res.data?.entities || [];
13
+ const entities = Array.isArray(res.data) ? res.data : (res.data?.entities || []);
14
14
 
15
15
  if (entities.length === 0) {
16
16
  console.log(chalk.yellow('No entities found.'));
@@ -46,7 +46,19 @@ export async function recipesGetCommand(recipeId) {
46
46
  if (r.interpretation) {
47
47
  console.log();
48
48
  console.log(chalk.bold('Interpretation:'));
49
- console.log(` ${r.interpretation}`);
49
+ if (typeof r.interpretation === 'object') {
50
+ for (const [key, val] of Object.entries(r.interpretation)) {
51
+ const label = key.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase());
52
+ if (Array.isArray(val)) {
53
+ console.log(` ${chalk.cyan(label)}:`);
54
+ for (const item of val) console.log(` - ${item}`);
55
+ } else {
56
+ console.log(` ${chalk.cyan(label)}: ${val}`);
57
+ }
58
+ }
59
+ } else {
60
+ console.log(` ${r.interpretation}`);
61
+ }
50
62
  }
51
63
 
52
64
  // System recipes have operational details (HOW)
@@ -15,7 +15,7 @@ export async function schemaShowCommand() {
15
15
  const appId = requireActiveApp();
16
16
  try {
17
17
  const res = await controlPlane('GET', `/apps/${appId}/schema`);
18
- const schema = res.data;
18
+ const schema = res.data?.schema || res.data;
19
19
 
20
20
  if (!schema) {
21
21
  console.log(chalk.yellow('No schema configured. Generate one with: trucontext schema generate'));
@@ -24,20 +24,54 @@ export async function schemaShowCommand() {
24
24
 
25
25
  console.log(chalk.bold('Schema:'), schema.name || appId);
26
26
  console.log(chalk.bold('Version:'), schema.version || 'v1');
27
+ if (schema.authorship_model) console.log(chalk.bold('Authorship:'), schema.authorship_model);
27
28
 
28
- if (schema.custom_node_types?.length > 0) {
29
+ // Layers / services
30
+ if (schema.layers?.length > 0) {
31
+ console.log(chalk.bold('\nServices:'));
32
+ for (const l of schema.layers) {
33
+ const status = l.enabled ? chalk.green('on') : chalk.dim('off');
34
+ console.log(` ${chalk.cyan(l.id)} [${status}] — ${l.description || ''} ${chalk.dim(`(${l.phase})`)}`);
35
+ }
36
+ }
37
+
38
+ // System + schema node types
39
+ const nodeTypes = schema.node_types || [];
40
+ const customNodeTypes = schema.custom_node_types || [];
41
+ if (nodeTypes.length > 0 || customNodeTypes.length > 0) {
29
42
  console.log(chalk.bold('\nNode Types:'));
30
- for (const t of schema.custom_node_types) {
31
- console.log(` ${chalk.cyan(t.name)} ${t.description || ''}`);
43
+ for (const t of [...nodeTypes, ...customNodeTypes]) {
44
+ const source = customNodeTypes.includes(t) ? chalk.dim(' [custom]') : '';
45
+ console.log(` ${chalk.cyan(t.name || t.label)}${source}${t.description ? ` — ${t.description}` : ''}`);
32
46
  if (t.properties?.length > 0) {
33
47
  console.log(` ${chalk.dim(t.properties.join(', '))}`);
34
48
  }
35
49
  }
36
50
  }
37
51
 
38
- if (schema.custom_edge_types?.length > 0) {
52
+ // Edge types
53
+ const edgeTypes = schema.edge_types || [];
54
+ const customEdgeTypes = schema.custom_edge_types || [];
55
+ if (edgeTypes.length > 0 || customEdgeTypes.length > 0) {
39
56
  console.log(chalk.bold('\nEdge Types:'));
40
- console.log(` ${chalk.dim(schema.custom_edge_types.join(', '))}`);
57
+ console.log(` ${chalk.dim([...edgeTypes, ...customEdgeTypes].map(e => typeof e === 'string' ? e : e.name || e.type).join(', '))}`);
58
+ }
59
+
60
+ // Service subscriptions
61
+ if (schema.subscriptions?.length > 0) {
62
+ console.log(chalk.bold('\nSubscribed Services:'));
63
+ for (const sub of schema.subscriptions) {
64
+ const svc = typeof sub === 'string' ? sub : (sub.service_id || sub);
65
+ console.log(` ${chalk.dim(svc)}`);
66
+ }
67
+ }
68
+
69
+ // Custom relationship types
70
+ if (schema.custom_relationship_types?.length > 0) {
71
+ console.log(chalk.bold('\nCustom Relationship Types:'));
72
+ for (const t of schema.custom_relationship_types) {
73
+ console.log(` ${chalk.dim(t.type)} — ${t.description || ''}`);
74
+ }
41
75
  }
42
76
  } catch (err) {
43
77
  console.error(chalk.red(`Failed: ${err.message}`));
@@ -54,10 +88,12 @@ export async function schemaGenerateCommand(options) {
54
88
  }
55
89
 
56
90
  console.log(chalk.dim('Generating schema...'));
57
- const res = await controlPlane('POST', '/schema/generate', {
91
+ const body = {
58
92
  description: options.description,
59
93
  appName: options.name || appId,
60
- });
94
+ };
95
+ if (options.authorshipModel) body.authorship_model = options.authorshipModel;
96
+ const res = await controlPlane('POST', '/schema/generate', body);
61
97
 
62
98
  console.log(chalk.green('Schema generated.'));
63
99
  const schema = res.data;
@@ -72,3 +108,14 @@ export async function schemaGenerateCommand(options) {
72
108
  process.exit(1);
73
109
  }
74
110
  }
111
+
112
+ export async function schemaSetAuthorshipCommand(model) {
113
+ const appId = requireActiveApp();
114
+ try {
115
+ await controlPlane('PUT', `/apps/${appId}/schema`, { authorship_model: model });
116
+ console.log(chalk.green(`Authorship model set to: ${chalk.bold(model)}`));
117
+ } catch (err) {
118
+ console.error(chalk.red(`Failed: ${err.message}`));
119
+ process.exit(1);
120
+ }
121
+ }