docks-kit 0.20.6 → 0.20.8
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/AGENTS.md +18 -16
- package/README.md +17 -6
- package/cli/docs/command-guards.md +269 -0
- package/cli/docs/install.md +23 -12
- package/cli/docs/models.md +3 -2
- package/cli/docs/modifiers.md +4 -3
- package/cli/docs/omp-context.md +9 -2
- package/cli/docs/omp-models.md +43 -19
- package/cli/docs/plugins.md +12 -7
- package/cli/docs/sync-layers.md +26 -9
- package/cli/docs/toolchain.md +7 -4
- package/cli/src/argv.ts +2 -0
- package/cli/src/argvSurface.ts +23 -0
- package/cli/src/argvValidate.ts +3 -3
- package/cli/src/commands/docs.ts +6 -1
- package/cli/src/commands/harnesses.ts +15 -4
- package/cli/src/commands/omp.ts +92 -41
- package/cli/src/commands/status.ts +15 -0
- package/cli/src/commands/sync.ts +6 -6
- package/cli/src/commands/toolchain.ts +8 -2
- package/cli/src/commands/update.ts +51 -10
- package/cli/src/engine-native/DESIGN.md +56 -35
- package/cli/src/engine-native/atomicWrite.ts +64 -0
- package/cli/src/engine-native/claudeLsp.ts +9 -2
- package/cli/src/engine-native/claudeOptionalPlugins.ts +19 -6
- package/cli/src/engine-native/claudePluginPasses.ts +77 -21
- package/cli/src/engine-native/claudeRemovals.ts +245 -57
- package/cli/src/engine-native/claudeRetired.ts +1 -1
- package/cli/src/engine-native/claudeSettings.ts +46 -19
- package/cli/src/engine-native/claudeSettingsModifiers.ts +3 -3
- package/cli/src/engine-native/claudeSync.ts +18 -16
- package/cli/src/engine-native/codexConfig.ts +72 -12
- package/cli/src/engine-native/codexHooks.ts +3 -3
- package/cli/src/engine-native/codexPaths.ts +14 -0
- package/cli/src/engine-native/codexPlugins.ts +48 -23
- package/cli/src/engine-native/codexStatus.ts +2 -1
- package/cli/src/engine-native/codexSync.ts +33 -7
- package/cli/src/engine-native/codexToml.ts +161 -35
- package/cli/src/engine-native/deps.ts +4 -9
- package/cli/src/engine-native/engineCtx.ts +42 -14
- package/cli/src/engine-native/exec.ts +28 -1
- package/cli/src/engine-native/harnesses.ts +32 -8
- package/cli/src/engine-native/index.ts +6 -1
- package/cli/src/engine-native/kitDb.ts +12 -6
- package/cli/src/engine-native/liveModels.ts +2 -1
- package/cli/src/engine-native/models.ts +6 -3
- package/cli/src/engine-native/modes.ts +15 -10
- package/cli/src/engine-native/ompFileDeploy.ts +3 -4
- package/cli/src/engine-native/ompMarketplace.ts +9 -7
- package/cli/src/engine-native/ompOverlay.ts +37 -13
- package/cli/src/engine-native/ompPaths.ts +20 -9
- package/cli/src/engine-native/ompPlugins.ts +16 -15
- package/cli/src/engine-native/ompSync.ts +11 -6
- package/cli/src/engine-native/ompYaml.ts +91 -6
- package/cli/src/engine-native/os/darwin.ts +2 -0
- package/cli/src/engine-native/os/linux.ts +1 -0
- package/cli/src/engine-native/os/posix.ts +17 -5
- package/cli/src/engine-native/os/types.ts +2 -2
- package/cli/src/engine-native/os/windows.ts +24 -16
- package/cli/src/engine-native/skillsInstall.ts +10 -5
- package/cli/src/engine-native/skillsLinks.ts +14 -1
- package/cli/src/engine-native/skillsManifest.ts +20 -0
- package/cli/src/engine-native/skillsPrune.ts +33 -26
- package/cli/src/engine-native/skillsSync.ts +6 -3
- package/cli/src/engine-native/syncDispatch.ts +32 -18
- package/cli/src/engine.ts +29 -3
- package/cli/src/generated/sotPayload.ts +14 -14
- package/cli/src/main.ts +10 -3
- package/cli/src/manifests.ts +29 -11
- package/docks-kit +6 -3
- package/docks-kit.ps1 +22 -11
- package/package.json +1 -1
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
* be a behavior change. Guard order, message strings, and backup behavior
|
|
5
5
|
* are golden-tested.
|
|
6
6
|
*/
|
|
7
|
-
import { copyFileSync, existsSync, readFileSync,
|
|
7
|
+
import { copyFileSync, existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
8
8
|
|
|
9
9
|
import { payloadDisplayPath } from "../payload";
|
|
10
|
-
import {
|
|
10
|
+
import { replaceFile } from "./atomicWrite";
|
|
11
|
+
import {
|
|
12
|
+
isTomlHeaderLine,
|
|
13
|
+
mergeTableSettings,
|
|
14
|
+
mergeTopLevelSettings,
|
|
15
|
+
tomlContinuationLines,
|
|
16
|
+
} from "./codexToml";
|
|
11
17
|
import type { Ctx } from "./index";
|
|
12
18
|
|
|
13
19
|
// --------------------------------------------------------------- config ----
|
|
@@ -37,21 +43,26 @@ export function syncConfig(ctx: Ctx, sotConfigText: string, userConfig: string):
|
|
|
37
43
|
// overwrite the recovery copy with already-merged content.
|
|
38
44
|
const before = readFileSync(userConfig, "utf8");
|
|
39
45
|
const staging = `${userConfig}.merge.tmp`;
|
|
40
|
-
// Normalize once before record transforms
|
|
41
|
-
|
|
46
|
+
// Normalize once before record transforms: a BOM hides the first key or
|
|
47
|
+
// header, and CR bytes change table-header identity.
|
|
48
|
+
writeFileSync(staging, before.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n"));
|
|
42
49
|
|
|
43
50
|
scrubDeprecatedFeatures(ctx, staging);
|
|
44
51
|
removeRetiredPluginTables(ctx, staging);
|
|
52
|
+
removeRetiredTopLevelSettings(ctx, staging);
|
|
45
53
|
mergeTopLevelSettings(sotConfigText, staging);
|
|
46
54
|
mergeTableSettings(sotConfigText, staging);
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
const merged = readFileSync(staging, "utf8");
|
|
57
|
+
rmSync(staging, { force: true });
|
|
58
|
+
if (merged === before) {
|
|
50
59
|
verbose("Codex config already in sync");
|
|
51
60
|
} else {
|
|
52
61
|
copyFileSync(userConfig, `${userConfig}.bak`);
|
|
53
|
-
|
|
54
|
-
change(
|
|
62
|
+
replaceFile(userConfig, merged);
|
|
63
|
+
change(
|
|
64
|
+
"Codex config merged (backup at config.toml.bak; SoT tables replaced wholesale; user-only top-level keys and tables preserved)",
|
|
65
|
+
);
|
|
55
66
|
ctx.nextStepTriggers.codexRestart = true;
|
|
56
67
|
}
|
|
57
68
|
}
|
|
@@ -106,8 +117,7 @@ function scrubDeprecatedFeatures(ctx: Ctx, userConfig: string): void {
|
|
|
106
117
|
const next = scrubDeprecatedFeaturesText(content);
|
|
107
118
|
if (next === content) return;
|
|
108
119
|
|
|
109
|
-
|
|
110
|
-
renameSync(`${userConfig}.tmp`, userConfig);
|
|
120
|
+
replaceFile(userConfig, next);
|
|
111
121
|
change("Codex: scrubbed deprecated [features].use_legacy_landlock");
|
|
112
122
|
}
|
|
113
123
|
|
|
@@ -152,7 +162,57 @@ export function removeRetiredPluginTables(ctx: Ctx, userConfig: string): void {
|
|
|
152
162
|
const present = retiredPluginTables(content);
|
|
153
163
|
if (present.length === 0) return;
|
|
154
164
|
|
|
155
|
-
|
|
156
|
-
renameSync(`${userConfig}.tmp`, userConfig);
|
|
165
|
+
replaceFile(userConfig, removeRetiredPluginTablesText(content));
|
|
157
166
|
for (const id of present) change(`Codex: removed retired plugin table [plugins."${id}"]`);
|
|
158
167
|
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Top-level settings the kit retired. Each sync removes a deployed top-level
|
|
171
|
+
* line that holds exactly the retired kit value. A different user value stays.
|
|
172
|
+
*/
|
|
173
|
+
const RETIRED_TOP_LEVEL_SETTINGS: ReadonlyArray<{
|
|
174
|
+
readonly setting: string;
|
|
175
|
+
readonly pattern: RegExp;
|
|
176
|
+
}> = [
|
|
177
|
+
// Codex 0.159.0 deprecated `personality`; "pragmatic" no longer selects a style.
|
|
178
|
+
{
|
|
179
|
+
setting: 'personality = "pragmatic"',
|
|
180
|
+
pattern: /^[ \t]*personality[ \t]*=[ \t]*"pragmatic"[ \t]*$/,
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
/** Drop top-level lines that hold a retired kit setting; returns the text and the removed settings. */
|
|
185
|
+
function removeRetiredTopLevelSettingsText(content: string): {
|
|
186
|
+
readonly text: string;
|
|
187
|
+
readonly removed: ReadonlyArray<string>;
|
|
188
|
+
} {
|
|
189
|
+
const lines = content.split("\n");
|
|
190
|
+
const continuation = tomlContinuationLines(lines);
|
|
191
|
+
const removed: Array<string> = [];
|
|
192
|
+
const kept: Array<string> = [];
|
|
193
|
+
let inTable = false;
|
|
194
|
+
for (const [index, line] of lines.entries()) {
|
|
195
|
+
if (continuation[index] !== true && !inTable) {
|
|
196
|
+
if (isTomlHeaderLine(line)) {
|
|
197
|
+
inTable = true;
|
|
198
|
+
} else {
|
|
199
|
+
const retired = RETIRED_TOP_LEVEL_SETTINGS.find(({ pattern }) => pattern.test(line));
|
|
200
|
+
if (retired !== undefined) {
|
|
201
|
+
removed.push(retired.setting);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
kept.push(line);
|
|
207
|
+
}
|
|
208
|
+
return { text: removed.length === 0 ? content : kept.join("\n"), removed };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function removeRetiredTopLevelSettings(ctx: Ctx, userConfig: string): void {
|
|
212
|
+
const { change } = ctx.services.logger;
|
|
213
|
+
const { text, removed } = removeRetiredTopLevelSettingsText(readFileSync(userConfig, "utf8"));
|
|
214
|
+
if (removed.length === 0) return;
|
|
215
|
+
|
|
216
|
+
replaceFile(userConfig, text);
|
|
217
|
+
for (const setting of removed) change(`Codex: removed retired top-level setting ${setting}`);
|
|
218
|
+
}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* docks-kit retired before Codex could import them safely. Guard order,
|
|
4
4
|
* message strings, and backup behavior are golden-tested.
|
|
5
5
|
*/
|
|
6
|
-
import { copyFileSync, existsSync, readFileSync
|
|
6
|
+
import { copyFileSync, existsSync, readFileSync } from "node:fs";
|
|
7
7
|
|
|
8
|
+
import { replaceFile } from "./atomicWrite";
|
|
8
9
|
import { p } from "./exec";
|
|
9
10
|
import type { Ctx } from "./index";
|
|
10
11
|
import { isObject, jqStringify, parseJson, type Json } from "./jq";
|
|
@@ -82,8 +83,7 @@ export function removeRetiredImportedHooks(ctx: Ctx, codexDir: string): void {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
copyFileSync(hooksFile, `${hooksFile}.bak`);
|
|
85
|
-
|
|
86
|
-
renameSync(`${hooksFile}.tmp`, hooksFile);
|
|
86
|
+
replaceFile(hooksFile, jqStringify(result.value));
|
|
87
87
|
change(
|
|
88
88
|
`Codex: removed ${result.removed} retired imported docks-kit SessionStart hook(s) (backup at hooks.json.bak)`,
|
|
89
89
|
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex home resolution. Codex reads CODEX_HOME when it is set and not empty,
|
|
3
|
+
* and otherwise uses ~/.codex, so every kit read or write of Codex state uses
|
|
4
|
+
* the same rule.
|
|
5
|
+
*/
|
|
6
|
+
import { isAbsolute, resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { p } from "./exec";
|
|
9
|
+
|
|
10
|
+
export function codexHome(home: string, env: NodeJS.ProcessEnv = process.env): string {
|
|
11
|
+
const override = env["CODEX_HOME"];
|
|
12
|
+
if (override === undefined || override === "") return p(home, ".codex");
|
|
13
|
+
return isAbsolute(override) ? override : resolve(override);
|
|
14
|
+
}
|
|
@@ -3,16 +3,10 @@
|
|
|
3
3
|
* merge, legacy marketplace removal, and enabled-plugin refresh. Message
|
|
4
4
|
* strings and backup behavior are golden-tested.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
copyFileSync,
|
|
8
|
-
existsSync,
|
|
9
|
-
mkdirSync,
|
|
10
|
-
readFileSync,
|
|
11
|
-
renameSync,
|
|
12
|
-
writeFileSync,
|
|
13
|
-
} from "node:fs";
|
|
6
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
14
7
|
|
|
15
8
|
import { payloadDisplayPath } from "../payload";
|
|
9
|
+
import { replaceFile } from "./atomicWrite";
|
|
16
10
|
import { PLUGIN_TABLE_HEADER } from "./codexConfig";
|
|
17
11
|
import { isTomlHeaderLine } from "./codexToml";
|
|
18
12
|
import { p, processFailureSummary, spawnProcess } from "./exec";
|
|
@@ -23,12 +17,18 @@ import type { JsonObject } from "./sharedTypes";
|
|
|
23
17
|
|
|
24
18
|
// ---------------------------------------------------------- marketplace ----
|
|
25
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Merge the SoT marketplace into the deployed personal marketplace. Codex
|
|
22
|
+
* resolves a plugin id `<plugin>@<marketplace>` through the file's top-level
|
|
23
|
+
* `name`. When the deployed file has a different name, the file stays as it is
|
|
24
|
+
* and the SoT marketplace name comes back, because kit plugin ids cannot resolve.
|
|
25
|
+
*/
|
|
26
26
|
export function syncMarketplace(
|
|
27
27
|
ctx: Ctx,
|
|
28
28
|
sotMarketplaceText: string,
|
|
29
29
|
userMarketplace: string,
|
|
30
|
-
):
|
|
31
|
-
const { change, echo, verbose } = ctx.services.logger;
|
|
30
|
+
): string | undefined {
|
|
31
|
+
const { change, echo, verbose, warn } = ctx.services.logger;
|
|
32
32
|
const sotMarketplace = payloadDisplayPath("SoT/.codex/plugins/marketplace.json");
|
|
33
33
|
const repo = parseJson(sotMarketplaceText);
|
|
34
34
|
if (repo === undefined) throw new Error(`invalid SoT marketplace JSON: ${sotMarketplace}`);
|
|
@@ -40,6 +40,18 @@ export function syncMarketplace(
|
|
|
40
40
|
`invalid deployed Codex marketplace JSON: ${userMarketplace}. Fix or delete it.`,
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
const sotName = isObject(repo) && typeof repo["name"] === "string" ? repo["name"] : undefined;
|
|
45
|
+
const userName =
|
|
46
|
+
user !== undefined && isObject(user) && typeof user["name"] === "string"
|
|
47
|
+
? user["name"]
|
|
48
|
+
: undefined;
|
|
49
|
+
if (sotName !== undefined && userName !== undefined && userName !== sotName) {
|
|
50
|
+
warn(
|
|
51
|
+
`Codex personal marketplace ${userMarketplace} is named "${userName}", but kit plugins need "${sotName}". Rename it to "${sotName}" and update your [plugins."<plugin>@${userName}"] tables, or move your plugins to a different marketplace. Then run sync again.`,
|
|
52
|
+
);
|
|
53
|
+
return sotName;
|
|
54
|
+
}
|
|
43
55
|
const out = user === undefined ? undefined : jqStringify(mergeMarketplace(repo, user));
|
|
44
56
|
|
|
45
57
|
if (ctx.dryRun) {
|
|
@@ -52,25 +64,26 @@ export function syncMarketplace(
|
|
|
52
64
|
`[dry-run] merge ${sotMarketplace} -> ${userMarketplace} (backup at ${userMarketplace}.bak)`,
|
|
53
65
|
);
|
|
54
66
|
}
|
|
55
|
-
return;
|
|
67
|
+
return undefined;
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
mkdirSync(p(ctx.agentsDir, "plugins"), { recursive: true });
|
|
59
71
|
if (userText !== undefined && out !== undefined) {
|
|
60
72
|
if (out === userText) {
|
|
61
73
|
verbose("Codex marketplace already in sync");
|
|
62
|
-
return;
|
|
74
|
+
return undefined;
|
|
63
75
|
}
|
|
64
76
|
copyFileSync(userMarketplace, `${userMarketplace}.bak`);
|
|
65
|
-
|
|
66
|
-
renameSync(`${userMarketplace}.tmp`, userMarketplace);
|
|
77
|
+
replaceFile(userMarketplace, out);
|
|
67
78
|
change("Codex marketplace merged (backup at marketplace.json.bak)");
|
|
68
79
|
ctx.nextStepTriggers.codexRestart = true;
|
|
69
80
|
} else {
|
|
70
|
-
|
|
81
|
+
// Install the merge form, so the next sync merges to the same bytes.
|
|
82
|
+
writeFileSync(userMarketplace, jqStringify(mergeMarketplace(repo, {})));
|
|
71
83
|
change("Codex marketplace installed");
|
|
72
84
|
ctx.nextStepTriggers.codexRestart = true;
|
|
73
85
|
}
|
|
86
|
+
return undefined;
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
/**
|
|
@@ -190,11 +203,9 @@ function enabledPluginIdsFromText(configText: string): Array<string> {
|
|
|
190
203
|
return ids;
|
|
191
204
|
}
|
|
192
205
|
|
|
193
|
-
function
|
|
194
|
-
const first =
|
|
195
|
-
return first !== undefined
|
|
196
|
-
? `codex plugin add ${first}`
|
|
197
|
-
: "codex plugin add <plugin@marketplace>";
|
|
206
|
+
function manualPluginRefreshHint(pluginIds: ReadonlyArray<string>): string {
|
|
207
|
+
const first = pluginIds[0];
|
|
208
|
+
return first !== undefined ? `; then run: codex plugin add ${first}` : "";
|
|
198
209
|
}
|
|
199
210
|
|
|
200
211
|
async function installedPluginIdsFromCli(): Promise<Set<string> | undefined> {
|
|
@@ -214,9 +225,23 @@ async function installedPluginIdsFromCli(): Promise<Set<string> | undefined> {
|
|
|
214
225
|
return ids;
|
|
215
226
|
}
|
|
216
227
|
|
|
217
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Add the SoT-enabled plugins through the Codex CLI. `unresolvedMarketplace`
|
|
230
|
+
* names a marketplace that syncMarketplace could not deploy; ids from it are
|
|
231
|
+
* skipped, because `codex plugin add` cannot resolve them.
|
|
232
|
+
*/
|
|
233
|
+
export async function syncPlugins(
|
|
234
|
+
ctx: Ctx,
|
|
235
|
+
sotConfigText: string,
|
|
236
|
+
unresolvedMarketplace?: string,
|
|
237
|
+
): Promise<void> {
|
|
218
238
|
const { change, clearProgress, echo, progress, verbose, warn } = ctx.services.logger;
|
|
239
|
+
const desiredPluginIds = enabledPluginIdsFromText(sotConfigText).filter(
|
|
240
|
+
(pluginId) =>
|
|
241
|
+
unresolvedMarketplace === undefined || !pluginId.endsWith(`@${unresolvedMarketplace}`),
|
|
242
|
+
);
|
|
219
243
|
if (ctx.dryRun) {
|
|
244
|
+
if (desiredPluginIds.length === 0) return;
|
|
220
245
|
echo(
|
|
221
246
|
ctx.skipPluginRefresh
|
|
222
247
|
? "[dry-run] add missing enabled Codex plugins from SoT; skip refresh-only plugin updates"
|
|
@@ -227,10 +252,11 @@ export async function syncPlugins(ctx: Ctx, sotConfigText: string): Promise<void
|
|
|
227
252
|
|
|
228
253
|
if (ctx.services.deps.probe("codex").state === "missing") {
|
|
229
254
|
warn(
|
|
230
|
-
`codex CLI not in PATH - deployed config/marketplace only; install Codex with: ${standaloneInstallCommand(ctx)} | docs: https://developers.openai.com/codex/cli
|
|
255
|
+
`codex CLI not in PATH - deployed config/marketplace only; install Codex with: ${standaloneInstallCommand(ctx)} | docs: https://developers.openai.com/codex/cli${manualPluginRefreshHint(desiredPluginIds)}`,
|
|
231
256
|
);
|
|
232
257
|
return;
|
|
233
258
|
}
|
|
259
|
+
if (desiredPluginIds.length === 0) return;
|
|
234
260
|
if (ctx.services.deps.probe("git").state === "missing") {
|
|
235
261
|
ctx.services.deps.warnMissing(
|
|
236
262
|
"git",
|
|
@@ -240,7 +266,6 @@ export async function syncPlugins(ctx: Ctx, sotConfigText: string): Promise<void
|
|
|
240
266
|
return;
|
|
241
267
|
}
|
|
242
268
|
|
|
243
|
-
const desiredPluginIds = enabledPluginIdsFromText(sotConfigText);
|
|
244
269
|
let pluginIds = desiredPluginIds;
|
|
245
270
|
if (ctx.skipPluginRefresh) {
|
|
246
271
|
progress("Checking installed Codex plugins...");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EngineNative Codex status reporting: summary lines and next-step hints.
|
|
3
3
|
*/
|
|
4
|
+
import { codexHome } from "./codexPaths";
|
|
4
5
|
import { p } from "./exec";
|
|
5
6
|
import { enabledPluginIds } from "./codexPlugins";
|
|
6
7
|
import type { Ctx } from "./index";
|
|
@@ -9,7 +10,7 @@ import type { Ctx } from "./index";
|
|
|
9
10
|
|
|
10
11
|
export function codexSummary(ctx: Ctx): void {
|
|
11
12
|
const { echo } = ctx.services.logger;
|
|
12
|
-
const codexDir =
|
|
13
|
+
const codexDir = codexHome(ctx.home);
|
|
13
14
|
echo(`Codex: ${codexDir}`);
|
|
14
15
|
if (!ctx.dryRun) {
|
|
15
16
|
const count = enabledPluginIds(p(codexDir, "config.toml")).length;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
7
|
|
|
8
|
+
import { resolveEffort } from "../efforts";
|
|
8
9
|
import {
|
|
9
10
|
payloadBytes,
|
|
10
11
|
payloadDisplayPath,
|
|
@@ -14,8 +15,9 @@ import {
|
|
|
14
15
|
} from "../payload";
|
|
15
16
|
import { syncConfig } from "./codexConfig";
|
|
16
17
|
import { removeRetiredImportedHooks } from "./codexHooks";
|
|
18
|
+
import { codexHome } from "./codexPaths";
|
|
17
19
|
import { removeLegacyDocksMarketplace, syncMarketplace, syncPlugins } from "./codexPlugins";
|
|
18
|
-
import { syncCodexEffort, syncCodexModel } from "./codexToml";
|
|
20
|
+
import { replaceTopLevelSetting, syncCodexEffort, syncCodexModel } from "./codexToml";
|
|
19
21
|
import { p, spawnProcess } from "./exec";
|
|
20
22
|
import type { Ctx } from "./index";
|
|
21
23
|
import { compareCodepoints } from "./jq";
|
|
@@ -25,25 +27,49 @@ export { removeRetiredPluginTablesText } from "./codexConfig";
|
|
|
25
27
|
export { codexNextSteps, codexSummary } from "./codexStatus";
|
|
26
28
|
|
|
27
29
|
export async function codexSync(ctx: Ctx): Promise<void> {
|
|
28
|
-
const codexDir =
|
|
30
|
+
const codexDir = codexHome(ctx.home);
|
|
29
31
|
const sotConfig = payloadText("SoT/.codex/config.toml");
|
|
30
32
|
const userConfig = p(codexDir, "config.toml");
|
|
31
33
|
|
|
34
|
+
// Merge the SoT with the --codex-model / --codex-effort values already applied.
|
|
35
|
+
// A repeated modifier run then merges to the same bytes and keeps config.toml.bak.
|
|
36
|
+
let deployedSotConfig = sotConfig;
|
|
37
|
+
if (ctx.codexModel !== "") {
|
|
38
|
+
deployedSotConfig = replaceTopLevelSetting(
|
|
39
|
+
deployedSotConfig,
|
|
40
|
+
"model",
|
|
41
|
+
`model = "${ctx.codexModel}"`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (ctx.codexEffort !== "") {
|
|
45
|
+
deployedSotConfig = replaceTopLevelSetting(
|
|
46
|
+
deployedSotConfig,
|
|
47
|
+
"model_reasoning_effort",
|
|
48
|
+
`model_reasoning_effort = "${resolveEffort("codex", ctx.codexEffort)}"`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
32
52
|
await ensureBubblewrap(ctx);
|
|
33
53
|
if (!ctx.dryRun) mkdirSync(codexDir, { recursive: true });
|
|
34
|
-
|
|
54
|
+
// Only a real sync compares against this text; a dry run reads nothing.
|
|
55
|
+
const deployedBefore = ctx.dryRun
|
|
56
|
+
? undefined
|
|
57
|
+
: existsSync(userConfig)
|
|
58
|
+
? readFileSync(userConfig, "utf8")
|
|
59
|
+
: "";
|
|
60
|
+
syncConfig(ctx, deployedSotConfig, userConfig);
|
|
35
61
|
removeRetiredImportedHooks(ctx, codexDir);
|
|
36
|
-
syncCodexModel(ctx, ctx.codexModel);
|
|
37
|
-
syncCodexEffort(ctx, ctx.codexEffort);
|
|
62
|
+
syncCodexModel(ctx, ctx.codexModel, deployedBefore);
|
|
63
|
+
syncCodexEffort(ctx, ctx.codexEffort, deployedBefore);
|
|
38
64
|
syncRules(ctx, payloadPaths("SoT/.codex/rules/"), p(codexDir, "rules"));
|
|
39
65
|
syncAgentsMd(ctx, payloadText("SoT/.codex/AGENTS.md"), p(codexDir, "AGENTS.md"));
|
|
40
|
-
syncMarketplace(
|
|
66
|
+
const unresolvedMarketplace = syncMarketplace(
|
|
41
67
|
ctx,
|
|
42
68
|
payloadText("SoT/.codex/plugins/marketplace.json"),
|
|
43
69
|
p(ctx.agentsDir, "plugins", "marketplace.json"),
|
|
44
70
|
);
|
|
45
71
|
await removeLegacyDocksMarketplace(ctx, userConfig);
|
|
46
|
-
await syncPlugins(ctx, sotConfig);
|
|
72
|
+
await syncPlugins(ctx, sotConfig, unresolvedMarketplace);
|
|
47
73
|
}
|
|
48
74
|
|
|
49
75
|
// ---------------------------------------------------------- bubblewrap ----
|