dsh-reference-anything 0.3.1 → 0.3.2
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/LICENSE +22 -22
- package/NOTICE.md +52 -25
- package/README.md +334 -285
- package/cordis.patch.yml +89 -18
- package/lib/client.js +13530 -517
- package/lib/contract.d.ts +155 -3
- package/lib/contract.js +68 -4
- package/lib/download-directory.d.ts +18 -0
- package/lib/download-directory.js +55 -0
- package/lib/errors.d.ts +4 -0
- package/lib/host.d.ts +96 -3
- package/lib/host.js +88 -5
- package/lib/index.d.ts +22 -2
- package/lib/index.js +57 -7
- package/lib/opencli.d.ts +5 -3
- package/lib/opencli.js +13 -6
- package/lib/openlist/host.d.ts +157 -0
- package/lib/openlist/host.js +873 -0
- package/lib/openlist/index.d.ts +84 -0
- package/lib/openlist/index.js +507 -0
- package/lib/render.d.ts +12 -7
- package/lib/render.js +27 -21
- package/lib/sources/cloud-drive/cache.d.ts +60 -0
- package/lib/sources/cloud-drive/cache.js +107 -0
- package/lib/sources/cloud-drive/index.d.ts +190 -0
- package/lib/sources/cloud-drive/index.js +526 -0
- package/lib/sources/cloud-drive/providers/http.d.ts +27 -0
- package/lib/sources/cloud-drive/providers/http.js +73 -0
- package/lib/sources/cloud-drive/providers/openlist.d.ts +59 -0
- package/lib/sources/cloud-drive/providers/openlist.js +535 -0
- package/lib/sources/cloud-drive/registry.d.ts +53 -0
- package/lib/sources/cloud-drive/registry.js +101 -0
- package/lib/sources/cloud-drive/types.d.ts +169 -0
- package/lib/sources/cloud-drive/types.js +17 -0
- package/lib/sources/file.d.ts +2 -0
- package/lib/sources/file.js +2 -0
- package/lib/sources/local-agent/adapters/claude-code.d.ts +16 -0
- package/lib/sources/local-agent/adapters/claude-code.js +171 -0
- package/lib/sources/local-agent/adapters/codex.d.ts +20 -0
- package/lib/sources/local-agent/adapters/codex.js +204 -0
- package/lib/sources/local-agent/adapters/cursor.d.ts +23 -0
- package/lib/sources/local-agent/adapters/cursor.js +121 -0
- package/lib/sources/local-agent/adapters/gemini-cli.d.ts +20 -0
- package/lib/sources/local-agent/adapters/gemini-cli.js +141 -0
- package/lib/sources/local-agent/adapters/grokbuild.d.ts +22 -0
- package/lib/sources/local-agent/adapters/grokbuild.js +76 -0
- package/lib/sources/local-agent/adapters/hermes.d.ts +19 -0
- package/lib/sources/local-agent/adapters/hermes.js +85 -0
- package/lib/sources/local-agent/adapters/kimi.d.ts +28 -0
- package/lib/sources/local-agent/adapters/kimi.js +261 -0
- package/lib/sources/local-agent/adapters/openclaw.d.ts +21 -0
- package/lib/sources/local-agent/adapters/openclaw.js +120 -0
- package/lib/sources/local-agent/adapters/opencode.d.ts +44 -0
- package/lib/sources/local-agent/adapters/opencode.js +236 -0
- package/lib/sources/local-agent/adapters/pi.d.ts +26 -0
- package/lib/sources/local-agent/adapters/pi.js +242 -0
- package/lib/sources/local-agent/adapters/qoder.d.ts +19 -0
- package/lib/sources/local-agent/adapters/qoder.js +93 -0
- package/lib/sources/local-agent/adapters/reasonix.d.ts +23 -0
- package/lib/sources/local-agent/adapters/reasonix.js +90 -0
- package/lib/sources/local-agent/adapters/shared.d.ts +163 -0
- package/lib/sources/local-agent/adapters/shared.js +415 -0
- package/lib/sources/local-agent/adapters/sqlite-shared.d.ts +92 -0
- package/lib/sources/local-agent/adapters/sqlite-shared.js +215 -0
- package/lib/sources/local-agent/adapters/zcode.d.ts +41 -0
- package/lib/sources/local-agent/adapters/zcode.js +159 -0
- package/lib/sources/local-agent/index.d.ts +222 -0
- package/lib/sources/local-agent/index.js +656 -0
- package/lib/sources/local-agent/page.d.ts +55 -0
- package/lib/sources/local-agent/page.js +83 -0
- package/lib/sources/local-agent/path.d.ts +8 -0
- package/lib/sources/local-agent/path.js +43 -0
- package/lib/sources/local-agent/registry.d.ts +68 -0
- package/lib/sources/local-agent/registry.js +116 -0
- package/lib/sources/local-agent/scan.d.ts +175 -0
- package/lib/sources/local-agent/scan.js +472 -0
- package/lib/sources/local-agent/sqlite.d.ts +45 -0
- package/lib/sources/local-agent/sqlite.js +113 -0
- package/lib/sources/local-agent/store.d.ts +93 -0
- package/lib/sources/local-agent/store.js +113 -0
- package/lib/sources/local-agent/types.d.ts +338 -0
- package/lib/sources/local-agent/types.js +20 -0
- package/lib/sources/web-chat/index.d.ts +5 -1
- package/lib/sources/web-chat/index.js +47 -8
- package/lib/store/spec.d.ts +50 -0
- package/lib/store/spec.js +2 -2
- package/lib/sync/index.d.ts +1 -0
- package/lib/sync/index.js +28 -8
- package/lib/tool.d.ts +5 -0
- package/lib/tool.js +418 -45
- package/lib/typert.js +13 -1
- package/lib/types.d.ts +28 -2
- package/lib/update.d.ts +6 -0
- package/lib/update.js +29 -1
- package/lib/web.js +5 -1
- package/lib/wire.d.ts +80 -0
- package/lib/wire.js +30 -1
- package/opencli-plugin/chatgpt.js +30 -27
- package/opencli-plugin/claude.js +12 -8
- package/opencli-plugin/common.js +266 -187
- package/opencli-plugin/deepseek.js +8 -5
- package/opencli-plugin/gemini.js +42 -38
- package/opencli-plugin/grok.js +22 -21
- package/opencli-plugin/kimi.js +34 -31
- package/opencli-plugin/opencli-plugin.json +6 -6
- package/opencli-plugin/package.json +8 -8
- package/package.json +200 -185
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference source over transcripts other coding agents leave on disk.
|
|
3
|
+
*
|
|
4
|
+
* Claude Code and Codex both write every session to a JSONL file under the home
|
|
5
|
+
* directory. Those files are the record of work the user already did, and until
|
|
6
|
+
* now the only way to bring one into a DSH session was to copy it in by hand.
|
|
7
|
+
* This registers them as referenceable items instead: the `@` menu lists them,
|
|
8
|
+
* and the body is read only when the model asks for it by reference.
|
|
9
|
+
*
|
|
10
|
+
* Reference-only by design. Nothing here writes into DSH's session store —
|
|
11
|
+
* importing a transcript is a different feature with different failure modes,
|
|
12
|
+
* and conflating the two would make every listed transcript a pending mutation.
|
|
13
|
+
*
|
|
14
|
+
* @module dsh-reference-anything/local-agent
|
|
15
|
+
*/
|
|
16
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
17
|
+
import z from '@deepseek-ai/schemastery';
|
|
18
|
+
import type { ReferenceRef, ReferenceSnapshot, ReferenceSource, ReferenceSummary, ReferenceWindow } from '../../types.ts';
|
|
19
|
+
import type { AgentKind, ToolCallMode } from './types.ts';
|
|
20
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
21
|
+
export declare const name = "reference-local-agent";
|
|
22
|
+
/** The services this source is built on. */
|
|
23
|
+
export declare const inject: string[];
|
|
24
|
+
/** Registry id, and the `source` half of every reference this source owns. */
|
|
25
|
+
export declare const LOCAL_AGENT_SOURCE_ID = "local-agent";
|
|
26
|
+
/** Deployment settings for the local agent source. */
|
|
27
|
+
export interface Config {
|
|
28
|
+
/** Agents whose default locations are searched. */
|
|
29
|
+
agents?: AgentKind[];
|
|
30
|
+
/** Extra directories to search, as `~/`-prefixed or absolute paths. */
|
|
31
|
+
extraRoots?: {
|
|
32
|
+
kind: AgentKind;
|
|
33
|
+
path: string;
|
|
34
|
+
}[];
|
|
35
|
+
/** Whether discovery is limited to transcripts recorded in this workspace. */
|
|
36
|
+
scope?: 'workspace' | 'all';
|
|
37
|
+
/** Transcripts a directory scan will consider. */
|
|
38
|
+
maxTranscripts?: number;
|
|
39
|
+
/** Turns one read may return, however many the caller asks for. */
|
|
40
|
+
maxReadTurns?: number;
|
|
41
|
+
/** Bytes a read may stream before falling back to a tail-anchored pass. */
|
|
42
|
+
maxScanBytes?: number;
|
|
43
|
+
/** Records wanted from the start of a transcript when probing for metadata. */
|
|
44
|
+
headLines?: number;
|
|
45
|
+
/** Records wanted from its end, where the newest title lives. */
|
|
46
|
+
tailLines?: number;
|
|
47
|
+
/** How far a probe may read chasing those records before giving up. */
|
|
48
|
+
maxProbeBytes?: number;
|
|
49
|
+
/** Longest single record that will be materialized; longer ones are skipped. */
|
|
50
|
+
maxLineBytes?: number;
|
|
51
|
+
/** How long one directory scan is reused across a typing burst. */
|
|
52
|
+
directoryTtlMs?: number;
|
|
53
|
+
/** Whether the model sees the other agent's reasoning. */
|
|
54
|
+
includeThinking?: boolean;
|
|
55
|
+
/** How a tool call and its result are projected into a turn. */
|
|
56
|
+
toolCalls?: ToolCallMode;
|
|
57
|
+
/** Whether subagent branches are projected alongside the main thread. */
|
|
58
|
+
includeSidechains?: boolean;
|
|
59
|
+
/** Whether harness-injected preambles are removed from user turns. */
|
|
60
|
+
stripEnvironmentPreamble?: boolean;
|
|
61
|
+
/** Whether the database-backed formats may be read at all. */
|
|
62
|
+
sqlite?: boolean;
|
|
63
|
+
/** Message rows one database read may materialize, counted from the end. */
|
|
64
|
+
maxSessionRecords?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Runtime schema for {@link Config}.
|
|
68
|
+
*
|
|
69
|
+
* Roots are `~/`-prefixed strings expanded against the process's own home
|
|
70
|
+
* rather than paths resolved at authoring time, so a profile written on one
|
|
71
|
+
* machine still points somewhere sensible on another — and so an external
|
|
72
|
+
* overlay describing them cannot smuggle in an evaluated expression.
|
|
73
|
+
*/
|
|
74
|
+
export declare const Config: z<Config>;
|
|
75
|
+
declare module '@deepseek-ai/cordis' {
|
|
76
|
+
interface Context {
|
|
77
|
+
referenceLocalAgents: LocalAgentService;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Lists and reads other agents' transcripts from the local filesystem. */
|
|
81
|
+
export declare class LocalAgentService extends Service implements ReferenceSource {
|
|
82
|
+
static inject: string[];
|
|
83
|
+
static Config: z<Config>;
|
|
84
|
+
readonly id = "local-agent";
|
|
85
|
+
/**
|
|
86
|
+
* Gated: these are other sessions' conversations, often from other projects.
|
|
87
|
+
* The model may read one only after its user named it.
|
|
88
|
+
*/
|
|
89
|
+
readonly requiresGrant = true;
|
|
90
|
+
private readonly settings;
|
|
91
|
+
private readonly adapters;
|
|
92
|
+
private roots;
|
|
93
|
+
private readonly convert;
|
|
94
|
+
private cache;
|
|
95
|
+
private store;
|
|
96
|
+
constructor(ctx: Context, config?: Config);
|
|
97
|
+
protected [Service.init](): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* @returns whether any configured root is a readable directory.
|
|
100
|
+
*/
|
|
101
|
+
available(): Promise<boolean>;
|
|
102
|
+
/** Replace UI-managed extra roots while retaining every deployment root. */
|
|
103
|
+
setAgentDirectories(directories: Partial<Record<AgentKind, string>>): void;
|
|
104
|
+
/** Count transcripts recognized by the current roots, grouped by format. */
|
|
105
|
+
stats(signal?: AbortSignal): Promise<Array<{
|
|
106
|
+
kind: AgentKind;
|
|
107
|
+
conversations: number;
|
|
108
|
+
}>>;
|
|
109
|
+
/**
|
|
110
|
+
* List transcripts whose title or opening prompt matches `query`.
|
|
111
|
+
*
|
|
112
|
+
* Matching never touches a transcript's body. Ranking on body text would
|
|
113
|
+
* require reading every candidate on a keystroke, and an excerpt of one would
|
|
114
|
+
* put a conversation the user has not named in front of the model — the same
|
|
115
|
+
* invariant the web-chat source holds.
|
|
116
|
+
* @param query - case-insensitive substring; empty means the most recent.
|
|
117
|
+
* @param limit - maximum items to return.
|
|
118
|
+
* @param signal - cancellation from the caller.
|
|
119
|
+
* @returns matching transcripts, most relevant first, at most `limit`.
|
|
120
|
+
*/
|
|
121
|
+
list(query: string, limit: number, signal?: AbortSignal): Promise<ReferenceSummary[]>;
|
|
122
|
+
/**
|
|
123
|
+
* The same discovery, for a caller that knows whose workspace it is asking on.
|
|
124
|
+
*
|
|
125
|
+
* {@link list} has nowhere to learn that from and falls back to the host
|
|
126
|
+
* process's own directory, which is right for a CLI started inside the project
|
|
127
|
+
* and wrong for a Web server serving sessions rooted anywhere on the machine.
|
|
128
|
+
* The `@` menu comes through here instead and passes the session's own cwd, so
|
|
129
|
+
* `scope: 'workspace'` means the user's workspace rather than the server's.
|
|
130
|
+
* @param query - case-insensitive substring; empty means the most recent.
|
|
131
|
+
* @param limit - maximum items to return.
|
|
132
|
+
* @param cwd - the asking session's working directory.
|
|
133
|
+
* @param signal - cancellation from the caller.
|
|
134
|
+
* @returns matching transcripts, most relevant first, at most `limit`.
|
|
135
|
+
*/
|
|
136
|
+
listForWorkspace(query: string, limit: number, cwd: string, signal?: AbortSignal): Promise<ReferenceSummary[]>;
|
|
137
|
+
private listIn;
|
|
138
|
+
/** Durable discovery policy. Reads stay independent so granted old refs work. */
|
|
139
|
+
private enabledAgentKinds;
|
|
140
|
+
/**
|
|
141
|
+
* Read one window of turns from a transcript.
|
|
142
|
+
* @param ref - a reference this source owns; `ref.id` is `kind:relPath`.
|
|
143
|
+
* @param window - which turns to return.
|
|
144
|
+
* @param signal - cancellation from the caller.
|
|
145
|
+
* @returns the requested turns and their position in the conversation.
|
|
146
|
+
*/
|
|
147
|
+
read(ref: ReferenceRef, window: ReferenceWindow, signal?: AbortSignal): Promise<ReferenceSnapshot>;
|
|
148
|
+
/**
|
|
149
|
+
* Read one window of turns out of a database-backed session.
|
|
150
|
+
*
|
|
151
|
+
* A database is not streamable the way a JSONL file is: there is no byte
|
|
152
|
+
* offset that means "the turn before this one", so the whole conversation is
|
|
153
|
+
* materialized under a record cap and then sliced. That is affordable for the
|
|
154
|
+
* same reason the cap exists — the cap is what bounds the memory, and it
|
|
155
|
+
* counts from the *end*, so the turns nearest the present are the ones kept.
|
|
156
|
+
* @param adapter - the adapter that knows this schema.
|
|
157
|
+
* @param descriptor - the database and session to read.
|
|
158
|
+
* @param sessionId - which conversation inside the database.
|
|
159
|
+
* @param limit - turns to return.
|
|
160
|
+
* @param before - exclusive upper bound in turn indices.
|
|
161
|
+
* @param signal - cancellation from the caller.
|
|
162
|
+
* @returns the same page shape a streamed read produces.
|
|
163
|
+
*/
|
|
164
|
+
private readSession;
|
|
165
|
+
/** Reuse one directory scan across a typing burst. */
|
|
166
|
+
private scan;
|
|
167
|
+
/**
|
|
168
|
+
* Drop bookmarks whose transcripts are gone, but only after a complete scan.
|
|
169
|
+
*
|
|
170
|
+
* A scan that hit `maxTranscripts` reports the newest files, not all of
|
|
171
|
+
* them. Treating that list as everything on disk would evict the bookmark of
|
|
172
|
+
* every older transcript that is still there, and each would be re-probed
|
|
173
|
+
* the next time it surfaced — turning a cap on listing into a cache that can
|
|
174
|
+
* never warm.
|
|
175
|
+
*/
|
|
176
|
+
private prune;
|
|
177
|
+
/**
|
|
178
|
+
* Pair each transcript with what is known about it, probing a bounded few.
|
|
179
|
+
*
|
|
180
|
+
* A transcript with no bookmark yet renders under a fallback label and is
|
|
181
|
+
* picked up by a later call, because probing all of them at once would put an
|
|
182
|
+
* unbounded read behind a keystroke.
|
|
183
|
+
*/
|
|
184
|
+
private describe;
|
|
185
|
+
/** Read a transcript's two ends and fold them into a bookmark. */
|
|
186
|
+
private probe;
|
|
187
|
+
private summarize;
|
|
188
|
+
/**
|
|
189
|
+
* Resolve a reference id to a transcript inside a configured root.
|
|
190
|
+
*
|
|
191
|
+
* Containment is checked against the resolved real path, so neither a `..`
|
|
192
|
+
* segment nor a symlink out of a root can reach a file the deployment never
|
|
193
|
+
* offered.
|
|
194
|
+
*/
|
|
195
|
+
private locate;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Register the local agent reference source.
|
|
199
|
+
* @param ctx - the mounting context.
|
|
200
|
+
* @param config - validated deployment settings.
|
|
201
|
+
*/
|
|
202
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
203
|
+
/** Compose the reference id from the two parts that identify a transcript. */
|
|
204
|
+
export declare function referenceId(kind: AgentKind, relPath: string): string;
|
|
205
|
+
/**
|
|
206
|
+
* Split a database-backed relative path into the file and the session in it.
|
|
207
|
+
*
|
|
208
|
+
* Only the last separator counts: a database's own filename is far more likely
|
|
209
|
+
* to contain a `#` than a session id is, and taking the last one keeps the id
|
|
210
|
+
* unambiguous either way.
|
|
211
|
+
* @param relPath - the relative path half of a reference id.
|
|
212
|
+
* @returns the database path and session id, or undefined when none was named.
|
|
213
|
+
*/
|
|
214
|
+
export declare function splitSession(relPath: string): {
|
|
215
|
+
relPath: string;
|
|
216
|
+
sessionId: string;
|
|
217
|
+
} | undefined;
|
|
218
|
+
/** Split a reference id back into its parts, or undefined when it is not one. */
|
|
219
|
+
export declare function parseReferenceId(id: string): {
|
|
220
|
+
kind: AgentKind;
|
|
221
|
+
relPath: string;
|
|
222
|
+
} | undefined;
|