@usecontextlayer/ctxe 0.5.10 → 0.5.12
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 +29 -28
- package/dist/cli.mjs.map +1 -1
- package/package.json +6 -6
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";
|
|
@@ -61,7 +61,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
61
61
|
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region package.json
|
|
64
|
-
var version$2 = "0.5.
|
|
64
|
+
var version$2 = "0.5.12";
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region sentry.ts
|
|
@@ -30881,7 +30881,7 @@ function buildRootResetCommitMessage(input) {
|
|
|
30881
30881
|
return [
|
|
30882
30882
|
`ctxe: root reset @ ${input.resetId}`,
|
|
30883
30883
|
"",
|
|
30884
|
-
"reset: wipe synthesized
|
|
30884
|
+
"reset: wipe synthesized docs + cursors",
|
|
30885
30885
|
""
|
|
30886
30886
|
].join("\n");
|
|
30887
30887
|
}
|
|
@@ -31414,7 +31414,7 @@ async function executeSynthesizerRun(input) {
|
|
|
31414
31414
|
sliceJson: input.sliceJson,
|
|
31415
31415
|
synthesizer: input.synthesizer,
|
|
31416
31416
|
synthesizerImage: input.synthesizerImage,
|
|
31417
|
-
...input.
|
|
31417
|
+
...input.docsHostDir !== void 0 && { docsHostDir: input.docsHostDir }
|
|
31418
31418
|
});
|
|
31419
31419
|
const result = await input.executor.run(executorInput, input.hooks);
|
|
31420
31420
|
const completedAtMs = now().getTime();
|
|
@@ -31468,7 +31468,7 @@ function buildExecutorInput(input) {
|
|
|
31468
31468
|
sliceJson: input.sliceJson,
|
|
31469
31469
|
synthesizerBody: input.synthesizer.body,
|
|
31470
31470
|
synthesizerName: input.synthesizer.name,
|
|
31471
|
-
...input.
|
|
31471
|
+
...input.docsHostDir !== void 0 && { docsHostDir: input.docsHostDir }
|
|
31472
31472
|
};
|
|
31473
31473
|
}
|
|
31474
31474
|
function buildContextEngineEnv(input) {
|
|
@@ -31761,10 +31761,10 @@ var Engine = class {
|
|
|
31761
31761
|
return (await executeSynthesizerRun({
|
|
31762
31762
|
baseDsn: this.baseDsn,
|
|
31763
31763
|
claudeOauthToken: config.claudeOauthToken,
|
|
31764
|
+
docsHostDir: input.docsHostDir,
|
|
31764
31765
|
effortLevel: config.effortLevel,
|
|
31765
31766
|
executor: this.executor,
|
|
31766
31767
|
model: config.model,
|
|
31767
|
-
outputHostDir: input.outputDir,
|
|
31768
31768
|
rootDir: this.repo.rootDir,
|
|
31769
31769
|
runId,
|
|
31770
31770
|
sliceJson,
|
|
@@ -32122,7 +32122,7 @@ engine has prepared three files in your working directory:
|
|
|
32122
32122
|
|
|
32123
32123
|
- \`./synthesizer.md\` — your task definition. Read it first.
|
|
32124
32124
|
- \`./slice.json\` — the source-time query windows for this run.
|
|
32125
|
-
- \`./
|
|
32125
|
+
- \`./docs/\` — the only path that persists back to the host. Anything written
|
|
32126
32126
|
elsewhere is lost when the sandbox exits.
|
|
32127
32127
|
|
|
32128
32128
|
A \`contextengine-synthesizer\` skill is installed. Read and follow it — it defines how to
|
|
@@ -32134,8 +32134,8 @@ not write a manifest or any end-of-run report.
|
|
|
32134
32134
|
function workspaceGuestPath(rootDir) {
|
|
32135
32135
|
return path.resolve(rootDir);
|
|
32136
32136
|
}
|
|
32137
|
-
function
|
|
32138
|
-
return path.join(workspaceGuestPath(rootDir), "
|
|
32137
|
+
function docsGuestPath(rootDir) {
|
|
32138
|
+
return path.join(workspaceGuestPath(rootDir), "docs");
|
|
32139
32139
|
}
|
|
32140
32140
|
function synthesizerGuestPath(rootDir) {
|
|
32141
32141
|
return path.join(workspaceGuestPath(rootDir), "synthesizer.md");
|
|
@@ -32150,8 +32150,8 @@ function buildSynthesizerSandboxLayout(input) {
|
|
|
32150
32150
|
const rootDir = path.resolve(input.rootDir);
|
|
32151
32151
|
return {
|
|
32152
32152
|
bindMounts: [{
|
|
32153
|
-
guestPath:
|
|
32154
|
-
hostPath: input.
|
|
32153
|
+
guestPath: docsGuestPath(rootDir),
|
|
32154
|
+
hostPath: input.docsHostDir ?? path.join(rootDir, "docs"),
|
|
32155
32155
|
hostPathBehavior: "createDir",
|
|
32156
32156
|
mode: "rw"
|
|
32157
32157
|
}],
|
|
@@ -32259,7 +32259,7 @@ var MicrosandboxClaudeExecutor = class {
|
|
|
32259
32259
|
rootDir: input.rootDir,
|
|
32260
32260
|
sliceJson: input.sliceJson,
|
|
32261
32261
|
synthesizerBody: input.synthesizerBody,
|
|
32262
|
-
...input.
|
|
32262
|
+
...input.docsHostDir !== void 0 && { docsHostDir: input.docsHostDir }
|
|
32263
32263
|
});
|
|
32264
32264
|
const bootConfig = buildClaudeBootConfig({
|
|
32265
32265
|
bindMounts: layout.bindMounts,
|
|
@@ -32333,21 +32333,22 @@ function buildMicrosandboxClaudeRunPlan(input) {
|
|
|
32333
32333
|
sandboxName: input.sandboxName
|
|
32334
32334
|
};
|
|
32335
32335
|
}
|
|
32336
|
-
const
|
|
32337
|
-
const
|
|
32336
|
+
const RESERVED_DOCS_SUBDIRS = new Set(["types", "views"]);
|
|
32337
|
+
const DOCS_SUBDIR = "docs";
|
|
32338
32338
|
const CURSORS_DIR_RELATIVE = ".engine/cursors";
|
|
32339
32339
|
async function planRootReset(rootDir) {
|
|
32340
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));
|
|
32341
32342
|
return {
|
|
32342
|
-
|
|
32343
|
-
|
|
32343
|
+
cursorPaths: cursorFiles.map((name) => path.join(CURSORS_DIR_RELATIVE, name)).sort(),
|
|
32344
|
+
docsRemovalPaths: docsRemovalNames.map((name) => path.join(DOCS_SUBDIR, name)).sort()
|
|
32344
32345
|
};
|
|
32345
32346
|
}
|
|
32346
32347
|
async function runRootReset(repo, options = {}) {
|
|
32347
32348
|
const preflight = await runRootPreflight(repo);
|
|
32348
32349
|
if (!preflight.ready && !options.force) throw new Error(formatNotReadyError(repo, preflight.issues));
|
|
32349
32350
|
const plan = await planRootReset(repo.rootDir);
|
|
32350
|
-
for (const relativePath of [...plan.cursorPaths, ...plan.
|
|
32351
|
+
for (const relativePath of [...plan.cursorPaths, ...plan.docsRemovalPaths]) await rm(path.join(repo.rootDir, relativePath), {
|
|
32351
32352
|
force: true,
|
|
32352
32353
|
recursive: true
|
|
32353
32354
|
});
|
|
@@ -32357,8 +32358,8 @@ async function runRootReset(repo, options = {}) {
|
|
|
32357
32358
|
return {
|
|
32358
32359
|
commit: { sha },
|
|
32359
32360
|
kind: "reset",
|
|
32360
|
-
|
|
32361
|
-
|
|
32361
|
+
removedCursors: plan.cursorPaths,
|
|
32362
|
+
removedDocsPaths: plan.docsRemovalPaths
|
|
32362
32363
|
};
|
|
32363
32364
|
}
|
|
32364
32365
|
async function readDirNames(dir) {
|
|
@@ -38093,13 +38094,13 @@ async function runAdHocCommand(input) {
|
|
|
38093
38094
|
paths: input.paths,
|
|
38094
38095
|
workspaceId
|
|
38095
38096
|
});
|
|
38096
|
-
const
|
|
38097
|
+
const docsHostDir = resolve(input.out);
|
|
38097
38098
|
const outcome = await engine.runAdHoc({
|
|
38099
|
+
docsHostDir,
|
|
38098
38100
|
hooks: {
|
|
38099
38101
|
onStderr: (chunk) => process.stderr.write(chunk),
|
|
38100
38102
|
onStdout: (chunk) => process.stdout.write(chunk)
|
|
38101
38103
|
},
|
|
38102
|
-
outputDir,
|
|
38103
38104
|
synthesizerName: input.synthesizerName,
|
|
38104
38105
|
...window.from !== void 0 && { fromMs: window.from },
|
|
38105
38106
|
...window.to !== void 0 && { toMs: window.to },
|
|
@@ -38108,7 +38109,7 @@ async function runAdHocCommand(input) {
|
|
|
38108
38109
|
process.stderr.write(`${formatJsonOutput({
|
|
38109
38110
|
durationMs: outcome.durationMs,
|
|
38110
38111
|
exitCode: outcome.exitCode,
|
|
38111
|
-
out:
|
|
38112
|
+
out: docsHostDir,
|
|
38112
38113
|
status: outcome.status
|
|
38113
38114
|
})}\n`);
|
|
38114
38115
|
if (outcome.status !== "success") process.exitCode = 1;
|
|
@@ -38885,8 +38886,8 @@ async function runResetCommand(input) {
|
|
|
38885
38886
|
issues: preflight.issues,
|
|
38886
38887
|
ready: preflight.ready,
|
|
38887
38888
|
wouldRemove: {
|
|
38888
|
-
|
|
38889
|
-
|
|
38889
|
+
cursors: plan.cursorPaths,
|
|
38890
|
+
docs: plan.docsRemovalPaths
|
|
38890
38891
|
}
|
|
38891
38892
|
})}\n`);
|
|
38892
38893
|
return;
|
|
@@ -38966,7 +38967,7 @@ function createProgram() {
|
|
|
38966
38967
|
program.command("list").description("List synthesizers").action(async function() {
|
|
38967
38968
|
await runEngineListCommand(resolveRuntimePaths(this));
|
|
38968
38969
|
});
|
|
38969
|
-
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) {
|
|
38970
38971
|
const workspaceId = resolveWorkspaceId({ cliValue: options.workspaceId });
|
|
38971
38972
|
await runEngineStatusCommand(synthesizerName, resolveRuntimePaths(this), await resolveSyncHorizonCapture({ workspaceId }));
|
|
38972
38973
|
});
|
|
@@ -38979,14 +38980,14 @@ function createProgram() {
|
|
|
38979
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() {
|
|
38980
38981
|
await runRepairCommand(resolveRepoContext(this));
|
|
38981
38982
|
});
|
|
38982
|
-
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) {
|
|
38983
38984
|
await runResetCommand({
|
|
38984
38985
|
force: options.force ?? false,
|
|
38985
38986
|
repo: resolveRepoContext(this),
|
|
38986
38987
|
yes: options.yes ?? false
|
|
38987
38988
|
});
|
|
38988
38989
|
});
|
|
38989
|
-
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) {
|
|
38990
38991
|
await runAdHocCommand({
|
|
38991
38992
|
from: options.from,
|
|
38992
38993
|
last: options.last,
|
|
@@ -39036,4 +39037,4 @@ runCli().catch((error) => {
|
|
|
39036
39037
|
//#endregion
|
|
39037
39038
|
export { createProgram, resolveRepoContext, resolveRuntimePaths, runCli };
|
|
39038
39039
|
//# sourceMappingURL=cli.mjs.map
|
|
39039
|
-
//# debugId=
|
|
39040
|
+
//# debugId=1fc8117f-7ec8-5237-b3fc-002c9d8e686e
|