Commit Graph

506 Commits

Author SHA1 Message Date
xiaoen 529622b7d3 test(memory): add unit, concurrency, and benchmark tests
Cover all Store interface methods plus edge cases:
- Basic roundtrip, ordering, empty session, tool calls
- Logical truncation (keep last N, keep zero, keep more than exist)
- SetHistory replacing all + resetting skip offset
- Crash recovery with partial JSON lines
- Persistence across store instances
- Concurrent add+read (10 goroutines x 20 msgs)
- Simulated #704 race (summarizer vs main loop)
- Benchmarks for AddMessage and GetHistory (100/1000 msgs)
2026-02-26 08:35:04 +08:00
xiaoen 9f36e50807 feat(memory): implement append-only JSONL session store
Add JSONLStore that persists sessions as .jsonl files (one message per
line) plus .meta.json for summary and truncation offset.

Key design decisions:
- Append-only writes — no full-file rewrites on AddMessage
- Logical truncation via skip offset instead of physical deletion
- Per-session mutex for safe concurrent access
- Crash recovery: malformed trailing lines are silently skipped
- Atomic metadata writes using temp+rename

Zero new dependencies — pure stdlib.

Refs #711
2026-02-26 08:35:04 +08:00
xiaoen 32ec8cadeb feat(memory): define Store interface for session persistence
Introduce a backend-agnostic Store interface in pkg/memory/ that maps
one-to-one with the current SessionManager API. Each method is atomic
— no separate Save() call needed.

