@abelxiaoxing/cadence 2.0.38 → 2.0.41
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/docs/conversation-mode.md +31 -0
- package/docs/reuse-and-distribution.md +92 -0
- package/package.json +4 -3
- package/src/activity.ts +147 -0
- package/src/change-tools.mjs +45 -17
- package/src/index.ts +2 -0
- package/src/native-build.ts +1 -1
- package/src/operator-cli.mjs +4 -1
- package/src/research-tools.mjs +45 -419
- package/src/sdk-worker.mjs +5 -2
- package/src/service/activity-files.ts +190 -0
- package/src/service/coordination.ts +6 -3
- package/src/service-cli.mjs +26 -8
- package/src/service-host.mjs +5314 -4828
- package/src/worker-toolkit.mjs +31 -4
- package/src/workspace.ts +58 -1
- package/web/dist/assets/cadence.js +18 -18
- package/web/dist/manifest.json +5 -5
- package/src/research-scan.mjs +0 -393
|
@@ -227,12 +227,15 @@ export class ServiceCoordination {
|
|
|
227
227
|
readonly files: PrivateFiles;
|
|
228
228
|
readonly registryDirectory: string;
|
|
229
229
|
readonly stateHome: string;
|
|
230
|
-
/** null addresses only account
|
|
231
|
-
|
|
230
|
+
/** null addresses only the account registry. An already validated CheckoutStore
|
|
231
|
+
* lets registry observation retain the registered root without running Git. */
|
|
232
|
+
constructor(workspace: string | CheckoutStore | null, stateHome?: string) {
|
|
232
233
|
this.project =
|
|
233
234
|
workspace === null
|
|
234
235
|
? undefined
|
|
235
|
-
:
|
|
236
|
+
: workspace instanceof CheckoutStore
|
|
237
|
+
? workspace
|
|
238
|
+
: new CheckoutStore(resolveWorkspace(workspace).root, stateHome);
|
|
236
239
|
this.stateHome = this.project
|
|
237
240
|
? dirname(dirname(this.project.privateRoot))
|
|
238
241
|
: canonicalAmbientRoot(stateHome ?? defaultStateHome());
|
package/src/service-cli.mjs
CHANGED
|
@@ -1789,7 +1789,7 @@ function gitArguments(args) {
|
|
|
1789
1789
|
}
|
|
1790
1790
|
|
|
1791
1791
|
// src/workspace.ts
|
|
1792
|
-
import { spawnSync } from "node:child_process";
|
|
1792
|
+
import { execFile, spawnSync } from "node:child_process";
|
|
1793
1793
|
import { createHash } from "node:crypto";
|
|
1794
1794
|
import {
|
|
1795
1795
|
closeSync as closeSync2,
|
|
@@ -1918,6 +1918,9 @@ function resolveWorkspace(cwd) {
|
|
|
1918
1918
|
maxBuffer: 8192,
|
|
1919
1919
|
windowsHide: true
|
|
1920
1920
|
});
|
|
1921
|
+
return workspaceResult(actual, result);
|
|
1922
|
+
}
|
|
1923
|
+
function workspaceResult(actual, result) {
|
|
1921
1924
|
const topLevel = result.stdout?.replace(process.platform === "win32" ? /\r?\n$/ : /\n$/, "");
|
|
1922
1925
|
if (result.status === 0 && topLevel)
|
|
1923
1926
|
return { root: realpathSync(topLevel), cwd: actual };
|
|
@@ -3411,7 +3414,7 @@ class ServiceCoordination {
|
|
|
3411
3414
|
registryDirectory;
|
|
3412
3415
|
stateHome;
|
|
3413
3416
|
constructor(workspace, stateHome) {
|
|
3414
|
-
this.project = workspace === null ? undefined : new CheckoutStore(resolveWorkspace(workspace).root, stateHome);
|
|
3417
|
+
this.project = workspace === null ? undefined : workspace instanceof CheckoutStore ? workspace : new CheckoutStore(resolveWorkspace(workspace).root, stateHome);
|
|
3415
3418
|
this.stateHome = this.project ? dirname6(dirname6(this.project.privateRoot)) : canonicalAmbientRoot(stateHome ?? defaultStateHome());
|
|
3416
3419
|
const namespace = join6(this.stateHome, "cadence-assistant-v1");
|
|
3417
3420
|
this.files = new PrivateFiles(namespace);
|
|
@@ -7098,15 +7101,20 @@ function systemServiceStatus(s) {
|
|
|
7098
7101
|
}
|
|
7099
7102
|
|
|
7100
7103
|
// src/service/cli.ts
|
|
7101
|
-
function nativeCall(c, operation, reveal = false, controlBody) {
|
|
7104
|
+
function nativeCall(c, operation, reveal = false, controlBody, signal) {
|
|
7105
|
+
if (signal?.aborted)
|
|
7106
|
+
return Promise.reject(new ContractError("unavailable"));
|
|
7102
7107
|
const access = c.localAccess();
|
|
7103
7108
|
const url = new URL(`${access.endpoint}/local/v1/admin/${operation}`);
|
|
7104
|
-
const write2 = !["status", "diagnose"].includes(operation);
|
|
7109
|
+
const write2 = !["status", "diagnose", "activity"].includes(operation);
|
|
7110
|
+
const maximum = operation === "activity" ? 256 * 1024 : 16384;
|
|
7105
7111
|
const body = write2 ? JSON.stringify(controlBody ?? (reveal ? { reveal: true } : {})) : undefined;
|
|
7106
7112
|
return new Promise((resolve8, reject) => {
|
|
7107
7113
|
let timer;
|
|
7114
|
+
let removeAbort = () => {};
|
|
7108
7115
|
const fail = () => {
|
|
7109
7116
|
clearTimeout(timer);
|
|
7117
|
+
removeAbort();
|
|
7110
7118
|
reject(new ContractError("unavailable"));
|
|
7111
7119
|
};
|
|
7112
7120
|
const req = request(url, {
|
|
@@ -7126,7 +7134,7 @@ function nativeCall(c, operation, reveal = false, controlBody) {
|
|
|
7126
7134
|
res.on("error", fail);
|
|
7127
7135
|
res.on("data", (chunk) => {
|
|
7128
7136
|
bytes += chunk.length;
|
|
7129
|
-
if (bytes >
|
|
7137
|
+
if (bytes > maximum) {
|
|
7130
7138
|
res.destroy();
|
|
7131
7139
|
fail();
|
|
7132
7140
|
} else
|
|
@@ -7136,14 +7144,15 @@ function nativeCall(c, operation, reveal = false, controlBody) {
|
|
|
7136
7144
|
try {
|
|
7137
7145
|
if (res.statusCode !== 200)
|
|
7138
7146
|
throw new ContractError("unavailable");
|
|
7139
|
-
const reply = closed(parseWireJson(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)),
|
|
7147
|
+
const reply = closed(parseWireJson(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)), maximum), ["kind", "value"]);
|
|
7140
7148
|
if (reply.kind !== "ok")
|
|
7141
7149
|
throw new ContractError("unavailable");
|
|
7142
|
-
if (["status", "diagnose", "stop"].includes(operation)) {
|
|
7150
|
+
if (["status", "diagnose", "stop", "activity"].includes(operation)) {
|
|
7143
7151
|
if (!reply.value || typeof reply.value !== "object" || !("epoch" in reply.value) || reply.value.epoch !== access.epoch)
|
|
7144
7152
|
throw new ContractError("stale");
|
|
7145
7153
|
}
|
|
7146
7154
|
clearTimeout(timer);
|
|
7155
|
+
removeAbort();
|
|
7147
7156
|
resolve8(reply.value);
|
|
7148
7157
|
} catch {
|
|
7149
7158
|
fail();
|
|
@@ -7154,9 +7163,18 @@ function nativeCall(c, operation, reveal = false, controlBody) {
|
|
|
7154
7163
|
fail();
|
|
7155
7164
|
req.destroy();
|
|
7156
7165
|
}, 2000);
|
|
7166
|
+
const cancel = () => {
|
|
7167
|
+
fail();
|
|
7168
|
+
req.destroy();
|
|
7169
|
+
};
|
|
7170
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
7171
|
+
removeAbort = () => signal?.removeEventListener("abort", cancel);
|
|
7157
7172
|
req.on("error", fail);
|
|
7158
7173
|
req.on("close", fail);
|
|
7159
|
-
|
|
7174
|
+
if (signal?.aborted)
|
|
7175
|
+
cancel();
|
|
7176
|
+
else
|
|
7177
|
+
req.end(body);
|
|
7160
7178
|
});
|
|
7161
7179
|
}
|
|
7162
7180
|
var pause = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
|