Commit Graph

654 Commits

Author SHA1 Message Date
di-sukharev
5fde6dbb63 chore: tighten cli validation and tooling checks 2026-04-10 16:56:51 +03:00
di-sukharev
58b9d844b8 build 2026-04-10 15:27:58 +03:00
di-sukharev
9855ed1f69 3.2.19 v3.2.19 2026-04-10 15:27:56 +03:00
GPT8
7e41139d9c Merge pull request #552 from di-sukharev/improve_tests
Improve CLI test coverage and harden proxy configuration behavior
2026-04-10 15:26:34 +03:00
di-sukharev
66a8c2b52a fix(build): remove mistral cjs warning
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.
2026-04-10 15:24:09 +03:00
di-sukharev
57fb52a3c5 style(prettier): format source files 2026-04-10 15:20:27 +03:00
di-sukharev
88964cbc5e test(cli): overhaul e2e coverage and CI
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.
2026-04-10 15:16:32 +03:00
di-sukharev
cf27085ac9 fix(cli): tighten proxy and setup behavior
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.
2026-04-10 15:16:11 +03:00
GPT8
7fa2384761 Merge pull request #548 from SOV710/master
chore: add biome.json as an opt-in alternative to Prettier and ESLint
2026-04-08 16:41:04 +03:00
GPT8
fa1482d8b1 Merge pull request #549 from SOV710/fix-cli-flags
fix: make -c/--context, -y/--yes, and --fgm flags actually work
2026-04-08 16:40:35 +03:00
GPT8
f656c39f63 Merge pull request #550 from keith666666/master
feat(ollama): add OCO_OLLAMA_THINK config to control thinking mode
2026-04-08 16:36:09 +03:00
GPT8
420a15343c Merge pull request #538 from barnabasbusa/master
feat: display PR URL and auto-set upstream when pushing new branches
2026-04-08 16:35:37 +03:00
Barnabas Busa
fd9820dd64 Merge remote-tracking branch 'upstream/master' 2026-04-08 14:43:22 +02:00
Keith
2d9a26dc37 feat(ollama): add OCO_OLLAMA_THINK config to control thinking mode
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>
2026-04-07 18:27:38 +08:00
SOV710
8cbaa36e82 build 2026-04-05 03:58:40 +00:00
SOV710
42029fff4e refactor(prompts): null-safe, trim-aware user context handling
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.
2026-04-05 03:58:40 +00:00
SOV710
4d767da9e5 fix(prompts): make --fgm override OCO_EMOJI config
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.
2026-04-05 03:58:40 +00:00
SOV710
361327a8fe fix(generate): forward context through chunked large-diff prompt path
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.
2026-04-05 03:58:40 +00:00
SOV710
3a2fa11fcd fix(commit): preserve context and skip-confirm flag across regenerate
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.
2026-04-05 03:58:40 +00:00
SOV710
4056bfa547 fix(cli): strip -y/--fgm from extraArgs to prevent git commit conflict
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.
2026-04-05 03:58:40 +00:00
SOV710
a48d33096a fix(cli): strip -c/--context from extraArgs to prevent git commit conflict
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.
2026-04-05 03:58:40 +00:00
SOV710
d5dcd42d2c chore: add biome.json as an alternative to Prettier and ESLint
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.
2026-04-04 17:19:56 +00:00
di-sukharev
f300b5dd4e build 2026-04-03 19:07:22 +03:00
di-sukharev
15884724e6 3.2.18 v3.2.18 2026-04-03 19:07:19 +03:00
di-sukharev
0b6fda1c2b build 2026-04-03 19:06:18 +03:00
di-sukharev
a7fd0d8237 3.2.17 v3.2.17 2026-04-03 19:06:14 +03:00
di-sukharev
6cb67e5150 build 2026-04-03 19:05:33 +03:00
di-sukharev
62129503b3 3.2.16 v3.2.16 2026-04-03 19:05:31 +03:00
di-sukharev
f81e836f34 Merge branch 'master' of github.com:di-sukharev/opencommit 2026-04-03 19:05:26 +03:00
di-sukharev
c3d1fb379f build 2026-04-03 19:04:25 +03:00
di-sukharev
e17294abc7 3.2.15 v3.2.15 2026-04-03 19:04:22 +03:00
di-sukharev
789b4f5e9f pin axios bc of the 1.14.1 virus issue 2026-04-03 19:04:16 +03:00
GPT8
a9c9bcfd5a Merge pull request #547 from keith666666/fix/ollama-url-resolution
fix(engine): fix broken URL resolution in Ollama and MLX engines
2026-04-03 19:01:02 +03:00
keith666666
0ee82f7430 fix(engine): fix broken URL resolution in Ollama and MLX engines
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>
2026-04-02 10:52:32 +08:00
GPT8
9923dab532 Merge pull request #544 from majiayu000/fix/issue-529-max-completion-tokens
fix: use max_completion_tokens for reasoning models (o1/o3/o4/gpt-5)
2026-03-31 11:28:34 +03:00
majiayu000
f74ba2dfc6 fix: resolve CI failures — revert gemini test mock path and fix prettier formatting
Signed-off-by: majiayu000 <1835304752@qq.com>
2026-03-30 00:55:06 +08:00
majiayu000
53414438d1 fix: resolve unit test failures
- 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>
2026-03-30 00:54:48 +08:00
majiayu000
6982e76cf5 fix: improve type safety for max_completion_tokens params
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>
2026-03-30 00:54:48 +08:00
majiayu000
dc7f7f6552 fix: use max_completion_tokens for reasoning models in OpenAI engine
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>
2026-03-30 00:54:44 +08:00
GPT8
db8a22b0cb Merge pull request #546 from freedomsky11/feat/proxy-support
feat: add universal proxy support and fix Gemini model resolution (#536)
2026-03-29 19:20:36 +03:00
sky
e27007b6fe feat(proxy): add universal proxy support and fix Gemini model resolution (#536)
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>
2026-03-29 14:54:45 +00:00
GPT8
f51393e37a Merge pull request #545 from majiayu000/fix/issue-493-rebase-slow-hook
fix: skip migrations and version check when called as git hook
2026-03-27 15:27:05 +03:00
majiayu000
83f9193749 fix: stabilize e2e flow in clean CI env
Signed-off-by: majiayu000 <majiayu000@users.noreply.github.com>
2026-03-27 17:19:31 +08:00
majiayu000
bc608e97bd fix: skip migrations and version check when called as git hook
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>
2026-03-21 10:59:24 +08:00
GPT8
40182f26b3 Merge pull request #542 from ymrdf/master
Fix: Allow OCO_API_URL to override DeepSeek engine baseURL
2026-03-14 20:02:34 +03:00
gaozhenqian
62d56a5278 Fix: Allow OCO_API_URL to override DeepSeek engine baseURL
- 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
2026-03-12 14:22:45 +08:00
di-sukharev
9e601ca6b5 build 2026-02-24 15:10:52 +03:00
di-sukharev
4a9b1391a3 3.2.14 v3.2.14 2026-02-24 15:10:50 +03:00
di-sukharev
3fe71c1d23 build 2026-02-24 15:09:51 +03:00
di-sukharev
2f2e888098 Merge branch 'master' of github.com:di-sukharev/opencommit 2026-02-24 15:09:37 +03:00