Refs #711
2026-02-26 08:35:04 +08:00
daming大铭 094d65916d Merge pull request #779 from wgjtyu/main
add proxy support for TavilySearchProvider
2026-02-25 23:41:16 +08:00
George Wang ef1989f12e Update pkg/tools/web.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-25 23:04:41 +08:00
George Wang c8a553f109 add proxy support for TavilySearchProvider 2026-02-25 22:37:05 +08:00
Zhaoyikaiii 740cdcaeaf fix: remove redundant tools definitions from system prompt (#771)
* fix: remove redundant tools definitions from system prompt

Tools are already provided to the LLM via JSON schema through
ToProviderDefs(), so the text-based tools section in the system
prompt is redundant.

This removes the buildToolsSection() logic and the tools field
from ContextBuilder, reducing system prompt length while maintaining
the "ALWAYS use tools" rule reminder.

Fixes #731

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: correct spelling 'initialized' (was 'initialised')

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-25 20:44:07 +08:00
daming大铭 53578da51b Merge pull request #617 from Zhaoyikaiii/fix/repeated-context-reprocessing
fix: implement caching for system prompt to avoid repeated context reprocessing (fixes #607)
2026-02-25 19:51:23 +08:00
Guoguo d1d19b12ce docs: update wechat qrcode (#767)
Signed-off-by: Guoguo <i@qwq.trade>
2026-02-25 22:19:55 +11:00
daming大铭 f7fc8bb6e9 Merge pull request #770 from xiaket/ci-golangci-cleanup
(ci) golangci cleanup
2026-02-25 19:18:11 +08:00
daming大铭 9c7933dd00 Merge pull request #730 from winterfx/main
fix: multi-tool-call results incorrectly dropped causing LLM API 400
2026-02-25 19:12:03 +08:00
Kai Xia 9be1cd6277 a moved case of nakedret
Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:32:57 +11:00
Kai Xia b190e6e910 enable whitespace
Whitespace is a linter that checks for unnecessary newlines at the start and end of functions, if, for, etc.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:31:07 +11:00
Kai Xia d8b164b3d4 enable wastedassign
Finds wasted assignment statements.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:31:07 +11:00
Kai Xia 6830790692 enable predeclared
Find code that shadows one of Go's predeclared identifiers.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:31:07 +11:00
Kai Xia 4e6589d51f enable prealloc
Find slice declarations that could potentially be pre-allocated.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:31:07 +11:00
Kai Xia 09cf8efde6 enable nakedret
Checks that functions with naked returns are not longer than a maximum size (can be zero).

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:31:07 +11:00
Kai Xia c5e8e19f54 enable misspell
Finds commonly misspelled English words.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:14:19 +11:00
Kai Xia 1fab1967d2 enable goprintffuncname
Checks that printf-like functions are named with `f` at the end.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:14:19 +11:00
Kai Xia 06daa30e75 enable dogsled
Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()).

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:14:19 +11:00
Kai Xia 95f22bc07b enable bodyclose
Checks whether HTTP response body is closed successfully.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-25 21:14:19 +11:00
Guoguo 974337f4ab ci: add rpm and deb support in goreleaser
Signed-off-by: Guoguo <i@qwq.trade>
2026-02-25 16:32:40 +08:00
Guoguo 43611e2c4e ci: add loongarch64, remove s390x and mips64 support in goreleaser
Signed-off-by: Guoguo <i@qwq.trade>
2026-02-25 16:32:40 +08:00
Ruslan Semagin 73f27803d4 refactor(cli): migrate to Cobra-based command structure (#429)
* refactor(cli): migrate to Cobra-based command structure

Refactor CLI to use Cobra instead of manual os.Args parsing.

- Introduce root command and structured subcommands under cmd/picoclaw/internal
- Convert agent, auth, cron, gateway, migrate, onboard, skills, status and version to Cobra commands
- Replace manual flag parsing with Cobra flags
- Remove direct os.Args usage from command handlers
- Keep existing command behavior and output semantics

This change focuses on CLI structure and maintainability.
No business logic changes intended.

* chore(cli): remove version2 alias and make cobra a direct dependency

* test(cli): add basic command tests

- Add tests for CLI command tree and flag parsing
- Align LDFLAGS injection path for version info
- Remove unused manual help function

* test: migrate command tests to testify assertions

Replace standard library testing error checks (t.Error*, t.Fatalf)
with assert/require from stretchr/testify across all cobra command tests
for improved readability and consistency.

* fix(cli): make linter happy

* test: avoid duplication in windows config path test

* test: simplify allowed command checks using slices.Contains

* fix(skills): register subcommands during command construction

- Move subcommand registration out of PersistentPreRunE
- Ensure `picoclaw skills <subcommand>` resolves correctly
- Minor install command and test cleanups

* refactor(cli): address review feedback and improve command clarity

* fix(authLogoutCmd): rm os.Exit
2026-02-25 18:47:45 +11:00
Zhaoyikaiii edc78191c9 style: fix gci formatting in protocoltypes/types.go 2026-02-25 15:36:54 +08:00
Zhaoyikaiii 1f7cbd9164 fix: cache system prompt with mtime-based auto-invalidation (#607)
Avoid rebuilding the entire system prompt on every BuildMessages() call
by caching the static portion (identity, bootstrap, skills summary,
memory) and only recomputing it when workspace source files change.

Key changes:

- ContextBuilder caches the static prompt behind an RWMutex with
  double-checked locking. Source file changes are detected via cheap
  os.Stat mtime checks so no explicit invalidation is needed.

- Track file existence at cache time (existedAtCache map) so that
  newly created or deleted bootstrap/memory files also trigger a
  rebuild — the old modifiedSince() silently returned false on
  os.IsNotExist.

- Walk the skills directory recursively with filepath.WalkDir to
  catch content-only edits at any nesting depth; directory mtime
  alone misses in-place file modifications on most filesystems.

- ToolRegistry.sortedToolNames() sorts tool names before iteration,
  ensuring deterministic tool definition order across calls — a
  prerequisite for LLM-side prefix/KV cache reuse.

- Merge all context (static + dynamic + summary) into a single
  system message for provider compatibility: the Anthropic adapter
  extracts messages[0] as the top-level system parameter, and Codex
  reads only the first system message as instructions.

- Fix a data race in BuildMessages() where cachedSystemPrompt was
  read without holding the lock in a debug log statement.

- Add tests: single system message invariant, mtime auto-invalidation,
  new-file creation detection, skill file content change, explicit
  InvalidateCache, cache stability, concurrent access (20 goroutines
  x 50 iterations, passes go test -race), and a benchmark.
2026-02-25 15:27:45 +08:00
Achton Smidt Winther ec6da7a530 fix: reject empty task in spawn tool (#740)
The spawn tool accepts empty strings as valid task arguments, which
causes a subagent to run with no meaningful work. The subagent's
completion message is then routed back to the originating channel
(e.g. Signal, Discord), where the main agent processes it and may
hallucinate an unrelated response that gets sent to users.

Validate that the task parameter is non-empty after trimming whitespace.

Related: #545

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 07:39:49 +11:00
daming大铭 fd26fa7459 Merge pull request #587 from nayihz/feat_webtool_proxy
feat: add HTTP proxy support for web tools
2026-02-24 23:51:01 +08:00
daming大铭 eb138a3f13 Merge pull request #642 from Lixeer/main
fix: better session management for `github_copilot_provider`
2026-02-24 23:18:14 +08:00
Lixeer d09c64fcee fix: implement code review suggestions
Address all feedback from PR review:
- Lock granularity
- Empty response handling
- Shutdown race condition
- Interface naming
2026-02-24 22:33:04 +08:00
Kai Xia(夏恺) 100356e8ec refactor: cleanup dead code and turn on dead code detection in CI (#515)
* cleanup dead code.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* add these two back with flag.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* fix ci

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* remove this confusing line

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* make fmt

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* remove unused method.

picked up by golangci-lint run

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

---------

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-24 21:52:25 +08:00
winterfx b47a39af9c fix: handle multi-tool-call orphan detection in sanitizeHistoryForProvider
Walk backwards over preceding tool messages to find the nearest assistant
with ToolCalls, instead of only checking the immediate predecessor. Add
unit tests for sanitizeHistoryForProvider covering key edge cases.
2026-02-24 21:35:15 +08:00
daming大铭 18ba88869a Merge pull request #722 from ihao/main
fix: add CGO_ENABLED=0 for static build to fix cross-platform GLIBC e…
2026-02-24 19:53:38 +08:00
daming大铭 b10555cad2 Merge pull request #726 from xiaket/devx-make-improvements
DevX: minor improvements in Makefile
2026-02-24 19:46:36 +08:00
daming大铭 9cc0f8e685 Merge pull request #724 from mqyang56/fix/model-list-default-value-leak
fix: prevent DefaultConfig template values from leaking into user model_list entries
2026-02-24 19:43:23 +08:00
daming大铭 d20cb364a2 Merge pull request #677 from yinwm/refactor/model-to-model-name
refactor(config): rename model field to model_name
2026-02-24 19:05:40 +08:00
yinwm 01e2354b97 fix: align map values for proper formatting 2026-02-24 19:04:38 +08:00
Kai Xia 78e5bdad29 minor improvements in Makefile
Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-24 22:04:23 +11:00
yangmanqing 0d761ca608 fix: prevent DefaultConfig template values from leaking into user model_list entries 2026-02-24 17:57:28 +08:00
root 8405d390df fix: add CGO_ENABLED=0 for static build to fix cross-platform GLIBC errors 2026-02-24 04:19:18 -05:00
nayihz 76f2b42d5b feat: improve web proxy handling and coverage 2026-02-24 17:17:14 +08:00
Guoguo 8774526616 docs: add wechat and discord badge (#707)
Signed-off-by: Guoguo <i@qwq.trade>
2026-02-24 14:47:40 +08:00
daming大铭 b6e965e549 Merge pull request #604 from winterfx/fix/reasoning-content-missing
fix: preserve reasoning_content for OpenAI-compatible reasoning models
2026-02-24 14:20:36 +08:00
Guoguo 0434b49e8d docs: update wechat qrcode (#705) 2026-02-24 13:58:54 +08:00
Meng Zhuo 7cbfa89a96 Merge pull request #697 from xiaket/doc-remove-chinese-comments
[doc]translate Chinese comments
2026-02-24 08:36:18 +08:00
Kai Xia 6fb61539d7 translate Chinese comments
Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-24 10:27:49 +11:00
mattn 6fe3920a4d perf: refactoring collecting skills (#688)
* perf: refactoring collecting skills

* Fix order to store dir.Name()

* Add tests
2026-02-24 10:07:09 +11:00
Goksu Ceylan 09b1992dd7 fix(security): ensure custom deny patterns extend defaults instead of replacing them (#479)
* fix (security): custom deny patterns denying default patterns

* fix formatting whitespace
2026-02-24 09:02:44 +11:00
0x5487 2fa51d7b86 fix(security): change gateway default bind to 127.0.0.1 (#393)
* chore: Update default host bindings from 0.0.0.0 to 127.0.0.1 for various services and examples.

* config: Update default host bindings to 0.0.0.0 for improved Docker accessibility and add related documentation.

* chore: resolve conflict

* chore: remove link

* docs: Add a tip for Docker users regarding gateway host configuration to the French and Vietnamese READMEs.

* fix: typo issue

* docs: Update Chinese README.zh.md.
2026-02-24 08:54:10 +11:00
Chujiang 8a53cb9665 fix: align Docker Go version with go.mod and optimize logger (#596)
- Update Dockerfile to use golang:1.25-alpine to match go.mod (go 1.25.7)
- Optimize logger by avoiding string concatenation in file writes
- Add explicit empty string assignment for fieldStr when no fields

These changes improve build consistency and reduce memory allocations
in the hot logging path, which is important for the project's goal
of running on resource-constrained devices (<10MB RAM).

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 08:52:16 +11:00