@oh-my-pi/pi-coding-agent 2.3.1337 → 3.0.1337
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -34
- package/README.md +100 -100
- package/docs/compaction.md +8 -8
- package/docs/config-usage.md +113 -0
- package/docs/custom-tools.md +8 -8
- package/docs/extension-loading.md +58 -58
- package/docs/hooks.md +11 -11
- package/docs/rpc.md +4 -4
- package/docs/sdk.md +14 -14
- package/docs/session-tree-plan.md +1 -1
- package/docs/session.md +2 -2
- package/docs/skills.md +16 -16
- package/docs/theme.md +9 -9
- package/docs/tui.md +1 -1
- package/examples/README.md +1 -1
- package/examples/custom-tools/README.md +4 -4
- package/examples/custom-tools/subagent/README.md +13 -13
- package/examples/custom-tools/subagent/agents.ts +2 -2
- package/examples/custom-tools/subagent/index.ts +5 -5
- package/examples/hooks/README.md +3 -3
- package/examples/hooks/auto-commit-on-exit.ts +1 -1
- package/examples/hooks/custom-compaction.ts +1 -1
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/05-tools.ts +1 -1
- package/examples/sdk/08-slash-commands.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
- package/examples/sdk/README.md +2 -2
- package/package.json +13 -11
- package/src/capability/context-file.ts +40 -0
- package/src/capability/extension.ts +48 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +616 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +52 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +52 -0
- package/src/capability/settings.ts +35 -0
- package/src/capability/skill.ts +49 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/system-prompt.ts +35 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +166 -0
- package/src/cli/args.ts +2 -2
- package/src/cli/plugin-cli.ts +24 -19
- package/src/cli/update-cli.ts +10 -10
- package/src/config.ts +290 -6
- package/src/core/auth-storage.ts +32 -9
- package/src/core/bash-executor.ts +1 -1
- package/src/core/custom-commands/loader.ts +44 -50
- package/src/core/custom-tools/index.ts +1 -0
- package/src/core/custom-tools/loader.ts +67 -69
- package/src/core/custom-tools/types.ts +10 -1
- package/src/core/hooks/loader.ts +13 -42
- package/src/core/index.ts +0 -1
- package/src/core/logger.ts +7 -7
- package/src/core/mcp/client.ts +1 -1
- package/src/core/mcp/config.ts +94 -146
- package/src/core/mcp/index.ts +0 -4
- package/src/core/mcp/loader.ts +26 -22
- package/src/core/mcp/manager.ts +18 -23
- package/src/core/mcp/tool-bridge.ts +9 -1
- package/src/core/mcp/types.ts +2 -0
- package/src/core/model-registry.ts +25 -8
- package/src/core/plugins/installer.ts +1 -1
- package/src/core/plugins/loader.ts +17 -11
- package/src/core/plugins/manager.ts +2 -2
- package/src/core/plugins/paths.ts +12 -7
- package/src/core/plugins/types.ts +3 -3
- package/src/core/sdk.ts +48 -27
- package/src/core/session-manager.ts +4 -4
- package/src/core/settings-manager.ts +45 -21
- package/src/core/skills.ts +222 -293
- package/src/core/slash-commands.ts +34 -165
- package/src/core/system-prompt.ts +58 -65
- package/src/core/timings.ts +2 -2
- package/src/core/tools/lsp/config.ts +38 -17
- package/src/core/tools/task/artifacts.ts +1 -1
- package/src/core/tools/task/commands.ts +30 -107
- package/src/core/tools/task/discovery.ts +54 -66
- package/src/core/tools/task/executor.ts +9 -9
- package/src/core/tools/task/index.ts +10 -10
- package/src/core/tools/task/model-resolver.ts +27 -25
- package/src/core/tools/task/types.ts +2 -2
- package/src/core/tools/web-fetch.ts +3 -3
- package/src/core/tools/web-search/auth.ts +40 -34
- package/src/core/tools/web-search/index.ts +1 -1
- package/src/core/tools/web-search/providers/anthropic.ts +1 -1
- package/src/discovery/agents-md.ts +75 -0
- package/src/discovery/builtin.ts +646 -0
- package/src/discovery/claude.ts +623 -0
- package/src/discovery/cline.ts +102 -0
- package/src/discovery/codex.ts +571 -0
- package/src/discovery/cursor.ts +264 -0
- package/src/discovery/gemini.ts +368 -0
- package/src/discovery/github.ts +120 -0
- package/src/discovery/helpers.test.ts +127 -0
- package/src/discovery/helpers.ts +249 -0
- package/src/discovery/index.ts +84 -0
- package/src/discovery/mcp-json.ts +127 -0
- package/src/discovery/vscode.ts +99 -0
- package/src/discovery/windsurf.ts +216 -0
- package/src/main.ts +14 -13
- package/src/migrations.ts +24 -3
- package/src/modes/interactive/components/hook-editor.ts +1 -1
- package/src/modes/interactive/components/plugin-settings.ts +1 -1
- package/src/modes/interactive/components/settings-defs.ts +38 -2
- package/src/modes/interactive/components/settings-selector.ts +1 -0
- package/src/modes/interactive/components/welcome.ts +2 -2
- package/src/modes/interactive/interactive-mode.ts +211 -16
- package/src/modes/interactive/theme/theme-schema.json +1 -1
- package/src/utils/clipboard.ts +1 -1
- package/src/utils/shell-snapshot.ts +2 -2
- package/src/utils/shell.ts +7 -7
package/docs/skills.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
>
|
|
1
|
+
> omp can create skills. Ask it to build one for your use case.
|
|
2
2
|
|
|
3
3
|
# Skills
|
|
4
4
|
|
|
5
5
|
Skills are self-contained capability packages that the agent loads on-demand. A skill provides specialized workflows, setup instructions, helper scripts, and reference documentation for specific tasks.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
OMP implements the [Agent Skills standard](https://agentskills.io/specification).
|
|
8
8
|
|
|
9
9
|
**Example use cases:**
|
|
10
10
|
- Web search and content extraction (Brave Search API)
|
|
@@ -144,12 +144,12 @@ Skills are discovered from these locations (later wins on name collision):
|
|
|
144
144
|
1. `~/.codex/skills/**/SKILL.md` (Codex CLI, recursive)
|
|
145
145
|
2. `~/.claude/skills/*/SKILL.md` (Claude Code user, one level)
|
|
146
146
|
3. `<cwd>/.claude/skills/*/SKILL.md` (Claude Code project, one level)
|
|
147
|
-
4. `~/.
|
|
148
|
-
5. `<cwd>/.
|
|
147
|
+
4. `~/.omp/agent/skills/**/SKILL.md` (OMP user, recursive)
|
|
148
|
+
5. `<cwd>/.omp/skills/**/SKILL.md` (OMP project, recursive)
|
|
149
149
|
|
|
150
150
|
## Configuration
|
|
151
151
|
|
|
152
|
-
Configure skill loading in `~/.
|
|
152
|
+
Configure skill loading in `~/.omp/agent/settings.json`:
|
|
153
153
|
|
|
154
154
|
```json
|
|
155
155
|
{
|
|
@@ -173,8 +173,8 @@ Configure skill loading in `~/.pi/agent/settings.json`:
|
|
|
173
173
|
| `enableCodexUser` | `true` | Load from `~/.codex/skills/` |
|
|
174
174
|
| `enableClaudeUser` | `true` | Load from `~/.claude/skills/` |
|
|
175
175
|
| `enableClaudeProject` | `true` | Load from `<cwd>/.claude/skills/` |
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
176
|
+
| `enableOmpUser` | `true` | Load from `~/.omp/agent/skills/` |
|
|
177
|
+
| `enableOmpProject` | `true` | Load from `<cwd>/.omp/skills/` |
|
|
178
178
|
| `customDirectories` | `[]` | Additional directories to scan (supports `~` expansion) |
|
|
179
179
|
| `ignoredSkills` | `[]` | Glob patterns to exclude (e.g., `["deprecated-*", "test-skill"]`) |
|
|
180
180
|
| `includeSkills` | `[]` | Glob patterns to include (empty = all; e.g., `["git-*", "docker"]`) |
|
|
@@ -187,20 +187,20 @@ Use `--skills` to filter skills for a specific invocation:
|
|
|
187
187
|
|
|
188
188
|
```bash
|
|
189
189
|
# Only load specific skills
|
|
190
|
-
|
|
190
|
+
omp --skills git,docker
|
|
191
191
|
|
|
192
192
|
# Glob patterns
|
|
193
|
-
|
|
193
|
+
omp --skills "git-*,docker-*"
|
|
194
194
|
|
|
195
195
|
# All skills matching a prefix
|
|
196
|
-
|
|
196
|
+
omp --skills "aws-*"
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
This overrides the `includeSkills` setting for the current session.
|
|
200
200
|
|
|
201
201
|
## How Skills Work
|
|
202
202
|
|
|
203
|
-
1. At startup,
|
|
203
|
+
1. At startup, omp scans skill locations and extracts names + descriptions
|
|
204
204
|
2. The system prompt includes available skills in XML format
|
|
205
205
|
3. When a task matches, the agent uses `read` to load the full SKILL.md
|
|
206
206
|
4. The agent follows the instructions, using relative paths to reference scripts/assets
|
|
@@ -209,7 +209,7 @@ This is progressive disclosure: only descriptions are always in context, full in
|
|
|
209
209
|
|
|
210
210
|
## Validation Warnings
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
OMP validates skills against the Agent Skills standard and warns (but still loads) non-compliant skills:
|
|
213
213
|
|
|
214
214
|
- Name doesn't match parent directory
|
|
215
215
|
- Name exceeds 64 characters
|
|
@@ -260,9 +260,9 @@ cd /path/to/brave-search && npm install
|
|
|
260
260
|
|
|
261
261
|
## Compatibility
|
|
262
262
|
|
|
263
|
-
**Claude Code**:
|
|
263
|
+
**Claude Code**: OMP reads skills from `~/.claude/skills/*/SKILL.md`. The `allowed-tools` and `model` frontmatter fields are ignored.
|
|
264
264
|
|
|
265
|
-
**Codex CLI**:
|
|
265
|
+
**Codex CLI**: OMP reads skills from `~/.codex/skills/` recursively. Hidden files/directories and symlinks are skipped.
|
|
266
266
|
|
|
267
267
|
## Skill Repositories
|
|
268
268
|
|
|
@@ -275,10 +275,10 @@ For inspiration and ready-to-use skills:
|
|
|
275
275
|
|
|
276
276
|
CLI:
|
|
277
277
|
```bash
|
|
278
|
-
|
|
278
|
+
omp --no-skills
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
Settings (`~/.
|
|
281
|
+
Settings (`~/.omp/agent/settings.json`):
|
|
282
282
|
```json
|
|
283
283
|
{
|
|
284
284
|
"skills": {
|
package/docs/theme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
>
|
|
1
|
+
> omp can create themes. Ask it to build one for your use case.
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# OMP Coding Agent Themes
|
|
4
4
|
|
|
5
5
|
Themes allow you to customize the colors used throughout the coding agent TUI.
|
|
6
6
|
|
|
@@ -205,7 +205,7 @@ This is useful for:
|
|
|
205
205
|
|
|
206
206
|
## Built-in Themes
|
|
207
207
|
|
|
208
|
-
|
|
208
|
+
OMP comes with two built-in themes:
|
|
209
209
|
|
|
210
210
|
### `dark` (default)
|
|
211
211
|
|
|
@@ -227,26 +227,26 @@ Themes are configured in the settings (accessible via `/settings`):
|
|
|
227
227
|
|
|
228
228
|
Or use the `/theme` command interactively.
|
|
229
229
|
|
|
230
|
-
On first run,
|
|
230
|
+
On first run, OMP detects your terminal's background and sets a sensible default (`dark` or `light`).
|
|
231
231
|
|
|
232
232
|
## Custom Themes
|
|
233
233
|
|
|
234
234
|
### Theme Locations
|
|
235
235
|
|
|
236
|
-
Custom themes are loaded from `~/.
|
|
236
|
+
Custom themes are loaded from `~/.omp/agent/themes/*.json`.
|
|
237
237
|
|
|
238
238
|
### Creating a Custom Theme
|
|
239
239
|
|
|
240
240
|
1. **Create theme directory:**
|
|
241
241
|
|
|
242
242
|
```bash
|
|
243
|
-
mkdir -p ~/.
|
|
243
|
+
mkdir -p ~/.omp/agent/themes
|
|
244
244
|
```
|
|
245
245
|
|
|
246
246
|
2. **Create theme file:**
|
|
247
247
|
|
|
248
248
|
```bash
|
|
249
|
-
vim ~/.
|
|
249
|
+
vim ~/.omp/agent/themes/my-theme.json
|
|
250
250
|
```
|
|
251
251
|
|
|
252
252
|
3. **Define all colors:**
|
|
@@ -411,14 +411,14 @@ Example usage:
|
|
|
411
411
|
|
|
412
412
|
### Terminal Compatibility
|
|
413
413
|
|
|
414
|
-
|
|
414
|
+
OMP uses 24-bit RGB colors (`\x1b[38;2;R;G;Bm`). Most modern terminals support this:
|
|
415
415
|
|
|
416
416
|
- ✅ iTerm2, Alacritty, Kitty, WezTerm
|
|
417
417
|
- ✅ Windows Terminal
|
|
418
418
|
- ✅ VS Code integrated terminal
|
|
419
419
|
- ✅ Modern GNOME Terminal, Konsole
|
|
420
420
|
|
|
421
|
-
For older terminals with only 256-color support,
|
|
421
|
+
For older terminals with only 256-color support, OMP automatically falls back to the nearest 256-color approximation.
|
|
422
422
|
|
|
423
423
|
To check if your terminal supports truecolor:
|
|
424
424
|
|
package/docs/tui.md
CHANGED
package/examples/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Custom Tools Examples
|
|
2
2
|
|
|
3
|
-
Example custom tools for
|
|
3
|
+
Example custom tools for omp-coding-agent.
|
|
4
4
|
|
|
5
5
|
## Examples
|
|
6
6
|
|
|
@@ -38,13 +38,13 @@ See [subagent/README.md](subagent/README.md) for full documentation.
|
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
# Test directly (can point to any .ts file)
|
|
41
|
-
|
|
41
|
+
omp --tool examples/custom-tools/todo/index.ts
|
|
42
42
|
|
|
43
43
|
# Or copy entire folder to tools directory for persistent use
|
|
44
|
-
cp -r todo ~/.
|
|
44
|
+
cp -r todo ~/.omp/agent/tools/
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
Then in
|
|
47
|
+
Then in omp:
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
> add a todo "test custom tools"
|
|
@@ -4,7 +4,7 @@ Delegate tasks to specialized subagents with isolated context windows.
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Isolated context**: Each subagent runs in a separate `
|
|
7
|
+
- **Isolated context**: Each subagent runs in a separate `omp` process
|
|
8
8
|
- **Streaming output**: See tool calls and progress as they happen
|
|
9
9
|
- **Parallel streaming**: All parallel tasks stream updates simultaneously
|
|
10
10
|
- **Markdown rendering**: Final output rendered with proper formatting (expanded view)
|
|
@@ -35,30 +35,30 @@ From the repository root, symlink the files:
|
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
37
|
# Symlink the tool (must be in a subdirectory with index.ts)
|
|
38
|
-
mkdir -p ~/.
|
|
39
|
-
ln -sf "$(pwd)/packages/coding-agent/examples/custom-tools/subagent/subagent.ts" ~/.
|
|
40
|
-
ln -sf "$(pwd)/packages/coding-agent/examples/custom-tools/subagent/agents.ts" ~/.
|
|
38
|
+
mkdir -p ~/.omp/agent/tools/subagent
|
|
39
|
+
ln -sf "$(pwd)/packages/coding-agent/examples/custom-tools/subagent/subagent.ts" ~/.omp/agent/tools/subagent/index.ts
|
|
40
|
+
ln -sf "$(pwd)/packages/coding-agent/examples/custom-tools/subagent/agents.ts" ~/.omp/agent/tools/subagent/agents.ts
|
|
41
41
|
|
|
42
42
|
# Symlink agents
|
|
43
|
-
mkdir -p ~/.
|
|
43
|
+
mkdir -p ~/.omp/agent/agents
|
|
44
44
|
for f in packages/coding-agent/examples/custom-tools/subagent/agents/*.md; do
|
|
45
|
-
ln -sf "$(pwd)/$f" ~/.
|
|
45
|
+
ln -sf "$(pwd)/$f" ~/.omp/agent/agents/$(basename "$f")
|
|
46
46
|
done
|
|
47
47
|
|
|
48
48
|
# Symlink workflow commands
|
|
49
|
-
mkdir -p ~/.
|
|
49
|
+
mkdir -p ~/.omp/agent/commands
|
|
50
50
|
for f in packages/coding-agent/examples/custom-tools/subagent/commands/*.md; do
|
|
51
|
-
ln -sf "$(pwd)/$f" ~/.
|
|
51
|
+
ln -sf "$(pwd)/$f" ~/.omp/agent/commands/$(basename "$f")
|
|
52
52
|
done
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Security Model
|
|
56
56
|
|
|
57
|
-
This tool executes a separate `
|
|
57
|
+
This tool executes a separate `omp` subprocess with a delegated system prompt and tool/model configuration.
|
|
58
58
|
|
|
59
|
-
**Project-local agents** (`.
|
|
59
|
+
**Project-local agents** (`.omp/agents/*.md`) are repo-controlled prompts that can instruct the model to read files, run bash commands, etc.
|
|
60
60
|
|
|
61
|
-
**Default behavior:** Only loads **user-level agents** from `~/.
|
|
61
|
+
**Default behavior:** Only loads **user-level agents** from `~/.omp/agent/agents`.
|
|
62
62
|
|
|
63
63
|
To enable project-local agents, pass `agentScope: "both"` (or `"project"`). Only do this for repositories you trust.
|
|
64
64
|
|
|
@@ -136,8 +136,8 @@ System prompt for the agent goes here.
|
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
**Locations:**
|
|
139
|
-
- `~/.
|
|
140
|
-
- `.
|
|
139
|
+
- `~/.omp/agent/agents/*.md` - User-level (always loaded)
|
|
140
|
+
- `.omp/agents/*.md` - Project-level (only with `agentScope: "project"` or `"both"`)
|
|
141
141
|
|
|
142
142
|
Project agents override user agents with the same name when `agentScope: "both"`.
|
|
143
143
|
|
|
@@ -115,7 +115,7 @@ function isDirectory(p: string): boolean {
|
|
|
115
115
|
function findNearestProjectAgentsDir(cwd: string): string | null {
|
|
116
116
|
let currentDir = cwd;
|
|
117
117
|
while (true) {
|
|
118
|
-
const candidate = path.join(currentDir, ".
|
|
118
|
+
const candidate = path.join(currentDir, ".omp", "agents");
|
|
119
119
|
if (isDirectory(candidate)) return candidate;
|
|
120
120
|
|
|
121
121
|
const parentDir = path.dirname(currentDir);
|
|
@@ -125,7 +125,7 @@ function findNearestProjectAgentsDir(cwd: string): string | null {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
|
|
128
|
-
const userDir = path.join(os.homedir(), ".
|
|
128
|
+
const userDir = path.join(os.homedir(), ".omp", "agent", "agents");
|
|
129
129
|
const projectAgentsDir = findNearestProjectAgentsDir(cwd);
|
|
130
130
|
|
|
131
131
|
const userAgents = scope === "project" ? [] : loadAgentsFromDir(userDir, "user");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Subagent Tool - Delegate tasks to specialized agents
|
|
3
3
|
*
|
|
4
|
-
* Spawns a separate `
|
|
4
|
+
* Spawns a separate `omp` process for each subagent invocation,
|
|
5
5
|
* giving it an isolated context window.
|
|
6
6
|
*
|
|
7
7
|
* Supports three modes:
|
|
@@ -205,7 +205,7 @@ async function mapWithConcurrencyLimit<TIn, TOut>(
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
function writePromptToTempFile(agentName: string, prompt: string): { dir: string; filePath: string } {
|
|
208
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "
|
|
208
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "omp-subagent-"));
|
|
209
209
|
const safeName = agentName.replace(/[^\w.-]+/g, "_");
|
|
210
210
|
const filePath = path.join(tmpDir, `prompt-${safeName}.md`);
|
|
211
211
|
fs.writeFileSync(filePath, prompt, { encoding: "utf-8", mode: 0o600 });
|
|
@@ -280,7 +280,7 @@ async function runSingleAgent(
|
|
|
280
280
|
let wasAborted = false;
|
|
281
281
|
|
|
282
282
|
const exitCode = await new Promise<number>((resolve) => {
|
|
283
|
-
const proc = Bun.spawn(["
|
|
283
|
+
const proc = Bun.spawn(["omp", ...args], {
|
|
284
284
|
cwd: cwd ?? pi.cwd,
|
|
285
285
|
stdin: "ignore",
|
|
286
286
|
stdout: "pipe",
|
|
@@ -440,8 +440,8 @@ const factory: CustomToolFactory = (pi) => {
|
|
|
440
440
|
return [
|
|
441
441
|
"Delegate tasks to specialized subagents with isolated context.",
|
|
442
442
|
"Modes: single (agent + task), parallel (tasks array), chain (sequential with {previous} placeholder).",
|
|
443
|
-
'Default agent scope is "user" (from ~/.
|
|
444
|
-
'To enable project-local agents in .
|
|
443
|
+
'Default agent scope is "user" (from ~/.omp/agent/agents).',
|
|
444
|
+
'To enable project-local agents in .omp/agents, set agentScope: "both" (or "project").',
|
|
445
445
|
`User agents: ${userList.text}${userSuffix}.`,
|
|
446
446
|
`Project agents${projectDirNote}: ${projectList.text}${projectSuffix}.`,
|
|
447
447
|
].join(" ");
|
package/examples/hooks/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Hooks Examples
|
|
2
2
|
|
|
3
|
-
Example hooks for
|
|
3
|
+
Example hooks for omp-coding-agent.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
# Load a hook with --hook flag
|
|
9
|
-
|
|
9
|
+
omp --hook examples/hooks/permission-gate.ts
|
|
10
10
|
|
|
11
11
|
# Or copy to hooks directory for auto-discovery
|
|
12
|
-
cp permission-gate.ts ~/.
|
|
12
|
+
cp permission-gate.ts ~/.omp/agent/hooks/
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Examples
|
|
@@ -36,7 +36,7 @@ export default function (pi: HookAPI) {
|
|
|
36
36
|
|
|
37
37
|
// Generate a simple commit message
|
|
38
38
|
const firstLine = lastAssistantText.split("\n")[0] || "Work in progress";
|
|
39
|
-
const commitMessage = `[
|
|
39
|
+
const commitMessage = `[omp] ${firstLine.slice(0, 50)}${firstLine.length > 50 ? "..." : ""}`;
|
|
40
40
|
|
|
41
41
|
// Stage and commit
|
|
42
42
|
await pi.exec("git", ["add", "-A"]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Minimal SDK Usage
|
|
3
3
|
*
|
|
4
4
|
* Uses all defaults: discovers skills, hooks, tools, context files
|
|
5
|
-
* from cwd and ~/.
|
|
5
|
+
* from cwd and ~/.omp/agent. Model chosen from settings or first available.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { createAgentSession } from "@oh-my-pi/pi-coding-agent";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { createAgentSession, discoverSkills, SessionManager, type Skill } from "@oh-my-pi/pi-coding-agent";
|
|
9
9
|
|
|
10
|
-
// Discover all skills from cwd/.
|
|
10
|
+
// Discover all skills from cwd/.omp/skills, ~/.omp/agent/skills, etc.
|
|
11
11
|
const allSkills = discoverSkills();
|
|
12
12
|
console.log(
|
|
13
13
|
"Discovered skills:",
|
package/examples/sdk/05-tools.ts
CHANGED
|
@@ -82,7 +82,7 @@ session.subscribe((event) => {
|
|
|
82
82
|
await session.prompt("What's the weather in Tokyo?");
|
|
83
83
|
console.log();
|
|
84
84
|
|
|
85
|
-
// Merge with discovered tools from cwd/.
|
|
85
|
+
// Merge with discovered tools from cwd/.omp/tools and ~/.omp/agent/tools:
|
|
86
86
|
// const discovered = await discoverCustomTools();
|
|
87
87
|
// customTools: [...discovered, { tool: myTool }]
|
|
88
88
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
SessionManager,
|
|
12
12
|
} from "@oh-my-pi/pi-coding-agent";
|
|
13
13
|
|
|
14
|
-
// Discover commands from cwd/.
|
|
14
|
+
// Discover commands from cwd/.omp/commands/ and ~/.omp/agent/commands/
|
|
15
15
|
const discovered = discoverSlashCommands();
|
|
16
16
|
console.log("Discovered slash commands:");
|
|
17
17
|
for (const cmd of discovered) {
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
SessionManager,
|
|
14
14
|
} from "@oh-my-pi/pi-coding-agent";
|
|
15
15
|
|
|
16
|
-
// Default: discoverAuthStorage() uses ~/.
|
|
17
|
-
// discoverModels() loads built-in + custom models from ~/.
|
|
16
|
+
// Default: discoverAuthStorage() uses ~/.omp/agent/auth.json
|
|
17
|
+
// discoverModels() loads built-in + custom models from ~/.omp/agent/models.json
|
|
18
18
|
const authStorage = discoverAuthStorage();
|
|
19
19
|
const modelRegistry = discoverModels(authStorage);
|
|
20
20
|
|
package/examples/sdk/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SDK Examples
|
|
2
2
|
|
|
3
|
-
Programmatic usage of
|
|
3
|
+
Programmatic usage of omp-coding-agent via `createAgentSession()`.
|
|
4
4
|
|
|
5
5
|
## Examples
|
|
6
6
|
|
|
@@ -115,7 +115,7 @@ await session.prompt("Hello");
|
|
|
115
115
|
| `authStorage` | `discoverAuthStorage()` | Credential storage |
|
|
116
116
|
| `modelRegistry` | `discoverModels(authStorage)` | Model registry |
|
|
117
117
|
| `cwd` | `process.cwd()` | Working directory |
|
|
118
|
-
| `agentDir` | `~/.
|
|
118
|
+
| `agentDir` | `~/.omp/agent` | Config directory |
|
|
119
119
|
| `model` | From settings/first available | Model to use |
|
|
120
120
|
| `thinkingLevel` | From settings/"off" | off, low, medium, high |
|
|
121
121
|
| `systemPrompt` | Discovered | String or `(default) => modified` |
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-coding-agent",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1337",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"name": "
|
|
8
|
-
"configDir": ".
|
|
6
|
+
"ompConfig": {
|
|
7
|
+
"name": "omp",
|
|
8
|
+
"configDir": ".omp"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
|
-
"
|
|
11
|
+
"omp": "src/cli.ts"
|
|
12
12
|
},
|
|
13
13
|
"main": "./src/index.ts",
|
|
14
14
|
"types": "./src/index.ts",
|
|
@@ -32,20 +32,19 @@
|
|
|
32
32
|
"check": "tsgo --noEmit",
|
|
33
33
|
"clean": "rm -rf dist",
|
|
34
34
|
"build": "tsgo -p tsconfig.build.json && chmod +x dist/cli.js",
|
|
35
|
-
"build:binary": "bun build --compile ./src/cli.ts --outfile dist/
|
|
35
|
+
"build:binary": "bun build --compile ./src/cli.ts --outfile dist/omp",
|
|
36
36
|
"generate-template": "bun scripts/generate-template.ts",
|
|
37
37
|
"postinstall": "[ -f scripts/generate-template.ts ] && bun run generate-template || true",
|
|
38
38
|
"test": "bun test",
|
|
39
39
|
"prepublishOnly": "bun run generate-template && bun run clean && bun run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@oh-my-pi/pi-agent-core": "
|
|
43
|
-
"@oh-my-pi/pi-ai": "
|
|
44
|
-
"@oh-my-pi/pi-tui": "
|
|
42
|
+
"@oh-my-pi/pi-agent-core": "3.0.1337",
|
|
43
|
+
"@oh-my-pi/pi-ai": "3.0.1337",
|
|
44
|
+
"@oh-my-pi/pi-tui": "3.0.1337",
|
|
45
45
|
"@sinclair/typebox": "^0.34.46",
|
|
46
46
|
"ajv": "^8.17.1",
|
|
47
47
|
"chalk": "^5.5.0",
|
|
48
|
-
"node-html-parser": "^6.1.13",
|
|
49
48
|
"cli-highlight": "^2.1.11",
|
|
50
49
|
"diff": "^8.0.2",
|
|
51
50
|
"file-type": "^21.1.1",
|
|
@@ -53,9 +52,12 @@
|
|
|
53
52
|
"highlight.js": "^11.11.1",
|
|
54
53
|
"marked": "^15.0.12",
|
|
55
54
|
"minimatch": "^10.1.1",
|
|
55
|
+
"node-html-parser": "^6.1.13",
|
|
56
|
+
"smol-toml": "^1.6.0",
|
|
56
57
|
"strip-ansi": "^7.1.2",
|
|
57
58
|
"winston": "^3.17.0",
|
|
58
|
-
"winston-daily-rotate-file": "^5.0.0"
|
|
59
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
60
|
+
"yaml": "^2.8.2"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@types/diff": "^7.0.2",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Files Capability
|
|
3
|
+
*
|
|
4
|
+
* System instruction files (CLAUDE.md, AGENTS.md, GEMINI.md, etc.) that provide
|
|
5
|
+
* persistent guidance to the agent.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { defineCapability } from "./index";
|
|
9
|
+
import type { SourceMeta } from "./types";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A context file that provides persistent instructions to the agent.
|
|
13
|
+
*/
|
|
14
|
+
export interface ContextFile {
|
|
15
|
+
/** Absolute path to the file */
|
|
16
|
+
path: string;
|
|
17
|
+
/** File content */
|
|
18
|
+
content: string;
|
|
19
|
+
/** Which level this came from */
|
|
20
|
+
level: "user" | "project";
|
|
21
|
+
/** Distance from cwd (0 = in cwd, 1 = parent, etc.) for project files */
|
|
22
|
+
depth?: number;
|
|
23
|
+
/** Source metadata */
|
|
24
|
+
_source: SourceMeta;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const contextFileCapability = defineCapability<ContextFile>({
|
|
28
|
+
id: "context-files",
|
|
29
|
+
displayName: "Context Files",
|
|
30
|
+
description: "Persistent instruction files (CLAUDE.md, AGENTS.md, etc.) that guide agent behavior",
|
|
31
|
+
// Deduplicate by level: one user-level file, one project-level file
|
|
32
|
+
// Higher-priority providers shadow lower-priority ones at the same scope
|
|
33
|
+
key: (file) => file.level,
|
|
34
|
+
validate: (file) => {
|
|
35
|
+
if (!file.path) return "Missing path";
|
|
36
|
+
if (file.content === undefined) return "Missing content";
|
|
37
|
+
if (file.level !== "user" && file.level !== "project") return "Invalid level: must be 'user' or 'project'";
|
|
38
|
+
return undefined;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensions Capability
|
|
3
|
+
*
|
|
4
|
+
* Gemini-style extensions that provide MCP servers, tools, and context.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineCapability } from "./index";
|
|
8
|
+
import type { MCPServer } from "./mcp";
|
|
9
|
+
import type { SourceMeta } from "./types";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Extension manifest structure.
|
|
13
|
+
*/
|
|
14
|
+
export interface ExtensionManifest {
|
|
15
|
+
name?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
mcpServers?: Record<string, Omit<MCPServer, "name" | "_source">>;
|
|
18
|
+
tools?: unknown[];
|
|
19
|
+
context?: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A loaded extension.
|
|
24
|
+
*/
|
|
25
|
+
export interface Extension {
|
|
26
|
+
/** Extension name (from manifest.name or directory name) */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Absolute path to extension directory */
|
|
29
|
+
path: string;
|
|
30
|
+
/** Parsed manifest data */
|
|
31
|
+
manifest: ExtensionManifest;
|
|
32
|
+
/** Source level */
|
|
33
|
+
level: "user" | "project";
|
|
34
|
+
/** Source metadata */
|
|
35
|
+
_source: SourceMeta;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const extensionCapability = defineCapability<Extension>({
|
|
39
|
+
id: "extensions",
|
|
40
|
+
displayName: "Extensions",
|
|
41
|
+
description: "Gemini-style extensions providing MCP servers, tools, and context",
|
|
42
|
+
key: (ext) => ext.name,
|
|
43
|
+
validate: (ext) => {
|
|
44
|
+
if (!ext.name) return "Missing extension name";
|
|
45
|
+
if (!ext.path) return "Missing extension path";
|
|
46
|
+
return undefined;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks Capability
|
|
3
|
+
*
|
|
4
|
+
* Pre/post tool execution hooks defined as shell scripts.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { defineCapability } from "./index";
|
|
8
|
+
import type { SourceMeta } from "./types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A hook script.
|
|
12
|
+
*/
|
|
13
|
+
export interface Hook {
|
|
14
|
+
/** Hook name (filename without extension) */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Absolute path to hook file */
|
|
17
|
+
path: string;
|
|
18
|
+
/** Hook type (pre/post) and associated tool */
|
|
19
|
+
type: "pre" | "post";
|
|
20
|
+
/** Tool this hook applies to, or "*" for all */
|
|
21
|
+
tool: string;
|
|
22
|
+
/** Source level */
|
|
23
|
+
level: "user" | "project";
|
|
24
|
+
/** Source metadata */
|
|
25
|
+
_source: SourceMeta;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const hookCapability = defineCapability<Hook>({
|
|
29
|
+
id: "hooks",
|
|
30
|
+
displayName: "Hooks",
|
|
31
|
+
description: "Pre/post tool execution hooks",
|
|
32
|
+
key: (hook) => `${hook.type}:${hook.tool}:${hook.name}`,
|
|
33
|
+
validate: (hook) => {
|
|
34
|
+
if (!hook.name) return "Missing name";
|
|
35
|
+
if (!hook.path) return "Missing path";
|
|
36
|
+
if (hook.type !== "pre" && hook.type !== "post") return "Invalid type (must be 'pre' or 'post')";
|
|
37
|
+
if (!hook.tool) return "Missing tool";
|
|
38
|
+
return undefined;
|
|
39
|
+
},
|
|
40
|
+
});
|