Commit graph

104 commits

Author SHA1 Message Date
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
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
Jiang Bohan
ac7c124109 feat(cli): enhance status command with rich diagnostics
Improve skills:cli status command with:
- Summary view grouping ineligible skills by issue type
- Detailed view showing requirements checklist and diagnostics
- Color-coded output for better readability
- Quick actions section with actionable hints
- Support for verbose mode (-v) for additional details

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:33:10 +08:00
Jiang Bohan
deb96496e7 feat(skills): add detailed eligibility diagnostics with hints
Enhance eligibility checking to provide detailed diagnostics including:
- Diagnostic type categorization (binary, env, platform, config)
- Actionable hints for resolving issues
- Platform-specific install suggestions for common tools
- API key source hints for well-known services

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:33:06 +08:00
Jiang Bohan
3bd85b63a4 feat(skills): add async serialization for concurrent operations
Add serialize module to prevent concurrent operations from corrupting
files when multiple add/remove/install operations run simultaneously.

- Queue-based serialization by key
- Utility functions: isProcessing, getQueueLength, waitForKey, waitForAll
- Standard SerializeKeys for common operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:33:01 +08:00
Jiang Bohan
84f5c69b10 feat(cli): add real-time autocomplete dropdown for commands
Implement autocomplete input with visual dropdown suggestions:
- Shows matching commands as you type /
- Use arrow keys or Tab to navigate suggestions
- Enter to select, Escape to dismiss
- Displays command descriptions alongside names

No external dependencies - uses raw terminal control codes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:20:17 +08:00
Jiang Bohan
40b680266a docs(skills): add skill invocation documentation
Document Phase 4 skill invocation features:
- User invocation via slash commands
- Tab completion usage
- Invocation control frontmatter fields
- Command dispatch configuration
- Command name normalization rules

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:11:23 +08:00
Jiang Bohan
ac6f8fb493 feat(cli): add tab completion for skill commands
Integrate SkillManager with interactive CLI:
- Tab completion for /command prefixes
- Combined completion for built-in and skill commands
- Skill invocation handling with instructions context
- Updated /help to display available skill commands

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:11:19 +08:00
Jiang Bohan
4e10ee7e15 feat(skills): extend SkillManager with invocation methods
Add invocation capabilities to SkillManager:
- getSkillCommands: get user-invocable skill command specs
- resolveCommand: match user input to skill invocation
- getCompletions: get tab completions for command prefix
- buildModelSkillsPrompt: build prompt excluding user-only skills

Export invoke module functions for external use.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:11:13 +08:00
Jiang Bohan
42e2943999 feat(skills): add invoke module for skill commands
Implement skill command invocation system:
- resolveInvocationPolicy: get skill's invocation settings
- isUserInvocable/isModelInvocable: check invocation eligibility
- sanitizeCommandName: normalize skill names for commands
- buildSkillCommands: generate command specs from skills
- findSkillCommand: match command by name or skill ID
- resolveSkillInvocation: parse user input to skill invocation
- getCommandCompletions: tab completion for skill commands

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:11:07 +08:00
Jiang Bohan
8fbd72c329 feat(skills): add invocation types and parser support
Add types for skill invocation control:
- SkillInvocationPolicy for user-invocable/model-invocable flags
- SkillCommandSpec for command specifications
- SkillCommandDispatch for tool dispatch configuration
- SkillInvocationResult for resolved command results

Update parser to handle frontmatter fields:
- user-invocable (kebab-case, camelCase, snake_case)
- disable-model-invocation
- command-dispatch, command-tool, command-arg-mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:10:59 +08:00
yushen
eb4ce85602 refactor(hub): rename Device ID to Hub ID in console layer
Rename the business-layer concept from "Device ID" to "Hub ID" for
better user comprehension. The underlying network transport layer
still uses deviceId — Hub ID is passed as the deviceId value.

- Rename device.ts → hub-identity.ts, getDeviceId → getHubId
- Storage file: ~/.super-multica/device-id → ~/.super-multica/hub-id
- Hub property: deviceId → hubId
- API response field: deviceId → hubId
- Console UI label: "Device ID" → "Hub ID"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 16:02:00 +08:00
Jiang Bohan
578c8a6534 docs(skills): add README for skills system 2026-01-30 15:53:55 +08:00
yushen
b8201293b6 fix(agent): add OpenRouter provider support and guard against unknown models
Use generic OPENROUTER_* env vars (OPENROUTER_API_KEY, OPENROUTER_BASE_URL,
OPENROUTER_MODEL) via the existing fallback mechanism instead of hardcoding
mappings to OPENAI_* vars. Also add a guard when resolveModel returns
undefined to throw a clear error instead of crashing on property access.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:50:49 +08:00
Jiang Bohan
da3bb254ec fix(skills): support nested skill directories and managed skills
- Add managed skills directory (~/.super-multica/skills/) to loader
- Change discoverSkillDirs to recursively scan up to 3 levels deep
- Skip hidden directories during scan
- Fixes skills installed via `skills add` not being discovered

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:36:31 +08:00
Jiang Bohan
ecaada1df0 feat(skills): add CLI commands for add/remove skills
Add new CLI commands:
- add <source>: Add skill from GitHub (owner/repo format)
- remove <name>: Remove installed skill
- Support for --force flag to overwrite existing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:30:00 +08:00
Jiang Bohan
aee807e95a feat(skills): add module for GitHub skill installation
Implement skill download from GitHub repositories:
- parseSource() to handle owner/repo, owner/repo/skill, and full URLs
- addSkill() with shallow clone and sparse checkout support
- removeSkill() to uninstall skills
- listInstalledSkills() for listing managed skills
- Automatic .git cleanup after clone

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:29:55 +08:00
Jiang Bohan
1105a7ac1f feat(skills): add CLI for skills management
Add skills-cli.ts with commands:
- list: Show all skills with eligibility status
- status [id]: Show detailed skill info or summary
- install <id>: Install skill dependencies

Add skills:cli script to package.json

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:15:56 +08:00
Jiang Bohan
91709ddd84 feat(skills): integrate watcher into SkillManager
Add hot reload support to SkillManager:
- startWatching/stopWatching methods
- Version-based automatic cache invalidation
- Export install and watcher functions
- listAllSkillsWithStatus and checkSkillEligibility helpers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:15:51 +08:00
Jiang Bohan
8eba6c0f4a feat(skills): add file watcher for hot reload
Implement chokidar-based file watching for skill hot reload:
- Version-based cache invalidation
- Debounced change detection
- Change listener registration with onSkillsChange
- Dynamic chokidar import (optional dependency)
- Watch skill directories with configurable paths

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