trucontext 0.8.3 → 0.8.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trucontext",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "TruContext CLI — contextual memory for AI applications",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,7 +5,7 @@ import { getActiveApp, setActiveApp } from '../config.js';
5
5
  export async function appsCommand() {
6
6
  try {
7
7
  const res = await controlPlane('GET', '/apps');
8
- const apps = res.data?.apps || [];
8
+ const apps = Array.isArray(res.data) ? res.data : [];
9
9
  const activeApp = getActiveApp();
10
10
 
11
11
  if (apps.length === 0) {
@@ -27,7 +27,7 @@ export async function appsCommand() {
27
27
  export async function useCommand(appId) {
28
28
  try {
29
29
  const res = await controlPlane('GET', '/apps');
30
- const apps = res.data?.apps || [];
30
+ const apps = Array.isArray(res.data) ? res.data : [];
31
31
  const app = apps.find(a => a.appId === appId || a.name.toLowerCase() === appId.toLowerCase());
32
32
 
33
33
  if (!app) {
@@ -45,7 +45,7 @@ export async function usageCommand(options) {
45
45
  const params = [`period=${period}`];
46
46
  if (source) params.push(`source=${source}`);
47
47
  const res = await controlPlane('GET', `/billing/usage/${appId}?${params.join('&')}`);
48
- const usage = res.data || {};
48
+ const usage = res.data;
49
49
 
50
50
  if (!usage || (!usage.apiCalls && !usage.llmInputTokens && !usage.processingMs)) {
51
51
  console.log(chalk.yellow('No usage data available.'));
@@ -92,7 +92,7 @@ export async function usageHistoryCommand(options) {
92
92
  const params = [`period=${period}`];
93
93
  if (source) params.push(`source=${source}`);
94
94
  const res = await controlPlane('GET', `/billing/usage/${appId}/history?${params.join('&')}`);
95
- const historyData = res.data || {};
95
+ const historyData = res.data;
96
96
  const history = historyData.history || [];
97
97
 
98
98
  if (history.length === 0) {
@@ -135,8 +135,7 @@ export async function usageHistoryCommand(options) {
135
135
  export async function plansCommand() {
136
136
  try {
137
137
  const res = await controlPlane('GET', '/billing/plans');
138
- const plansData = res.data || {};
139
- const plans = plansData.plans || [];
138
+ const plans = Array.isArray(res.data) ? res.data : [];
140
139
 
141
140
  if (plans.length === 0) {
142
141
  console.log(chalk.yellow('No plans available.'));
@@ -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 = Array.isArray(res.data) ? res.data : (res.data?.contexts || []);
7
+ const contexts = res.data;
8
8
 
9
9
  if (contexts.length === 0) {
10
10
  console.log(chalk.yellow('No contexts. Create one with: trucontext contexts create <name>'));
@@ -27,7 +27,7 @@ export async function docsListCommand() {
27
27
  export async function docsShowCommand(slug) {
28
28
  try {
29
29
  const res = await publicApi('GET', `/public/docs/${slug}`);
30
- const doc = res.data || res;
30
+ const doc = res.data;
31
31
 
32
32
  if (!doc || !doc.title) {
33
33
  console.error(chalk.red(`No doc found for slug: ${slug}`));
@@ -70,13 +70,13 @@ export async function entitiesGetCommand(entityId) {
70
70
  try {
71
71
  const appId = getActiveApp();
72
72
  const res = await controlPlane('GET', `/apps/${appId}/entities/${entityId}`);
73
- const e = res.data || res;
73
+ const e = res.data;
74
74
  displayEntity(e);
75
75
 
76
76
  // Show edges if available
77
77
  try {
78
78
  const edgeRes = await controlPlane('GET', `/apps/${appId}/entities/${entityId}/edges`);
79
- const edges = edgeRes.data?.edges || edgeRes.data || [];
79
+ const edges = edgeRes.data;
80
80
  if (edges.length > 0) {
81
81
  console.log(chalk.dim(`\n Edges (${edges.length}):`));
82
82
  for (const edge of edges) {
@@ -138,7 +138,7 @@ export async function entitiesCreateCommand(options) {
138
138
  }
139
139
 
140
140
  const res = await controlPlane('POST', `/apps/${appId}/entities`, body);
141
- const e = res.data || res;
141
+ const e = res.data;
142
142
  console.log(chalk.green(`Created: ${chalk.bold(e.entityId || options.id)}`));
143
143
  } catch (err) {
144
144
  console.error(chalk.red(`Failed: ${err.message}`));
@@ -53,7 +53,7 @@ export async function ingestCommand(source, options) {
53
53
  });
54
54
 
55
55
  const res = await controlPlane('POST', `/apps/${appId}/ingest`, body);
56
- const data = res.data || res;
56
+ const data = res.data;
57
57
  console.log(chalk.green('Accepted'));
58
58
  console.log(chalk.dim(`Content ID: ${data.contentId}`));
59
59
  if (data.status === 'upload_required') {
@@ -45,7 +45,7 @@ export async function initCommand(name, options) {
45
45
  description,
46
46
  authorship_model: authorship,
47
47
  });
48
- const schema = schemaRes.data?.schema;
48
+ const schema = schemaRes.data;
49
49
 
50
50
  if (schema) {
51
51
  // Step 6: Save schema to app
@@ -96,7 +96,7 @@ export async function loginCommand(options) {
96
96
  // Fetch apps and select or create one
97
97
  try {
98
98
  const res = await controlPlane('GET', '/apps');
99
- const apps = res.data?.apps || [];
99
+ const apps = Array.isArray(res.data) ? res.data : [];
100
100
 
101
101
  if (apps.length === 1) {
102
102
  setActiveApp(apps[0].appId);
@@ -28,7 +28,7 @@ export async function queryCommand(question, options) {
28
28
  if (options.context) body.context_id = options.context;
29
29
 
30
30
  const res = await controlPlane('POST', `/apps/${appId}/mind/query`, body);
31
- const data = res.data || res;
31
+ const data = res.data;
32
32
 
33
33
  // Print answer
34
34
  if (data.answer?.summary) {
@@ -23,7 +23,7 @@ export async function recallCommand(query, options) {
23
23
  if (options.context) body.context_id = options.context;
24
24
 
25
25
  const res = await controlPlane('POST', `/apps/${appId}/recall`, body);
26
- const data = res.data || res;
26
+ const data = res.data;
27
27
 
28
28
  // Print synthesis
29
29
  if (data.synthesis?.summary) {
@@ -16,7 +16,7 @@ export async function recipesListCommand() {
16
16
  try {
17
17
  const appId = requireApp();
18
18
  const res = await controlPlane('GET', `/apps/${appId}/recipes`);
19
- const recipes = Array.isArray(res.data) ? res.data : (res.data?.recipes || res.recipes || []);
19
+ const recipes = res.data;
20
20
 
21
21
  if (recipes.length === 0) {
22
22
  console.log(chalk.yellow('No recipes found.'));
@@ -37,7 +37,7 @@ export async function recipesGetCommand(recipeId) {
37
37
  try {
38
38
  const appId = requireApp();
39
39
  const res = await controlPlane('GET', `/apps/${appId}/recipes/${recipeId}`);
40
- const r = res.data || res;
40
+ const r = res.data;
41
41
 
42
42
  console.log(chalk.bold(r.recipeId || recipeId));
43
43
  if (r.name) console.log(` name: ${r.name}`);
@@ -139,7 +139,7 @@ export async function recipesCreateCommand(options) {
139
139
  }
140
140
 
141
141
  const res = await controlPlane('POST', `/apps/${appId}/recipes`, body);
142
- const r = res.data || res;
142
+ const r = res.data;
143
143
  console.log(chalk.green(`Created: ${chalk.bold(r.recipeId || options.id)}`));
144
144
  } catch (err) {
145
145
  console.error(chalk.red(`Failed: ${err.message}`));
@@ -16,7 +16,7 @@ export async function relationshipTypesListCommand(options) {
16
16
  const path = `/apps/${appId}/relationship-types${qs ? `?${qs}` : ''}`;
17
17
 
18
18
  const res = await controlPlane('GET', path);
19
- const types = res.data?.types || res.data?.relationshipTypes || res.data || [];
19
+ const types = res.data;
20
20
 
21
21
  if (Array.isArray(types) && types.length === 0) {
22
22
  console.log(chalk.yellow('No relationship types found.'));
@@ -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?.schema || res.data;
18
+ const schema = res.data;
19
19
 
20
20
  if (!schema) {
21
21
  console.log(chalk.yellow('No schema configured. Generate one with: trucontext schema generate'));