@hy-sde-org/dsh-internal-urls 0.1.1-rc.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 +37 -0
- package/README.md +101 -0
- package/cordis.patch.yml +25 -0
- package/dist/conflict.d.ts +161 -0
- package/dist/conflict.d.ts.map +1 -0
- package/dist/conflict.js +625 -0
- package/dist/conflict.js.map +1 -0
- package/dist/gh.d.ts +63 -0
- package/dist/gh.d.ts.map +1 -0
- package/dist/gh.js +146 -0
- package/dist/gh.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +121 -0
- package/dist/index.js.map +1 -0
- package/dist/invariant.d.ts +16 -0
- package/dist/invariant.d.ts.map +1 -0
- package/dist/invariant.js +26 -0
- package/dist/invariant.js.map +1 -0
- package/dist/issue-pr.d.ts +96 -0
- package/dist/issue-pr.d.ts.map +1 -0
- package/dist/issue-pr.js +430 -0
- package/dist/issue-pr.js.map +1 -0
- package/dist/parse.d.ts +38 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +95 -0
- package/dist/parse.js.map +1 -0
- package/dist/router.d.ts +44 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +114 -0
- package/dist/router.js.map +1 -0
- package/dist/types.d.ts +151 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/examples/agent-preset/agent.cordis.yml +26 -0
- package/examples/agent-preset/preset.yml +3 -0
- package/package.json +104 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,EACb,MAAM,YAAY,CAAA;AAEnB;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAMhE;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAE9D,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,IAAI;IAU9C,+EAA+E;IAC/E,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAInC,2DAA2D;IAC3D,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIvD,+BAA+B;IAC/B,OAAO,IAAI,MAAM,EAAE;IAInB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAMjC,8DAA8D;IACxD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAYjF,4DAA4D;IACtD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlF,gGAAgG;IAC1F,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC;IAMxG,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,aAAa;CAItB"}
|
package/dist/router.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The internal-URL resolver registry: one handler per scheme, reachable by the
|
|
3
|
+
* read/grep/write tools as `ctx.internalUrls`. Handlers are stateless where
|
|
4
|
+
* possible; per-session shared state (ConflictHistory) lives in the service.
|
|
5
|
+
* @module @hy-sde-org/dsh-internal-urls/router
|
|
6
|
+
*/
|
|
7
|
+
import { parseInternalUrl, extractUriScheme, parseConflictReference } from "./parse.js";
|
|
8
|
+
/**
|
|
9
|
+
* Validates a handler registration: a non-empty alphabetic scheme, and a
|
|
10
|
+
* conflict with an existing registration is a programming error (each scheme
|
|
11
|
+
* may have exactly one handler).
|
|
12
|
+
*/
|
|
13
|
+
export function validateHandler(handler) {
|
|
14
|
+
const scheme = handler.scheme.toLowerCase();
|
|
15
|
+
if (!/^[a-z][a-z0-9+.-]*$/.test(handler.scheme)) {
|
|
16
|
+
throw new Error(`Internal URL handler: invalid scheme '${handler.scheme}'`);
|
|
17
|
+
}
|
|
18
|
+
return scheme;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One resolver registry. `register`/`unregister` manage the handler table;
|
|
22
|
+
* `canHandle` decides whether a model-supplied path routes away from the
|
|
23
|
+
* filesystem; `resolve`/`write` dispatch to the matching handler.
|
|
24
|
+
*/
|
|
25
|
+
export class InternalUrlRouter {
|
|
26
|
+
handlers = new Map();
|
|
27
|
+
/** Register (or replace) the handler for its scheme. Returns a disposer. */
|
|
28
|
+
register(handler) {
|
|
29
|
+
const scheme = validateHandler(handler);
|
|
30
|
+
const prior = this.handlers.get(scheme);
|
|
31
|
+
this.handlers.set(scheme, handler);
|
|
32
|
+
return () => {
|
|
33
|
+
if (this.handlers.get(scheme) === handler)
|
|
34
|
+
this.handlers.delete(scheme);
|
|
35
|
+
else if (prior !== undefined)
|
|
36
|
+
this.handlers.set(scheme, prior);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Remove the handler for `scheme`; returns false when none was registered. */
|
|
40
|
+
unregister(scheme) {
|
|
41
|
+
return this.handlers.delete(scheme.toLowerCase());
|
|
42
|
+
}
|
|
43
|
+
/** The registered handler for a scheme, or `undefined`. */
|
|
44
|
+
getHandler(scheme) {
|
|
45
|
+
return this.handlers.get(scheme.toLowerCase());
|
|
46
|
+
}
|
|
47
|
+
/** Every registered scheme. */
|
|
48
|
+
schemes() {
|
|
49
|
+
return [...this.handlers.keys()];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether `input` is a hierarchical `scheme://` URL (or the `<path>:conflict://`
|
|
53
|
+
* selector form) with a registered handler. This is the single gate the
|
|
54
|
+
* read/grep/write tools consult before touching the filesystem.
|
|
55
|
+
*/
|
|
56
|
+
canHandle(input) {
|
|
57
|
+
const scheme = extractUriScheme(input);
|
|
58
|
+
if (scheme !== undefined)
|
|
59
|
+
return this.handlers.has(scheme);
|
|
60
|
+
return parseConflictReference(input) !== null && this.handlers.has('conflict');
|
|
61
|
+
}
|
|
62
|
+
/** Resolve an internal URL through its registered handler. */
|
|
63
|
+
async resolve(input, context) {
|
|
64
|
+
const parsed = this.route(input);
|
|
65
|
+
const handler = this.handlers.get(parsed.scheme);
|
|
66
|
+
if (handler === undefined)
|
|
67
|
+
throw this.unknownScheme(parsed.scheme);
|
|
68
|
+
const resource = await handler.resolve(parsed, context);
|
|
69
|
+
return {
|
|
70
|
+
...resource,
|
|
71
|
+
// The router stamps immutability so handlers never encode the same fact twice.
|
|
72
|
+
immutable: resource.immutable ?? handler.immutable,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Write an internal URL through its registered handler. */
|
|
76
|
+
async write(input, content, context) {
|
|
77
|
+
const parsed = this.route(input);
|
|
78
|
+
const handler = this.handlers.get(parsed.scheme);
|
|
79
|
+
if (handler === undefined)
|
|
80
|
+
throw this.unknownScheme(parsed.scheme);
|
|
81
|
+
if (handler.write === undefined) {
|
|
82
|
+
throw new Error(`${parsed.scheme}:// URLs are read-only for write; use the protocol-specific tool for mutations.`);
|
|
83
|
+
}
|
|
84
|
+
await handler.write(parsed, content, context);
|
|
85
|
+
}
|
|
86
|
+
/** Candidate completions for `scheme://<query>`, or `null` when the scheme has no completer. */
|
|
87
|
+
async complete(scheme, query, context) {
|
|
88
|
+
const handler = this.handlers.get(scheme.toLowerCase());
|
|
89
|
+
if (handler?.complete === undefined)
|
|
90
|
+
return null;
|
|
91
|
+
return handler.complete(query, context);
|
|
92
|
+
}
|
|
93
|
+
route(input) {
|
|
94
|
+
let parsed = null;
|
|
95
|
+
try {
|
|
96
|
+
parsed = parseInternalUrl(input);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
parsed = parseConflictReference(input);
|
|
100
|
+
}
|
|
101
|
+
if (parsed === null || !this.handlers.has(parsed.scheme)) {
|
|
102
|
+
const scheme = extractUriScheme(input) ?? parsed?.scheme;
|
|
103
|
+
if (scheme === undefined)
|
|
104
|
+
throw new Error(`Not an internal URL: ${input}`);
|
|
105
|
+
throw this.unknownScheme(scheme);
|
|
106
|
+
}
|
|
107
|
+
return parsed;
|
|
108
|
+
}
|
|
109
|
+
unknownScheme(scheme) {
|
|
110
|
+
const available = this.schemes().map(candidate => `${candidate}://`).join(', ');
|
|
111
|
+
return new Error(`Unknown protocol: ${scheme}://\nSupported: ${available || 'none'}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAUvF;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAAwB;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAA;IAC3C,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,yCAAyC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAC7E,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IACX,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAA;IAE9D,4EAA4E;IAC5E,QAAQ,CAAC,OAAwB;QAC/B,MAAM,MAAM,GAAG,eAAe,C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,KAAK,SAAS;YAAE,OAAO,IAAI,CAAA;QAChD,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;IAEO,KAAK,CAAC,KAAa;QACzB,IAAI,MAAM,GAA6B,IAAI,CAAA;QAC3C,IAAI,CAAC;YACH,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC;QACD,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACzD,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,MAAM,EAAE,MAAM,CAAA;YACxD,IAAI,MAAM,KAAK,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAA;YAC1E,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,aAAa,CAAC,MAAc;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/E,OAAO,IAAI,KAAK,CAAC,qBAAqB,MAAM,mBAAmB,SAAS,IAAI,MAAM,EAAE,CAAC,CAAA;IACvF,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vocabulary for the internal-URL routing system: FS-shaped `scheme://` URLs
|
|
3
|
+
* (`conflict://`, `pr://`, `issue://`, …) resolved by the read/grep/write
|
|
4
|
+
* tools through one resolver registry (`ctx.internalUrls`).
|
|
5
|
+
*
|
|
6
|
+
* A handler resolves a parsed internal URL to an {@link InternalResource}
|
|
7
|
+
* (text content plus optional backing-file materialization), and may opt into
|
|
8
|
+
* write dispatch so the write tool can mutate remote/meta surfaces instead of
|
|
9
|
+
* a literal file.
|
|
10
|
+
* @module @hy-sde-org/dsh-internal-urls/types
|
|
11
|
+
*/
|
|
12
|
+
/** MIME tags the model-facing text may claim. */
|
|
13
|
+
export type InternalContentType = 'text/markdown' | 'application/json' | 'text/plain';
|
|
14
|
+
/**
|
|
15
|
+
* Raw resource payload returned by protocol handlers. The `immutable` flag is
|
|
16
|
+
* applied by the router from {@link ProtocolHandler.immutable}, so handlers do
|
|
17
|
+
* not need to set it themselves.
|
|
18
|
+
*/
|
|
19
|
+
export interface InternalResource {
|
|
20
|
+
/** Canonical URL that was resolved. */
|
|
21
|
+
url: string;
|
|
22
|
+
/** Resolved text content. */
|
|
23
|
+
content: string;
|
|
24
|
+
/** MIME type of `content`. */
|
|
25
|
+
contentType: InternalContentType;
|
|
26
|
+
/** Content size in bytes, when known. */
|
|
27
|
+
size?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Underlying filesystem path, when the resource is backed by a local file
|
|
30
|
+
* (e.g. a future `local://`). The agent-facing display stays `url`; the path
|
|
31
|
+
* is for materializing edits and searches.
|
|
32
|
+
*/
|
|
33
|
+
sourcePath?: string;
|
|
34
|
+
/** Additional notes about resolution, rendered below the content. */
|
|
35
|
+
notes?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* True when the resolved content cannot be edited by the agent (sealed
|
|
38
|
+
* artifacts, harness docs, machine-generated summaries). Mutable resources
|
|
39
|
+
* (conflict regions) behave like editable files.
|
|
40
|
+
*/
|
|
41
|
+
immutable?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* True when the resource is a directory listing rather than file content.
|
|
44
|
+
* `grep` refuses such a resource without a `sourcePath`.
|
|
45
|
+
*/
|
|
46
|
+
isDirectory?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A single autocomplete candidate for the host/path portion of a `scheme://`
|
|
50
|
+
* URL, produced by {@link ProtocolHandler.complete}.
|
|
51
|
+
*/
|
|
52
|
+
export interface UrlCompletion {
|
|
53
|
+
/** The text that follows `scheme://` for this candidate. */
|
|
54
|
+
value: string;
|
|
55
|
+
/** Human-facing label for the dropdown; defaults to {@link value}. */
|
|
56
|
+
label?: string;
|
|
57
|
+
/** Optional one-line description shown beside the candidate. */
|
|
58
|
+
description?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A parsed internal URL (`scheme://host/path?query`). Keeps the raw segments
|
|
62
|
+
* before URL normalization so numeric hosts, casing, and traversal markers
|
|
63
|
+
* survive, and carries the exact input string for byte-exact matching.
|
|
64
|
+
*/
|
|
65
|
+
export interface ParsedInternalUrl {
|
|
66
|
+
/** Scheme without the `:` (already lowercased), e.g. `conflict`, `pr`. */
|
|
67
|
+
scheme: string;
|
|
68
|
+
/** Raw host segment exactly as typed (case preserved, no normalization). */
|
|
69
|
+
rawHost: string;
|
|
70
|
+
/** Raw pathname exactly as typed (leading `/` preserved, no normalization). */
|
|
71
|
+
rawPathname: string;
|
|
72
|
+
/**
|
|
73
|
+
* Decoded non-empty path segments following the leading slash. Rejects
|
|
74
|
+
* empty, `.`, and `..` segments.
|
|
75
|
+
*/
|
|
76
|
+
pathSegments: string[];
|
|
77
|
+
/** Query parameters under `?…` (empty when the input carries none). */
|
|
78
|
+
searchParams: URLSearchParams;
|
|
79
|
+
/** Normalized href (`new URL(input).href`). */
|
|
80
|
+
href: string;
|
|
81
|
+
/** The exact input string, before any normalization. */
|
|
82
|
+
rawHref: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Caller-supplied context threaded into handlers so schemes that resolve
|
|
86
|
+
* against the calling session (default repo, conflict history, cwd-relative
|
|
87
|
+
* files) act on the session that initiated the read/write, never the first
|
|
88
|
+
* session to register.
|
|
89
|
+
*/
|
|
90
|
+
export interface ResolveContext {
|
|
91
|
+
/** Working directory of the calling session. */
|
|
92
|
+
cwd?: string;
|
|
93
|
+
/** The caller's abort signal. */
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
/**
|
|
96
|
+
* Opaque per-session key used for session-scoped handler state (e.g.
|
|
97
|
+
* {@link module:@hy-sde-org/dsh-internal-urls/conflict ConflictHistory}).
|
|
98
|
+
*/
|
|
99
|
+
sessionKey?: string;
|
|
100
|
+
/**
|
|
101
|
+
* When set, handlers that would otherwise materialize expensive content may
|
|
102
|
+
* return the resource shape with `content` empty — callers that only need
|
|
103
|
+
* `sourcePath` (search) pass this so a large resource still resolves without
|
|
104
|
+
* buffering it.
|
|
105
|
+
*/
|
|
106
|
+
pathOnly?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/** Caller context for write dispatch to host-owned URI handlers. */
|
|
109
|
+
export interface WriteContext {
|
|
110
|
+
/** Working directory of the calling session. */
|
|
111
|
+
cwd?: string;
|
|
112
|
+
/** The caller's abort signal. */
|
|
113
|
+
signal?: AbortSignal;
|
|
114
|
+
/** Opaque per-session key — see {@link ResolveContext.sessionKey}. */
|
|
115
|
+
sessionKey?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Opaque per-call sandbox policy (the write tool's resolved mode + workspace
|
|
118
|
+
* root) forwarded so a handler that mutates a backing file keeps the same
|
|
119
|
+
* confinement semantics as a plain `write` call. Opaque here; the handler's
|
|
120
|
+
* file bridge applies it when calling `ctx.fs`.
|
|
121
|
+
*/
|
|
122
|
+
sandboxPolicy?: unknown;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A handler for a specific internal URL scheme (e.g. `conflict://`, `pr://`).
|
|
126
|
+
*/
|
|
127
|
+
export interface ProtocolHandler {
|
|
128
|
+
/** The scheme without trailing `://` (e.g. `conflict`). */
|
|
129
|
+
readonly scheme: string;
|
|
130
|
+
/**
|
|
131
|
+
* Whether resources produced by this handler are immutable (never editable
|
|
132
|
+
* by the agent). `true` suppresses write affordances; `false` marks the
|
|
133
|
+
* resource as writable (e.g. conflict regions).
|
|
134
|
+
*/
|
|
135
|
+
readonly immutable: boolean;
|
|
136
|
+
/** Resolve an internal URL to its content. Throws a user-friendly error on failure. */
|
|
137
|
+
resolve(url: ParsedInternalUrl, context?: ResolveContext): Promise<InternalResource>;
|
|
138
|
+
/**
|
|
139
|
+
* Optional write hook. When present, the write tool dispatches
|
|
140
|
+
* `write(url, content)` here instead of writing to a filesystem path.
|
|
141
|
+
* Handlers that omit it are read-only.
|
|
142
|
+
*/
|
|
143
|
+
write?(url: ParsedInternalUrl, content: string, context?: WriteContext): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Optional autocomplete hook — candidate completions for the host/path
|
|
146
|
+
* portion of a `scheme://` URL. Must be fast and local; omitted by network
|
|
147
|
+
* backed schemes.
|
|
148
|
+
*/
|
|
149
|
+
complete?(query?: string, context?: ResolveContext): Promise<UrlCompletion[]>;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,iDAAiD;AACjD,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG,kBAAkB,GAAG,YAAY,CAAA;AAErF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,8BAA8B;IAC9B,WAAW,EAAE,mBAAmB,CAAA;IAChC,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;OAGG;IAC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AO,CAAA;IAC3B,uFAAuF;IACvF,OAAO,CAAC,GAAG,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACpF;;;;OAIG;IACH,KAAK,CAAC,CAAC,GAAG,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtF;;;;OAIG;IACH,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;CAC9E"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vocabulary for the internal-URL routing system: FS-shaped `scheme://` URLs
|
|
3
|
+
* (`conflict://`, `pr://`, `issue://`, …) resolved by the read/grep/write
|
|
4
|
+
* tools through one resolver registry (`ctx.internalUrls`).
|
|
5
|
+
*
|
|
6
|
+
* A handler resolves a parsed internal URL to an {@link InternalResource}
|
|
7
|
+
* (text content plus optional backing-file materialization), and may opt into
|
|
8
|
+
* write dispatch so the write tool can mutate remote/meta surfaces instead of
|
|
9
|
+
* a literal file.
|
|
10
|
+
* @module @hy-sde-org/dsh-internal-urls/types
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# User agent preset for @hy-sde-org/dsh-internal-urls on OFFICIAL DeepSeek
|
|
2
|
+
# Harness releases (dsh-v0.1.1-rc.2 and later).
|
|
3
|
+
#
|
|
4
|
+
# Install: copy this directory to ~/.dsh/.agent-presets/<id>/ (pick any id),
|
|
5
|
+
# then select the preset in the Web UI preset picker (or `dsh agent` CLI).
|
|
6
|
+
# All three packages must be installed (`dsh plugin add`) so these rows
|
|
7
|
+
# resolve; the `internal-urls` SERVICE row is added host-wide by the bundle.
|
|
8
|
+
#
|
|
9
|
+
# These rows mount the ROUTING `read`/`write`/`edit` (dsh-tool-fs-internal-urls)
|
|
10
|
+
# and `grep` (dsh-tool-fs-search-internal-urls) — fork builds of the harness
|
|
11
|
+
# tool packages that resolve conflict://, issue://, pr:// etc. through the
|
|
12
|
+
# host registry and behave exactly like the stock tools on plain filesystem
|
|
13
|
+
# paths. Agent-scope shadowing makes them THE read/write/grep for this
|
|
14
|
+
# session; the deployment's stock read/write/grep keep serving other scopes.
|
|
15
|
+
#
|
|
16
|
+
# Copy any other rows from the preset you normally use (persona, bash, todo,
|
|
17
|
+
# ask-user, skills, ...) next to these; only the two filesystem rows are
|
|
18
|
+
# special. `sampleOverCapGlobResults` is a required tool-fs-search config.
|
|
19
|
+
|
|
20
|
+
- id: tool-fs-internal-urls
|
|
21
|
+
name: '@hy-sde-org/dsh-tool-fs-internal-urls'
|
|
22
|
+
|
|
23
|
+
- id: tool-fs-search-internal-urls
|
|
24
|
+
name: '@hy-sde-org/dsh-tool-fs-search-internal-urls'
|
|
25
|
+
config:
|
|
26
|
+
sampleOverCapGlobResults: false
|
package/package.json
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hy-sde-org/dsh-internal-urls",
|
|
3
|
+
"version": "0.1.1-rc.2",
|
|
4
|
+
"description": "FS-shaped internal URL schemes (conflict://, pr://, issue://, …) resolved through one registry behind the read/grep/write tools — a standalone service plugin for DeepSeek Harness with no upstream harness changes required.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./parse": {
|
|
14
|
+
"types": "./dist/parse.d.ts",
|
|
15
|
+
"default": "./dist/parse.js"
|
|
16
|
+
},
|
|
17
|
+
"./types": {
|
|
18
|
+
"types": "./dist/types.d.ts",
|
|
19
|
+
"default": "./dist/types.js"
|
|
20
|
+
},
|
|
21
|
+
"./router": {
|
|
22
|
+
"types": "./dist/router.d.ts",
|
|
23
|
+
"default": "./dist/router.js"
|
|
24
|
+
},
|
|
25
|
+
"./conflict": {
|
|
26
|
+
"types": "./dist/conflict.d.ts",
|
|
27
|
+
"default": "./dist/conflict.js"
|
|
28
|
+
},
|
|
29
|
+
"./gh": {
|
|
30
|
+
"types": "./dist/gh.d.ts",
|
|
31
|
+
"default": "./dist/gh.js"
|
|
32
|
+
},
|
|
33
|
+
"./issue-pr": {
|
|
34
|
+
"types": "./dist/issue-pr.d.ts",
|
|
35
|
+
"default": "./dist/issue-pr.js"
|
|
36
|
+
},
|
|
37
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"cordis.patch.yml",
|
|
43
|
+
"examples/agent-preset/agent.cordis.yml",
|
|
44
|
+
"examples/agent-preset/preset.yml",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=22.19.0"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/hy-sde/dsh-internal-urls.git"
|
|
57
|
+
},
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"dsh": {
|
|
60
|
+
"bundle": {
|
|
61
|
+
"patch": "./cordis.patch.yml"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@deepseek-ai/dsh-fs": "^0.1.1-rc.2"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
69
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
70
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.1-rc.2",
|
|
71
|
+
"@deepseek-ai/dsh-subprocess": "^0.1.1-rc.2"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
75
|
+
"@deepseek-ai/dsh-fs": "^0.1.1-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
77
|
+
"@deepseek-ai/dsh-llm": "^0.1.1-rc.2",
|
|
78
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.1-rc.2",
|
|
79
|
+
"@deepseek-ai/dsh-subprocess": "^0.1.1-rc.2",
|
|
80
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.2",
|
|
81
|
+
"@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
|
|
82
|
+
"@types/node": "^24.0.0",
|
|
83
|
+
"typescript": "^5.9.3",
|
|
84
|
+
"vitest": "^3.2.7",
|
|
85
|
+
"@hy-sde-org/dsh-tool-fs-internal-urls": "0.1.1-rc.2"
|
|
86
|
+
},
|
|
87
|
+
"keywords": [
|
|
88
|
+
"deepseek",
|
|
89
|
+
"agent",
|
|
90
|
+
"harness",
|
|
91
|
+
"dsh-plugin",
|
|
92
|
+
"internal-urls",
|
|
93
|
+
"conflict",
|
|
94
|
+
"github",
|
|
95
|
+
"pr",
|
|
96
|
+
"issue"
|
|
97
|
+
],
|
|
98
|
+
"scripts": {
|
|
99
|
+
"clean": "rm -rf dist",
|
|
100
|
+
"build": "tsc -p tsconfig.build.json",
|
|
101
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
102
|
+
"test": "vitest run"
|
|
103
|
+
}
|
|
104
|
+
}
|