Commit Graph

76 Commits

Author SHA1 Message Date
roboomp 7289cd4baf fix(mcp): expanded plugin env headers
Expanded environment variable placeholders in Claude marketplace plugin MCP url and headers before registration. Added a regression test covering context7-style HTTP server headers.\n\nFixes #3621
2026-06-27 03:16:45 +00:00
can1357 74d7dfd2fa Merge PR #3354: fix: migrate coding-agent tests to removeWithRetries (@oldschoola) 2026-06-27 02:06:38 +02:00
can1357 ae1650d689 refactor: renamed search and find tools to grep and glob
- Renamed the `find` and `search` tools to `glob` and `grep` respectively across the codebase to improve command clarity.
- Implemented full-stack support for the renamed tools, including CLI arguments, system prompts, SDK exports, and tool registration.
- Added automated migration logic in `settings` to transform legacy `find` and `search` configuration keys to their new equivalents.
- Updated the `collab-web` renderer registry to ensure backwards compatibility with legacy tool outputs.
2026-06-27 00:57:55 +02:00
Dr Kennedy Umege 5ea467aa3c fix: address gc review edge cases 2026-06-26 12:58:30 +01:00
oldschoola a2854ba768 fix: migrate coding-agent tests from fs.rm to removeWithRetries
Migrate 203 test files (356 call sites) from fs.rm/fs.rmSync to
removeWithRetries/removeSyncWithRetries to reduce EBUSY test failures
on Windows. removeWithRetries is now exported from @oh-my-pi/pi-utils.

The migration uses a regex-based approach that:
- Replaces fs.rm(path, { recursive, force }) → removeWithRetries(path)
- Replaces fs.rmSync(path, { recursive, force }) → removeSyncWithRetries(path)
- Replaces fs.rm(path) → removeWithRetries(path) (no options)
- Skips fs.rm/fs.rmSync inside template literals (bun --eval scripts)
- Adds imports to existing @oh-my-pi/pi-utils import or creates new one
- Removes unused fs imports where fs.rm was the only fs usage (4 files)
2026-06-23 15:28:05 -07:00
roboomp bcfb5b5d8b fix(marketplace): preserved plugin root scope
Carried user/project root scope through enabled plugin enumeration so project marketplace installs keep project-level discovery metadata.
2026-06-22 08:59:24 +00:00
roboomp c531117869 fix(mcp): normalized opencode command arrays
Mapped OpenCode MCP array commands to stdio command plus args and accepted environment as the provider-native env key.\n\nAdded regression coverage for array command normalization, environment mapping, env fallback, and empty args omission.\n\nFixes #3180
2026-06-21 09:23:54 +00:00
can1357 d4317d3d20 feat(ai): consolidated OpenAI-family streaming and add OpenRouter API support
This change introduces a new `openrouter` API type and extensively refactors OpenAI-family streaming providers, centralizing shared logic and improving robustness.

Key changes include:
- **Unified OpenAI-family Logic:** Consolidated core utilities, compat resolution, request shaping, and stream processing into `openai-shared.ts`, reducing duplication across `openai-completions`, `openai-responses`, and `openai-codex-responses`.
- **OpenRouter API Type:** Introduced a dedicated `openrouter` API type with dual-surface compatibility, allowing it to dispatch requests as either OpenAI Chat Completions or Responses.
- **Enhanced Provider Integration:**
    - Improved Perplexity search to leverage shared OpenAI streaming transports, including API-key fallback to OpenRouter and support for Perplexity's Responses API.
    - Integrated xAI-specific logic directly into the shared `stream.ts` dispatch, removing the dedicated `xai-responses` provider.
    - Refined credential parsing for Google Gemini CLI and handling of Azure deployment names.
