@usecontextlayer/ctxe 0.5.9 → 0.5.11
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/dist/cli.mjs +30 -28
- package/dist/cli.mjs.map +1 -1
- package/package.json +9 -8
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1fc8117f-7ec8-5237-b3fc-002c9d8e686e")}catch(e){}}();
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as Sentry from "@sentry/node";
|
|
6
6
|
import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
@@ -28,6 +28,7 @@ import net from "net";
|
|
|
28
28
|
import tls from "tls";
|
|
29
29
|
import crypto$1 from "crypto";
|
|
30
30
|
import { performance as performance$1 } from "perf_hooks";
|
|
31
|
+
import { Temporal } from "temporal-polyfill";
|
|
31
32
|
import f from "node:readline";
|
|
32
33
|
|
|
33
34
|
//#region \0rolldown/runtime.js
|
|
@@ -60,7 +61,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
60
61
|
|
|
61
62
|
//#endregion
|
|
62
63
|
//#region package.json
|
|
63
|
-
var version$2 = "0.5.
|
|
64
|
+
var version$2 = "0.5.11";
|
|
64
65
|
|
|
65
66
|
//#endregion
|
|
66
67
|
//#region sentry.ts
|
|
@@ -30880,7 +30881,7 @@ function buildRootResetCommitMessage(input) {
|
|
|
30880
30881
|
return [
|
|
30881
30882
|
`ctxe: root reset @ ${input.resetId}`,
|
|
30882
30883
|
"",
|
|
30883
|
-
"reset: wipe synthesized
|
|
30884
|
+
"reset: wipe synthesized docs + cursors",
|
|
30884
30885
|
""
|
|
30885
30886
|
].join("\n");
|
|
30886
30887
|
}
|
|
@@ -31413,7 +31414,7 @@ async function executeSynthesizerRun(input) {
|
|
|
31413
31414
|
sliceJson: input.sliceJson,
|
|
31414
31415
|
synthesizer: input.synthesizer,
|
|
31415
31416
|
synthesizerImage: input.synthesizerImage,
|
|
31416
|
-
...input.
|
|
31417
|
+
...input.docsHostDir !== void 0 && { docsHostDir: input.docsHostDir }
|
|
31417
31418
|
});
|
|
31418
31419
|
const result = await input.executor.run(executorInput, input.hooks);
|
|
31419
31420
|
const completedAtMs = now().getTime();
|
|
@@ -31467,7 +31468,7 @@ function buildExecutorInput(input) {
|
|
|
31467
31468
|
sliceJson: input.sliceJson,
|
|
31468
31469
|
synthesizerBody: input.synthesizer.body,
|
|
31469
31470
|
synthesizerName: input.synthesizer.name,
|
|
31470
|
-
...input.
|
|
31471
|
+
...input.docsHostDir !== void 0 && { docsHostDir: input.docsHostDir }
|
|
31471
31472
|
};
|
|
31472
31473
|
}
|
|
31473
31474
|
function buildContextEngineEnv(input) {
|
|
@@ -31760,10 +31761,10 @@ var Engine = class {
|
|
|
31760
31761
|
return (await executeSynthesizerRun({
|
|
31761
31762
|
baseDsn: this.baseDsn,
|
|
31762
31763
|
claudeOauthToken: config.claudeOauthToken,
|
|
31764
|
+
docsHostDir: input.docsHostDir,
|
|
31763
31765
|
effortLevel: config.effortLevel,
|
|
31764
31766
|
executor: this.executor,
|
|
31765
31767
|
model: config.model,
|
|
31766
|
-
outputHostDir: input.outputDir,
|
|
31767
31768
|
rootDir: this.repo.rootDir,
|
|
31768
31769
|
runId,
|
|
31769
31770
|
sliceJson,
|
|
@@ -32121,7 +32122,7 @@ engine has prepared three files in your working directory:
|
|
|
32121
32122
|
|
|
32122
32123
|
- \`./synthesizer.md\` — your task definition. Read it first.
|
|
32123
32124
|
- \`./slice.json\` — the source-time query windows for this run.
|
|
32124
|
-
- \`./
|
|
32125
|
+
- \`./docs/\` — the only path that persists back to the host. Anything written
|
|
32125
32126
|
elsewhere is lost when the sandbox exits.
|
|
32126
32127
|
|
|
32127
32128
|
A \`contextengine-synthesizer\` skill is installed. Read and follow it — it defines how to
|
|
@@ -32133,8 +32134,8 @@ not write a manifest or any end-of-run report.
|
|
|
32133
32134
|
function workspaceGuestPath(rootDir) {
|
|
32134
32135
|
return path.resolve(rootDir);
|
|
32135
32136
|
}
|
|
32136
|
-
function
|
|
32137
|
-
return path.join(workspaceGuestPath(rootDir), "
|
|
32137
|
+
function docsGuestPath(rootDir) {
|
|
32138
|
+
return path.join(workspaceGuestPath(rootDir), "docs");
|
|
32138
32139
|
}
|
|
32139
32140
|
function synthesizerGuestPath(rootDir) {
|
|
32140
32141
|
return path.join(workspaceGuestPath(rootDir), "synthesizer.md");
|
|
@@ -32149,8 +32150,8 @@ function buildSynthesizerSandboxLayout(input) {
|
|
|
32149
32150
|
const rootDir = path.resolve(input.rootDir);
|
|
32150
32151
|
return {
|
|
32151
32152
|
bindMounts: [{
|
|
32152
|
-
guestPath:
|
|
32153
|
-
hostPath: input.
|
|
32153
|
+
guestPath: docsGuestPath(rootDir),
|
|
32154
|
+
hostPath: input.docsHostDir ?? path.join(rootDir, "docs"),
|
|
32154
32155
|
hostPathBehavior: "createDir",
|
|
32155
32156
|
mode: "rw"
|
|
32156
32157
|
}],
|
|
@@ -32258,7 +32259,7 @@ var MicrosandboxClaudeExecutor = class {
|
|
|
32258
32259
|
rootDir: input.rootDir,
|
|
32259
32260
|
sliceJson: input.sliceJson,
|
|
32260
32261
|
synthesizerBody: input.synthesizerBody,
|
|
32261
|
-
...input.
|
|
32262
|
+
...input.docsHostDir !== void 0 && { docsHostDir: input.docsHostDir }
|
|
32262
32263
|
});
|
|
32263
32264
|
const bootConfig = buildClaudeBootConfig({
|
|
32264
32265
|
bindMounts: layout.bindMounts,
|
|
@@ -32332,21 +32333,22 @@ function buildMicrosandboxClaudeRunPlan(input) {
|
|
|
32332
32333
|
sandboxName: input.sandboxName
|
|
32333
32334
|
};
|
|
32334
32335
|
}
|
|
32335
|
-
const
|
|
32336
|
-
const
|
|
32336
|
+
const RESERVED_DOCS_SUBDIRS = new Set(["types", "views"]);
|
|
32337
|
+
const DOCS_SUBDIR = "docs";
|
|
32337
32338
|
const CURSORS_DIR_RELATIVE = ".engine/cursors";
|
|
32338
32339
|
async function planRootReset(rootDir) {
|
|
32339
32340
|
const cursorFiles = (await readDirNames(cursorsDirPath(rootDir))).filter((name) => name.endsWith(".json"));
|
|
32341
|
+
const docsRemovalNames = (await readDirNames(path.join(rootDir, DOCS_SUBDIR))).filter((name) => !RESERVED_DOCS_SUBDIRS.has(name));
|
|
32340
32342
|
return {
|
|
32341
|
-
|
|
32342
|
-
|
|
32343
|
+
cursorPaths: cursorFiles.map((name) => path.join(CURSORS_DIR_RELATIVE, name)).sort(),
|
|
32344
|
+
docsRemovalPaths: docsRemovalNames.map((name) => path.join(DOCS_SUBDIR, name)).sort()
|
|
32343
32345
|
};
|
|
32344
32346
|
}
|
|
32345
32347
|
async function runRootReset(repo, options = {}) {
|
|
32346
32348
|
const preflight = await runRootPreflight(repo);
|
|
32347
32349
|
if (!preflight.ready && !options.force) throw new Error(formatNotReadyError(repo, preflight.issues));
|
|
32348
32350
|
const plan = await planRootReset(repo.rootDir);
|
|
32349
|
-
for (const relativePath of [...plan.cursorPaths, ...plan.
|
|
32351
|
+
for (const relativePath of [...plan.cursorPaths, ...plan.docsRemovalPaths]) await rm(path.join(repo.rootDir, relativePath), {
|
|
32350
32352
|
force: true,
|
|
32351
32353
|
recursive: true
|
|
32352
32354
|
});
|
|
@@ -32356,8 +32358,8 @@ async function runRootReset(repo, options = {}) {
|
|
|
32356
32358
|
return {
|
|
32357
32359
|
commit: { sha },
|
|
32358
32360
|
kind: "reset",
|
|
32359
|
-
|
|
32360
|
-
|
|
32361
|
+
removedCursors: plan.cursorPaths,
|
|
32362
|
+
removedDocsPaths: plan.docsRemovalPaths
|
|
32361
32363
|
};
|
|
32362
32364
|
}
|
|
32363
32365
|
async function readDirNames(dir) {
|
|
@@ -38092,13 +38094,13 @@ async function runAdHocCommand(input) {
|
|
|
38092
38094
|
paths: input.paths,
|
|
38093
38095
|
workspaceId
|
|
38094
38096
|
});
|
|
38095
|
-
const
|
|
38097
|
+
const docsHostDir = resolve(input.out);
|
|
38096
38098
|
const outcome = await engine.runAdHoc({
|
|
38099
|
+
docsHostDir,
|
|
38097
38100
|
hooks: {
|
|
38098
38101
|
onStderr: (chunk) => process.stderr.write(chunk),
|
|
38099
38102
|
onStdout: (chunk) => process.stdout.write(chunk)
|
|
38100
38103
|
},
|
|
38101
|
-
outputDir,
|
|
38102
38104
|
synthesizerName: input.synthesizerName,
|
|
38103
38105
|
...window.from !== void 0 && { fromMs: window.from },
|
|
38104
38106
|
...window.to !== void 0 && { toMs: window.to },
|
|
@@ -38107,7 +38109,7 @@ async function runAdHocCommand(input) {
|
|
|
38107
38109
|
process.stderr.write(`${formatJsonOutput({
|
|
38108
38110
|
durationMs: outcome.durationMs,
|
|
38109
38111
|
exitCode: outcome.exitCode,
|
|
38110
|
-
out:
|
|
38112
|
+
out: docsHostDir,
|
|
38111
38113
|
status: outcome.status
|
|
38112
38114
|
})}\n`);
|
|
38113
38115
|
if (outcome.status !== "success") process.exitCode = 1;
|
|
@@ -38884,8 +38886,8 @@ async function runResetCommand(input) {
|
|
|
38884
38886
|
issues: preflight.issues,
|
|
38885
38887
|
ready: preflight.ready,
|
|
38886
38888
|
wouldRemove: {
|
|
38887
|
-
|
|
38888
|
-
|
|
38889
|
+
cursors: plan.cursorPaths,
|
|
38890
|
+
docs: plan.docsRemovalPaths
|
|
38889
38891
|
}
|
|
38890
38892
|
})}\n`);
|
|
38891
38893
|
return;
|
|
@@ -38965,7 +38967,7 @@ function createProgram() {
|
|
|
38965
38967
|
program.command("list").description("List synthesizers").action(async function() {
|
|
38966
38968
|
await runEngineListCommand(resolveRuntimePaths(this));
|
|
38967
38969
|
});
|
|
38968
|
-
program.command("status").argument("[synthesizer]", "Only show this synthesizer").option("--workspace-id <id>", "Slate workspace id whose plan resolves the base to read sync state from. Falls back to CTXE_WORKSPACE_ID.").description("Print each synthesizer's freshness as JSON: its frontier (the source-time its cursor has reached), how far that lags behind now (
|
|
38970
|
+
program.command("status").argument("[synthesizer]", "Only show this synthesizer").option("--workspace-id <id>", "Slate workspace id whose plan resolves the base to read sync state from. Falls back to CTXE_WORKSPACE_ID.").description("Print each synthesizer's freshness as JSON: its frontier (the source-time its cursor has reached), how far that lags behind now (docs staleness), how much confirmed-synced ground is still pending below the sync horizon (whether the engine is keeping up — the planner's own measure), and its latest run.").action(async function(synthesizerName, options) {
|
|
38969
38971
|
const workspaceId = resolveWorkspaceId({ cliValue: options.workspaceId });
|
|
38970
38972
|
await runEngineStatusCommand(synthesizerName, resolveRuntimePaths(this), await resolveSyncHorizonCapture({ workspaceId }));
|
|
38971
38973
|
});
|
|
@@ -38978,14 +38980,14 @@ function createProgram() {
|
|
|
38978
38980
|
program.command("repair").description("Explicit out-of-band root repair: reconciles the root against origin (fast-forward when behind; publish own unpushed commits, or discard them to origin when the push is rejected) and rolls back a dirty tree preserving .engine/runs/**.").action(async function() {
|
|
38979
38981
|
await runRepairCommand(resolveRepoContext(this));
|
|
38980
38982
|
});
|
|
38981
|
-
program.command("reset").option("--yes", "Execute the reset (delete cursors + wipe synthesized
|
|
38983
|
+
program.command("reset").option("--yes", "Execute the reset (delete cursors + wipe synthesized docs, then commit). Without it, prints the plan and exits without mutating.").option("--force", "Reset even when the root is not preflight-ready (e.g. a dirty working tree). Use with care; normally you commit authored config or run 'ctxe repair' first.").description("Reset the whole workspace to a clean pre-synthesis state so it can be rebuilt from scratch: delete every synthesizer cursor (the next run bootstraps from the configured oldestConsideredPoint) and wipe all synthesized docs under docs/ except the authored types/ and views/, in one commit. Whole-workspace by design — docs/ is not partitioned by synthesizer. Preserves .engine/runs/**. Default is a dry run; pass --yes to execute, then rebuild with 'ctxe backfill <synthesizer>' or 'ctxe daemon start'.").action(async function(options) {
|
|
38982
38984
|
await runResetCommand({
|
|
38983
38985
|
force: options.force ?? false,
|
|
38984
38986
|
repo: resolveRepoContext(this),
|
|
38985
38987
|
yes: options.yes ?? false
|
|
38986
38988
|
});
|
|
38987
38989
|
});
|
|
38988
|
-
program.command("adhoc").argument("<synthesizer>", "Synthesizer name").option("--from <iso>", "Window start (ISO-8601, exclusive). Defaults to the engine's oldestConsideredPoint when omitted.").option("--to <iso>", "Window end (ISO-8601, inclusive). Defaults to now when omitted.").option("--last <duration>", "Relative window ending now, e.g. \"7d\", \"12h\", \"30m\". Mutually exclusive with --from/--to.").requiredOption("--out <dir>", "Directory the synthesized
|
|
38990
|
+
program.command("adhoc").argument("<synthesizer>", "Synthesizer name").option("--from <iso>", "Window start (ISO-8601, exclusive). Defaults to the engine's oldestConsideredPoint when omitted.").option("--to <iso>", "Window end (ISO-8601, inclusive). Defaults to now when omitted.").option("--last <duration>", "Relative window ending now, e.g. \"7d\", \"12h\", \"30m\". Mutually exclusive with --from/--to.").requiredOption("--out <dir>", "Directory the synthesized docs are written to. Used exactly as-is (created if missing); the synthesizer reads its current contents as prior docs.").option("--workspace-id <id>", "Slate workspace id whose plan supplies the run config and the base to sync. Falls back to CTXE_WORKSPACE_ID.").option("--model <model>", "Override the plan's Claude model for this run only. Omitted → the workspace plan's model governs. Never persisted.").description("Ephemeral authoring run: run a synthesizer once over an explicit window into --out, reading your live (uncommitted) synthesizer.md. The guest's docs/ is exactly --out's contents — the checkout's docs/ (including docs/types) is NOT visible; copy docs/types into --out to give the run your live type-defs. Touches nothing durable — no preflight, no sync horizon, no cursor, no commit, no push. Streams the run to stdout; saves no transcript. Exits non-zero on a non-success run.").action(async function(synthesizerName, options) {
|
|
38989
38991
|
await runAdHocCommand({
|
|
38990
38992
|
from: options.from,
|
|
38991
38993
|
last: options.last,
|
|
@@ -39035,4 +39037,4 @@ runCli().catch((error) => {
|
|
|
39035
39037
|
//#endregion
|
|
39036
39038
|
export { createProgram, resolveRepoContext, resolveRuntimePaths, runCli };
|
|
39037
39039
|
//# sourceMappingURL=cli.mjs.map
|
|
39038
|
-
//# debugId=
|
|
39040
|
+
//# debugId=1fc8117f-7ec8-5237-b3fc-002c9d8e686e
|