Commit graph

208 commits

Author SHA1 Message Date
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 Zhang
ace1a2fe6b
Merge pull request #41 from multica-ai/forrestchang/exec-blocking
fix(agent): improve exec tool with three-layer buffers and real-time updates
2026-01-31 18:54:36 +08:00
Jiayuan
69cad35b4b docs(skill-creator): support profile-specific skill creation
Update skill-creator instructions to:
- Default to profile directory when running under a profile
- Fall back to global directory when no profile is active
- Show both directory structures
- Add profile skill removal instructions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:53:27 +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
6bb8f2d9e0 docs(skill-creator): update precedence to reflect simplified sources
Update Skill Precedence section to show only two sources:
1. Profile-specific skills (highest priority)
2. Global skills (~/.super-multica/skills/)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 18:44:39 +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 Zhang
a5f979fceb
Merge pull request #40 from multica-ai/forrestchang/fix-cli-multiline-flash
fix(cli): handle terminal line wrapping in autocomplete input
2026-01-31 18:29:07 +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
Bohan Jiang
96c93cf958
Merge pull request #39 from multica-ai/feat/tools-system
feat(tools): comprehensive tools system with policy filtering and memory tools
2026-01-31 02:26:20 +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
83ab7ee743
Merge pull request #38 from multica-ai/fix/chat-assistant-message-width
fix(web): remove max-width constraint on assistant messages
2026-01-30 23:54:03 +08:00
Naiyuan Qing
86a8c91c9b fix(web): remove max-width constraint on assistant messages
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:52:11 +08:00
Naiyuan Qing
fd46d7ba9a
Merge pull request #37 from multica-ai/feat/web-v1
Feat/web v1
2026-01-30 23:40:08 +08:00
Naiyuan Qing
716bbceaf4 refactor(chat, hooks): simplify handleSend and update useDeviceId to use useSyncExternalStore
- Simplified handleSend function in Chat component by removing unnecessary useCallback.
- Refactored useDeviceId hook to utilize useSyncExternalStore for better state management and removed useState and useEffect for device ID retrieval.
- Updated useGateway hook to ensure onMessageRef is set correctly on options change.
- Enhanced useScrollFade hook to properly cancel animation frames on cleanup.
2026-01-30 23:38:10 +08:00
Naiyuan Qing
5ee3176d3a docs: restore missing Atomic Commits details in CLAUDE.md
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:20:16 +08:00
Naiyuan Qing
403c44f536 refactor(web): unify hub + agent state into single Zustand store
Replace useState-based useHub hook and separate useActiveAgent store
with a single useHubStore (Zustand). This fixes the bug where
HubSidebar and Chat held independent state copies, causing stale data
and duplicate 30s polling. Agent create/delete logic now lives in the
store with automatic activeAgentId management.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:15:11 +08:00
Naiyuan Qing
cb28fbecc0 refactor(web): remove agent ID copy button from chat header
Keep only the device ID copy interaction; agent ID is display-only.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:12:49 +08:00
Naiyuan Qing
94f32701c7 feat(ui): auto-activate newly created agent
Return the new agent ID from createAgent and set it as active
immediately after creation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:05:43 +08:00
Naiyuan Qing
cdd146e31f feat(web): restore device ID display and copy button in chat header
Re-add deviceId (full UUID) with copy-to-clipboard button next to the
SidebarTrigger, matching the original behavior from commit 0975510.
Both deviceId and agentId now have independent copy states.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:04:52 +08:00
Naiyuan Qing
d04952da91 feat(web): restore agent ID copy button in chat header
Re-add the copy-to-clipboard button that was lost when chat.tsx was
rewritten for hub/agent support. Clicking copies the full agentId,
shows a checkmark icon for 2s, and triggers a toast confirmation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:55:57 +08:00
Naiyuan Qing
3b1bc5a17f fix(ui): use data-active: syntax and add text color for active agent item
Align with sidebar component library convention: use Tailwind v4 native
data-active: instead of data-[active]:, and add missing
text-sidebar-accent-foreground for active state.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:54:59 +08:00
Naiyuan Qing
78e34a1d63 refactor(ui): unify agent item hover to full row
Replace SidebarMenuButton with a custom flex row div that handles hover
and active states on the entire item, not just the text area. Delete
button uses stopPropagation to avoid triggering selection.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:51:21 +08:00
Naiyuan Qing
da5565adcf fix(ui): wrap agent ID in span for CSS truncate ellipsis
SidebarMenuButton applies truncate via [&>span:last-child]:truncate,
so the text must be in a <span> rather than a bare text node to get
overflow-hidden + text-ellipsis + whitespace-nowrap.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:49:10 +08:00
Naiyuan Qing
f1244f467b refactor(ui): replace absolute-positioned delete with flex layout in HubSidebar
Drop SidebarMenuAction (absolute positioning) in favor of a flex row:
left side (SidebarMenuButton) gets flex-1 min-w-0 for natural truncation,
right side (delete button) sits as a normal flex child with hover reveal.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:48:19 +08:00
Naiyuan Qing
bcaf14464a fix(ui): improve disabled state cursor and no-agent empty state
- Add cursor-not-allowed and reduced opacity to ChatInput when disabled
- Show user icon in empty state when no agent is selected
- Pass contextual placeholder text based on agent selection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:45:53 +08:00
Naiyuan Qing
3190be60c3 fix(ui): soften HubSidebar styling and improve UX
Use CSS truncation for agent/hub IDs instead of JS slicing, show delete
button only on hover via showOnHover prop, and reduce contrast on status
dots, labels, and placeholder text for a more subtle appearance.

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