- **Robustness & Consistency:** Improved error handling for Codex, standardized output token parameter resolution, and ensured consistent application of reasoning suppression across all Chat Completions dialects.
- **New Documentation:** Added `provider-endpoint-constraints.md` to detail endpoint-specific behaviors and quirks for various providers.
- **Telemetry & Debugging:** Extended telemetry propagation to advisor calls and overflow compaction tasks. Improved debugging for Codex WebSocket failures and stream error messages.
- **Tooling & Security:** Updated browser stealth scripts to prevent detection and added a new `ts-no-inline-cast-access` TTSR rule.
2026-06-17 21:36:48 +02:00
can1357 c509a5d59c fix(coding-agent): honor comma-separated and **/* Copilot applyTo globs
GitHub documents applyTo as a single comma-separated string (e.g.
"**/*.ts,**/*.tsx") and treats both ** and **/* as all-files. The rule
loader kept the whole CSV value as one glob and missed **/* for
always-apply. Split applyTo via parseCSV and include **/* as all-files.

Addresses review feedback on #2734.
2026-06-16 14:23:50 +02:00
roboomp 063ce1ba00 fix(coding-agent): loaded github instruction rules
Added GitHub Copilot instruction-file discovery to the github rule provider path, mapping applyTo frontmatter into always-apply or glob-scoped rules and avoiding duplicate always-apply prompt content when context imports the same file.\n\nFixes #2731
2026-06-16 02:30:58 +00:00
can1357 b7a6a5e44c Merge PR #2651: fix(coding-agent): hide plugin skills from slash commands 2026-06-15 19:46:13 +02:00
can1357 ec752d77e8 Merge PR #1983: feat(discovery): GitHub Copilot user-global instructions, env dirs, and prompts (#1913, #1915, #1916) 2026-06-15 19:46:12 +02:00
roboomp 40ad1c6a7b style: bun run fix 2026-06-15 12:52:36 +00:00
roboomp b21385d13c fix(coding-agent): hid plugin skills from slash commands
Removed Claude marketplace plugin skill mirroring from slash-command discovery while keeping real plugin commands registered.\n\nFixes #2645
2026-06-15 12:52:12 +00:00
Ogrodev 0123a46f83 Merge remote-tracking branch 'upstream/main' into feat/profiles-and-alias
# Conflicts:
#	packages/coding-agent/src/cli/args.ts
2026-06-14 19:10:31 -03:00
roboomp c1b27d2716 style: bun run fix 2026-06-14 07:12:50 +00:00
roboomp fde233278c fix(cli): synthesize plugin skill slash commands from directory basename
When a Claude plugin skill's SKILL.md frontmatter uses a display-style
name (e.g. `name: Understand Anything`), the synthesized slash command
inherited that text. `expandSlashCommand` splits the command at the
first whitespace, so `/understand` never resolved and the multi-word
form could not expand either.

Use `path.basename(path.dirname(skill.path))` so the slash command
always matches the documented `skills/<name>/SKILL.md` → `/<name>`
contract while the frontmatter still drives the description/body.

Fixes #2415
2026-06-14 07:12:42 +00:00
roboomp 0b444b83bf fix(cli): exposed claude plugin skills as slash commands
Loaded Claude Code marketplace plugin SKILL.md files into the slash-command capability so Claude-native plugin docs like /understand work in autocomplete and invocation.\n\nAdded a regression covering OMP installed plugin registries and bare slash-command expansion.\n\nFixes #2415
2026-06-12 19:28:35 +00:00
Asaf Mahlev a8db2747e5 fix(discovery): correct Copilot custom-instruction-dir and prompt handling
Address review against GitHub Copilot CLI docs (add-custom-instructions):

