Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cli/docs/omp-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ Sync cannot tell the old kit value from the same value that you set again.
It prunes both on every sync. To keep an old kit value, set it in a project
configuration or in a `PI_CONFIG_FILES` file, which sync does not write.

The kit writes no OpenCode setting. Sync still prunes
`commands.enableOpencodeProject: false` (the row above) and
`commands.enableOpencodeUser: false`, which the kit dropped in the omp 18.19.0
cleanup, while they hold that old kit value, also when you set that value
yourself. omp then uses the value of another settings layer, such as a
project configuration or a `PI_CONFIG_FILES` file, or else its own default.
`commands.enableOpencodeProject: false` turns off the project OpenCode
commands, so to keep that opt-out, set it in a project configuration or a
`PI_CONFIG_FILES` file.
`commands.enableOpencodeUser` only adds the user OpenCode commands: `false`
is omp's default, and it does not turn them off when `enabledProviders` opts
OpenCode in.

The `github` tool is off by default. Its `pr_push` operation runs git
directly, so the `bash.patterns` guards do not see it. The `issue://` and
`pr://` read schemes do not need the tool. omp reads them through its GitHub
Expand Down
22 changes: 22 additions & 0 deletions cli/test/unit/ompRemovals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,28 @@ describe("retired omp config keys", () => {
});
});

// An older kit wrote both OpenCode command switches as `false`. Sync prunes
// them at that value only; any other value stays, with the rest of the file.
it("prunes both OpenCode command switches at the old kit value false", () => {
const { file, root } = deployConfig(
"commands:\n enableOpencodeUser: false\n enableOpencodeProject: false\nuserOnly: 1\n",
);

expect(syncOmpRemovals(testCtx(root), file, false)).toBe(2);
expect(parse(readFileSync(file, "utf8"))).toEqual({ userOnly: 1 });
});

it.each([["enableOpencodeUser"], ["enableOpencodeProject"]])(
"keeps commands.%s: true and leaves the file unchanged",
(key) => {
const text = `commands:\n ${key}: true\nuserOnly: 1\n`;
const { file, root } = deployConfig(text);

expect(syncOmpRemovals(testCtx(root), file, false)).toBe(0);
expect(readFileSync(file, "utf8")).toBe(text);
},
);

// The owner returned these 18 overrides to the omp 19.0.0 defaults. Each one
// holds its shipped value here, so sync prunes all 18 in one pass. The user
// edited `compaction.thresholdTokens`, which an earlier kit retired at -1
Expand Down
30 changes: 30 additions & 0 deletions cli/test/unit/ompRetiredSync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,33 @@ describe("public sync over a config.yml from an earlier kit", () => {
SPAWN_TIMEOUT_MS,
);
});

/** Every key name of a parsed YAML value, nested keys included. */
function keyNames(node: unknown): Array<string> {
if (typeof node !== "object" || node === null) return [];
return Object.entries(node).flatMap(([key, value]) => [key, ...keyNames(value)]);
}

describe("public sync of a fresh home", () => {
it(
"writes no OpenCode setting and names no OpenCode setup",
() => {
const nativeHost = { nativeHost: true } as const;
const run = runPublicCli(["sync"], "home-fresh", makeStubDir({}, nativeHost), nativeHost);

expect(run.exitCode, run.stderr).toBe(0);
const config: unknown = parse(
readFileSync(join(run.home, ".omp", "agent", "config.yml"), "utf8"),
);
// A shipped setting first, so an empty or scalar file cannot pass.
expect(valueAt(config, "astGrep.enabled")).toBe(true);
expect(valueAt(config, "commands")).toBeUndefined();
expect(keyNames(config).filter((key) => /opencode/i.test(key))).toEqual([]);
// A provider opt-in, bare or path-scoped, would import the user OpenCode
// commands. The kit ships no `enabledProviders`, so none may appear.
expect(valueAt(config, "enabledProviders")).toBeUndefined();
expect(`${run.stdout}${run.stderr}`).not.toMatch(/opencode/i);
},
SPAWN_TIMEOUT_MS,
);
});
Loading