Commit graph

122 commits

Author SHA1 Message Date
Naiyuan Qing
3d7b13555f refactor(sdk): unify gateway-sdk into @multica/sdk package
Sync latest code from src/shared/gateway-sdk/ into packages/sdk/,
update all backend imports to use @multica/sdk, and remove the
duplicate src/shared/gateway-sdk/ directory.

- Translate Chinese comments to English in SDK source
- Fix package.json exports with default condition
- Add @multica/sdk as workspace dependency for backend
- Update imports in gateway, test-client, and hub

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 13:43:52 +08:00
Jiayuan Zhang
46b7906272
Merge pull request #51 from multica-ai/jiayuan/fix-web-search
fix(web-search): use correct model name based on Perplexity API key type
2026-02-02 00:55:31 +08:00
Jiayuan
52a8b5a612 fix(web-search): use correct model name based on Perplexity API key type
- Direct Perplexity API (pplx-*) uses "sonar-pro" model name
- OpenRouter (sk-or-*) uses "perplexity/sonar-pro" model name
- Refactor inferPerplexityBaseUrl to inferPerplexityConfig returning both baseUrl and model
- Export internal functions for potential reuse

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:49:41 +08:00
Jiayuan
8228643924 feat(skills): auto-sync bundled skills based on version comparison
When loading skills, automatically check if bundled skills have a higher
version than managed skills. If so, update the managed skill to the
newer bundled version.

This ensures users get skill updates when upgrading multica, without
needing manual intervention.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 00:15:40 +08:00
Jiayuan
a990a1c3ca feat(profile): add interactive setup command for agent profiles
- Add `multica profile setup <id>` command for interactive profile setup
- Create profile-setup skill with conversational setup wizard
- Agent collects user info through natural dialogue and updates profile files
- Supports updating user.md, workspace.md, and config.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:49:48 +08:00
Jiayuan
e7f84755b3 refactor(profile): simplify profile structure by removing identity and bootstrap
- Remove identity.md and bootstrap.md from profile files
- Merge identity content into soul.md (now contains identity, personality, and behavior)
- Update templates, storage, and types to reflect new structure
- Update tests to match new profile structure

Profile now has 4 files: soul.md, user.md, workspace.md, memory.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:49:37 +08:00
Jiayuan
52850920ac refactor(cli): unify CLI with multica command and subcommands
- Create unified entry point at src/agent/cli/index.ts
- Add subcommand modules: run, chat, session, profile, skills, tools, credentials, dev
- Support both 'multica' and 'mu' aliases
- Add session management commands (list, show, delete)
- Integrate dev server commands into CLI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 23:09:44 +08:00
Jiayuan
f0aa1e1b4d feat(profile): add profile directory path to system prompt
- Update workspace.md template with Profile Files table explaining
  when to update each file
- Inject actual profile directory path in buildSystemPrompt()
- Add getProfileDir() method to ProfileManager
- Agent can now use edit/write tools to update profile files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:11:30 +08:00
Jiayuan
9661226979 feat(profile): enhance templates with user.md and workspace.md
- Enrich soul.md with core truths, boundaries, and continuity guidance
  inspired by moltbot's template design
