Replace the createRequire fallback with a direct Mistral import so the CJS build stops emitting the import.meta warning.
Refresh the bundled out/cli.cjs artifact after the change.
Split smoke, core, and prompt-module suites and make test:e2e self-contained with an explicit build step and version-check bypass.
Move core CLI coverage to a process-based harness with mock OpenAI boundary checks, add user-path scenarios, refresh CI jobs, and commit the rebuilt out/cli.cjs artifact.
Support explicit proxy disabling and ambient proxy fallback without leaking env state into config.
Improve first-run detection, endpoint-specific error messaging, diff exclusions, and runtime helper boundaries covered by unit tests.
Adds support for passing the `think` param to Ollama's /api/chat endpoint,
allowing users to disable reasoning blocks on models like qwen3.5 via
`oco config set OCO_OLLAMA_THINK=false`.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous userInputCodeContext only skipped the context block
when context was exactly '' or ' '. Anything else (e.g. a string of
whitespace, null, undefined) would inject an empty or
whitespace-only <context>…</context> tag into the system prompt.
Trim the input and guard against null/undefined:
- accept string | undefined | null
- normalize via `(context ?? '').trim()`
- skip the injection whenever the trimmed value is empty
Also inline the INIT_MAIN_PROMPT IIFE into a normal function body
and introduce a `content` local, removing a layer of nesting that
obscured the prompt assembly. Behavior is unchanged.
getCommitConvention gated the entire GitMoji branch on
config.OCO_EMOJI, so --fgm was silently ignored unless the user had
previously run `oco config set OCO_EMOJI true`. Since OCO_EMOJI
defaults to false, --fgm was a no-op for most users.
This violates the standard CLI convention that command-line flags
should override configuration. Restructure getCommitConvention so
that --fgm forces FULL_GITMOJI_SPEC regardless of OCO_EMOJI:
--fgm=true → FULL_GITMOJI_SPEC
--fgm=false + OCO_EMOJI=true → GITMOJI_HELP (unchanged)
--fgm=false + OCO_EMOJI=false → CONVENTIONAL_COMMIT_KEYWORDS (unchanged)
No other files need changes — the fgm flag was already threaded
correctly through cli.ts → commit.ts → generateCommitMessageByDiff
→ getMainCommitPrompt → getCommitConvention.
When a staged diff exceeds MAX_REQUEST_TOKENS, generateCommitMessageByDiff
routes through getCommitMsgsPromisesFromFileDiffs →
getMessagesPromisesByChangesInFile → generateCommitMessageChatCompletionPrompt
to produce one sub-prompt per chunk. That entire chain was threading
`fullGitMojiSpec` but never `context`, so `-c/--context` was silently
dropped for any diff large enough to trigger chunking, even though
the simple (non-chunked) path forwarded it correctly.
Add a `context` parameter to each of the three helpers and thread it
through to generateCommitMessageChatCompletionPrompt so the user's
context is present in every sub-prompt.
When the user answers "No" at the confirmation prompt and chooses to
regenerate, the recursive call to generateCommitMessageFromGitDiff
forwarded only `diff`, `extraArgs`, and `fullGitMojiSpec`. Both
`context` and `skipCommitConfirmation` were silently dropped, so:
- `-c/--context` was honored only on the first attempt and lost on
every regeneration;
- `-y/--yes` was honored only on the first attempt, forcing a manual
confirmation after regeneration.
Forward both fields through the recursive call so the user's flags
are respected for the full lifetime of the commit() invocation.
Same class of bug as the -c/--context fix: these flags could leak
into extraArgs and be forwarded to the internal `git commit` call,
causing unexpected behavior.
Extend the extraArgs sanitization to also strip -y, --yes, --fgm,
and their values.
cleye's ignoreArgv passes unconsumed flags and arguments through to
the internal `git commit` execa call. Although -c/--context is
defined as a known cleye flag, a defensive guard is needed to strip
it from extraArgs in case it leaks through, which would conflict
with git's own handling.
Add a sanitization step at the entry of commit() that filters -c,
--context, and their values from extraArgs before they are forwarded
to the git commit invocation.
For developers who prefer Biome, this config mirrors the existing
.prettierrc rules (single quotes, no trailing commas) and ESLint rules
(recommended rules, no-console as error, import sorting via assist).
This is not a replacement — Prettier and ESLint remain the primary
tooling. biome.json is an opt-in for those who already use Biome.
Both OllamaEngine and MLXEngine had two bugs in URL construction:
1. `axios.create({url: ...})` was used instead of `baseURL`, but `url`
in axios config sets a default request URL - not a base prefix. This
caused the URL to be ignored when `.post()` was called with a path.
2. `this.client.getUri(this.config)` was used to resolve the POST URL,
but passing the engine config (which contains non-axios properties
like `apiKey`, `model`, etc.) produced malformed URLs. When
`apiKey` is null (the default for Ollama), the URL resolved to
`http://localhost:11434/null`, returning HTTP 405.
Fix: construct the full endpoint URL once in the constructor and pass
it directly to `axios.post()`, matching how FlowiseEngine already works.
Co-Authored-By: Claude <noreply@anthropic.com>
- Add chalk to jest transformIgnorePatterns so ESM chalk import works
- Fix wrong mock path in gemini.test.ts (../src -> ../../src)
Signed-off-by: majiayu000 <1835304752@qq.com>
Remove Record<string, unknown> type annotation to let TypeScript infer
the params object type, preserving type checking on all properties.
Cast to ChatCompletionCreateParamsNonStreaming at the create() call site
to accommodate the SDK's missing max_completion_tokens type. Add unit
test for reasoning model detection regex.
Signed-off-by: majiayu000 <1835304752@qq.com>
Newer OpenAI models (o1, o3, o4, gpt-5 series) reject the max_tokens
parameter and require max_completion_tokens instead. These reasoning
models also do not support temperature and top_p parameters.
Conditionally set the correct token parameter and omit unsupported
sampling parameters based on the model name.
Fixes#529
Signed-off-by: majiayu000 <1835304752@qq.com>
Integrated undici ProxyAgent for native fetch and HttpsProxyAgent for axios/openai/anthropic. Upgraded @google/generative-ai to fix#536. Added OCO_PROXY config.
Co-authored-by: uni <uni@hanwei.ink>
Move isHookCalled() check before runMigrations() and
checkIsLatestVersion() so that during git rebase, each pick commit
exits immediately without expensive I/O and network calls.
Also adds missing await on prepareCommitMessageHook() to properly
handle async errors.
Closes#493
Signed-off-by: majiayu000 <1835304752@qq.com>
- Move hardcoded baseURL before ...config spread in constructor
- This allows user config to override the default DeepSeek API URL
- Fixes issue #539 where OCO_API_URL was ignored by DeepSeek engine