@opvs-ai/cli 0.23.0 → 0.24.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/README.md +73 -0
- package/claude-plugin/.claude-plugin/marketplace.json +14 -0
- package/claude-plugin/.claude-plugin/plugin.json +9 -0
- package/claude-plugin/.mcp.json +8 -0
- package/claude-plugin/README.md +24 -0
- package/claude-plugin/hooks/hooks.json +50 -0
- package/claude-plugin/skills/remember/SKILL.md +31 -0
- package/claude-plugin/skills/remember/scripts/remember.mjs +121 -0
- package/dist/.build-stamp.json +4 -4
- package/dist/commands/code-graph.d.ts +17 -0
- package/dist/commands/code-graph.js +64 -0
- package/dist/commands/code-graph.js.map +1 -0
- package/dist/commands/code.d.ts +13 -3
- package/dist/commands/code.js +191 -3
- package/dist/commands/code.js.map +1 -1
- package/dist/commands/memory-capture.d.ts +76 -0
- package/dist/commands/memory-capture.js +562 -0
- package/dist/commands/memory-capture.js.map +1 -0
- package/dist/commands/memory-hook.js +13 -4
- package/dist/commands/memory-hook.js.map +1 -1
- package/dist/commands/memory-install.d.ts +17 -0
- package/dist/commands/memory-install.js +349 -0
- package/dist/commands/memory-install.js.map +1 -0
- package/dist/commands/memory-lessons.d.ts +8 -0
- package/dist/commands/memory-lessons.js +135 -0
- package/dist/commands/memory-lessons.js.map +1 -0
- package/dist/commands/memory.js +6 -0
- package/dist/commands/memory.js.map +1 -1
- package/dist/commands/orgChart.d.ts +3 -0
- package/dist/commands/orgChart.js +88 -0
- package/dist/commands/orgChart.js.map +1 -0
- package/dist/commands/tasks.js +45 -3
- package/dist/commands/tasks.js.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/redact.d.ts +16 -0
- package/dist/lib/redact.js +92 -0
- package/dist/lib/redact.js.map +1 -0
- package/package.json +3 -1
- package/runtime-plugins/cline/opvs-memory.ts +99 -0
- package/runtime-plugins/opencode/opvs-memory.ts +94 -0
package/dist/commands/code.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* opvs code — the tenant code index query door (TCI · 2.2)
|
|
2
|
+
* opvs code — the tenant code index query door (TCI · 2.2 + 2.4)
|
|
3
3
|
*
|
|
4
4
|
* The question this answers is "does this already exist in the repo?", asked by
|
|
5
|
-
* an agent that is about to write something. It is the CLI face of
|
|
6
|
-
*
|
|
5
|
+
* an agent that is about to write something. It is the CLI face of every read
|
|
6
|
+
* the API serves under `/api/v1/code/{project_id}/`: context, summary, tree,
|
|
7
|
+
* files, symbols, and the stable-node reads (resolve, changes).
|
|
7
8
|
*
|
|
8
9
|
* ⚠️ THE VERDICT IS NOT THE WHOLE ANSWER.
|
|
9
10
|
* `indexed: false` and `verdict: "none"` are DIFFERENT facts and the API returns
|
|
@@ -18,6 +19,15 @@
|
|
|
18
19
|
* scope ceiling. `code:write` (the ingest lane) is deliberately not, and there is
|
|
19
20
|
* no CLI command for it: an index pass is a 50,000-row bulk load and a worker
|
|
20
21
|
* session must not be able to spend one (D5).
|
|
22
|
+
*
|
|
23
|
+
* SEND ONLY WHAT THE USER SET (TCI-112, P2.4)
|
|
24
|
+
* ---------------------------------------------
|
|
25
|
+
* Every option here is optional except `--project`. The brief is explicit: do
|
|
26
|
+
* not invent a default the server did not ask for. A `branch=undefined` on the
|
|
27
|
+
* wire is a real filter reading as "the branch named 'undefined'"; a
|
|
28
|
+
* `directory=` left out of `/files` lets the API apply its own `.` default; a
|
|
29
|
+
* `format=undefined` is a literal string on the URL. Each `if (opts.x) ...`
|
|
30
|
+
* gate exists so the request the server sees is the request the user asked for.
|
|
21
31
|
*/
|
|
22
32
|
import { getEffectiveConfig, createClient } from "@opvs-ai/core";
|
|
23
33
|
import { buildUrl, printResponse } from "../lib/format.js";
|
|
@@ -86,5 +96,183 @@ export function registerCodeCommands(program) {
|
|
|
86
96
|
process.exit(1);
|
|
87
97
|
}
|
|
88
98
|
});
|
|
99
|
+
// ── tree: the directory rollup behind the canvas (TCI-25) ───────
|
|
100
|
+
code
|
|
101
|
+
.command("tree")
|
|
102
|
+
.description("Directory rollup for a project — where the code lives, how deep, and how much was stored")
|
|
103
|
+
.requiredOption("--project <id>", "Project id (board_groups.id where kind=project)")
|
|
104
|
+
.option("--branch <name>", "Answer from a specific indexed branch")
|
|
105
|
+
.option("--depth <n>", "Deepest directory level to return (1-based; server max 3)")
|
|
106
|
+
.option("--format <fmt>", "yaml | md | json — overrides the configured default")
|
|
107
|
+
.action(async (opts) => {
|
|
108
|
+
const wsSlug = program.opts().workspace;
|
|
109
|
+
const cfg = getEffectiveConfig(wsSlug);
|
|
110
|
+
try {
|
|
111
|
+
const client = createClient(wsSlug);
|
|
112
|
+
const params = {};
|
|
113
|
+
if (opts.branch)
|
|
114
|
+
params.branch = opts.branch;
|
|
115
|
+
if (opts.depth)
|
|
116
|
+
params.depth = opts.depth;
|
|
117
|
+
const url = buildUrl(`/api/v1/code/${opts.project}/tree`, params, opts.format || cfg.format);
|
|
118
|
+
const res = await client.get(url);
|
|
119
|
+
await printResponse(res);
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
const e = err;
|
|
123
|
+
console.error(`Error: ${e.detail || "Failed to fetch code tree"}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// ── files: the files beneath one directory that carry symbols ───
|
|
128
|
+
code
|
|
129
|
+
.command("files [directory]")
|
|
130
|
+
.description("Files beneath a directory that carry symbols, most first (default directory: '.')")
|
|
131
|
+
.requiredOption("--project <id>", "Project id (board_groups.id where kind=project)")
|
|
132
|
+
.option("--direct", "Only files sitting directly in the directory, not beneath it")
|
|
133
|
+
.option("--branch <name>", "Answer from a specific indexed branch")
|
|
134
|
+
.option("--limit <n>", "Max files to return")
|
|
135
|
+
.option("--format <fmt>", "yaml | md | json — overrides the configured default")
|
|
136
|
+
.action(async (directory, opts) => {
|
|
137
|
+
const wsSlug = program.opts().workspace;
|
|
138
|
+
const cfg = getEffectiveConfig(wsSlug);
|
|
139
|
+
try {
|
|
140
|
+
const client = createClient(wsSlug);
|
|
141
|
+
const params = {};
|
|
142
|
+
// Only set `directory` if the user gave one. The API's default is `.`,
|
|
143
|
+
// so omitting it is a request for the whole repo — NOT a request for
|
|
144
|
+
// the literal string "undefined".
|
|
145
|
+
if (directory !== undefined)
|
|
146
|
+
params.directory = directory;
|
|
147
|
+
if (opts.direct)
|
|
148
|
+
params.direct = "true";
|
|
149
|
+
if (opts.branch)
|
|
150
|
+
params.branch = opts.branch;
|
|
151
|
+
if (opts.limit)
|
|
152
|
+
params.limit = opts.limit;
|
|
153
|
+
const url = buildUrl(`/api/v1/code/${opts.project}/files`, params, opts.format || cfg.format);
|
|
154
|
+
const res = await client.get(url);
|
|
155
|
+
await printResponse(res);
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
const e = err;
|
|
159
|
+
console.error(`Error: ${e.detail || "Failed to fetch code files"}`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
// ── symbols: every symbol in one file, in file order ─────────────
|
|
164
|
+
code
|
|
165
|
+
.command("symbols <file_path>")
|
|
166
|
+
.description("Every symbol in one file, in file order (no edges)")
|
|
167
|
+
.requiredOption("--project <id>", "Project id (board_groups.id where kind=project)")
|
|
168
|
+
.option("--branch <name>", "Answer from a specific indexed branch")
|
|
169
|
+
.option("--limit <n>", "Max symbols to return")
|
|
170
|
+
.option("--format <fmt>", "yaml | md | json — overrides the configured default")
|
|
171
|
+
.action(async (filePath, opts) => {
|
|
172
|
+
const wsSlug = program.opts().workspace;
|
|
173
|
+
const cfg = getEffectiveConfig(wsSlug);
|
|
174
|
+
try {
|
|
175
|
+
const client = createClient(wsSlug);
|
|
176
|
+
const params = { file_path: filePath };
|
|
177
|
+
if (opts.branch)
|
|
178
|
+
params.branch = opts.branch;
|
|
179
|
+
if (opts.limit)
|
|
180
|
+
params.limit = opts.limit;
|
|
181
|
+
const url = buildUrl(`/api/v1/code/${opts.project}/symbols`, params, opts.format || cfg.format);
|
|
182
|
+
const res = await client.get(url);
|
|
183
|
+
await printResponse(res);
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
const e = err;
|
|
187
|
+
console.error(`Error: ${e.detail || "Failed to fetch code symbols"}`);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
// ── resolve: text anchors to the current state of stable nodes ──
|
|
192
|
+
// The schema caps `anchors` at 1000. The cap is checked HERE, before any
|
|
193
|
+
// request, so a too-large batch fails locally (exit 1) and never spends a
|
|
194
|
+
// request slot on the server — the same locality a worker session needs
|
|
195
|
+
// (D5: a worker must not be able to spend a `code:write`, and by extension a
|
|
196
|
+
// 1000-anchor resolve that the server will refuse anyway).
|
|
197
|
+
const MAX_RESOLVE_ANCHORS = 1000;
|
|
198
|
+
code
|
|
199
|
+
.command("resolve <anchors...>")
|
|
200
|
+
.description("Resolve text anchors to the current state of stable code nodes (max 1000 anchors)")
|
|
201
|
+
.requiredOption("--project <id>", "Project id (board_groups.id where kind=project)")
|
|
202
|
+
.option("--format <fmt>", "yaml | md | json — overrides the configured default")
|
|
203
|
+
.action(async (anchors, opts) => {
|
|
204
|
+
if (anchors.length > MAX_RESOLVE_ANCHORS) {
|
|
205
|
+
console.error(`Error: too many anchors (${anchors.length}); max is ${MAX_RESOLVE_ANCHORS}`);
|
|
206
|
+
process.exit(1);
|
|
207
|
+
}
|
|
208
|
+
const wsSlug = program.opts().workspace;
|
|
209
|
+
const cfg = getEffectiveConfig(wsSlug);
|
|
210
|
+
try {
|
|
211
|
+
const client = createClient(wsSlug);
|
|
212
|
+
const url = buildUrl(`/api/v1/code/${opts.project}/nodes/resolve`, undefined, opts.format || cfg.format);
|
|
213
|
+
const res = await client.post(url, { anchors });
|
|
214
|
+
await printResponse(res);
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
const e = err;
|
|
218
|
+
console.error(`Error: ${e.detail || "Failed to resolve code nodes"}`);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
// ── changes: stable-node history feed (TCI-102, TCI-127) ─────────
|
|
223
|
+
// D47 (wave 2, TCI-122): the endpoint takes `node_id=` (repeatable, at most
|
|
224
|
+
// 100) and `path_prefix=` to scope history to one file or one subtree. The
|
|
225
|
+
// cap is enforced HERE, before any request, so a 101-id batch fails locally
|
|
226
|
+
// and never spends a request slot on the server (D5).
|
|
227
|
+
//
|
|
228
|
+
// `buildUrl` in `@opvs-ai/core` takes a flat record — it cannot send two
|
|
229
|
+
// `node_id=` parameters, because `Record<string, ...>` collapses repeated
|
|
230
|
+
// keys to the last value. Per the brief, the query string is built in this
|
|
231
|
+
// command instead. The `buildUrl` call still carries every single-valued
|
|
232
|
+
// param (`after`, `limit`, `path_prefix`, `format`); the repeated `node_id`
|
|
233
|
+
// values are appended by hand, one `node_id=<value>` per occurrence. The
|
|
234
|
+
// repeated keys are kept intact by `encodeURIComponent`.
|
|
235
|
+
const MAX_CHANGE_NODE_IDS = 100;
|
|
236
|
+
code
|
|
237
|
+
.command("changes")
|
|
238
|
+
.description("Stable-node history feed for the attached branch, oldest first")
|
|
239
|
+
.requiredOption("--project <id>", "Project id (board_groups.id where kind=project)")
|
|
240
|
+
.option("--after <id>", "Return events after this event id (cursor)")
|
|
241
|
+
.option("--limit <n>", "Max events to return (server max 500)")
|
|
242
|
+
.option("--node-id <id>", "Stable node UUID; repeat to select up to 100 nodes", (value, prev) => [...prev, value], [])
|
|
243
|
+
.option("--path-prefix <path>", "Repo-relative path; matches the file itself and its descendants")
|
|
244
|
+
.option("--format <fmt>", "yaml | md | json — overrides the configured default")
|
|
245
|
+
.action(async (opts) => {
|
|
246
|
+
const nodeIds = Array.isArray(opts.nodeId) ? opts.nodeId : [];
|
|
247
|
+
if (nodeIds.length > MAX_CHANGE_NODE_IDS) {
|
|
248
|
+
console.error(`Error: too many --node-id values (${nodeIds.length}); max is ${MAX_CHANGE_NODE_IDS}`);
|
|
249
|
+
process.exit(1);
|
|
250
|
+
}
|
|
251
|
+
const wsSlug = program.opts().workspace;
|
|
252
|
+
const cfg = getEffectiveConfig(wsSlug);
|
|
253
|
+
try {
|
|
254
|
+
const client = createClient(wsSlug);
|
|
255
|
+
const params = {};
|
|
256
|
+
if (opts.after)
|
|
257
|
+
params.after = opts.after;
|
|
258
|
+
if (opts.limit)
|
|
259
|
+
params.limit = opts.limit;
|
|
260
|
+
if (opts.pathPrefix)
|
|
261
|
+
params.path_prefix = opts.pathPrefix;
|
|
262
|
+
const url = buildUrl(`/api/v1/code/${opts.project}/nodes/changes`, params, opts.format || cfg.format);
|
|
263
|
+
const finalUrl = nodeIds.length > 0
|
|
264
|
+
? `${url}${url.includes("?") ? "&" : "?"}${nodeIds
|
|
265
|
+
.map((id) => `node_id=${encodeURIComponent(id)}`)
|
|
266
|
+
.join("&")}`
|
|
267
|
+
: url;
|
|
268
|
+
const res = await client.get(finalUrl);
|
|
269
|
+
await printResponse(res);
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
const e = err;
|
|
273
|
+
console.error(`Error: ${e.detail || "Failed to fetch code node changes"}`);
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
89
277
|
}
|
|
90
278
|
//# sourceMappingURL=code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/commands/code.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/commands/code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,UAAU,oBAAoB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O;qBAC7C,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC;qBAChD,IAAI,CAAC,GAAG,CAAC,EAAE;gBAChB,CAAC,CAAC,GAAG,CAAC;YACR,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACvC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,GAA0B,CAAC;YACrC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,IAAI,mCAAmC,EAAE,CAAC,CAAC;YAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Opt-in, local-first session capture for supported coding runtimes. */
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { type ContentState } from "../lib/redact.js";
|
|
4
|
+
type Runtime = "claude_code" | "cline" | "codex" | "cursor" | "opencode";
|
|
5
|
+
type HookName = "post-tool" | "stop" | "session-end";
|
|
6
|
+
type PluginRuntime = "cline" | "opencode";
|
|
7
|
+
type EventKind = "session.started" | "action" | "observation" | "message" | "error" | "session.completed";
|
|
8
|
+
export interface CaptureEvent {
|
|
9
|
+
id: string;
|
|
10
|
+
kind: EventKind;
|
|
11
|
+
index: number;
|
|
12
|
+
fidelity: "seen" | "guessed";
|
|
13
|
+
content_state: ContentState;
|
|
14
|
+
timestamp?: string;
|
|
15
|
+
data: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface CaptureState {
|
|
18
|
+
version: 1;
|
|
19
|
+
enabled: true;
|
|
20
|
+
token: string;
|
|
21
|
+
api_url: string;
|
|
22
|
+
brand_id: number | null;
|
|
23
|
+
codex_files: Record<string, number>;
|
|
24
|
+
}
|
|
25
|
+
export interface CapturePayload {
|
|
26
|
+
runtime: Runtime;
|
|
27
|
+
session_id: string;
|
|
28
|
+
events: CaptureEvent[];
|
|
29
|
+
}
|
|
30
|
+
interface FetchLike {
|
|
31
|
+
(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
32
|
+
}
|
|
33
|
+
export declare function loadCaptureState(): CaptureState | null;
|
|
34
|
+
export declare function saveCaptureState(state: CaptureState): void;
|
|
35
|
+
export declare function disableCapture(): void;
|
|
36
|
+
export declare function deterministicEventId(runtime: Runtime, sessionId: string, eventIndex: number, rawLine: string): string;
|
|
37
|
+
/** Map one Claude hook input. No field not named here can leave the machine. */
|
|
38
|
+
export declare function buildClaudeEvents(hook: HookName, input: Record<string, unknown>, options?: {
|
|
39
|
+
rawLine?: string;
|
|
40
|
+
redact?: boolean;
|
|
41
|
+
}): CapturePayload;
|
|
42
|
+
/** Map Cursor hook input conservatively; every semantic mapping is inferred. */
|
|
43
|
+
export declare function buildCursorEvents(hook: HookName, input: Record<string, unknown>, options?: {
|
|
44
|
+
rawLine?: string;
|
|
45
|
+
redact?: boolean;
|
|
46
|
+
}): CapturePayload | null;
|
|
47
|
+
/** Map an OpenCode or Cline hook conservatively; their semantics are inferred. */
|
|
48
|
+
export declare function buildPluginRuntimeEvent(runtime: PluginRuntime, hook: HookName, input: Record<string, unknown>, options?: {
|
|
49
|
+
rawLine?: string;
|
|
50
|
+
redact?: boolean;
|
|
51
|
+
}): CapturePayload | null;
|
|
52
|
+
/** Map one Codex session JSONL line using only documented message/tool fields. */
|
|
53
|
+
export declare function buildCodexEvent(sessionId: string, lineIndex: number, rawLine: string, redact?: boolean): CaptureEvent | null;
|
|
54
|
+
export declare function sendCapture(state: CaptureState, payload: CapturePayload, fetchImpl?: FetchLike): Promise<void>;
|
|
55
|
+
type AgentHookDependencies = {
|
|
56
|
+
loadState: typeof loadCaptureState;
|
|
57
|
+
send: typeof sendCapture;
|
|
58
|
+
readInput: () => Promise<string>;
|
|
59
|
+
};
|
|
60
|
+
export declare function runAgentHook(hook: HookName, dependencies?: Partial<AgentHookDependencies>, options?: {
|
|
61
|
+
runtime?: PluginRuntime;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
/** Find only the rollout belonging to this Codex thread. */
|
|
64
|
+
export declare function codexRolloutForThread(root: string, threadId: string): string | null;
|
|
65
|
+
type CodexNotifyDependencies = {
|
|
66
|
+
loadState: typeof loadCaptureState;
|
|
67
|
+
saveState: typeof saveCaptureState;
|
|
68
|
+
send: typeof sendCapture;
|
|
69
|
+
readInput: () => Promise<string>;
|
|
70
|
+
codexHome: () => string;
|
|
71
|
+
};
|
|
72
|
+
export declare function runCodexNotify(payload?: string, dependencies?: Partial<CodexNotifyDependencies>): Promise<void>;
|
|
73
|
+
export declare function enableCapture(workspace: string | undefined, suppliedToken: string | undefined, fetchImpl?: FetchLike): Promise<void>;
|
|
74
|
+
/** Add `hook ...` and `capture on|off` below an existing memory command. */
|
|
75
|
+
export declare function registerCaptureHooks(memory: Command): void;
|
|
76
|
+
export {};
|