greprag 5.32.0 → 5.34.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/dist/codex-hook-events.d.ts +20 -0
- package/dist/codex-hook-events.js +156 -0
- package/dist/codex-hook-events.js.map +1 -0
- package/dist/commands/codex-app-server.d.ts +1 -0
- package/dist/commands/codex-app-server.js +179 -0
- package/dist/commands/codex-app-server.js.map +1 -0
- package/dist/commands/codex-doctor.js +3 -1
- package/dist/commands/codex-doctor.js.map +1 -1
- package/dist/commands/codex.js +6 -0
- package/dist/commands/codex.js.map +1 -1
- package/dist/commands/corpus/index.d.ts +1 -0
- package/dist/commands/corpus/index.js +5 -0
- package/dist/commands/corpus/index.js.map +1 -1
- package/dist/commands/corpus/refresh.d.ts +1 -0
- package/dist/commands/corpus/refresh.js +60 -0
- package/dist/commands/corpus/refresh.js.map +1 -1
- package/dist/commands/desk-line.d.ts +36 -0
- package/dist/commands/desk-line.js +230 -0
- package/dist/commands/desk-line.js.map +1 -0
- package/dist/commands/init.js +75 -7
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/opencode-relay.d.ts +136 -0
- package/dist/commands/opencode-relay.js +529 -0
- package/dist/commands/opencode-relay.js.map +1 -0
- package/dist/commands/opencode-watch.d.ts +17 -0
- package/dist/commands/opencode-watch.js +493 -0
- package/dist/commands/opencode-watch.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.js +5 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/watcher-registry.d.ts +8 -0
- package/dist/commands/watcher-registry.js +19 -0
- package/dist/commands/watcher-registry.js.map +1 -1
- package/dist/hook.js +54 -83
- package/dist/hook.js.map +1 -1
- package/dist/index.js +220 -1
- package/dist/index.js.map +1 -1
- package/dist/opencode-plugin-helpers.d.ts +200 -0
- package/dist/opencode-plugin-helpers.js +512 -0
- package/dist/opencode-plugin-helpers.js.map +1 -0
- package/dist/opencode-plugin.d.ts +37 -134
- package/dist/opencode-plugin.js +648 -364
- package/dist/opencode-plugin.js.map +1 -1
- package/dist/session-id.d.ts +8 -6
- package/dist/session-id.js +10 -9
- package/dist/session-id.js.map +1 -1
- package/package.json +8 -4
|
@@ -6,15 +6,35 @@
|
|
|
6
6
|
* 2. Capture every completed (user, assistant) turn pair to /v1/memory/turn
|
|
7
7
|
* for episodic compaction.
|
|
8
8
|
*
|
|
9
|
-
* Loaded by
|
|
9
|
+
* Loaded by opencode from ~/.config/opencode/plugins/greprag-memory.js
|
|
10
10
|
* (installed by `greprag init --opencode`). All types are declared inline so
|
|
11
|
-
* the file has zero external runtime imports
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* the file has zero external runtime imports beyond the helpers module and
|
|
12
|
+
* Node built-ins — opencode's loader hands the compiled module straight to
|
|
13
|
+
* Bun with no resolution step against our dependency tree.
|
|
14
|
+
*
|
|
15
|
+
* adr: adr/opencode-monitor-relay.md — see entries 2026-06-06 (f) for the
|
|
16
|
+
* `export = { id, server }` rationale (single V1 plugin module, no
|
|
17
|
+
* `__esModule` wrapper, no `__test` helper export) and (g) for the recap
|
|
18
|
+
* renderer alignment with `greprag-hook` (single source of truth for the
|
|
19
|
+
* recap body pushed at session start), and (h) for the defensive
|
|
20
|
+
* `output.system` / optional-`sessionID` handling.
|
|
21
|
+
*
|
|
22
|
+
* Opencode SessionStart model:
|
|
23
|
+
* Opencode has no true SessionStart hook (confirmed against sst/opencode
|
|
24
|
+
* docs and corroborated by other plugins — Superpowers, codexfi,
|
|
25
|
+
* opencode-rules, context-mode — all of which use
|
|
26
|
+
* `experimental.chat.system.transform` as a turn-1 surrogate). The
|
|
27
|
+
* experimental hook fires before each LLM call; we push the recap on the
|
|
28
|
+
* first fire per session and skip later fires. This is a turn-1 model,
|
|
29
|
+
* not a true session-start model, but it's the closest opencode has and
|
|
30
|
+
* it's what other working plugins do.
|
|
14
31
|
*
|
|
15
32
|
* Hook surface used (verified against sst/opencode dev branch):
|
|
16
33
|
* - experimental.chat.system.transform — fires before each LLM call. We
|
|
17
|
-
* push recap text on the FIRST fire per sessionID and ignore later
|
|
34
|
+
* push recap text on the FIRST fire per sessionID and ignore later
|
|
35
|
+
* fires. Defensive: sessionID is optional (opencode issue #6142), and
|
|
36
|
+
* output.system may arrive as `string | string[]` depending on
|
|
37
|
+
* runtime/version — we handle both shapes.
|
|
18
38
|
* - event — receives every bus event. We listen for "message.updated" with
|
|
19
39
|
* role="assistant" and info.time.completed set (assistant message
|
|
20
40
|
* finalized), then fetch the session's full message list via the supplied
|
|
@@ -29,13 +49,19 @@ interface OpenCodeProject {
|
|
|
29
49
|
name?: string;
|
|
30
50
|
path?: string;
|
|
31
51
|
}
|
|
52
|
+
interface OpenCodeSession {
|
|
53
|
+
id: string;
|
|
54
|
+
directory?: string;
|
|
55
|
+
path?: string;
|
|
56
|
+
projectID?: string;
|
|
57
|
+
}
|
|
32
58
|
interface OpenCodeClient {
|
|
33
59
|
session: {
|
|
34
|
-
|
|
60
|
+
get: (args: {
|
|
35
61
|
path: {
|
|
36
62
|
id: string;
|
|
37
63
|
};
|
|
38
|
-
}) => Promise<
|
|
64
|
+
}) => Promise<OpenCodeSession>;
|
|
39
65
|
};
|
|
40
66
|
}
|
|
41
67
|
interface OpenCodePluginContext {
|
|
@@ -46,139 +72,16 @@ interface OpenCodePluginContext {
|
|
|
46
72
|
serverUrl: URL;
|
|
47
73
|
$: unknown;
|
|
48
74
|
}
|
|
49
|
-
interface UserInfo {
|
|
50
|
-
id: string;
|
|
51
|
-
sessionID: string;
|
|
52
|
-
role: 'user';
|
|
53
|
-
time: {
|
|
54
|
-
created: number;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
interface AssistantInfo {
|
|
58
|
-
id: string;
|
|
59
|
-
sessionID: string;
|
|
60
|
-
role: 'assistant';
|
|
61
|
-
parentID: string;
|
|
62
|
-
modelID: string;
|
|
63
|
-
providerID: string;
|
|
64
|
-
time: {
|
|
65
|
-
created: number;
|
|
66
|
-
completed?: number;
|
|
67
|
-
};
|
|
68
|
-
agent: string;
|
|
69
|
-
path: {
|
|
70
|
-
cwd: string;
|
|
71
|
-
root: string;
|
|
72
|
-
};
|
|
73
|
-
cost: number;
|
|
74
|
-
error?: unknown;
|
|
75
|
-
}
|
|
76
|
-
type MessageInfo = UserInfo | AssistantInfo;
|
|
77
|
-
interface WithParts {
|
|
78
|
-
info: MessageInfo;
|
|
79
|
-
parts: Part[];
|
|
80
|
-
}
|
|
81
|
-
interface TextPart {
|
|
82
|
-
type: 'text';
|
|
83
|
-
text: string;
|
|
84
|
-
synthetic?: boolean;
|
|
85
|
-
ignored?: boolean;
|
|
86
|
-
}
|
|
87
|
-
type ToolState = {
|
|
88
|
-
status: 'pending';
|
|
89
|
-
input: Record<string, unknown>;
|
|
90
|
-
} | {
|
|
91
|
-
status: 'running';
|
|
92
|
-
input: Record<string, unknown>;
|
|
93
|
-
title?: string;
|
|
94
|
-
} | {
|
|
95
|
-
status: 'completed';
|
|
96
|
-
input: Record<string, unknown>;
|
|
97
|
-
output: string;
|
|
98
|
-
title: string;
|
|
99
|
-
} | {
|
|
100
|
-
status: 'error';
|
|
101
|
-
input: Record<string, unknown>;
|
|
102
|
-
error: string;
|
|
103
|
-
};
|
|
104
|
-
interface ToolPart {
|
|
105
|
-
type: 'tool';
|
|
106
|
-
callID: string;
|
|
107
|
-
tool: string;
|
|
108
|
-
state: ToolState;
|
|
109
|
-
}
|
|
110
|
-
interface GenericPart {
|
|
111
|
-
type: string;
|
|
112
|
-
[key: string]: unknown;
|
|
113
|
-
}
|
|
114
|
-
type Part = TextPart | ToolPart | GenericPart;
|
|
115
|
-
interface BusEvent {
|
|
116
|
-
id?: string;
|
|
117
|
-
type: string;
|
|
118
|
-
properties: Record<string, unknown>;
|
|
119
|
-
}
|
|
120
75
|
type Hooks = {
|
|
121
76
|
'experimental.chat.system.transform'?: (input: {
|
|
122
|
-
sessionID
|
|
77
|
+
sessionID?: string;
|
|
123
78
|
model: unknown;
|
|
124
79
|
}, output: {
|
|
125
|
-
system: string[];
|
|
126
|
-
}) => Promise<void> | void;
|
|
127
|
-
event?: (input: {
|
|
128
|
-
event: BusEvent;
|
|
80
|
+
system: string | string[];
|
|
129
81
|
}) => Promise<void> | void;
|
|
130
82
|
};
|
|
131
|
-
interface ProjectAnchor {
|
|
132
|
-
projectId: string;
|
|
133
|
-
projectName: string;
|
|
134
|
-
memoryCapture: boolean;
|
|
135
|
-
sessionStartRecap: boolean;
|
|
136
|
-
inboxNotify: 'every_turn' | 'session_start_only' | 'off';
|
|
137
|
-
}
|
|
138
|
-
/** Resolve the project anchor for `worktree` using the same 4-level cascade
|
|
139
|
-
* the Claude Code CLI uses (packages/cli/src/project-anchor.ts). Settings
|
|
140
|
-
* always come from the nearest repo-level file when one exists, regardless
|
|
141
|
-
* of which identity level resolved.
|
|
142
|
-
*
|
|
143
|
-
* 1. Anchor file with explicit `project_id` → file-based identity
|
|
144
|
-
* 2. Git repo with at least one commit → root-commit-derived UUID
|
|
145
|
-
* 3. Ephemeral cwd + ~/.greprag/project.json exists → global anchor
|
|
146
|
-
* 4. Path-hash fallback (never returns null; lets capture flow until
|
|
147
|
-
* `greprag init` runs and `greprag doctor` consolidates) */
|
|
148
|
-
declare function readAnchor(worktree: string): ProjectAnchor;
|
|
149
|
-
declare function extractText(parts: Part[]): string;
|
|
150
|
-
interface ToolCallSummary {
|
|
151
|
-
name: string;
|
|
152
|
-
target?: string;
|
|
153
|
-
brief?: string;
|
|
154
|
-
}
|
|
155
|
-
/** Pull a one-line summary out of each tool call: name + a target string + an
|
|
156
|
-
* optional brief for shell commands. Mirrors the shape the Claude Code hook
|
|
157
|
-
* posts so server-side compaction sees identical structure regardless of
|
|
158
|
-
* client origin. */
|
|
159
|
-
declare function extractToolCalls(parts: Part[]): ToolCallSummary[];
|
|
160
|
-
declare function extractFilesTouched(parts: Part[]): string[];
|
|
161
|
-
type TurnProvenance = 'session-turn' | 'skill-injection' | 'continuation-summary' | 'chip-prompt';
|
|
162
|
-
interface Envelope {
|
|
163
|
-
userPrompt: string;
|
|
164
|
-
agentResponse: string;
|
|
165
|
-
toolCalls: ToolCallSummary[];
|
|
166
|
-
filesTouched: string[];
|
|
167
|
-
status: 'completed' | 'errored';
|
|
168
|
-
provenance: TurnProvenance;
|
|
169
|
-
}
|
|
170
|
-
declare function buildEnvelope(userParts: Part[], assistantParts: Part[], errored: boolean): Envelope;
|
|
171
|
-
declare const GrepRAGMemoryPlugin: (ctx: OpenCodePluginContext) => Promise<Hooks>;
|
|
172
83
|
declare const _default: {
|
|
173
|
-
server: (ctx: OpenCodePluginContext) => Promise<Hooks>;
|
|
174
84
|
id: string;
|
|
85
|
+
server: (ctx: OpenCodePluginContext) => Promise<Hooks>;
|
|
175
86
|
};
|
|
176
|
-
export
|
|
177
|
-
export { GrepRAGMemoryPlugin };
|
|
178
|
-
export declare const __test: {
|
|
179
|
-
extractText: typeof extractText;
|
|
180
|
-
extractToolCalls: typeof extractToolCalls;
|
|
181
|
-
extractFilesTouched: typeof extractFilesTouched;
|
|
182
|
-
buildEnvelope: typeof buildEnvelope;
|
|
183
|
-
readAnchor: typeof readAnchor;
|
|
184
|
-
};
|
|
87
|
+
export = _default;
|