@kirkchinese/harness-forge 0.4.0 → 0.5.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/README.md +4 -0
- package/docs/DETAIL.zh.md +47 -0
- package/lib/agents/presets.d.ts +7 -0
- package/lib/agents/presets.js +11 -1
- package/lib/agents/profiles.js +3 -2
- package/lib/agents/row.js +3 -1
- package/lib/client/paths.d.ts +12 -0
- package/lib/client/paths.js +68 -0
- package/lib/client/typert.d.ts +12 -1
- package/lib/client/typert.js +54 -6
- package/lib/client.js +1593 -270
- package/lib/commands/row.js +1 -1
- package/lib/context/instructions.js +5 -5
- package/lib/dsh/host.d.ts +3 -0
- package/lib/dsh/host.js +3 -0
- package/lib/forge/contract.d.ts +42 -2
- package/lib/forge/contract.js +3 -1
- package/lib/forge/follow.d.ts +30 -0
- package/lib/forge/follow.js +73 -0
- package/lib/forge/ledger.d.ts +70 -7
- package/lib/forge/ledger.js +314 -42
- package/lib/forge/projects.d.ts +5 -2
- package/lib/forge/projects.js +23 -16
- package/lib/forge/remote/archive.d.ts +65 -0
- package/lib/forge/remote/archive.js +565 -0
- package/lib/forge/remote/code-parts.d.ts +18 -0
- package/lib/forge/remote/code-parts.js +76 -0
- package/lib/forge/remote/fetch.d.ts +265 -0
- package/lib/forge/remote/fetch.js +1133 -0
- package/lib/forge/remote/service.d.ts +256 -0
- package/lib/forge/remote/service.js +868 -0
- package/lib/forge/service.d.ts +19 -9
- package/lib/forge/service.js +47 -31
- package/lib/forge/settings.d.ts +5 -3
- package/lib/forge/settings.js +11 -4
- package/lib/forge/state.d.ts +60 -0
- package/lib/forge/state.js +174 -58
- package/lib/hooks/broker/engine.js +2 -8
- package/lib/hooks/broker/session-events.d.ts +5 -0
- package/lib/hooks/broker/session-events.js +12 -3
- package/lib/hooks/broker/types.d.ts +7 -5
- package/lib/hooks/condition.d.ts +78 -2
- package/lib/hooks/condition.js +494 -73
- package/lib/hooks/config.d.ts +1 -1
- package/lib/hooks/config.js +4 -0
- package/lib/hooks/glob.d.ts +41 -0
- package/lib/hooks/glob.js +114 -0
- package/lib/hooks/permissions.d.ts +8 -3
- package/lib/hooks/permissions.js +119 -26
- package/lib/hooks/powershell-aliases.d.ts +19 -0
- package/lib/hooks/powershell-aliases.js +58 -0
- package/lib/hooks/process.d.ts +17 -0
- package/lib/hooks/process.js +156 -1
- package/lib/hooks/row.js +2 -0
- package/lib/hooks/runner.d.ts +17 -4
- package/lib/hooks/runner.js +42 -13
- package/lib/hooks/shell-commands.d.ts +10 -1
- package/lib/hooks/shell-commands.js +74 -10
- package/lib/hooks/shell.d.ts +3 -2
- package/lib/hooks/shell.js +5 -2
- package/lib/hooks/vocabulary.js +3 -1
- package/lib/mcp/catalog.d.ts +5 -2
- package/lib/mcp/catalog.js +18 -10
- package/lib/mcp/mount.d.ts +40 -2
- package/lib/mcp/mount.js +131 -31
- package/lib/mcp/policy.d.ts +42 -0
- package/lib/mcp/policy.js +43 -0
- package/lib/mcp/remote.js +5 -15
- package/lib/mcp/row.js +111 -17
- package/lib/mods/loader.js +4 -0
- package/lib/mods/service/turns.d.ts +8 -7
- package/lib/mods/service/turns.js +10 -35
- package/lib/opencode/bun.js +14 -2
- package/lib/opencode/row.d.ts +14 -1
- package/lib/opencode/row.js +38 -20
- package/lib/opencode/runtime/server.js +2 -1
- package/lib/porting/adapter-paths.d.ts +13 -0
- package/lib/porting/adapter-paths.js +120 -0
- package/lib/porting/port-gap.d.ts +10 -4
- package/lib/porting/port-gap.js +43 -7
- package/lib/porting/prompt.js +9 -7
- package/lib/porting/row.js +7 -5
- package/lib/porting/verify-port.d.ts +3 -10
- package/lib/porting/verify-port.js +12 -34
- package/lib/sessions/chat-import.d.ts +48 -0
- package/lib/sessions/chat-import.js +44 -0
- package/lib/sessions/claude.d.ts +16 -10
- package/lib/sessions/claude.js +76 -55
- package/lib/sessions/codex-discover.d.ts +34 -0
- package/lib/sessions/codex-discover.js +205 -0
- package/lib/sessions/codex-meta.d.ts +63 -0
- package/lib/sessions/codex-meta.js +148 -0
- package/lib/sessions/codex-text.d.ts +9 -0
- package/lib/sessions/codex-text.js +44 -0
- package/lib/sessions/codex.d.ts +34 -22
- package/lib/sessions/codex.js +150 -183
- package/lib/sessions/opencode.d.ts +15 -9
- package/lib/sessions/opencode.js +77 -58
- package/lib/sessions/persist.d.ts +162 -0
- package/lib/sessions/persist.js +377 -0
- package/lib/sessions/row.d.ts +2 -1
- package/lib/sessions/row.js +75 -9
- package/lib/sessions/turns.d.ts +31 -0
- package/lib/sessions/turns.js +63 -0
- package/lib/sessions/zstd.d.ts +15 -0
- package/lib/sessions/zstd.js +152 -0
- package/lib/shared/render.d.ts +30 -1
- package/lib/shared/render.js +813 -48
- package/lib/skills/provider.d.ts +2 -0
- package/lib/skills/provider.js +8 -2
- package/lib/skills/row.js +1 -1
- package/lib/workbench/adapter-coverage.d.ts +20 -2
- package/lib/workbench/adapter-coverage.js +46 -7
- package/lib/workbench/overview.d.ts +77 -27
- package/lib/workbench/overview.js +99 -12
- package/lib/workbench/remote.d.ts +64 -21
- package/lib/workbench/remote.js +181 -42
- package/lib/workbench/settings.d.ts +5 -1
- package/lib/workbench/settings.js +6 -2
- package/lib/workbench/workbench.d.ts +34 -4
- package/lib/workbench/workbench.js +147 -46
- package/locale/zh.json +2 -1
- package/package.json +3 -2
- package/lib/forge/marketplace-install.d.ts +0 -3
- package/lib/forge/marketplace-install.js +0 -64
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { type ArchiveSpec, type GitSpec, type NpmSpec } from '@kirkchinese/harness-forge-core';
|
|
2
|
+
import { type TreeLimits } from './archive.js';
|
|
3
|
+
/**
|
|
4
|
+
* One HTTP GET: connecting to `address` (checked already) for the URL's host,
|
|
5
|
+
* never resolving the name again; or, with `proxy`, through that proxy, which
|
|
6
|
+
* resolves it.
|
|
7
|
+
*/
|
|
8
|
+
export type PinnedFetch = (url: string, init: {
|
|
9
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
readonly address?: string;
|
|
12
|
+
readonly family?: 4 | 6;
|
|
13
|
+
readonly proxy?: string;
|
|
14
|
+
}) => Promise<Response>;
|
|
15
|
+
/** What Harness Forge reaches through a proxy, besides the configured npm registry and the hosts the person pasted: GitHub and npm. */
|
|
16
|
+
export declare const PROXY_HOSTS: ReadonlySet<string>;
|
|
17
|
+
/** The proxy git, npm and Harness Forge use for a URL, as they read the environment; undefined for a direct connection. */
|
|
18
|
+
export declare function proxyFor(url: URL): URL | undefined;
|
|
19
|
+
/** How a subprocess is run. */
|
|
20
|
+
export interface RunOptions {
|
|
21
|
+
readonly cwd?: string;
|
|
22
|
+
readonly timeoutMs: number;
|
|
23
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
24
|
+
/** Aborting kills the process. */
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/** Runs a program to its end and resolves with its stdout; a missing program rejects with `code: 'ENOENT'`. */
|
|
28
|
+
export type Runner = (command: string, args: readonly string[], options: RunOptions) => Promise<string>;
|
|
29
|
+
/** What the fetcher reaches outside the process: replaced in tests. */
|
|
30
|
+
export interface FetchDeps {
|
|
31
|
+
readonly fetch: PinnedFetch;
|
|
32
|
+
/** Runs `git`. */
|
|
33
|
+
readonly git: Runner;
|
|
34
|
+
/** Runs `npm` (as {@link npmLaunch} finds it). */
|
|
35
|
+
readonly npm: Runner;
|
|
36
|
+
/** The addresses a host name resolves to. */
|
|
37
|
+
readonly lookup: (host: string) => Promise<readonly string[]>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whose say-so a fetch is on: `user` for what the person pasted (any host they
|
|
41
|
+
* typed), `marketplace` for what a marketplace entry names (HTTPS to public
|
|
42
|
+
* addresses only).
|
|
43
|
+
*/
|
|
44
|
+
export type Trust = 'user' | 'marketplace';
|
|
45
|
+
/** One operation: its trust and its wall-clock bound, shared by every step of it. */
|
|
46
|
+
export interface FetchContext {
|
|
47
|
+
readonly trust: Trust;
|
|
48
|
+
readonly signal: AbortSignal;
|
|
49
|
+
readonly deadline: number;
|
|
50
|
+
/** Hosts the person pasted (lowercase): reached through a proxy besides {@link PROXY_HOSTS}, when the person's say-so counts. */
|
|
51
|
+
readonly userHosts: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/** Time and size bounds. */
|
|
54
|
+
export interface FetchLimits {
|
|
55
|
+
/** A git fetch, an archive download, an npm pack or install. */
|
|
56
|
+
readonly fetchMs: number;
|
|
57
|
+
/** A `git ls-remote`, a commit lookup or an `npm view`. */
|
|
58
|
+
readonly lookupMs: number;
|
|
59
|
+
/** One whole operation (opening a marketplace, preparing or installing a plugin), every step included. */
|
|
60
|
+
readonly operationMs: number;
|
|
61
|
+
/** A hosted `marketplace.json`. */
|
|
62
|
+
readonly jsonBytes: number;
|
|
63
|
+
readonly jsonMs: number;
|
|
64
|
+
/** An archive (a GitHub tarball, a zip source, an npm tarball). */
|
|
65
|
+
readonly archiveBytes: number;
|
|
66
|
+
/** What one git fetch or npm install may write, enforced while it runs. */
|
|
67
|
+
readonly tree: TreeLimits;
|
|
68
|
+
/** How often the size of what a subprocess writes is checked. */
|
|
69
|
+
readonly pollMs: number;
|
|
70
|
+
}
|
|
71
|
+
/** Claude Code's own bounds where it has them (120 s clone; 5 MiB / 10 s JSON; 256 MiB archives), a little more time for slow links. */
|
|
72
|
+
export declare const DEFAULT_LIMITS: FetchLimits;
|
|
73
|
+
/** A text with the credentials of any URL in it replaced (proxy passwords never reach a message). */
|
|
74
|
+
export declare function redact(text: string): string;
|
|
75
|
+
/** A text with every URL in it shown as {@link shown} shows one (for what git and npm write to stderr). */
|
|
76
|
+
export declare function scrub(text: string): string;
|
|
77
|
+
/** A URL as messages show it: no credentials, no query string (signed URLs), no fragment. */
|
|
78
|
+
export declare function shown(url: string | URL): string;
|
|
79
|
+
/**
|
|
80
|
+
* {@link PinnedFetch} over `http(s).request`: directly, its `lookup` answering
|
|
81
|
+
* with the address checked; or through a proxy, a CONNECT tunnel carrying TLS
|
|
82
|
+
* for https (the request is written on that socket alone, with no agent of its
|
|
83
|
+
* own), an absolute URL for http. No connection reuse. `ca` replaces the
|
|
84
|
+
* trusted certificates (tests).
|
|
85
|
+
*/
|
|
86
|
+
export declare function httpClient(options?: {
|
|
87
|
+
readonly ca?: string | Buffer;
|
|
88
|
+
}): PinnedFetch;
|
|
89
|
+
/** The machine's git, npm, HTTP and resolver. */
|
|
90
|
+
export declare const SYSTEM_DEPS: FetchDeps;
|
|
91
|
+
/** Whether an IP address is on the public internet. */
|
|
92
|
+
export declare function isPublicAddress(address: string): boolean;
|
|
93
|
+
/** A git checkout of one commit. */
|
|
94
|
+
export interface Checkout {
|
|
95
|
+
/** The repository root, as checked out. */
|
|
96
|
+
readonly dir: string;
|
|
97
|
+
readonly sha: string;
|
|
98
|
+
}
|
|
99
|
+
/** One npm package version as its registry describes it. */
|
|
100
|
+
export interface NpmVersion {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
/** An exact version. */
|
|
103
|
+
readonly version: string;
|
|
104
|
+
/** `sha512-…` of its tarball. */
|
|
105
|
+
readonly integrity: string;
|
|
106
|
+
/** The registry it is fetched from, with a trailing slash. */
|
|
107
|
+
readonly registry: string;
|
|
108
|
+
/** Its tarball, on the registry's origin. */
|
|
109
|
+
readonly tarball: string;
|
|
110
|
+
}
|
|
111
|
+
/** Fetches into `<root>/cache` (checkouts to browse and copy from) and the directories its callers name. */
|
|
112
|
+
export declare class RemoteFetcher {
|
|
113
|
+
readonly root: string;
|
|
114
|
+
private readonly deps;
|
|
115
|
+
readonly limits: FetchLimits;
|
|
116
|
+
private gitVersion;
|
|
117
|
+
constructor(root: string, deps?: FetchDeps, limits?: FetchLimits);
|
|
118
|
+
/** A new operation: every step taken with it shares its wall-clock bound. */
|
|
119
|
+
context(trust: Trust, userHosts?: readonly string[]): FetchContext;
|
|
120
|
+
/**
|
|
121
|
+
* Refuse a host Harness Forge may not reach through a proxy: GitHub and npm
|
|
122
|
+
* ({@link PROXY_HOSTS}), the configured npm registry, and (for what the
|
|
123
|
+
* person pasted, not what a marketplace names) the hosts they pasted.
|
|
124
|
+
*/
|
|
125
|
+
private allowProxied;
|
|
126
|
+
/** The same operation on another's say-so (an entry of a marketplace being read). */
|
|
127
|
+
static as(context: FetchContext, trust: Trust): FetchContext;
|
|
128
|
+
private remaining;
|
|
129
|
+
/**
|
|
130
|
+
* Run a subprocess within the operation's bound; with `watch`, the
|
|
131
|
+
* directory it writes is measured while it runs and the process killed
|
|
132
|
+
* once it is past the size bound.
|
|
133
|
+
*/
|
|
134
|
+
private run;
|
|
135
|
+
/** A host's addresses, within the operation's bound (and the lookup bound). */
|
|
136
|
+
private resolveHost;
|
|
137
|
+
/**
|
|
138
|
+
* The addresses of a host, refused (with `checked`) when any of them is not
|
|
139
|
+
* on the public internet or the name does not resolve.
|
|
140
|
+
*/
|
|
141
|
+
addresses(host: string, context: FetchContext, checked: boolean): Promise<readonly string[]>;
|
|
142
|
+
/** Refuse a URL the operation may not request: only https for a marketplace, http(s) for the person. */
|
|
143
|
+
private allowHttp;
|
|
144
|
+
/**
|
|
145
|
+
* Bytes of a URL, refused past `maxBytes` (declared or received) or
|
|
146
|
+
* `timeoutMs`. Each hop connects to the address checked for it; redirects
|
|
147
|
+
* are followed by hand and, wherever the first hop pointed, every later one
|
|
148
|
+
* must be a public address.
|
|
149
|
+
*/
|
|
150
|
+
download(url: string, maxBytes: number, timeoutMs: number, context: FetchContext, headers?: Record<string, string>): Promise<Buffer>;
|
|
151
|
+
/** A hosted JSON document (a `marketplace.json`, a registry document). */
|
|
152
|
+
json(url: string, context?: FetchContext, maxBytes?: number, accept?: string): Promise<Record<string, unknown>>;
|
|
153
|
+
/** Empty hooks, template and working directories and an empty global configuration: what git reads instead of this computer's. */
|
|
154
|
+
private isolation;
|
|
155
|
+
/** The environment git runs in: no `GIT_*` variable of this process, no system or global configuration, no prompts, no LFS downloads. */
|
|
156
|
+
private gitEnv;
|
|
157
|
+
/** git's version, asked once; undefined when git is not installed. */
|
|
158
|
+
private version;
|
|
159
|
+
/** Whether git is installed. */
|
|
160
|
+
hasGit(): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* Whether git may fetch `url` in this operation. For a marketplace's URL,
|
|
163
|
+
* git must connect to the addresses Harness Forge checked: that needs
|
|
164
|
+
* `http.curloptResolve` (git 2.37+) and no proxy resolving hosts instead;
|
|
165
|
+
* behind a proxy only github.com is fetched with git.
|
|
166
|
+
*/
|
|
167
|
+
private gitFor;
|
|
168
|
+
/**
|
|
169
|
+
* The `-c` options every git command for a URL runs with, and the URL as
|
|
170
|
+
* Harness Forge read it (what git is given): nothing of this computer's that
|
|
171
|
+
* runs code, only the URL's transport, no redirects, the proxy Harness Forge
|
|
172
|
+
* chose (or none), and for a marketplace HTTPS pinned to the public
|
|
173
|
+
* addresses checked.
|
|
174
|
+
*/
|
|
175
|
+
private gitOptions;
|
|
176
|
+
private runGit;
|
|
177
|
+
/** The commit a git source points at now: its pinned SHA, else its ref (or default branch) on the remote. */
|
|
178
|
+
latest(spec: GitSpec, context?: FetchContext): Promise<string>;
|
|
179
|
+
private gitRequired;
|
|
180
|
+
/** Where checkouts of one source (URL and directory) are kept. */
|
|
181
|
+
cacheDir(spec: GitSpec): string;
|
|
182
|
+
/**
|
|
183
|
+
* Check out a git source at `sha` (else at what it points at now) under the
|
|
184
|
+
* cache, reusing a checkout of that commit. A checkout is never replaced:
|
|
185
|
+
* one is made in a directory of its own and renamed into place; old ones are
|
|
186
|
+
* collected by the service between operations.
|
|
187
|
+
*/
|
|
188
|
+
checkout(spec: GitSpec, context?: FetchContext, sha?: string): Promise<Checkout>;
|
|
189
|
+
/** Fetch one commit (depth 1, no blobs but those checked out, only the plugin's directory) into an empty repository. */
|
|
190
|
+
private gitCheckout;
|
|
191
|
+
private tarballCheckout;
|
|
192
|
+
/**
|
|
193
|
+
* The registry npm is configured with, read without running npm:
|
|
194
|
+
* `npm_config_registry`, else the `registry=` line of the user's `.npmrc`,
|
|
195
|
+
* else npm's own. Per-scope registries and auth are not read.
|
|
196
|
+
*/
|
|
197
|
+
configuredRegistry(): string;
|
|
198
|
+
/** The registry an npm source is fetched from: the configured one, or one a marketplace names when it is npm's own or the configured one. */
|
|
199
|
+
registryOf(spec: NpmSpec): string;
|
|
200
|
+
/**
|
|
201
|
+
* The exact version an npm source names now (an exact version, or a
|
|
202
|
+
* dist-tag such as `latest`; not a range), with its tarball and integrity,
|
|
203
|
+
* read from the registry's document by Harness Forge itself.
|
|
204
|
+
*/
|
|
205
|
+
npmLatest(spec: NpmSpec, context?: FetchContext): Promise<NpmVersion>;
|
|
206
|
+
/**
|
|
207
|
+
* Download one package version's tarball (nothing else), check it against
|
|
208
|
+
* its integrity, and unpack it to `<dest>/package`. npm does not run.
|
|
209
|
+
* @returns the package directory and its `package.json`.
|
|
210
|
+
*/
|
|
211
|
+
npmFetch(pkg: NpmVersion, dest: string, context: FetchContext): Promise<{
|
|
212
|
+
dir: string;
|
|
213
|
+
manifest: Record<string, unknown>;
|
|
214
|
+
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Install a confirmed package's dependencies into `prefix` (its own
|
|
217
|
+
* `package.json` naming only them). The person confirmed the plugin, so its
|
|
218
|
+
* registry dependencies are trusted, as OpenCode installs plugins; still,
|
|
219
|
+
* install scripts do not run, npm's cache is inside `prefix` (in the size
|
|
220
|
+
* bound), and the resolved tree is refused when any package in it is not a
|
|
221
|
+
* tarball from the registry with an integrity.
|
|
222
|
+
*/
|
|
223
|
+
npmDependencies(prefix: string, dependencies: NpmDependencies, registry: string, context: FetchContext): Promise<void>;
|
|
224
|
+
/** Download and unpack a zip `archive` source into `dest`; its sha256 is the revision. */
|
|
225
|
+
archive(spec: ArchiveSpec, dest: string, context: FetchContext): Promise<{
|
|
226
|
+
root: string;
|
|
227
|
+
digest: string;
|
|
228
|
+
}>;
|
|
229
|
+
/** A directory inside `root`, or a failure naming the path that leaves it. */
|
|
230
|
+
static inside(root: string, path: string | undefined): string;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The lockfile version npm is told to write: 3, the default of npm 7 and
|
|
234
|
+
* later, holds only the `packages` map the audit reads (version 1 has none,
|
|
235
|
+
* so an audit of it would see nothing).
|
|
236
|
+
*/
|
|
237
|
+
export declare const NPM_LOCKFILE_VERSION = 3;
|
|
238
|
+
interface Lockfile {
|
|
239
|
+
readonly lockfileVersion?: unknown;
|
|
240
|
+
readonly packages?: Readonly<Record<string, {
|
|
241
|
+
readonly resolved?: unknown;
|
|
242
|
+
readonly integrity?: unknown;
|
|
243
|
+
readonly link?: unknown;
|
|
244
|
+
readonly inBundle?: unknown;
|
|
245
|
+
}>>;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Refuse a resolved dependency tree with any package that is not a registry
|
|
249
|
+
* tarball: a link (`file:`, `link:`, `workspace:`), a git or URL source, a
|
|
250
|
+
* tarball on another origin, or one without an integrity. Bundled packages
|
|
251
|
+
* come inside a registry tarball; `npm:` aliases resolve to registry tarballs
|
|
252
|
+
* like any other.
|
|
253
|
+
*/
|
|
254
|
+
export declare function refuseForeignPackages(lock: Lockfile, registry: string): void;
|
|
255
|
+
/** A package's dependencies to install, each a registry lookup. */
|
|
256
|
+
export interface NpmDependencies {
|
|
257
|
+
readonly dependencies: Readonly<Record<string, string>>;
|
|
258
|
+
readonly optionalDependencies: Readonly<Record<string, string>>;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* What a package declares to install with it, refused when any of it is not
|
|
262
|
+
* a registry lookup (git, GitHub, `file:`, `link:`, `workspace:`, a URL).
|
|
263
|
+
*/
|
|
264
|
+
export declare function dependenciesOf(manifest: Readonly<Record<string, unknown>>): NpmDependencies;
|
|
265
|
+
export {};
|