fix(models): skipped configured hooks in catalog listing
This commit is contained in:
@@ -160,6 +160,10 @@
|
||||
|
||||
- Fixed hidden tool snapshots preventing long streamed assistant responses from entering terminal scrollback ([#8285](https://github.com/can1357/oh-my-pi/pull/8285) by [@dannyboy-ai](https://github.com/dannyboy-ai)).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Prevented `omp models` from loading ambient hook factories while preserving extension-contributed providers ([#8414](https://github.com/can1357/oh-my-pi/pull/8414) by [@starlink-awaken](https://github.com/starlink-awaken)).
|
||||
|
||||
## [17.2.15] - 2026-08-12
|
||||
|
||||
### Added
|
||||
|
||||
@@ -666,12 +666,14 @@ export async function discoverExtensionPaths(
|
||||
// runner, which owns the current runtime event bus. Non-ambient discovery
|
||||
// scans only this invocation's configured package roots; it must not consult
|
||||
// settings, installed packages, or process-global CLI injection state.
|
||||
if (ambient && options.includeAmbientHooks !== false) {
|
||||
const hooks = await loadCapability<Hook>(hookCapability.id, loadOptions);
|
||||
for (const hookPath of hooks.items
|
||||
.map(hook => hook.path)
|
||||
.filter(hookPath => isExtensionFile(path.basename(hookPath)))) {
|
||||
addPath(hookPath);
|
||||
if (ambient) {
|
||||
if (options.includeAmbientHooks !== false) {
|
||||
const hooks = await loadCapability<Hook>(hookCapability.id, loadOptions);
|
||||
for (const hookPath of hooks.items
|
||||
.map(hook => hook.path)
|
||||
.filter(hookPath => isExtensionFile(path.basename(hookPath)))) {
|
||||
addPath(hookPath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const configuredPath of configuredPaths) {
|
||||
|
||||
@@ -25,6 +25,7 @@ let extPath: string;
|
||||
let explicitPackagePath: string;
|
||||
let ambientExtPath: string;
|
||||
let ambientHookMarkerPath: string;
|
||||
let configuredHookMarkerPath: string;
|
||||
let dbPath: string;
|
||||
let shutdownExtPath: string;
|
||||
let shutdownPath: string;
|
||||
@@ -67,7 +68,9 @@ beforeAll(async () => {
|
||||
explicitPackagePath = tmp.join("explicit-package");
|
||||
ambientExtPath = tmp.join("ambient.ts");
|
||||
ambientHookMarkerPath = tmp.join("ambient-hook-loaded");
|
||||
configuredHookMarkerPath = tmp.join("configured-hook-loaded");
|
||||
await fs.mkdir(tmp.join("explicit-package", "src"), { recursive: true });
|
||||
await fs.mkdir(tmp.join("explicit-package", "hooks", "pre"), { recursive: true });
|
||||
const hookDir = path.join(getProjectAgentDir(tmp.path()), "hooks", "pre");
|
||||
await fs.mkdir(hookDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
@@ -80,6 +83,12 @@ export default function () {}
|
||||
tmp.join("explicit-package", "package.json"),
|
||||
JSON.stringify({ name: "explicit-package", omp: { extensions: ["./src/main.ts"] } }),
|
||||
);
|
||||
await fs.writeFile(
|
||||
tmp.join("explicit-package", "hooks", "pre", "models-poison.ts"),
|
||||
`await Bun.write(${JSON.stringify(configuredHookMarkerPath)}, "loaded");
|
||||
export default function () {}
|
||||
`,
|
||||
);
|
||||
await fs.writeFile(
|
||||
tmp.join("explicit-package", "src", "main.ts"),
|
||||
`export default function (pi) {
|
||||
@@ -174,16 +183,17 @@ test("omp models does not execute ambient hooks while retaining explicit provide
|
||||
modelRegistry,
|
||||
cwd: tmp.path(),
|
||||
action: "ls",
|
||||
additionalExtensionPaths: [extPath],
|
||||
additionalExtensionPaths: [explicitPackagePath],
|
||||
});
|
||||
} finally {
|
||||
process.stdout.write = originalWrite;
|
||||
}
|
||||
|
||||
const output = captured.join("");
|
||||
expect(output).toContain("test-gw");
|
||||
expect(output).toContain("test-model");
|
||||
expect(output).toContain("explicit-gw");
|
||||
expect(output).toContain("explicit-model");
|
||||
expect(await Bun.file(ambientHookMarkerPath).exists()).toBe(false);
|
||||
expect(await Bun.file(configuredHookMarkerPath).exists()).toBe(false);
|
||||
} finally {
|
||||
authStorage.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user