@neta-art/cohub-cli 2.3.2 → 2.4.0
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/NOTICE +4 -0
- package/dist/commands/references.js +33 -10
- package/package.json +5 -3
package/NOTICE
ADDED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { createClient } from "../client.js";
|
|
2
2
|
import { table, json as outJson, jsonRequested, error, handleHttp } from "../output.js";
|
|
3
3
|
const RESOURCE_TYPES = new Set([
|
|
4
|
-
"
|
|
4
|
+
"turn",
|
|
5
5
|
"session",
|
|
6
|
+
"space",
|
|
6
7
|
"checkpoint",
|
|
7
8
|
]);
|
|
8
9
|
const REFERENCE_KINDS = new Set([
|
|
9
10
|
"session_fork",
|
|
10
11
|
"space_fork",
|
|
11
12
|
"checkpoint_fork",
|
|
13
|
+
"mod",
|
|
12
14
|
"mention",
|
|
13
15
|
"tool_call",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
+
"agent_tool_file_read",
|
|
17
|
+
"agent_tool_file_write",
|
|
18
|
+
"agent_tool_file_edit",
|
|
19
|
+
"agent_tool_file_ls",
|
|
20
|
+
"agent_tool_file_find",
|
|
21
|
+
"agent_tool_file_grep",
|
|
16
22
|
]);
|
|
17
23
|
const DIRECTIONS = new Set(["out", "in", "both"]);
|
|
18
|
-
const GROUP_BYS = new Set(["kind", "targetType", "sourceType", "day"]);
|
|
24
|
+
const GROUP_BYS = new Set(["kind", "targetType", "target", "sourceType", "day"]);
|
|
19
25
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
20
26
|
function parseSource(value) {
|
|
21
27
|
const idx = value.indexOf(":");
|
|
@@ -47,11 +53,11 @@ function clampNumber(value, fallback, min, max) {
|
|
|
47
53
|
export function registerReferences(program) {
|
|
48
54
|
const references = program
|
|
49
55
|
.command("references")
|
|
50
|
-
.description("Inspect resource references (forks, mentions, tool calls, mods,
|
|
56
|
+
.description("Inspect resource references (forks, mentions, tool calls, mods, file access)");
|
|
51
57
|
references
|
|
52
58
|
.command("query")
|
|
53
59
|
.description("List references touching a resource")
|
|
54
|
-
.argument("<source>", "Resource selector, e.g. session:<uuid
|
|
60
|
+
.argument("<source>", "Resource selector, e.g. turn:<uuid>, session:<uuid>, space:<uuid>")
|
|
55
61
|
.option("--direction <dir>", "out | in | both", "both")
|
|
56
62
|
.option("--kinds <kinds>", "Comma-separated kinds to include")
|
|
57
63
|
.option("--days <n>", "Only references seen within the last N days")
|
|
@@ -60,9 +66,10 @@ export function registerReferences(program) {
|
|
|
60
66
|
.addHelpText("after", `
|
|
61
67
|
|
|
62
68
|
Examples:
|
|
69
|
+
cohub references query turn:<uuid> --kinds agent_tool_file_read,agent_tool_file_write
|
|
63
70
|
cohub references query session:<uuid> --json
|
|
64
71
|
cohub references query space:<uuid> --direction in --kinds mention,tool_call
|
|
65
|
-
cohub references query space:<uuid> --kinds
|
|
72
|
+
cohub references query space:<uuid> --kinds agent_tool_file_read --days 30
|
|
66
73
|
`)
|
|
67
74
|
.action(async (source, opts) => {
|
|
68
75
|
const client = createClient();
|
|
@@ -86,7 +93,7 @@ Examples:
|
|
|
86
93
|
const rows = result.references.map((r) => ({
|
|
87
94
|
kind: r.kind,
|
|
88
95
|
source: `${r.sourceType}:${r.sourceId.slice(0, 8)}`,
|
|
89
|
-
target:
|
|
96
|
+
target: formatTarget(r.targetType, r.targetId),
|
|
90
97
|
count: r.count,
|
|
91
98
|
lastSeen: r.updatedAt.slice(0, 10),
|
|
92
99
|
}));
|
|
@@ -109,15 +116,17 @@ Examples:
|
|
|
109
116
|
.command("aggregate")
|
|
110
117
|
.description("Grouped reference counts for a space")
|
|
111
118
|
.argument("<spaceId>", "Space id")
|
|
112
|
-
.option("--group-by <field>", "kind | targetType | sourceType | day", "kind")
|
|
119
|
+
.option("--group-by <field>", "kind | targetType | target | sourceType | day", "kind")
|
|
113
120
|
.option("--kinds <kinds>", "Comma-separated kinds to include")
|
|
114
121
|
.option("--days <n>", "Only references seen within the last N days")
|
|
122
|
+
.option("--limit <n>", "Maximum groups, 1-500", "200")
|
|
115
123
|
.option("--json", "Output as JSON")
|
|
116
124
|
.addHelpText("after", `
|
|
117
125
|
|
|
118
126
|
Examples:
|
|
119
127
|
cohub references aggregate <spaceId> --json
|
|
120
128
|
cohub references aggregate <spaceId> --group-by targetType
|
|
129
|
+
cohub references aggregate <spaceId> --group-by target --kinds agent_tool_file_read --limit 20
|
|
121
130
|
cohub references aggregate <spaceId> --group-by day --days 30
|
|
122
131
|
`)
|
|
123
132
|
.action(async (spaceId, opts) => {
|
|
@@ -130,7 +139,8 @@ Examples:
|
|
|
130
139
|
return error(`Invalid group-by: ${opts.groupBy}`);
|
|
131
140
|
const kinds = parseKinds(opts.kinds);
|
|
132
141
|
const days = opts.days ? clampNumber(opts.days, 30, 1, 365) : undefined;
|
|
133
|
-
const
|
|
142
|
+
const limit = clampNumber(opts.limit, 200, 1, 500);
|
|
143
|
+
const result = await client.references.aggregate({ spaceId: spaceId.trim(), groupBy, kinds, days, limit });
|
|
134
144
|
if (jsonRequested(opts))
|
|
135
145
|
return outJson(result);
|
|
136
146
|
const rows = result.groups.map((g) => ({
|
|
@@ -151,3 +161,16 @@ Examples:
|
|
|
151
161
|
}
|
|
152
162
|
});
|
|
153
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Render a target for the table. File targets are `{spaceId}:{path}`; show the
|
|
166
|
+
* short space id plus the full path rather than blindly truncating.
|
|
167
|
+
*/
|
|
168
|
+
function formatTarget(targetType, targetId) {
|
|
169
|
+
if (targetType === "file") {
|
|
170
|
+
const idx = targetId.indexOf(":");
|
|
171
|
+
if (idx > 0)
|
|
172
|
+
return `file:${targetId.slice(0, 8)}…${targetId.slice(idx)}`;
|
|
173
|
+
return `file:${targetId}`;
|
|
174
|
+
}
|
|
175
|
+
return `${targetType}:${targetId.slice(0, 8)}`;
|
|
176
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"bin",
|
|
13
|
-
"README.md"
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"NOTICE"
|
|
14
16
|
],
|
|
15
17
|
"dependencies": {
|
|
16
18
|
"@neta-art/generation": "^0.1.13",
|
|
17
19
|
"commander": "^15.0.0",
|
|
18
20
|
"sharp": "^0.35.3",
|
|
19
|
-
"@neta-art/cohub": "2.
|
|
21
|
+
"@neta-art/cohub": "2.12.0"
|
|
20
22
|
},
|
|
21
23
|
"publishConfig": {
|
|
22
24
|
"access": "public"
|