- Add user.md template for building user profile and preferences
- Add workspace.md template for workspace behavior guidelines
- Update memory.md and bootstrap.md with more structured content
- Update all related storage, types, and test files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 22:04:35 +08:00
Jiayuan
e571bd5918 refactor(profile): remove tools.md template
The tools.md template content duplicated information already present in
each tool's schema description, causing maintenance burden and potential
inconsistencies. Tool usage guidelines can be added to soul.md if needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 21:55:22 +08:00
Jiayuan
98a447b7a2 test(cli): add comprehensive tests for output formatting functions
Added 36 tests covering toolDisplayName, formatToolArgs, extractResultDetails, and formatResultSummary functions. Also refactored code to eliminate duplicate truncate function and remove unused variable.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-01 02:53:23 +08:00
Jiayuan
5520fec251 feat(cli): add detailed tool info display for glob, web_search, web_fetch
- Add display name mappings for glob, web_search, web_fetch tools
- Show relevant args: glob pattern, search query, URL hostname/path
- Display result summaries: file count, search results count, page title/size
- Add grep result summary showing match count

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 02:40:59 +08:00
Jiayuan
3ee8946e29 feat(credentials): add JSON5 credential system 2026-02-01 02:28:27 +08:00
Jiayuan Zhang
b1d80f29ae
feat(agent): enhance interactive CLI with colors, spinner, and status bar (#43)
* feat(agent): improve interactive CLI with colors, spinner, and status bar

- Add colors.ts module with ANSI terminal color utilities
- Add spinner animation for tool execution feedback
- Add persistent status bar showing session/provider/model
- Apply colors to welcome banner, prompts, commands, and suggestions
- Support NO_COLOR env for accessibility

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

* fix(agent): correct cursor position with ANSI-colored prompts

Strip ANSI escape codes when calculating visual length of prompt
to ensure cursor is positioned correctly after colored text.

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

* fix(agent): prevent duplicate input echo in interactive CLI

Lazy-initialize readline.Interface only when multiline mode is active.
This prevents readline from interfering with autocomplete's raw mode,
which was causing user input to be echoed twice.

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

* refactor(agent): move CLI files to dedicated cli/ directory

Reorganize CLI-related files into src/agent/cli/ for better separation:
- interactive.ts (was interactive-cli.ts)
- non-interactive.ts (was cli.ts)
- profile.ts, skills.ts, tools.ts (was *-cli.ts)
- autocomplete.ts, colors.ts, output.ts (CLI utilities)

Update all imports, package.json scripts, and build configuration.

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

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 21:07:07 +08:00
Jiayuan Zhang
b7e1063b3a
Merge pull request #42 from multica-ai/forrestchang/find-skills-location
Simplify skills loading to managed + profile sources
2026-01-31 18:58:32 +08:00
Jiayuan
53bd52b137 feat(agent): add process list action for activity monitoring
Add 'list' action to process tool that displays all registered processes
with their ID, command, status, duration, and source (exec/process).

Example output:
ID                                    COMMAND        STATUS       DURATION  SOURCE
019c139c-dbb7-70ec-ab91-0a7fd2711043  curl -X POST   running         15.2s  [exec]

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:49:16 +08:00
Jiayuan
aaf0522303 feat(cli): display real-time tool execution updates
Handle tool_execution_update events in CLI output to show live progress
while commands are running. Shows the last 60 characters of output on
a single line that updates in place.

This completes the real-time streaming feature added to exec tool.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:40:40 +08:00
Jiayuan
14bcebee2a feat(agent): add real-time streaming updates to exec tool
Utilize the onUpdate callback from pi-agent-core's AgentTool interface
to stream output updates in real-time while commands are executing.

- Accept onUpdate as 4th parameter in execute function
- Emit tailBuffer updates on each stdout/stderr data event
- Stop emitting updates once command is backgrounded (yielded)

This enables UI to show live command output progress via the
tool_execution_update agent event.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:31:50 +08:00
Jiayuan
cbb13b26d1 fix(agent): return collected output when exec auto-backgrounds
Previously, when a command exceeded yieldMs (default 5s) and was
auto-backgrounded, exec returned an empty output string. This caused
agents to misinterpret slow commands (like curl) as failed, leading
to infinite retry loops.

Changes:
- Implement three-layer buffer system (pending 30KB + aggregated 200KB + tail 1KB)
- Return collected output snapshot when backgrounding instead of empty string
- Increase default yieldMs from 5s to 10s for better coverage
- Add auto sweeper for terminated process cleanup (30min TTL)
- Register process immediately on spawn to capture all output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:31:50 +08:00
Jiayuan
34358645de fix(cli): handle terminal line wrapping in autocomplete input
When input exceeds terminal width, the text wraps to new lines but the
old code only cleared one line, causing screen flashing and duplicate
lines. Now tracks input line count and cursor position across wrapped
lines for proper rendering.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:25:37 +08:00
Jiayuan
d90edea8d0 fix(skills): call initializeManagedSkills in loadAllSkills
Automatically initialize managed skills directory with bundled skills
on first load. This ensures bundled skills are available without
requiring explicit initialization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:20:59 +08:00
Jiayuan
dafe1085b4 refactor(skills): simplify loading to managed + profile sources
- Remove bundled, extraDirs, and plugin skill sources
- Skills now load from only two sources:
  1. managed (~/.super-multica/skills/) - global skills
  2. profile (~/.super-multica/agent-profiles/<id>/skills/) - profile-specific
- Add initializeManagedSkills() to copy bundled skills on first run
- Delete plugin.ts (multica.plugin.json discovery)
- Update documentation and tests

This simplifies the architecture by treating bundled skills as
managed skills that are initialized once, rather than maintaining
multiple loading sources with complex precedence.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:16:16 +08:00
Jiang Bohan
22d60f889c docs(tools): simplify roadmap and add Chinese translation
- Replace phased roadmap with simple future tools list
- Add Chinese README (README.zh-CN.md)
- Add language switching links between EN/CN docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
22536fd24c fix(memory): handle exactOptionalPropertyTypes for optional fields
Use spread operator to conditionally add description property
instead of assigning undefined to optional fields.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
424a330972 fix(memory): fix TypeScript discriminated union narrowing
Use `validation.valid === false` instead of `!validation.valid`
to properly narrow the discriminated union type.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
1a98446a4c docs(tools): document memory tools
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
d9cd79f847 feat(tools): register memory tools and add group:memory
- Update createAllTools to accept options object with profileId
- Add memory tools when profileId is provided
- Add group:memory tool group for memory tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
4a9220b09f test(memory): add storage layer tests
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
8484ba6cb2 feat(memory): add persistent key-value storage for agents
- Add memory tool types (MemoryEntry, MemoryStorageOptions, etc.)
- Implement file-based storage layer with validateKey, memoryGet,
  memorySet, memoryDelete, memoryList functions
- Create memory_get, memory_set, memory_delete, memory_list tools
- Store data in profile directory: ~/.super-multica/agent-profiles/<id>/memory/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
cd0888dc33 docs(tools): add Agent Profile integration section
Add architecture diagram showing Hub-Agent-Client relationship and
document how Profile config.json integrates with tools configuration.
Mark Phase 2 as complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
37aafe655e docs(profile): add README with config.json documentation
Document the Profile system structure, configuration options,
CLI usage, and programmatic API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
3c0f132ff8 feat(tools): integrate Profile tools config with runner
Add mergeToolsConfig function to combine Profile tools config with
CLI options. Profile config serves as base, CLI options override.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
9467ac9fff feat(profile): add config.json support for profile configuration
Add ProfileConfig interface with tools, provider, model, and
thinkingLevel settings. ProfileManager now exposes getToolsConfig()
and getProfileConfig() methods.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
11e2564aac docs(tools): add comprehensive README with architecture diagram
Document the 4-layer policy filter system, tool groups, profiles,
and usage examples for both CLI and programmatic interfaces.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
e44861b56c fix(tools): resolve exactOptionalPropertyTypes errors
Handle undefined values correctly in optional object properties
for TypeScript strict mode compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
7d04253791 fix(tools): replace replaceAll with replace for ES2020 compatibility
Use regex replace instead of replaceAll to support older target versions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
ae6d516952 feat(tools): add tools:cli for inspecting tool configuration
New CLI commands:
- pnpm tools:cli list - list available tools with optional filtering
- pnpm tools:cli groups - show all tool groups
- pnpm tools:cli profiles - show all profiles

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:42 +08:00
Jiang Bohan
67d54306a1 feat(cli): add tools configuration options
Add --tools-profile, --tools-allow, and --tools-deny CLI options
to configure tool policy from command line.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:22 +08:00
Jiang Bohan
ab7c0774ba test(tools): add policy system unit tests
Test coverage for:
- Tool group expansion
- Profile policies
- Allow/deny filtering
- Provider-specific rules
- Subagent restrictions
- Combined policy layers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:22 +08:00
Jiang Bohan
12a4677107 refactor(tools): integrate policy filtering into resolveTools
- Add ToolsConfig to AgentOptions for policy configuration
- Add isSubagent flag for subagent tool restrictions
- Refactor resolveTools to apply 4-layer policy filtering
- Add createAllTools and getAllToolNames utility functions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:22 +08:00
Jiang Bohan
57f31b2f79 feat(tools): add tool policy system with 4-layer filtering
Implement a flexible tool policy system that supports:
- Tool groups (group:fs, group:runtime, group:web)
- Predefined profiles (minimal, coding, web, full)
- Global allow/deny lists
- Provider-specific rules
- Subagent restrictions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 02:25:22 +08:00
Naiyuan Qing
30a1fd02b8 feat(console): enable CORS for cross-origin web app requests
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:40:38 +08:00
Jiang Bohan
2a96fc9227 fix(autocomplete): Tab completes selected suggestion to input
- First Tab: highlights first suggestion
- Second Tab: completes highlighted suggestion to input with trailing space
- Use arrow keys to navigate between suggestions
2026-01-30 17:49:12 +08:00
Jiang Bohan
423bb6e5a6 docs: add language switch and update root README skills section
- Add English/Chinese language switch links to skills READMEs
- Update root README.md with new skills features and CLI examples
- Link to full skills documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 17:10:01 +08:00
Bohan Jiang
20b45c0bcf
Merge pull request #36 from multica-ai/feat/skills-system
feat(skills): complete skills system implementation
2026-01-30 17:07:12 +08:00
Jiang Bohan
8974f52669 docs(skills): add plugin system docs and Chinese translation
- Document plugin system in Loading & Precedence section
- Add guidance on when to use plugins vs `add` command
- Create README.zh-CN.md with full Chinese translation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 17:03:39 +08:00
Jiang Bohan
8c2f8add76 feat(skills): add plugin system for npm package discovery
- Add plugin.ts with manifest loading and plugin discovery
- Scan node_modules for packages with multica.plugin.json
- Auto-discover and load skills from installed npm packages
- Integrate plugin skills into SkillManager via loader.ts
- Add workspaceDir and pluginPaths options to SkillManagerOptions
- Export plugin types and functions from index.ts

This enables users to install skill packages via npm and have them
automatically discovered without running `skills add`.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:48:36 +08:00
Jiang Bohan
a07e3ae280 docs(skills): add documentation for diagnostics and serialization
Document new Phase 5 features:
- Status diagnostics with diagnostic types table
- Async serialization API and utilities
- Updated troubleshooting section

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:33:23 +08:00
Jiang Bohan
3f1566694d chore(skills): export new diagnostics and serialize modules
Export checkEligibilityDetailed, DiagnosticItem, serialize, and
related utilities from skills index.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:33:19 +08:00
Jiang Bohan
7ddf4f76a3 refactor(skills): add serialization to add/remove/install operations
Apply async serialization to prevent concurrent operations:
- addSkill: serialized by target skill name
- removeSkill: serialized by skill name
- installSkill: serialized by skill ID

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:33:14 +08:00