@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
|
@@ -205,3 +205,34 @@ A parent session may record a whole batch of tool results together, so those tim
|
|
|
205
205
|
Long workflows retain earlier steps in readonly pages rather than stopping at a step count.
|
|
206
206
|
Open **Earlier workflow steps** in the WebUI, **Earlier steps** in native history, or use `cadence_status` with the returned `stepsBefore` as `before`.
|
|
207
207
|
Route revisions and failed attempts remain visible; a later successful attempt never rewrites their original outcomes.
|
|
208
|
+
|
|
209
|
+
## Discover active Pi work
|
|
210
|
+
|
|
211
|
+
The unified WebUI sidebar automatically lists active work in this account and state home, including projects you have never selected.
|
|
212
|
+
An interactive terminal must load the Cadence extension: a real model/tool round appears even without `/cadence`, but an idle terminal or idle owner does not.
|
|
213
|
+
Terminal rounds are observe-only; owner turns and workflows retain their actual queue, execution, recovery and settlement phases and existing authorized controls.
|
|
214
|
+
The counts deduplicate projects and sessions, while separate terminal instances and owner work keep their own sources.
|
|
215
|
+
|
|
216
|
+
Click an activity to remember its directory and read the shared Pi session at the observed branch.
|
|
217
|
+
This does not start or associate an owner, grant execution consent or expand workbench Stop.
|
|
218
|
+
If Pi has not flushed its first session file, the page says history is not yet readable; it never invents messages or treats that session as a new draft.
|
|
219
|
+
A different session-directory configuration can leave an activity visible but its history unavailable; Cadence never follows an arbitrary reported session path.
|
|
220
|
+
A fixed observed branch stays fixed until you choose another branch; background discovery cannot take over your open page.
|
|
221
|
+
|
|
222
|
+
Finished activity leaves the list without closing its history page.
|
|
223
|
+
Lost or partial observations are explicitly stale/unknown, not evidence of success or completion; uncertain rows have a short retention window.
|
|
224
|
+
This discovers neither idle terminals nor other accounts/hosts, and does not provide remote control of ordinary CLI Pi.
|
|
225
|
+
|
|
226
|
+
## Investigating installed packages
|
|
227
|
+
|
|
228
|
+
Cadence research, diagnosis and review remain readonly, but their search roots are defaults rather than a barrier around the checkout.
|
|
229
|
+
Use Pi's standard `read`, `ls`, `grep` and `find` with an explicit host path to inspect an installed package; `~` refers to the service account's home.
|
|
230
|
+
Searches follow Pi's `.gitignore` behavior; inspect ignored dependencies and backups with explicit file paths and directory listings rather than treating no matches as proof that they do not exist.
|
|
231
|
+
`grep` accepts one regular expression by default, or `literal: true` for exact text; `find` accepts glob patterns such as `**/*.ts`.
|
|
232
|
+
Read one file at a time with `offset` and `limit`, following the next-offset notice for remaining text.
|
|
233
|
+
For truncated searches or listings, follow the tool's limit notice or narrow the query; ordinary file tools have no `depth`, batch or cursor parameters.
|
|
234
|
+
Searches use already available `rg` and `fd`/`fdfind` binaries or Pi's existing tool cache; missing tools are reported without automatically downloading or installing them.
|
|
235
|
+
|
|
236
|
+
Readonly subagents do not have shell or editing tools: use the direct listing, search and read tools rather than a `bash` pipeline.
|
|
237
|
+
Approved implementation workers keep their existing shell and editing tools.
|
|
238
|
+
This distinction preserves execution consent; it is not an OS sandbox or permission to copy credentials or profiles.
|
|
@@ -31,3 +31,95 @@ The no-project entry never initializes an SDK session, manufactures a checkout,
|
|
|
31
31
|
A technical service-process cwd is not a model/tool workspace.
|
|
32
32
|
The built same-origin routing covers both HTTP requests and WebSockets, while browser authority and project consent remain distinct from native management capability.
|
|
33
33
|
New Linux manager tests exercise the no-workspace default; macOS/Windows generated-definition tests are not native-platform execution qualification.
|
|
34
|
+
|
|
35
|
+
## Maintainer releases from any computer
|
|
36
|
+
|
|
37
|
+
`.github/workflows/publish.yml` publishes through GitHub Actions and npm Trusted Publishing (OIDC).
|
|
38
|
+
Only tag pushes trigger this workflow; there is no branch, pull-request, GitHub Release or manual-dispatch trigger.
|
|
39
|
+
Creating and pushing a stable `vMAJOR.MINOR.PATCH` tag is an explicit publication action; a local tag alone does nothing.
|
|
40
|
+
The workflow is repository-owned, not tied to the developer's computer or Pi session.
|
|
41
|
+
An agent can perform the release steps after an explicit user release request, using authorized GitHub access; it needs no npm token.
|
|
42
|
+
The workflow does not install Cadence globally, restart a service, deploy an application or create a GitHub Release.
|
|
43
|
+
|
|
44
|
+
### One-time setup
|
|
45
|
+
|
|
46
|
+
1. Review, commit and push the workflow and its helper/tests to `abelxiaoxing/cadence` on `main` before creating a release tag.
|
|
47
|
+
2. In GitHub repository **Settings → Environments**, create `npm-release` and restrict deployment to selected tags matching `v*`.
|
|
48
|
+
For deliberately unattended publishing, this dedicated environment must not require approval on every run; review existing organization/environment policies rather than silently removing protections.
|
|
49
|
+
Protect `main` and workflow changes, and use repository rulesets to restrict release-tag creation to trusted maintainers and prevent tag updates/deletion.
|
|
50
|
+
A maintainer allowed to change the publishing workflow or create an eligible release tag is being entrusted with npm publication.
|
|
51
|
+
3. In the npm package **Settings → Trusted publishing**, add a GitHub Actions publisher with these exact values:
|
|
52
|
+
|
|
53
|
+
| Field | Value |
|
|
54
|
+
| ----------------- | ------------------------------------------------------------- |
|
|
55
|
+
| Organization/user | `abelxiaoxing` |
|
|
56
|
+
| Repository | `cadence` |
|
|
57
|
+
| Workflow filename | `publish.yml` (not its full path) |
|
|
58
|
+
| Environment | `npm-release` |
|
|
59
|
+
| Allowed actions | Enable direct **`npm publish`**, not only `npm stage publish` |
|
|
60
|
+
|
|
61
|
+
Complete the maintainer authentication requested by npm for this one-time trust configuration.
|
|
62
|
+
Existing trust connections must be reviewed; do not revoke another publisher incidentally.
|
|
63
|
+
4. No `NPM_TOKEN` or `NODE_AUTH_TOKEN` secret is required.
|
|
64
|
+
Account 2FA can remain enabled, including npm's **Require two-factor authentication and disallow tokens** setting: it restricts traditional tokens, not this OIDC publisher.
|
|
65
|
+
Stage-only permission still requires a human to approve each version and is not the unattended route.
|
|
66
|
+
After a successful migration, separately review whether old automation tokens are still needed; this workflow never revokes them.
|
|
67
|
+
|
|
68
|
+
This lane requires GitHub-hosted runners; npm does not currently support self-hosted runners for this trust flow.
|
|
69
|
+
See npm's [Trusted Publishing documentation](https://docs.npmjs.com/trusted-publishers) for current platform and permission requirements.
|
|
70
|
+
The workflow pins its runtimes and third-party actions; review pin updates together with the normal verification gate.
|
|
71
|
+
|
|
72
|
+
### Release a new version
|
|
73
|
+
|
|
74
|
+
From a clean `main` checkout on any authorized computer:
|
|
75
|
+
|
|
76
|
+
1. Explicitly choose an unused stable version newer than npm's current `latest`; update `package.json` and regenerate operator/service/Web outputs through the canonical builders.
|
|
77
|
+
Configure the external private disk-backed temporary directory required by the repository's verification instructions.
|
|
78
|
+
2. Run `bun run verify`, review the candidate, and make the explicitly authorized release commit.
|
|
79
|
+
There is no additional slow/browser/paid-model/service-manager release gate.
|
|
80
|
+
3. Push that commit to `main`, then create and push its matching annotated tag:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
git push origin main
|
|
84
|
+
version=$(node -p "require('./package.json').version")
|
|
85
|
+
git tag -a "v$version" -m "Release $version" HEAD
|
|
86
|
+
git push origin "refs/tags/v$version"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
These commands publish the selected version; do not use the current already-published version as a test.
|
|
90
|
+
Do not force-move or delete a release tag to repair a failed release.
|
|
91
|
+
4. Follow **Actions → Publish npm**.
|
|
92
|
+
A successful dispatch or artifact upload is not proof of npm publication.
|
|
93
|
+
The final step verifies registry version/integrity, the `latest` tag and the actual downloaded tarball bytes.
|
|
94
|
+
|
|
95
|
+
The tag must name the checked-out event commit, match `package.json`, and already belong to `main`.
|
|
96
|
+
Pre-release/build-metadata tags, forks, moved/deleted tags, dirty checkouts, existing versions and versions behind the observed `latest` are refused.
|
|
97
|
+
This stable-release lane owns registry, access and dist-tag options; `package.json` must not add a competing `publishConfig`.
|
|
98
|
+
|
|
99
|
+
The preparation job has no OIDC permission.
|
|
100
|
+
It installs the frozen lockfile on its disposable runner, runs the sole gate, and audits a separate real Bun tarball.
|
|
101
|
+
A fresh publish job installs no project dependencies and builds nothing.
|
|
102
|
+
It downloads the immutable artifact by ID, checks its SHA-256 and every body against the clean tagged source, then calls `npm publish` once with lifecycle scripts disabled.
|
|
103
|
+
Only that job receives the OIDC permission.
|
|
104
|
+
No profile, private-state directory or local credential file is copied into either job.
|
|
105
|
+
|
|
106
|
+
Releases are serialized without cancelling an in-progress publish.
|
|
107
|
+
GitHub can replace a pending run when another is queued, so push one release tag at a time and inspect each run's outcome.
|
|
108
|
+
There is no automatic retry of `npm publish`, version bump, unpublish, dist-tag repair or staged-package approval.
|
|
109
|
+
After a failed or interrupted publish, inspect npm before retrying: the registry may have accepted the request despite a lost client reply.
|
|
110
|
+
Confirmation makes bounded readonly observations for propagation and does not convert a failed publish command into a successful command receipt.
|
|
111
|
+
The live-ref/latest checks are not a transaction with other maintainers; an external publication can still race and must be investigated rather than overwritten.
|
|
112
|
+
|
|
113
|
+
### Delayed or unconfirmed publication
|
|
114
|
+
|
|
115
|
+
npm can accept `npm publish` and then process the package asynchronously before its version, `latest` and tarball become publicly visible.
|
|
116
|
+
The confirmation helper uses one monotonic observation deadline for metadata requests, body reads and polling delays; its total window, interval and unchanged per-request ceiling live beside the constants in `scripts/npm-release.mjs`.
|
|
117
|
+
Candidate-version or tarball 404s and a lagging `latest` are retried with readonly requests only.
|
|
118
|
+
Digest, identity, tarball URL, streamed-byte mismatches and a newer `latest` refuse immediately; other HTTP, transport and malformed-response failures are not treated as propagation.
|
|
119
|
+
Each request is limited by the remaining total time, aborted on expiry and awaited through settlement; successful or failed reads dispose their timers.
|
|
120
|
+
|
|
121
|
+
The confirmation step records the original publish-step outcome separately in its failure log and job summary.
|
|
122
|
+
A successful publish followed by an observation timeout means **publication is still unconfirmed**, not that the publish command failed or the version is safe to reuse.
|
|
123
|
+
Keep that run's original audited artifact and digest, then independently recheck registry metadata, `latest` and downloaded bytes against that same artifact.
|
|
124
|
+
Do not rerun the publish job or workflow, replay `npm publish`, move/delete its tag, or repair registry state automatically.
|
|
125
|
+
A later matching readonly observation can confirm publication, but does not rewrite the earlier run's failed outcome; confirmation also cannot turn an originally failed publish command into a successful receipt.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abelxiaoxing/cadence",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.41",
|
|
4
4
|
"description": "Conversation-driven Pi workspace: persistent native and WebUI workflows, explicit plan approval, checks and local delivery.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"src/git-environment.mjs",
|
|
59
59
|
"src/git-environment.d.mts",
|
|
60
60
|
"src/research-tools.mjs",
|
|
61
|
-
"src/research-scan.mjs",
|
|
62
61
|
"src/worker-toolkit.mjs",
|
|
63
62
|
"src/worker-workspace.mjs",
|
|
64
63
|
"src/worker-workspace.d.mts",
|
|
@@ -91,7 +90,9 @@
|
|
|
91
90
|
"src/data-shapes.ts",
|
|
92
91
|
"src/service/checkout-lock.ts",
|
|
93
92
|
"src/service/liveness.ts",
|
|
94
|
-
"src/agent-browser"
|
|
93
|
+
"src/agent-browser",
|
|
94
|
+
"src/activity.ts",
|
|
95
|
+
"src/service/activity-files.ts"
|
|
95
96
|
],
|
|
96
97
|
"pi": {
|
|
97
98
|
"extensions": [
|
package/src/activity.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/** Reports only an interactive Pi's real agent lifetime; no presence, owner or control. */
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
|
+
import {
|
|
5
|
+
type ExtensionAPI,
|
|
6
|
+
getAgentDir,
|
|
7
|
+
} from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import {
|
|
9
|
+
ACTIVITY_RENEW_MS,
|
|
10
|
+
ActivityFiles,
|
|
11
|
+
type NativeActivity,
|
|
12
|
+
} from "./service/activity-files.ts";
|
|
13
|
+
import { selfMark } from "./service/liveness.ts";
|
|
14
|
+
import { type FileSnapshot, hash } from "./service/private-files.ts";
|
|
15
|
+
import {
|
|
16
|
+
privateWorkspace,
|
|
17
|
+
resolveWorkspaceAsync,
|
|
18
|
+
stateHomeInside,
|
|
19
|
+
} from "./workspace.ts";
|
|
20
|
+
|
|
21
|
+
export interface ActivityPublisherOptions {
|
|
22
|
+
store?: () => Pick<
|
|
23
|
+
ActivityFiles,
|
|
24
|
+
"scope" | "publish" | "withdraw" | "retireDead"
|
|
25
|
+
>;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
canonical?: (cwd: string, signal: AbortSignal) => string | Promise<string>;
|
|
28
|
+
}
|
|
29
|
+
export function registerActivity(
|
|
30
|
+
pi: ExtensionAPI,
|
|
31
|
+
options: ActivityPublisherOptions = {},
|
|
32
|
+
): void {
|
|
33
|
+
if (process.env.CADENCE_SUBAGENT_CHILD === "1") return;
|
|
34
|
+
const instance = randomUUID();
|
|
35
|
+
const now = options.now ?? Date.now;
|
|
36
|
+
let active:
|
|
37
|
+
| {
|
|
38
|
+
id: string;
|
|
39
|
+
sessionId: string;
|
|
40
|
+
abort: AbortController;
|
|
41
|
+
record?: NativeActivity;
|
|
42
|
+
saved?: FileSnapshot;
|
|
43
|
+
store?: ReturnType<NonNullable<ActivityPublisherOptions["store"]>>;
|
|
44
|
+
}
|
|
45
|
+
| undefined;
|
|
46
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
47
|
+
let retired = false;
|
|
48
|
+
const stop = () => {
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
timer = undefined;
|
|
51
|
+
const previous = active;
|
|
52
|
+
active = undefined; // Fence callbacks before any filesystem operation.
|
|
53
|
+
previous?.abort.abort();
|
|
54
|
+
try {
|
|
55
|
+
if (previous?.store && previous.saved)
|
|
56
|
+
previous.store.withdraw(instance, previous.saved);
|
|
57
|
+
} catch {
|
|
58
|
+
/* Retain uncertain bytes; discovery reports stale/unknown, not success. */
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
pi.on("agent_start", (_event, ctx) => {
|
|
62
|
+
if (retired || ctx.mode !== "tui" || !ctx.hasUI) return;
|
|
63
|
+
try {
|
|
64
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
65
|
+
if (active?.sessionId === sessionId) return; // retries/compaction/queued continuation
|
|
66
|
+
stop();
|
|
67
|
+
const cwdAtStart = ctx.cwd,
|
|
68
|
+
sessionScope = hash(ctx.sessionManager.getSessionDir()),
|
|
69
|
+
startedAt = now();
|
|
70
|
+
const current = {
|
|
71
|
+
id: randomUUID(),
|
|
72
|
+
sessionId,
|
|
73
|
+
abort: new AbortController(),
|
|
74
|
+
} as NonNullable<typeof active>;
|
|
75
|
+
active = current;
|
|
76
|
+
// Lifecycle hooks never await publication. One callback at a time; timers
|
|
77
|
+
// neither keep Pi alive nor run after settlement/session replacement.
|
|
78
|
+
const publish = async () => {
|
|
79
|
+
if (active !== current || retired) return;
|
|
80
|
+
try {
|
|
81
|
+
if (!current.store) {
|
|
82
|
+
current.store =
|
|
83
|
+
options.store?.() ?? new ActivityFiles(getAgentDir());
|
|
84
|
+
const resolving = options.canonical
|
|
85
|
+
? options.canonical(cwdAtStart, current.abort.signal)
|
|
86
|
+
: resolveWorkspaceAsync(cwdAtStart, current.abort.signal).then(
|
|
87
|
+
({ root, cwd }) => {
|
|
88
|
+
if (privateWorkspace(root) || stateHomeInside(root))
|
|
89
|
+
throw new Error("private-workspace");
|
|
90
|
+
return realpathSync(cwd);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
const cwd =
|
|
94
|
+
typeof resolving === "string" ? resolving : await resolving;
|
|
95
|
+
if (active !== current || retired) return;
|
|
96
|
+
current.store.retireDead(now());
|
|
97
|
+
current.record = {
|
|
98
|
+
schema: "cadence-pi-activity/1",
|
|
99
|
+
instance,
|
|
100
|
+
activity: current.id,
|
|
101
|
+
scope: current.store.scope,
|
|
102
|
+
sessionScope,
|
|
103
|
+
process: selfMark(),
|
|
104
|
+
cwd,
|
|
105
|
+
sessionId,
|
|
106
|
+
leaf: null,
|
|
107
|
+
startedAt,
|
|
108
|
+
renewedAt: now(),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const record = current.record;
|
|
112
|
+
if (!record) return;
|
|
113
|
+
record.leaf = ctx.sessionManager.getLeafId();
|
|
114
|
+
record.renewedAt = now();
|
|
115
|
+
current.saved = current.store.publish(record, current.saved);
|
|
116
|
+
timer = setTimeout(publish, ACTIVITY_RENEW_MS);
|
|
117
|
+
timer.unref?.();
|
|
118
|
+
} catch {
|
|
119
|
+
/* Observation failures do not fail, cancel or retry Pi work. */
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
timer = setTimeout(publish, 0);
|
|
123
|
+
timer.unref?.();
|
|
124
|
+
} catch {
|
|
125
|
+
/* Metadata is optional; no error escapes into Pi. */
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
// agent_end is deliberately NOT a settlement signal.
|
|
129
|
+
pi.on("agent_settled", (_event, ctx) => {
|
|
130
|
+
if (!active || retired) return;
|
|
131
|
+
try {
|
|
132
|
+
if (active.sessionId === ctx.sessionManager.getSessionId()) stop();
|
|
133
|
+
} catch {
|
|
134
|
+
// An invalidated public context cannot fail Pi's final notification.
|
|
135
|
+
// Preserve uncertain metadata but never keep renewing an idle report.
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
timer = undefined;
|
|
138
|
+
const previous = active;
|
|
139
|
+
active = undefined;
|
|
140
|
+
previous?.abort.abort();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
pi.on("session_shutdown", () => {
|
|
144
|
+
retired = true;
|
|
145
|
+
stop();
|
|
146
|
+
});
|
|
147
|
+
}
|
package/src/change-tools.mjs
CHANGED
|
@@ -5,6 +5,27 @@ import { randomUUID } from "node:crypto";
|
|
|
5
5
|
import { Type } from "typebox";
|
|
6
6
|
import { gitArguments, gitEnvironment } from "./git-environment.mjs";
|
|
7
7
|
|
|
8
|
+
// Only fixed-revision evidence retains a cursor protocol. Inactive fields have
|
|
9
|
+
// a legal wire value even if a provider requires every declared property.
|
|
10
|
+
const optional = (schema) =>
|
|
11
|
+
Type.Optional({
|
|
12
|
+
...schema,
|
|
13
|
+
type: [schema.type, "null"],
|
|
14
|
+
...(schema.enum ? { enum: [...schema.enum, null] } : {}),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const parameters = Type.Object(
|
|
18
|
+
{
|
|
19
|
+
mode: optional(
|
|
20
|
+
Type.String({ enum: ["paths", "diff", "base", "candidate"] }),
|
|
21
|
+
),
|
|
22
|
+
path: optional(Type.String({ maxLength: 1024 })),
|
|
23
|
+
cursor: optional(Type.String({ maxLength: 128 })),
|
|
24
|
+
close: optional(Type.Boolean({ enum: [true] })),
|
|
25
|
+
},
|
|
26
|
+
{ additionalProperties: false },
|
|
27
|
+
);
|
|
28
|
+
|
|
8
29
|
export const CHANGE_LIMITS = Object.freeze({
|
|
9
30
|
scans: 4,
|
|
10
31
|
pageBytes: 2048,
|
|
@@ -42,15 +63,29 @@ export function createChangeTools(binding) {
|
|
|
42
63
|
const execute = async (_id, args, signal) => {
|
|
43
64
|
if (closing) throw new Error("Change observations closed");
|
|
44
65
|
if (signal?.aborted) throw new Error("Change observation canceled");
|
|
45
|
-
if (
|
|
46
|
-
|
|
66
|
+
if (
|
|
67
|
+
!args ||
|
|
68
|
+
typeof args !== "object" ||
|
|
69
|
+
Array.isArray(args) ||
|
|
70
|
+
Object.keys(args).some(
|
|
71
|
+
(key) => !Object.hasOwn(parameters.properties, key),
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
throw new Error(
|
|
75
|
+
"Invalid change arguments: use only declared fields; omit unused fields or set them to null",
|
|
76
|
+
);
|
|
77
|
+
args = Object.fromEntries(
|
|
78
|
+
Object.entries(args).filter(([, value]) => value !== null),
|
|
79
|
+
);
|
|
47
80
|
let scan;
|
|
48
81
|
if (args.cursor !== undefined) {
|
|
49
82
|
if (
|
|
50
83
|
Object.keys(args).some((k) => !["cursor", "close"].includes(k)) ||
|
|
51
84
|
(args.close !== undefined && args.close !== true)
|
|
52
85
|
)
|
|
53
|
-
throw new Error(
|
|
86
|
+
throw new Error(
|
|
87
|
+
"A change cursor request accepts only cursor and optional close:true; omit mode/path or set them to null. For a new query, omit cursor/close or set them to null",
|
|
88
|
+
);
|
|
54
89
|
scan = cursors.get(args.cursor);
|
|
55
90
|
if (!scan)
|
|
56
91
|
throw new Error(
|
|
@@ -59,8 +94,10 @@ export function createChangeTools(binding) {
|
|
|
59
94
|
cursors.delete(args.cursor);
|
|
60
95
|
clearTimeout(scan.timer);
|
|
61
96
|
} else {
|
|
62
|
-
if (
|
|
63
|
-
throw new Error(
|
|
97
|
+
if (args.close !== undefined)
|
|
98
|
+
throw new Error(
|
|
99
|
+
"Invalid change arguments: close:true requires a returned cursor; omit close and cursor or set them to null for a new query",
|
|
100
|
+
);
|
|
64
101
|
const mode = args.mode ?? "paths",
|
|
65
102
|
path = args.path;
|
|
66
103
|
if (!["paths", "diff", "base", "candidate"].includes(mode))
|
|
@@ -233,18 +270,9 @@ export function createChangeTools(binding) {
|
|
|
233
270
|
name: "changes",
|
|
234
271
|
label: "changes",
|
|
235
272
|
description:
|
|
236
|
-
"Readonly evidence for the owner's fixed base/candidate commits. mode paths lists changed paths (Git-quoted), diff reads patches, base/candidate reads one file at that revision. Optional checkout-relative path narrows a diff. Text may split across pages: continue exclusively with {cursor}; {cursor,close:true} releases it. more is incomplete, including empty progress. No arbitrary refs, Git commands, shell or writes.",
|
|
237
|
-
parameters
|
|
238
|
-
|
|
239
|
-
mode: Type.Optional(
|
|
240
|
-
Type.String({ enum: ["paths", "diff", "base", "candidate"] }),
|
|
241
|
-
),
|
|
242
|
-
path: Type.Optional(Type.String({ maxLength: 1024 })),
|
|
243
|
-
cursor: Type.Optional(Type.String({ maxLength: 128 })),
|
|
244
|
-
close: Type.Optional(Type.Literal(true)),
|
|
245
|
-
},
|
|
246
|
-
{ additionalProperties: false },
|
|
247
|
-
),
|
|
273
|
+
"Readonly evidence for the owner's fixed base/candidate commits. mode paths lists changed paths (Git-quoted), diff reads patches, base/candidate reads one file at that revision. Optional checkout-relative path narrows a diff. Text may split across pages: continue exclusively with {cursor}; {cursor,close:true} releases it. more is incomplete, including empty progress. No arbitrary refs, Git commands, shell or writes. Omit unused parameters or set them to null; never invent a cursor or mix query and cursor fields.",
|
|
274
|
+
parameters,
|
|
275
|
+
constrainedSampling: { type: "json_schema", strict: "prefer" },
|
|
248
276
|
execute,
|
|
249
277
|
},
|
|
250
278
|
],
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
2
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { registerActivity } from "./activity.ts";
|
|
3
4
|
import { registerAgentPanel } from "./agent-panel.ts";
|
|
4
5
|
import { registerCadenceAgentFeed } from "./agent-panel-cadence.ts";
|
|
5
6
|
import { registerCadenceMode } from "./cadence-mode.ts";
|
|
@@ -12,6 +13,7 @@ import { CONFIG_MISSING, startupCardLines } from "./startup-card.ts";
|
|
|
12
13
|
* actual host binding belongs to the readonly history shell’s session_start. */
|
|
13
14
|
export default function register(pi: ExtensionAPI): void {
|
|
14
15
|
if (process.env.CADENCE_SUBAGENT_CHILD === "1") return;
|
|
16
|
+
registerActivity(pi);
|
|
15
17
|
registerHistoryShell(pi);
|
|
16
18
|
registerCadenceMode(pi);
|
|
17
19
|
// Readonly: notices the browser continuing the session this terminal holds.
|
package/src/native-build.ts
CHANGED
package/src/operator-cli.mjs
CHANGED
|
@@ -116,7 +116,7 @@ function gitArguments(args) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// src/workspace.ts
|
|
119
|
-
import { spawnSync } from "node:child_process";
|
|
119
|
+
import { execFile, spawnSync } from "node:child_process";
|
|
120
120
|
import { createHash } from "node:crypto";
|
|
121
121
|
import {
|
|
122
122
|
closeSync,
|
|
@@ -245,6 +245,9 @@ function resolveWorkspace(cwd) {
|
|
|
245
245
|
maxBuffer: 8192,
|
|
246
246
|
windowsHide: true
|
|
247
247
|
});
|
|
248
|
+
return workspaceResult(actual, result);
|
|
249
|
+
}
|
|
250
|
+
function workspaceResult(actual, result) {
|
|
248
251
|
const topLevel = result.stdout?.replace(process.platform === "win32" ? /\r?\n$/ : /\n$/, "");
|
|
249
252
|
if (result.status === 0 && topLevel)
|
|
250
253
|
return { root: realpathSync(topLevel), cwd: actual };
|