- COPILOT_CUSTOM_INSTRUCTIONS_DIRS: each dir contributes AGENTS.md (context) and .github/instructions/**/*.instructions.md (recursive), per spec. Dropped the non-spec <dir>/copilot-instructions.md and the wrong top-level <dir>/*.instructions.md scan.

- Scan the project .github/instructions/ tree recursively ('within or below').

- Prompts: .github/prompts/*.prompt.md is a VS Code construct, not a Copilot CLI feature; dropped the fictional ~/.copilot/prompts/ user dir and reframed comments/descriptions accordingly.
2026-06-12 19:15:34 +03:00
Asaf Mahlev 873f3222a1 feat(discovery): GitHub Copilot user-global instructions and prompts
The github provider only scanned the project .github/ tree, so Copilot CLI's user-global config was ignored. Add user-global instructions (~/.copilot/copilot-instructions.md), COPILOT_HOME relocation, COPILOT_CUSTOM_INSTRUCTIONS_DIRS (copilot-instructions.md + *.instructions.md), and prompt discovery (*.prompt.md in .github/prompts/ and ~/.copilot/prompts/).

Closes #1913, #1915, #1916.
2026-06-12 19:15:33 +03:00
Ogrodev 73b1f895d1 Merge upstream/main into feat/profiles-and-alias 2026-06-08 15:54:57 -03:00
can1357 6ceda1d477 Merge remote-tracking branch 'origin/farm/dd3aaf05/expand-agents-md-at-imports' 2026-06-08 19:08:37 +02:00
can1357 9d457f73d9 test: migrated test imports to package subpath exports
- Replaced relative `../src` imports with `@oh-my-pi/pi-ai` and `@oh-my-pi/pi-agent-core` subpaths.
2026-06-08 19:03:55 +02:00
roboomp 8500070700 fix(coding-agent): expanded @-imports in AGENTS.md/CLAUDE.md context files
CLAUDE.md, AGENTS.md, GEMINI.md (and the other discovered context-file
flavors) all carry the @-import convention every other agent ships:
`@path/to/file` inside a memory file inlines that file's contents at
launch. The discovery loaders previously read the file content verbatim
and handed it straight to the system prompt builder, so a CLAUDE.md
whose entire body is `@AGENTS.md` shipped a single literal `@AGENTS.md`
line and Claude never saw the project rules.

Added discovery/at-imports.ts implementing the Claude-Code semantics:
relative paths resolve against the importing file's directory, `~/`
expands to home, recursion stops at MAX_AT_IMPORT_DEPTH (5) with cycle
detection, fenced code blocks and inline code spans are opaque so
`npm install @types/node` and `git@github.com` round-trip verbatim, and
missing files keep the literal @-token intact. Wired the expander
into loadProjectContextFiles so every provider that registers under
the context-file capability benefits without per-provider plumbing.

Fixes #2111
2026-06-08 15:02:18 +00:00
can1357 bf6b80e575 feat(discovery): added built-in test timers rule to defaults
- Added a new built-in TTSR rule `ts-no-test-timers.md` that flags `Bun.sleep`, `setTimeout`, and `setInterval` usage in `*.test.ts` files.
- Registered `ts-no-test-timers` in the built-in rules index so it ships with default discovery providers.
- Updated builtin-defaults tests to enforce rule-name uniqueness and verify the new rule only matches in `*.test.ts` scopes.
2026-06-08 15:18:54 +02:00
can1357 a84da2a61e feat(coding-agent): added AST-condition matching for interrupt flow rule handling
- Added astCondition to rule frontmatter parsing and rule metadata, with AST-grep normalization.
- Updated TTSR bucketing so astCondition-only rules are treated as interruptible matches.
- Added ts-redundant-clear-guard as a built-in JS/TS tool rule for guarded clear* calls.
- Added AST snapshot matching in agent sessions with per-stream cache throttling and cleanup.
2026-06-08 14:57:17 +02:00
Ogrodev 5f374e520e Merge remote-tracking branch 'upstream/main' into feat/profiles-and-alias 2026-06-05 09:16:22 -03:00
can1357 a1ef5d62ec Merge remote-tracking branch 'origin/farm/f2c1d17f/fix-github-skills-discovery' 2026-06-05 11:44:46 +02:00
can1357 c39350d598 fix(dry-balance): decoupled bench mode from sampling flags
- Skipped count/concurrency normalization when --bench is set.
- Errored when no OAuth accounts resolve for the provider.
- Updated flag docs to run one request per OAuth account.
2026-06-05 11:43:17 +02:00
can1357 eb8e4f7657 feat(task): added read-summarize override for subagents
- Parsed `read-summarize` frontmatter into `readSummarize` field.
- Applied `read.summarize.enabled: false` override on isolated subagent settings.
- Disabled summarization for `explore` and `librarian` agents.
2026-06-05 11:36:13 +02:00
roboomp a4be51f08c fix(discovery): scan .github/skills via the github provider
The github provider registered context-files (.github/copilot-instructions.md)
and instructions (.github/instructions/*.instructions.md), but no skills
capability — so .github/skills/<name>/SKILL.md, the layout GitHub documents
for Copilot Agent Skills, was silently never discovered. The skill://
URL resolved to 'Available: none' and nothing surfaced in the system prompt.

Register a skill capability on the github provider (priority 30, project-only)
pointing at .github/skills/ and reuse scanSkillsFromDir with
requireDescription: true to match the Agent Skills spec and the sibling
native/omp-plugins providers. Pin the wiring with a discovery test that
loads the skills capability scoped to the github provider against a temp
cwd containing a SKILL.md, and a negative case that drops a skill missing
a description.

Fixes #1906
2026-06-05 05:36:05 +00:00
Ogrodev b99039ded2 fix(coding-agent): profile-scope native config discovery and load symlinked extension dirs
Native user-level config discovery (MCP, skills, rules, slash commands, prompts, instructions, hooks, tools, settings, extensions, and the top-level SYSTEM.md/RULES.md/AGENTS.md) now resolves the user scope through getAgentDir() in builtin.ts, omp-extension-roots.ts, and the discovery-layer getUserPath() helper. A named profile sees only its own ~/.omp/profiles/<name>/agent config instead of the default profile's ~/.omp/agent leaking into every profile, matching the /mcp config writer and getMCPConfigPath("user").

discoverExtensionModulePaths now detects top-level symlinked directories that the native glob skips (follow_links=false) and synthesizes their index/package.json entry-point matches, so an extension shared across profiles via a symlink loads like a real directory. Symlinked extension files were already handled.

cli: check --tiny-worker on the profile-flag-stripped resolvedArgv, matching the adjacent --smoke-test check and launch routing.
2026-06-04 15:07:55 -03:00
can1357 6baa985672 feat(coding-agent): added ts-no-deprecated-leftovers builtin rule
- Warns against leaving `@deprecated` compatibility shims instead of finishing a refactor.
- Registered in the builtin rule index and covered by the defaults test.
2026-06-03 00:13:24 +02:00
can1357 f53efd75ca test(coding-agent/discovery): updated discovery plugin name expectations in tests
- Updated listClaudePluginRoots test assertions to expect unprefixed skill identifiers.
- Adjusted both manifest and outside-skill discovery expectations to match the updated naming.
- Ensured the tests now look for plain skill names instead of namespaced values.
2026-06-02 11:16:56 +02:00
Can Bölük be022d8a89 Merge branch 'main' into farm/ad674fba/fix-claude-subdir-commands 2026-06-01 18:23:10 +03:00
can1357 caeaf4e4d2 feat(coding-agent): added builtin default rules and disable controls
- Added 14 bundled TTSR rules (TypeScript and Rust conventions) embedded into the binary via the lowest-priority `builtin-defaults` provider.
- Extracted rule bucketing into `bucketRules` with support for `disabledRules` and `builtinRules` settings.
- Added `ttsr.builtinRules` and `ttsr.disabledRules` settings to control which rules are active per session.
2026-05-31 02:09:55 +02:00
roboomp bd3bb3ec28 fix(coding-agent): preserved claude root command precedence
Ordered recursively discovered Claude command files so root basename commands stay ahead of nested basename duplicates while nested files still get namespace aliases.\n\nFixes #1523
2026-05-30 03:23:04 +00:00
roboomp 270f72ac71 fix(coding-agent): preserved claude command basenames
Kept recursive Claude command files invocable by their basename while adding colon namespace aliases for tools that install namespaced workflows.\n\nFixes #1523
2026-05-30 03:18:33 +00:00
roboomp 43c90b4b33 style: bun run fix 2026-05-30 03:11:55 +00:00
roboomp 223e98cfac fix(coding-agent): resolved claude command namespaces
Loaded Claude slash commands recursively and derived names from paths relative to .claude/commands so subdirectory commands match Claude Code's namespace format.\n\nAdded regression coverage for project and user command namespaces.\n\nFixes #1523
2026-05-30 03:11:45 +00:00
roboomp 4d108c1951 fix(plugins): enumerate linked plugins for sub-discovery
PluginManager.link symlinks the package into <plugins>/node_modules
and records it in omp-plugins.lock.json, but never writes to
<plugins>/package.json#dependencies. getEnabledPlugins iterated only
the dependency map, so the documented `omp install ./local-extension`
workflow (delegated to plugin link) succeeded but its sibling skills/,
hooks/, tools/, etc. stayed invisible after install.

Iterate the union of package.json#dependencies and
omp-plugins.lock.json#plugins so symlinked-only packages surface
alongside npm/marketplace installs. Lockfile entries whose
node_modules tree has since been deleted (stale link) are skipped
silently. Linked-only setups with no <plugins>/package.json at all
now work too.

Per-PR review feedback: https://github.com/can1357/oh-my-pi/pull/1498
2026-05-29 06:34:10 +00:00
roboomp bdce9cf068 feat(discovery): scan installed plugin packages for sub-discovery
Marketplace and `omp plugin link` installs write to
`<plugins>/node_modules/` rather than to `extensions:` in settings,
so the original PR still missed their sibling skills/, hooks/,
tools/, commands/, rules/, prompts/, .mcp.json sub-trees. Wire
listOmpExtensionRoots to enumerate getEnabledPlugins(cwd, { home })
in addition to CLI-injected and settings-driven roots.

Adds an optional { home } parameter to getEnabledPlugins so the
discovery loader can pass through LoadContext.home for tempdir-rooted
tests. The getPluginsNodeModules/getPluginsPackageJson/
getPluginsLockfile helpers gain the same optional home overload so
they mirror getPluginsDir.

Per-PR review feedback: https://github.com/can1357/oh-my-pi/pull/1498
2026-05-29 06:28:33 +00:00
roboomp db525316ab fix(discovery): wire extension package sub-dirs into discovery + add top-level install command
Bug 1: capability loaders in src/discovery/builtin.ts only walked
.omp/ and ~/.omp/agent/, so extension packages registered via
extensions: in settings or --extension on the CLI shipped their
skills/, hooks/pre|post/, tools/, commands/, rules/, prompts/, and
.mcp.json silently — the docs at omp.sh/docs/extension-authoring
advertise the opposite. Add a new omp-plugins discovery provider that
scans every configured extension package directory for those
sub-trees, plus a small omp-extension-roots helper that resolves the
union of settings-driven and CLI-injected roots. main.ts injects CLI
extension paths via injectOmpExtensionCliRoots before any capability
load.

Bug 2: install was never registered as a top-level subcommand, so
`omp install ./my-extension` was rewritten to `launch install
./my-extension` and forwarded to the LLM as an initial prompt. Add a
top-level install command that routes local paths to plugin link and
remote specs to plugin install. Extract the command table into
src/cli-commands.ts so tests can introspect registered subcommands
without triggering cli.ts's top-level await.

Fixes #1496
2026-05-29 06:16:32 +00:00
Tommy Carlsson 5b35cd626b feat: add autoloadSkills frontmatter field for agent definitions
Adds optional autoloadSkills field to agent frontmatter that automatically loads listed skills when a sub-agent is spawned. Uses the same buildSkillPromptMessage + sendCustomMessage mechanism as interactive skill loading, queued via sendCustomMessage({ triggerTurn: false }) before the first session.prompt(task). No extra agent turns, no new injection path. Skills stay in listing for sub-resource access. Compaction behavior matches manual loading. Unknown skill names silently skipped.

Lore-id: f85fdbdc
Constraint: autoload must use buildSkillPromptMessage + sendCustomMessage, never modify systemPrompt or use contextFiles
Constraint: triggerTurn must be false to avoid extra agent turns
Rejected: append to systemPrompt | agent cannot distinguish skill content from own instructions
Rejected: contextFiles injection | agent sees opaque file blob, cannot discover sub-resources
Rejected: promptCustomMessage per skill | N extra agent turns with model inference
Directive: autoload skill names are resolved against parent session skill list at spawn time in task/index.ts
Tested: TypeScript compiles clean with tsc --noEmit
Tested: parseAgentFields parses array and CSV string frontmatter
Tested: parseAgentFields returns undefined for absent and empty fields
Not-tested: bun test cannot run locally due to missing pi_natives native addon (requires Rust toolchain)
Confidence: high
Scope-risk: moderate
Reversibility: clean
2026-05-24 19:35:40 +04:00
roboomp 2b9eaee0b5 style: bun run fix 2026-05-21 15:42:33 +00:00
roboomp 1be2ead968 fix(discovery): load top-level RULES.md as sticky always-apply rule
The native rule discovery provider only scanned the rules/ subdirectory under .omp/ and ~/.omp/agent/. The documented top-level RULES.md file (per https://omp.sh/docs/context-files) was silently ignored — neither ~/.omp/agent/RULES.md nor <repo>/.omp/RULES.md was ever read.

Load both as synthetic rules with alwaysApply forced to true (the whole point of RULES.md is to be reattached every turn). Project scope walks up from cwd to repoRoot using the same nearest-.omp/ search AGENTS.md uses.

Fixes #1266
2026-05-21 15:42:27 +00:00
roboomp d895f2223a fix(discovery): stop agents provider from scanning ~/.agent[s]/ as project
`getProjectPathCandidates` walks up from cwd to repoRoot (or home as a
fallback). When cwd is anywhere under $HOME and no closer .git boundary
exists, that walk-up reaches the home directory and enumerates
`~/.agent/<segments>` and `~/.agents/<segments>` as project paths.
`getUserPathCandidates` then enumerates the very same directories as
user paths, so every skill/rule/prompt/command/AGENTS.md found there
loaded twice. The capability deduper marks the second copy as shadowed,
but the Extension Dashboard renders shadowed entries — so users see one
active + one greyed-out duplicate of every home-level skill.

Skip the home directory inside the walk-up while still terminating the
loop on it; ancestors above home are still visited if the cwd happens
to live above (e.g. monorepo `home: tempDir` test fixtures).

Tests:
- Drop the duplicated copy of `getProjectPathCandidates` from the
  monorepo-skills test; import the real one so behavior stays in sync.
- Replace the old "walk-up stops at home when no repo root" assertion
  (which encoded the buggy behavior) with one that pins the new
  contract: home-level `.agent[s]/skills` are NOT enumerated as
  project paths.
- Add an explicit regression assertion that project ∩ user candidate
  sets are empty when cwd is under home.

Fixes #1116
2026-05-16 15:04:42 +00:00
Can Bölük c29e76b72c Merge pull request #1085 from can1357/farm/20cf0415/bug-claude-plugin-manifest-commands-key-
fix(discovery): honor Claude plugin commands manifest key
2026-05-15 05:03:58 +02:00
roboomp 8108394516 fix(discovery): honor manifest commands key for claude plugin slash commands
The ClaudePluginManifest interface was missing the `commands` field
(the standard Claude plugin format), and resolvePluginDir only checked
the legacy `slash-commands` key. Plugins declaring their command path
via `"commands": "..."` silently fell back to the hardcoded
`<plugin-root>/commands/` directory, which doesn't exist for
Claude-format plugins, so no slash commands were ever loaded.

Changes:
- Added `commands?: string` to ClaudePluginManifest.
- Changed resolvePluginDir to accept ReadonlyArray<keyof
  ClaudePluginManifest> and iterate in priority order; the first
  non-empty match wins.
- loadSlashCommands now passes ["commands", "slash-commands"] so
  the canonical Claude plugin key takes precedence over the legacy one.
- Added two regression tests: one covering the `commands` key in
  isolation, one verifying its precedence over `slash-commands` when
  both fields are present.

Fixes #1076
2026-05-15 02:10:22 +00:00
roboomp 1b40197b8c fix(discovery): respect disabledProviders in discoverAgents for claude-plugins
discoverAgents() called listClaudePluginRoots() unconditionally, so agents
from Claude Code marketplace plugins appeared in /agents and the Agent
Control Center even when claude-plugins was listed in disabledProviders.

Guard the listClaudePluginRoots() call with isProviderEnabled("claude-plugins"),
returning an empty roots array when the provider is disabled — matching how
filterProviders() handles every other capability's provider set.

Added regression test that verifies both the enabled path (agents visible)
and the disabled path (agents absent) using a real temp-directory plugin
registry fixture.

Fixes #1075
2026-05-15 01:06:59 +00:00