@agentuity/cli 0.0.101 → 0.0.103
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/AGENTS.md +19 -188
- package/bin/cli.ts +21 -14
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +41 -12
- package/dist/cli.js.map +1 -1
- package/dist/cmd/ai/index.d.ts.map +1 -1
- package/dist/cmd/ai/index.js +6 -1
- package/dist/cmd/ai/index.js.map +1 -1
- package/dist/cmd/ai/prompt/agent.d.ts +7 -0
- package/dist/cmd/ai/prompt/agent.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/agent.js +12 -323
- package/dist/cmd/ai/prompt/agent.js.map +1 -1
- package/dist/cmd/ai/prompt/api.d.ts +7 -0
- package/dist/cmd/ai/prompt/api.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/api.js +12 -260
- package/dist/cmd/ai/prompt/api.js.map +1 -1
- package/dist/cmd/ai/prompt/version.d.ts +35 -0
- package/dist/cmd/ai/prompt/version.d.ts.map +1 -0
- package/dist/cmd/ai/prompt/version.js +55 -0
- package/dist/cmd/ai/prompt/version.js.map +1 -0
- package/dist/cmd/ai/prompt/web.d.ts +7 -0
- package/dist/cmd/ai/prompt/web.d.ts.map +1 -1
- package/dist/cmd/ai/prompt/web.js +12 -283
- package/dist/cmd/ai/prompt/web.js.map +1 -1
- package/dist/cmd/ai/skills/generate.d.ts +3 -0
- package/dist/cmd/ai/skills/generate.d.ts.map +1 -0
- package/dist/cmd/ai/skills/generate.js +65 -0
- package/dist/cmd/ai/skills/generate.js.map +1 -0
- package/dist/cmd/ai/skills/generator.d.ts +4 -0
- package/dist/cmd/ai/skills/generator.d.ts.map +1 -0
- package/dist/cmd/ai/skills/generator.js +402 -0
- package/dist/cmd/ai/skills/generator.js.map +1 -0
- package/dist/cmd/ai/skills/index.d.ts +4 -0
- package/dist/cmd/ai/skills/index.d.ts.map +1 -0
- package/dist/cmd/ai/skills/index.js +21 -0
- package/dist/cmd/ai/skills/index.js.map +1 -0
- package/dist/cmd/auth/signup.d.ts.map +1 -1
- package/dist/cmd/auth/signup.js +1 -0
- package/dist/cmd/auth/signup.js.map +1 -1
- package/dist/cmd/build/entry-generator.d.ts.map +1 -1
- package/dist/cmd/build/entry-generator.js +40 -5
- package/dist/cmd/build/entry-generator.js.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts +7 -1
- package/dist/cmd/build/vite/bun-dev-server.d.ts.map +1 -1
- package/dist/cmd/build/vite/bun-dev-server.js +30 -26
- package/dist/cmd/build/vite/bun-dev-server.js.map +1 -1
- package/dist/cmd/build/vite/metadata-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/metadata-generator.js +58 -7
- package/dist/cmd/build/vite/metadata-generator.js.map +1 -1
- package/dist/cmd/build/vite/prompt-generator.d.ts +23 -0
- package/dist/cmd/build/vite/prompt-generator.d.ts.map +1 -0
- package/dist/cmd/build/vite/prompt-generator.js +123 -0
- package/dist/cmd/build/vite/prompt-generator.js.map +1 -0
- package/dist/cmd/build/vite/registry-generator.d.ts.map +1 -1
- package/dist/cmd/build/vite/registry-generator.js +28 -11
- package/dist/cmd/build/vite/registry-generator.js.map +1 -1
- package/dist/cmd/build/vite/server-bundler.d.ts +4 -0
- package/dist/cmd/build/vite/server-bundler.d.ts.map +1 -1
- package/dist/cmd/build/vite/server-bundler.js +45 -16
- package/dist/cmd/build/vite/server-bundler.js.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-asset-server-config.js +4 -0
- package/dist/cmd/build/vite/vite-asset-server-config.js.map +1 -1
- package/dist/cmd/build/vite/vite-builder.d.ts.map +1 -1
- package/dist/cmd/build/vite/vite-builder.js +99 -87
- package/dist/cmd/build/vite/vite-builder.js.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.js +80 -27
- package/dist/cmd/cloud/deploy.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.js +3 -1
- package/dist/cmd/cloud/keyvalue/create-namespace.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.js +3 -1
- package/dist/cmd/cloud/keyvalue/delete-namespace.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/delete.js +3 -1
- package/dist/cmd/cloud/keyvalue/delete.js.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.d.ts.map +1 -1
- package/dist/cmd/cloud/keyvalue/set.js +4 -2
- package/dist/cmd/cloud/keyvalue/set.js.map +1 -1
- package/dist/cmd/cloud/stream/get.d.ts.map +1 -1
- package/dist/cmd/cloud/stream/get.js +2 -13
- package/dist/cmd/cloud/stream/get.js.map +1 -1
- package/dist/cmd/cloud/vector/delete-namespace.d.ts +3 -0
- package/dist/cmd/cloud/vector/delete-namespace.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/delete-namespace.js +77 -0
- package/dist/cmd/cloud/vector/delete-namespace.js.map +1 -0
- package/dist/cmd/cloud/vector/index.d.ts.map +1 -1
- package/dist/cmd/cloud/vector/index.js +21 -4
- package/dist/cmd/cloud/vector/index.js.map +1 -1
- package/dist/cmd/cloud/vector/list-namespaces.d.ts +3 -0
- package/dist/cmd/cloud/vector/list-namespaces.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/list-namespaces.js +42 -0
- package/dist/cmd/cloud/vector/list-namespaces.js.map +1 -0
- package/dist/cmd/cloud/vector/stats.d.ts +3 -0
- package/dist/cmd/cloud/vector/stats.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/stats.js +142 -0
- package/dist/cmd/cloud/vector/stats.js.map +1 -0
- package/dist/cmd/cloud/vector/upsert.d.ts +3 -0
- package/dist/cmd/cloud/vector/upsert.d.ts.map +1 -0
- package/dist/cmd/cloud/vector/upsert.js +192 -0
- package/dist/cmd/cloud/vector/upsert.js.map +1 -0
- package/dist/cmd/dev/file-watcher.d.ts.map +1 -1
- package/dist/cmd/dev/file-watcher.js +90 -31
- package/dist/cmd/dev/file-watcher.js.map +1 -1
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/index.js +244 -64
- package/dist/cmd/dev/index.js.map +1 -1
- package/dist/cmd/dev/skills.d.ts +10 -0
- package/dist/cmd/dev/skills.d.ts.map +1 -0
- package/dist/cmd/dev/skills.js +57 -0
- package/dist/cmd/dev/skills.js.map +1 -0
- package/dist/cmd/dev/sync.js +7 -7
- package/dist/cmd/dev/sync.js.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +1 -0
- package/dist/cmd/index.js.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/create.js +3 -0
- package/dist/cmd/project/create.js.map +1 -1
- package/dist/cmd/project/template-flow.d.ts +1 -0
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.js +30 -5
- package/dist/cmd/project/template-flow.js.map +1 -1
- package/dist/cmd/setup/index.d.ts.map +1 -1
- package/dist/cmd/setup/index.js +1 -0
- package/dist/cmd/setup/index.js.map +1 -1
- package/dist/cmd/upgrade/index.d.ts +15 -0
- package/dist/cmd/upgrade/index.d.ts.map +1 -1
- package/dist/cmd/upgrade/index.js +59 -4
- package/dist/cmd/upgrade/index.js.map +1 -1
- package/dist/domain.d.ts +45 -0
- package/dist/domain.d.ts.map +1 -0
- package/dist/domain.js +200 -0
- package/dist/domain.js.map +1 -0
- package/dist/schema-generator.d.ts +2 -0
- package/dist/schema-generator.d.ts.map +1 -1
- package/dist/schema-generator.js +18 -0
- package/dist/schema-generator.js.map +1 -1
- package/dist/steps.d.ts +1 -1
- package/dist/steps.d.ts.map +1 -1
- package/dist/steps.js +16 -5
- package/dist/steps.js.map +1 -1
- package/dist/tui/prompt.d.ts +1 -2
- package/dist/tui/prompt.d.ts.map +1 -1
- package/dist/tui/prompt.js +8 -4
- package/dist/tui/prompt.js.map +1 -1
- package/dist/tui.d.ts +16 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +23 -2
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +9 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +47 -12
- package/src/cmd/ai/index.ts +6 -1
- package/src/cmd/ai/prompt/agent.md +306 -0
- package/src/cmd/ai/prompt/agent.ts +12 -322
- package/src/cmd/ai/prompt/api.md +360 -0
- package/src/cmd/ai/prompt/api.ts +13 -260
- package/src/cmd/ai/prompt/version.ts +61 -0
- package/src/cmd/ai/prompt/web.md +509 -0
- package/src/cmd/ai/prompt/web.ts +12 -282
- package/src/cmd/ai/skills/generate.ts +75 -0
- package/src/cmd/ai/skills/generator.ts +519 -0
- package/src/cmd/ai/skills/index.ts +23 -0
- package/src/cmd/auth/signup.ts +1 -0
- package/src/cmd/build/entry-generator.ts +43 -7
- package/src/cmd/build/vite/bun-dev-server.ts +31 -28
- package/src/cmd/build/vite/metadata-generator.ts +73 -7
- package/src/cmd/build/vite/prompt-generator.ts +169 -0
- package/src/cmd/build/vite/registry-generator.ts +33 -10
- package/src/cmd/build/vite/server-bundler.ts +53 -22
- package/src/cmd/build/vite/vite-asset-server-config.ts +5 -0
- package/src/cmd/build/vite/vite-builder.ts +107 -87
- package/src/cmd/cloud/deploy.ts +103 -31
- package/src/cmd/cloud/keyvalue/create-namespace.ts +3 -1
- package/src/cmd/cloud/keyvalue/delete-namespace.ts +3 -1
- package/src/cmd/cloud/keyvalue/delete.ts +3 -1
- package/src/cmd/cloud/keyvalue/set.ts +4 -2
- package/src/cmd/cloud/stream/get.ts +2 -9
- package/src/cmd/cloud/vector/delete-namespace.ts +89 -0
- package/src/cmd/cloud/vector/index.ts +21 -4
- package/src/cmd/cloud/vector/list-namespaces.ts +46 -0
- package/src/cmd/cloud/vector/stats.ts +160 -0
- package/src/cmd/cloud/vector/upsert.ts +216 -0
- package/src/cmd/dev/file-watcher.ts +101 -32
- package/src/cmd/dev/index.ts +343 -115
- package/src/cmd/dev/skills.ts +82 -0
- package/src/cmd/dev/sync.ts +7 -7
- package/src/cmd/index.ts +1 -0
- package/src/cmd/project/create.ts +3 -0
- package/src/cmd/project/template-flow.ts +37 -5
- package/src/cmd/setup/index.ts +1 -0
- package/src/cmd/upgrade/index.ts +68 -4
- package/src/domain.ts +273 -0
- package/src/schema-generator.ts +23 -0
- package/src/steps.ts +16 -5
- package/src/tui/prompt.ts +11 -5
- package/src/tui.ts +21 -2
- package/src/types/md.d.ts +8 -0
- package/src/types.ts +12 -3
- package/dist/cmd/cloud/domain.d.ts +0 -17
- package/dist/cmd/cloud/domain.d.ts.map +0 -1
- package/dist/cmd/cloud/domain.js +0 -79
- package/dist/cmd/cloud/domain.js.map +0 -1
- package/src/cmd/cloud/domain.ts +0 -100
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import { createCommand } from '../../../types';
|
|
2
2
|
import { deleteSubcommand } from './delete';
|
|
3
|
+
import { deleteNamespaceSubcommand } from './delete-namespace';
|
|
3
4
|
import { getSubcommand } from './get';
|
|
5
|
+
import { listNamespacesSubcommand } from './list-namespaces';
|
|
4
6
|
import { searchSubcommand } from './search';
|
|
7
|
+
import { statsSubcommand } from './stats';
|
|
8
|
+
import { upsertSubcommand } from './upsert';
|
|
5
9
|
import { getCommand } from '../../../command-prefix';
|
|
6
10
|
|
|
7
11
|
export const vectorCommand = createCommand({
|
|
8
12
|
name: 'vector',
|
|
9
13
|
aliases: ['vec'],
|
|
10
14
|
description: 'Manage vector storage for your projects',
|
|
11
|
-
tags: ['requires-auth', '
|
|
15
|
+
tags: ['requires-auth', 'slow'],
|
|
12
16
|
examples: [
|
|
13
17
|
{
|
|
14
|
-
command: getCommand('cloud vector search "query text"'),
|
|
18
|
+
command: getCommand('cloud vector search products "query text"'),
|
|
15
19
|
description: 'Search vector storage',
|
|
16
20
|
},
|
|
17
|
-
{
|
|
21
|
+
{
|
|
22
|
+
command: getCommand('cloud vec upsert products doc1 --document "text"'),
|
|
23
|
+
description: 'Upsert a vector',
|
|
24
|
+
},
|
|
25
|
+
{ command: getCommand('cloud vec get products doc1'), description: 'Get vector by key' },
|
|
26
|
+
{ command: getCommand('cloud vec stats'), description: 'Show namespace statistics' },
|
|
27
|
+
],
|
|
28
|
+
subcommands: [
|
|
29
|
+
upsertSubcommand,
|
|
30
|
+
searchSubcommand,
|
|
31
|
+
getSubcommand,
|
|
32
|
+
deleteSubcommand,
|
|
33
|
+
statsSubcommand,
|
|
34
|
+
listNamespacesSubcommand,
|
|
35
|
+
deleteNamespaceSubcommand,
|
|
18
36
|
],
|
|
19
|
-
subcommands: [searchSubcommand, getSubcommand, deleteSubcommand],
|
|
20
37
|
requires: { auth: true, project: true },
|
|
21
38
|
});
|
|
22
39
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createStorageAdapter } from './util';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
|
|
7
|
+
const NamespaceListResponseSchema = z.array(z.string().describe('Namespace name'));
|
|
8
|
+
|
|
9
|
+
export const listNamespacesSubcommand = createCommand({
|
|
10
|
+
name: 'list-namespaces',
|
|
11
|
+
aliases: ['namespaces', 'ns'],
|
|
12
|
+
description: 'List all vector namespaces',
|
|
13
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
14
|
+
requires: { auth: true, project: true },
|
|
15
|
+
examples: [
|
|
16
|
+
{ command: getCommand('vector list-namespaces'), description: 'List all namespaces' },
|
|
17
|
+
{ command: getCommand('vector namespaces'), description: 'List namespaces (using alias)' },
|
|
18
|
+
{ command: getCommand('vector ns'), description: 'List namespaces (short alias)' },
|
|
19
|
+
],
|
|
20
|
+
schema: {
|
|
21
|
+
response: NamespaceListResponseSchema,
|
|
22
|
+
},
|
|
23
|
+
webUrl: '/services/vector',
|
|
24
|
+
idempotent: true,
|
|
25
|
+
|
|
26
|
+
async handler(ctx) {
|
|
27
|
+
const { options } = ctx;
|
|
28
|
+
const storage = await createStorageAdapter(ctx);
|
|
29
|
+
const namespaces = await storage.getNamespaces();
|
|
30
|
+
|
|
31
|
+
if (!options.json) {
|
|
32
|
+
if (namespaces.length === 0) {
|
|
33
|
+
tui.info('No vector namespaces found');
|
|
34
|
+
} else {
|
|
35
|
+
tui.info(`Found ${namespaces.length} namespace(s):`);
|
|
36
|
+
for (const name of namespaces) {
|
|
37
|
+
tui.arrow(name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return namespaces;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export default listNamespacesSubcommand;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createStorageAdapter } from './util';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
|
|
7
|
+
const VectorItemStatsSchema = z.object({
|
|
8
|
+
embedding: z.array(z.number()).optional().describe('The embedding vector'),
|
|
9
|
+
document: z.string().optional().describe('Original document text'),
|
|
10
|
+
size: z.number().describe('Size in bytes'),
|
|
11
|
+
metadata: z.record(z.string(), z.unknown()).optional().describe('Metadata'),
|
|
12
|
+
firstUsed: z.number().describe('First access timestamp (ms)'),
|
|
13
|
+
lastUsed: z.number().describe('Last access timestamp (ms)'),
|
|
14
|
+
count: z.number().optional().describe('Access count (only available in cloud storage)'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const VectorNamespaceStatsSchema = z.object({
|
|
18
|
+
sum: z.number().describe('Total size in bytes'),
|
|
19
|
+
count: z.number().describe('Number of vectors'),
|
|
20
|
+
createdAt: z.number().optional().describe('Creation timestamp (ms)'),
|
|
21
|
+
lastUsed: z.number().optional().describe('Last used timestamp (ms)'),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const VectorStatsResponseSchema = z.union([
|
|
25
|
+
VectorNamespaceStatsSchema.extend({
|
|
26
|
+
namespace: z.string().describe('Namespace name'),
|
|
27
|
+
sampledResults: z.record(z.string(), VectorItemStatsSchema).optional(),
|
|
28
|
+
}),
|
|
29
|
+
z.record(z.string(), VectorNamespaceStatsSchema),
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
export const statsSubcommand = createCommand({
|
|
33
|
+
name: 'stats',
|
|
34
|
+
description: 'Get statistics for vector storage',
|
|
35
|
+
tags: ['read-only', 'fast', 'requires-auth'],
|
|
36
|
+
requires: { auth: true, project: true },
|
|
37
|
+
idempotent: true,
|
|
38
|
+
examples: [
|
|
39
|
+
{ command: getCommand('vector stats'), description: 'Show stats for all namespaces' },
|
|
40
|
+
{
|
|
41
|
+
command: getCommand('vector stats products'),
|
|
42
|
+
description: 'Show detailed stats for products namespace',
|
|
43
|
+
},
|
|
44
|
+
{ command: getCommand('vector stats embeddings'), description: 'Show stats for embeddings' },
|
|
45
|
+
],
|
|
46
|
+
schema: {
|
|
47
|
+
args: z.object({
|
|
48
|
+
name: z.string().optional().describe('the vector namespace (optional)'),
|
|
49
|
+
}),
|
|
50
|
+
response: VectorStatsResponseSchema,
|
|
51
|
+
},
|
|
52
|
+
webUrl: (ctx) =>
|
|
53
|
+
ctx.args.name ? `/services/vector/${encodeURIComponent(ctx.args.name)}` : '/services/vector',
|
|
54
|
+
|
|
55
|
+
async handler(ctx) {
|
|
56
|
+
const { args, options } = ctx;
|
|
57
|
+
const storage = await createStorageAdapter(ctx);
|
|
58
|
+
|
|
59
|
+
if (args.name) {
|
|
60
|
+
const stats = await storage.getStats(args.name);
|
|
61
|
+
|
|
62
|
+
if (!options.json) {
|
|
63
|
+
if (stats.count === 0 && stats.sum === 0) {
|
|
64
|
+
tui.info(`Namespace ${tui.bold(args.name)} is empty or does not exist`);
|
|
65
|
+
} else {
|
|
66
|
+
tui.info(`Statistics for ${tui.bold(args.name)}:`);
|
|
67
|
+
tui.info(` Vectors: ${stats.count}`);
|
|
68
|
+
const sizeDisplay =
|
|
69
|
+
stats.sum < 1024 * 1024
|
|
70
|
+
? `${stats.sum.toLocaleString()} bytes`
|
|
71
|
+
: `${(stats.sum / (1024 * 1024)).toFixed(2)} MB`;
|
|
72
|
+
tui.info(` Total size: ${sizeDisplay}`);
|
|
73
|
+
|
|
74
|
+
if (stats.createdAt) {
|
|
75
|
+
tui.info(` Created: ${new Date(stats.createdAt).toLocaleString()}`);
|
|
76
|
+
}
|
|
77
|
+
if (stats.lastUsed) {
|
|
78
|
+
tui.info(` Last used: ${new Date(stats.lastUsed).toLocaleString()}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (stats.sampledResults && Object.keys(stats.sampledResults).length > 0) {
|
|
82
|
+
tui.info('');
|
|
83
|
+
tui.info(` Sample vectors (${Object.keys(stats.sampledResults).length}):`);
|
|
84
|
+
|
|
85
|
+
const tableData = Object.entries(stats.sampledResults).map(([key, item]) => {
|
|
86
|
+
const docPreview = item.document
|
|
87
|
+
? item.document.length > 30
|
|
88
|
+
? item.document.substring(0, 27) + '...'
|
|
89
|
+
: item.document
|
|
90
|
+
: '-';
|
|
91
|
+
return {
|
|
92
|
+
Key: key,
|
|
93
|
+
Size: `${item.size} bytes`,
|
|
94
|
+
Accesses: item.count ?? '-',
|
|
95
|
+
'Last Used': new Date(item.lastUsed).toLocaleDateString(),
|
|
96
|
+
Document: docPreview,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
tui.table(tableData, [
|
|
101
|
+
{ name: 'Key', alignment: 'left' },
|
|
102
|
+
{ name: 'Size', alignment: 'right' },
|
|
103
|
+
{ name: 'Accesses', alignment: 'right' },
|
|
104
|
+
{ name: 'Last Used', alignment: 'left' },
|
|
105
|
+
{ name: 'Document', alignment: 'left' },
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
namespace: args.name,
|
|
113
|
+
...stats,
|
|
114
|
+
};
|
|
115
|
+
} else {
|
|
116
|
+
const allStats = await storage.getAllStats();
|
|
117
|
+
const entries = Object.entries(allStats);
|
|
118
|
+
|
|
119
|
+
if (!options.json) {
|
|
120
|
+
if (entries.length === 0) {
|
|
121
|
+
tui.info('No vector namespaces found');
|
|
122
|
+
} else {
|
|
123
|
+
tui.info(
|
|
124
|
+
`Found ${entries.length} ${tui.plural(entries.length, 'namespace', 'namespaces')}:`
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const tableData = entries.map(([name, stats]) => {
|
|
128
|
+
const sizeDisplay =
|
|
129
|
+
stats.sum < 1024 * 1024
|
|
130
|
+
? `${stats.sum.toLocaleString()} bytes`
|
|
131
|
+
: `${(stats.sum / (1024 * 1024)).toFixed(2)} MB`;
|
|
132
|
+
return {
|
|
133
|
+
Namespace: name,
|
|
134
|
+
Vectors: stats.count,
|
|
135
|
+
Size: sizeDisplay,
|
|
136
|
+
Created: stats.createdAt
|
|
137
|
+
? new Date(stats.createdAt).toLocaleDateString()
|
|
138
|
+
: '-',
|
|
139
|
+
'Last Used': stats.lastUsed
|
|
140
|
+
? new Date(stats.lastUsed).toLocaleDateString()
|
|
141
|
+
: '-',
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
tui.table(tableData, [
|
|
146
|
+
{ name: 'Namespace', alignment: 'left' },
|
|
147
|
+
{ name: 'Vectors', alignment: 'right' },
|
|
148
|
+
{ name: 'Size', alignment: 'right' },
|
|
149
|
+
{ name: 'Created', alignment: 'left' },
|
|
150
|
+
{ name: 'Last Used', alignment: 'left' },
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return allStats;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
export default statsSubcommand;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createCommand } from '../../../types';
|
|
3
|
+
import * as tui from '../../../tui';
|
|
4
|
+
import { createStorageAdapter } from './util';
|
|
5
|
+
import { getCommand } from '../../../command-prefix';
|
|
6
|
+
import type { VectorUpsertParams } from '@agentuity/core';
|
|
7
|
+
|
|
8
|
+
const VectorUpsertResponseSchema = z.object({
|
|
9
|
+
success: z.boolean().describe('Whether the operation succeeded'),
|
|
10
|
+
namespace: z.string().describe('Namespace name'),
|
|
11
|
+
count: z.number().describe('Number of vectors upserted'),
|
|
12
|
+
results: z
|
|
13
|
+
.array(
|
|
14
|
+
z.object({
|
|
15
|
+
key: z.string().describe('Vector key'),
|
|
16
|
+
id: z.string().describe('Vector ID'),
|
|
17
|
+
})
|
|
18
|
+
)
|
|
19
|
+
.describe('Upsert results with key-to-id mappings'),
|
|
20
|
+
durationMs: z.number().describe('Operation duration in milliseconds'),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const upsertSubcommand = createCommand({
|
|
24
|
+
name: 'upsert',
|
|
25
|
+
aliases: ['put', 'add'],
|
|
26
|
+
description: 'Add or update vectors in the vector storage',
|
|
27
|
+
tags: ['mutating', 'updates-resource', 'slow', 'requires-auth'],
|
|
28
|
+
idempotent: true,
|
|
29
|
+
requires: { auth: true, project: true },
|
|
30
|
+
examples: [
|
|
31
|
+
{
|
|
32
|
+
command: getCommand('vector upsert products doc1 --document "Comfortable office chair"'),
|
|
33
|
+
description: 'Upsert a single vector with document text',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
command: getCommand(
|
|
37
|
+
'vector upsert products doc1 --document "Chair" --metadata \'{"category":"furniture"}\''
|
|
38
|
+
),
|
|
39
|
+
description: 'Upsert with metadata',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
command: getCommand('vector upsert embeddings vec1 --embeddings "[0.1, 0.2, 0.3]"'),
|
|
43
|
+
description: 'Upsert with pre-computed embeddings',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
command: getCommand('vector upsert products --file vectors.json'),
|
|
47
|
+
description: 'Bulk upsert from JSON file',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
command: `cat vectors.json | ${getCommand('vector upsert products -')}`,
|
|
51
|
+
description: 'Bulk upsert from stdin',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
schema: {
|
|
55
|
+
args: z.object({
|
|
56
|
+
namespace: z.string().min(1).describe('the vector storage namespace'),
|
|
57
|
+
key: z
|
|
58
|
+
.string()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('the key for single vector upsert (not used with --file or stdin)'),
|
|
61
|
+
}),
|
|
62
|
+
options: z.object({
|
|
63
|
+
document: z.string().optional().describe('document text to embed'),
|
|
64
|
+
embeddings: z.string().optional().describe('pre-computed embeddings as JSON array'),
|
|
65
|
+
metadata: z.string().optional().describe('metadata as JSON object'),
|
|
66
|
+
file: z
|
|
67
|
+
.string()
|
|
68
|
+
.optional()
|
|
69
|
+
.describe('path to JSON file containing vectors, or "-" for stdin'),
|
|
70
|
+
}),
|
|
71
|
+
response: VectorUpsertResponseSchema,
|
|
72
|
+
},
|
|
73
|
+
webUrl: (ctx) => `/services/vector/${encodeURIComponent(ctx.args.namespace)}`,
|
|
74
|
+
|
|
75
|
+
async handler(ctx) {
|
|
76
|
+
const { args, opts, options, logger } = ctx;
|
|
77
|
+
const storage = await createStorageAdapter(ctx);
|
|
78
|
+
|
|
79
|
+
let documents: VectorUpsertParams[] = [];
|
|
80
|
+
|
|
81
|
+
// Check if reading from file or stdin
|
|
82
|
+
const fileArg = opts.file || (args.key === '-' ? '-' : undefined);
|
|
83
|
+
|
|
84
|
+
if (fileArg) {
|
|
85
|
+
let content: string;
|
|
86
|
+
|
|
87
|
+
if (fileArg === '-') {
|
|
88
|
+
// Read from stdin
|
|
89
|
+
const chunks: Uint8Array[] = [];
|
|
90
|
+
const reader = Bun.stdin.stream().getReader();
|
|
91
|
+
|
|
92
|
+
while (true) {
|
|
93
|
+
const { done, value } = await reader.read();
|
|
94
|
+
if (done) break;
|
|
95
|
+
chunks.push(value);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const decoder = new TextDecoder();
|
|
99
|
+
content = chunks.map((chunk) => decoder.decode(chunk, { stream: true })).join('');
|
|
100
|
+
} else {
|
|
101
|
+
// Read from file
|
|
102
|
+
const file = Bun.file(fileArg);
|
|
103
|
+
if (!(await file.exists())) {
|
|
104
|
+
tui.fatal(`File not found: ${fileArg}`);
|
|
105
|
+
}
|
|
106
|
+
content = await file.text();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
const parsed = JSON.parse(content.trim());
|
|
111
|
+
if (Array.isArray(parsed)) {
|
|
112
|
+
documents = parsed as VectorUpsertParams[];
|
|
113
|
+
} else {
|
|
114
|
+
documents = [parsed as VectorUpsertParams];
|
|
115
|
+
}
|
|
116
|
+
} catch {
|
|
117
|
+
tui.fatal('Invalid JSON in input file/stdin');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Validate documents
|
|
121
|
+
for (const doc of documents) {
|
|
122
|
+
if (!doc.key || typeof doc.key !== 'string') {
|
|
123
|
+
tui.fatal('Each document must have a non-empty "key" property');
|
|
124
|
+
}
|
|
125
|
+
if (!doc.document && !('embeddings' in doc)) {
|
|
126
|
+
tui.fatal(
|
|
127
|
+
`Document with key "${doc.key}" must have either "document" or "embeddings" property`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
// Single vector upsert via command line arguments
|
|
133
|
+
if (!args.key) {
|
|
134
|
+
tui.fatal('Key is required for single vector upsert. Use --file for bulk upsert.');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!opts.document && !opts.embeddings) {
|
|
138
|
+
tui.fatal('Either --document or --embeddings is required');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (opts.document && opts.embeddings) {
|
|
142
|
+
tui.fatal('Cannot use both --document and --embeddings');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let metadata: Record<string, unknown> | undefined;
|
|
146
|
+
if (opts.metadata) {
|
|
147
|
+
try {
|
|
148
|
+
metadata = JSON.parse(opts.metadata);
|
|
149
|
+
} catch {
|
|
150
|
+
tui.fatal('Invalid JSON in --metadata');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (opts.document) {
|
|
155
|
+
documents = [
|
|
156
|
+
{
|
|
157
|
+
key: args.key,
|
|
158
|
+
document: opts.document,
|
|
159
|
+
metadata,
|
|
160
|
+
},
|
|
161
|
+
];
|
|
162
|
+
} else if (opts.embeddings) {
|
|
163
|
+
let embeddings: number[];
|
|
164
|
+
try {
|
|
165
|
+
embeddings = JSON.parse(opts.embeddings);
|
|
166
|
+
if (!Array.isArray(embeddings) || !embeddings.every((n) => typeof n === 'number')) {
|
|
167
|
+
throw new Error('Not an array of numbers');
|
|
168
|
+
}
|
|
169
|
+
} catch {
|
|
170
|
+
tui.fatal('Invalid embeddings: must be a JSON array of numbers');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
documents = [
|
|
174
|
+
{
|
|
175
|
+
key: args.key,
|
|
176
|
+
embeddings,
|
|
177
|
+
metadata,
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (documents.length === 0) {
|
|
184
|
+
tui.fatal('No documents to upsert');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const started = Date.now();
|
|
188
|
+
|
|
189
|
+
logger.debug(`Upserting ${documents.length} vector(s) to ${args.namespace}`);
|
|
190
|
+
|
|
191
|
+
const results = await storage.upsert(args.namespace, ...documents);
|
|
192
|
+
const durationMs = Date.now() - started;
|
|
193
|
+
|
|
194
|
+
if (!options.json) {
|
|
195
|
+
tui.success(
|
|
196
|
+
`Upserted ${results.length} vector(s) to ${tui.bold(args.namespace)} (${durationMs}ms)`
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
if (results.length <= 10) {
|
|
200
|
+
for (const result of results) {
|
|
201
|
+
tui.arrow(`${result.key} → ${result.id}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
success: true,
|
|
208
|
+
namespace: args.namespace,
|
|
209
|
+
count: results.length,
|
|
210
|
+
results,
|
|
211
|
+
durationMs,
|
|
212
|
+
};
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export default upsertSubcommand;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Handles both backend (API, agents, lib) and generates restart signals.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { watch, type FSWatcher, statSync, readdirSync } from 'node:fs';
|
|
9
|
-
import { resolve } from 'node:path';
|
|
8
|
+
import { watch, type FSWatcher, statSync, readdirSync, lstatSync } from 'node:fs';
|
|
9
|
+
import { resolve, relative } from 'node:path';
|
|
10
10
|
import type { Logger } from '../../types';
|
|
11
11
|
import { createAgentTemplates, createAPITemplates } from './templates';
|
|
12
12
|
|
|
@@ -34,13 +34,29 @@ export function createFileWatcher(options: FileWatcherOptions): FileWatcherManag
|
|
|
34
34
|
let paused = false;
|
|
35
35
|
let buildCooldownTimer: NodeJS.Timeout | null = null;
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
// This
|
|
39
|
-
const
|
|
37
|
+
// Directories to ignore - these are NEVER traversed into
|
|
38
|
+
// This prevents EMFILE errors from symlink cycles in node_modules
|
|
39
|
+
const ignoreDirs = new Set([
|
|
40
|
+
'.agentuity',
|
|
41
|
+
'.agents',
|
|
42
|
+
'.claude',
|
|
43
|
+
'.code',
|
|
44
|
+
'.opencode',
|
|
45
|
+
'node_modules',
|
|
46
|
+
'.git',
|
|
47
|
+
'dist',
|
|
48
|
+
'build',
|
|
49
|
+
'.next',
|
|
50
|
+
'.turbo',
|
|
51
|
+
]);
|
|
40
52
|
|
|
41
|
-
//
|
|
53
|
+
// Paths to ignore for file change events (but may still be traversed)
|
|
42
54
|
const ignorePaths = [
|
|
43
55
|
'.agentuity',
|
|
56
|
+
'.agents',
|
|
57
|
+
'.claude',
|
|
58
|
+
'.code',
|
|
59
|
+
'.opencode',
|
|
44
60
|
'node_modules',
|
|
45
61
|
'.git',
|
|
46
62
|
'dist',
|
|
@@ -168,47 +184,100 @@ export function createFileWatcher(options: FileWatcherOptions): FileWatcherManag
|
|
|
168
184
|
}
|
|
169
185
|
|
|
170
186
|
/**
|
|
171
|
-
*
|
|
187
|
+
* Recursively collect all directories to watch, skipping ignored directories.
|
|
188
|
+
* This prevents EMFILE errors from symlink cycles in node_modules.
|
|
172
189
|
*/
|
|
173
|
-
function
|
|
174
|
-
|
|
190
|
+
function collectWatchDirs(dir: string, visited: Set<string> = new Set()): string[] {
|
|
191
|
+
const dirs: string[] = [dir];
|
|
175
192
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
logger.trace('Setting up watcher for: %s', watchPath);
|
|
193
|
+
try {
|
|
194
|
+
// Use lstat to check for symlinks - get the real path to detect cycles
|
|
195
|
+
const stat = lstatSync(dir);
|
|
180
196
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
197
|
+
// Skip symlinks to prevent following circular symlinks
|
|
198
|
+
if (stat.isSymbolicLink()) {
|
|
199
|
+
logger.trace('Skipping symlink: %s', dir);
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
184
202
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
logger.
|
|
203
|
+
// Track visited inodes to detect cycles
|
|
204
|
+
const key = `${stat.dev}:${stat.ino}`;
|
|
205
|
+
if (visited.has(key)) {
|
|
206
|
+
logger.trace('Skipping already visited directory (cycle detected): %s', dir);
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
visited.add(key);
|
|
210
|
+
|
|
211
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
212
|
+
|
|
213
|
+
for (const entry of entries) {
|
|
214
|
+
if (!entry.isDirectory()) continue;
|
|
215
|
+
|
|
216
|
+
const name = entry.name;
|
|
217
|
+
|
|
218
|
+
// Skip ignored directories entirely - this is the key fix
|
|
219
|
+
if (ignoreDirs.has(name)) {
|
|
220
|
+
logger.trace('Skipping ignored directory: %s', resolve(dir, name));
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Skip hidden directories (except specific ones like .env folders)
|
|
225
|
+
if (name.startsWith('.')) {
|
|
226
|
+
logger.trace('Skipping hidden directory: %s', resolve(dir, name));
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const fullPath = resolve(dir, name);
|
|
231
|
+
dirs.push(...collectWatchDirs(fullPath, visited));
|
|
189
232
|
}
|
|
233
|
+
} catch (error) {
|
|
234
|
+
logger.trace('Error reading directory %s: %s', dir, error);
|
|
190
235
|
}
|
|
191
236
|
|
|
192
|
-
|
|
237
|
+
return dirs;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Start watching files
|
|
242
|
+
*/
|
|
243
|
+
function start() {
|
|
244
|
+
logger.debug('Starting file watchers for hot reload...');
|
|
245
|
+
|
|
246
|
+
// Collect all directories to watch, excluding node_modules and other ignored dirs
|
|
247
|
+
const allDirs = collectWatchDirs(rootDir);
|
|
248
|
+
|
|
249
|
+
// Add additional paths
|
|
193
250
|
if (additionalPaths && additionalPaths.length > 0) {
|
|
194
251
|
for (const additionalPath of additionalPaths) {
|
|
195
252
|
const fullPath = resolve(rootDir, additionalPath);
|
|
196
|
-
|
|
197
|
-
|
|
253
|
+
allDirs.push(...collectWatchDirs(fullPath));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
198
256
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
});
|
|
257
|
+
// De-duplicate directories
|
|
258
|
+
const uniqueDirs = [...new Set(allDirs)];
|
|
202
259
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
260
|
+
logger.debug('Collected %d directories to watch', uniqueDirs.length);
|
|
261
|
+
|
|
262
|
+
// Watch each directory non-recursively
|
|
263
|
+
for (const watchPath of uniqueDirs) {
|
|
264
|
+
try {
|
|
265
|
+
// Use non-recursive watch to avoid traversing into node_modules
|
|
266
|
+
const watcher = watch(watchPath, { recursive: false }, (eventType, changedFile) => {
|
|
267
|
+
// Construct relative path from rootDir for consistent handling
|
|
268
|
+
const relPath = changedFile
|
|
269
|
+
? relative(rootDir, resolve(watchPath, changedFile))
|
|
270
|
+
: relative(rootDir, watchPath);
|
|
271
|
+
handleFileChange(eventType, relPath || changedFile, rootDir);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
watchers.push(watcher);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
logger.trace('Failed to start watcher for %s: %s', watchPath, error);
|
|
208
277
|
}
|
|
209
278
|
}
|
|
210
279
|
|
|
211
|
-
logger.debug('File watchers started (%d
|
|
280
|
+
logger.debug('File watchers started (%d directories)', watchers.length);
|
|
212
281
|
}
|
|
213
282
|
|
|
214
283
|
/**
|