@amanm/openpaw 0.1.0

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.
Files changed (72) hide show
  1. package/AGENTS.md +1 -0
  2. package/README.md +144 -0
  3. package/agent/agent.ts +217 -0
  4. package/agent/context-scan.ts +81 -0
  5. package/agent/file-editor-store.ts +27 -0
  6. package/agent/index.ts +31 -0
  7. package/agent/memory-store.ts +404 -0
  8. package/agent/model.ts +14 -0
  9. package/agent/prompt-builder.ts +139 -0
  10. package/agent/prompt-context-files.ts +151 -0
  11. package/agent/sandbox-paths.ts +52 -0
  12. package/agent/session-store.ts +80 -0
  13. package/agent/skill-catalog.ts +25 -0
  14. package/agent/skills/discover.ts +100 -0
  15. package/agent/tool-stream-format.ts +126 -0
  16. package/agent/tool-yaml-like.ts +96 -0
  17. package/agent/tools/bash.ts +100 -0
  18. package/agent/tools/file-editor.ts +293 -0
  19. package/agent/tools/list-dir.ts +58 -0
  20. package/agent/tools/load-skill.ts +40 -0
  21. package/agent/tools/memory.ts +84 -0
  22. package/agent/turn-context.ts +46 -0
  23. package/agent/types.ts +37 -0
  24. package/agent/workspace-bootstrap.ts +98 -0
  25. package/bin/openpaw.cjs +177 -0
  26. package/bundled-skills/find-skills/SKILL.md +163 -0
  27. package/cli/components/chat-app.tsx +759 -0
  28. package/cli/components/onboard-ui.tsx +325 -0
  29. package/cli/components/theme.ts +16 -0
  30. package/cli/configure.tsx +0 -0
  31. package/cli/lib/chat-transcript-types.ts +11 -0
  32. package/cli/lib/markdown-render-node.ts +523 -0
  33. package/cli/lib/onboard-markdown-syntax-style.ts +55 -0
  34. package/cli/lib/ui-messages-to-chat-transcript.ts +157 -0
  35. package/cli/lib/use-auto-copy-selection.ts +38 -0
  36. package/cli/onboard.tsx +248 -0
  37. package/cli/openpaw.tsx +144 -0
  38. package/cli/reset.ts +12 -0
  39. package/cli/tui.tsx +31 -0
  40. package/config/index.ts +3 -0
  41. package/config/paths.ts +71 -0
  42. package/config/personality-copy.ts +68 -0
  43. package/config/storage.ts +80 -0
  44. package/config/types.ts +37 -0
  45. package/gateway/bootstrap.ts +25 -0
  46. package/gateway/channel-adapter.ts +8 -0
  47. package/gateway/daemon-manager.ts +191 -0
  48. package/gateway/index.ts +18 -0
  49. package/gateway/session-key.ts +13 -0
  50. package/gateway/slash-command-tokens.ts +39 -0
  51. package/gateway/start-messaging.ts +40 -0
  52. package/gateway/telegram/active-thread-store.ts +89 -0
  53. package/gateway/telegram/adapter.ts +290 -0
  54. package/gateway/telegram/assistant-markdown.ts +48 -0
  55. package/gateway/telegram/bot-commands.ts +40 -0
  56. package/gateway/telegram/chat-preferences.ts +100 -0
  57. package/gateway/telegram/constants.ts +5 -0
  58. package/gateway/telegram/index.ts +4 -0
  59. package/gateway/telegram/message-html.ts +138 -0
  60. package/gateway/telegram/message-queue.ts +19 -0
  61. package/gateway/telegram/reserved-command-filter.ts +33 -0
  62. package/gateway/telegram/session-file-discovery.ts +62 -0
  63. package/gateway/telegram/session-key.ts +13 -0
  64. package/gateway/telegram/session-label.ts +14 -0
  65. package/gateway/telegram/sessions-list-reply.ts +39 -0
  66. package/gateway/telegram/stream-delivery.ts +618 -0
  67. package/gateway/tui/constants.ts +2 -0
  68. package/gateway/tui/tui-active-thread-store.ts +103 -0
  69. package/gateway/tui/tui-session-discovery.ts +94 -0
  70. package/gateway/tui/tui-session-label.ts +22 -0
  71. package/gateway/tui/tui-sessions-list-message.ts +37 -0
  72. package/package.json +52 -0
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Node launcher shim for OpenPaw.
5
+ *
6
+ * Purpose:
7
+ * - Keep npm global install UX (`npm i -g openpaw`) simple.
8
+ * - Ensure Bun is available before running the Bun-native TypeScript CLI.
9
+ * - Offer interactive Bun install on macOS/Linux when missing.
10
+ */
11
+
12
+ const { spawn, spawnSync } = require("node:child_process");
13
+ const { existsSync } = require("node:fs");
14
+ const os = require("node:os");
15
+ const path = require("node:path");
16
+ const readline = require("node:readline");
17
+
18
+ /** Absolute CLI entrypoint shipped in the npm package. */
19
+ const CLI_ENTRY = path.resolve(__dirname, "..", "cli", "openpaw.tsx");
20
+
21
+ /** Home-local Bun binary path used by official installer on Unix systems. */
22
+ const HOME_BUN_BIN = path.join(os.homedir(), ".bun", "bin", "bun");
23
+
24
+ /**
25
+ * Returns a PATH string that includes default Bun install directory if present.
26
+ */
27
+ function pathWithHomeBun(envPath) {
28
+ if (!existsSync(HOME_BUN_BIN)) {
29
+ return envPath || "";
30
+ }
31
+ const delimiter = process.platform === "win32" ? ";" : ":";
32
+ const segments = (envPath || "").split(delimiter).filter(Boolean);
33
+ const homeBunDir = path.dirname(HOME_BUN_BIN);
34
+ if (!segments.includes(homeBunDir)) {
35
+ segments.unshift(homeBunDir);
36
+ }
37
+ return segments.join(delimiter);
38
+ }
39
+
40
+ /**
41
+ * Resolves Bun binary by trying PATH (and `~/.bun/bin`) with lightweight version checks.
42
+ */
43
+ function resolveBunBinary() {
44
+ const env = { ...process.env, PATH: pathWithHomeBun(process.env.PATH) };
45
+ const checkPath = spawnSync("bun", ["--version"], {
46
+ env,
47
+ stdio: "ignore",
48
+ });
49
+ if (checkPath.status === 0) {
50
+ return { bun: "bun", env };
51
+ }
52
+
53
+ if (existsSync(HOME_BUN_BIN)) {
54
+ const checkHome = spawnSync(HOME_BUN_BIN, ["--version"], {
55
+ env,
56
+ stdio: "ignore",
57
+ });
58
+ if (checkHome.status === 0) {
59
+ return { bun: HOME_BUN_BIN, env };
60
+ }
61
+ }
62
+
63
+ return null;
64
+ }
65
+
66
+ /**
67
+ * Prompts the user for a yes/no choice and resolves `true` only for affirmative answers.
68
+ */
69
+ function promptYesNo(question) {
70
+ return new Promise((resolve) => {
71
+ const rl = readline.createInterface({
72
+ input: process.stdin,
73
+ output: process.stdout,
74
+ });
75
+
76
+ rl.question(question, (answer) => {
77
+ rl.close();
78
+ const value = String(answer || "").trim().toLowerCase();
79
+ resolve(value === "" || value === "y" || value === "yes");
80
+ });
81
+ });
82
+ }
83
+
84
+ /**
85
+ * Runs official Bun installer on Unix (`curl ... | bash`) and returns success flag.
86
+ */
87
+ function installBunUnix() {
88
+ const cmd = "curl -fsSL https://bun.sh/install | bash";
89
+ const result = spawnSync("bash", ["-lc", cmd], { stdio: "inherit" });
90
+ return result.status === 0;
91
+ }
92
+
93
+ /**
94
+ * Prints manual Bun install guidance and exits with failure.
95
+ */
96
+ function failWithBunInstructions() {
97
+ if (process.platform === "win32") {
98
+ console.error("Bun is required to run OpenPaw.");
99
+ console.error("Install Bun from https://bun.sh/docs/installation and rerun `openpaw`.");
100
+ process.exit(1);
101
+ }
102
+
103
+ console.error("Bun is required to run OpenPaw.");
104
+ console.error("Install with: curl -fsSL https://bun.sh/install | bash");
105
+ console.error("Then restart your shell and rerun `openpaw`.");
106
+ process.exit(1);
107
+ }
108
+
109
+ /**
110
+ * Ensures Bun is present. When missing on macOS/Linux, asks permission to install it.
111
+ */
112
+ async function ensureBun() {
113
+ const resolved = resolveBunBinary();
114
+ if (resolved) {
115
+ return resolved;
116
+ }
117
+
118
+ if (process.platform === "win32") {
119
+ failWithBunInstructions();
120
+ }
121
+
122
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
123
+ failWithBunInstructions();
124
+ }
125
+
126
+ const consent = await promptYesNo("Bun is required but not found. Install Bun now? [Y/n] ");
127
+ if (!consent) {
128
+ failWithBunInstructions();
129
+ }
130
+
131
+ const installed = installBunUnix();
132
+ if (!installed) {
133
+ console.error("Bun install failed.");
134
+ failWithBunInstructions();
135
+ }
136
+
137
+ const after = resolveBunBinary();
138
+ if (!after) {
139
+ console.error("Bun installed but not detected in PATH.");
140
+ failWithBunInstructions();
141
+ }
142
+
143
+ return after;
144
+ }
145
+
146
+ /**
147
+ * Executes Bun CLI (`bun run <entry> ...args`) with inherited stdio and signal forwarding.
148
+ */
149
+ function runBunCli(bun, env) {
150
+ const args = ["run", CLI_ENTRY, ...process.argv.slice(2)];
151
+ const child = spawn(bun, args, {
152
+ stdio: "inherit",
153
+ env,
154
+ });
155
+
156
+ child.on("exit", (code, signal) => {
157
+ if (signal) {
158
+ process.kill(process.pid, signal);
159
+ return;
160
+ }
161
+ process.exit(code ?? 1);
162
+ });
163
+ }
164
+
165
+ /**
166
+ * Launcher entrypoint.
167
+ */
168
+ async function main() {
169
+ const { bun, env } = await ensureBun();
170
+ runBunCli(bun, env);
171
+ }
172
+
173
+ main().catch((err) => {
174
+ const message = err instanceof Error ? err.message : String(err);
175
+ console.error(`OpenPaw launcher error: ${message}`);
176
+ process.exit(1);
177
+ });
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: find-skills
3
+ description: 'Discover and install specialized agent skills from the open ecosystem (skills.sh, npx skills). Use when users ask "how do I do X", "find a skill for X", whether a capability exists, want to extend the agent, search tools/templates/workflows, or install community skills. Source: https://skills.sh/vercel-labs/skills/find-skills'
4
+ ---
5
+
6
+ # Find Skills
7
+
8
+ This skill helps you discover and install skills from the open agent skills ecosystem.
9
+
10
+ ## When to Use This Skill
11
+
12
+ Use this skill when the user:
13
+
14
+ - Asks "how do I do X" where X might be a common task with an existing skill
15
+ - Says "find a skill for X" or "is there a skill for X"
16
+ - Asks "can you do X" where X is a specialized capability
17
+ - Expresses interest in extending agent capabilities
18
+ - Wants to search for tools, templates, or workflows
19
+ - Mentions they wish they had help with a specific domain (design, testing, deployment, etc.)
20
+
21
+ ## What is the Skills CLI?
22
+
23
+ The Skills CLI (`npx skills`) is the package manager for the open agent skills ecosystem. Skills are modular packages that extend agent capabilities with specialized knowledge, workflows, and tools.
24
+
25
+ **Key commands:**
26
+
27
+ - `npx skills find [query]` — Search for skills interactively or by keyword
28
+ - `npx skills add <package>` — Install a skill from GitHub or other sources
29
+ - `npx skills check` — Check for skill updates
30
+ - `npx skills update` — Update all installed skills
31
+
32
+ **Browse skills at:** [skills.sh](https://skills.sh/)
33
+
34
+ ## OpenPaw: workspace, shell, and where skills live
35
+
36
+ - **Default bundle:** A fresh OpenPaw workspace only includes **find-skills** under `workspace/.agents/skills/find-skills/`. Anything else is installed later.
37
+ - **`bash` tool:** Commands run with **cwd = the OpenPaw workspace root** (e.g. `~/.openpaw/workspace`) when the filesystem sandbox is on — so paths like `.agents/skills` are relative to that directory.
38
+ - **Install new skills into this workspace:** Use **project** scope (do **not** use `-g` / `--global` for OpenPaw’s copy). The Skills CLI maps the **`universal`** agent to project-local **`./.agents/skills/`**. Prefer:
39
+
40
+ ```bash
41
+ npx skills add <owner/repo> --skill <skill-name> -a universal -y
42
+ ```
43
+
44
+ Examples:
45
+
46
+ ```bash
47
+ npx skills find "ascii art"
48
+ npx skills add some-org/some-skills-repo --skill ascii-art -a universal -y
49
+ ```
50
+
51
+ After installing, OpenPaw rescans skill directories automatically before each model step and when using `load_skill`, `file_editor`, or `list_dir`—no restart required.
52
+
53
+ ## How to Help Users Find Skills
54
+
55
+ ### Step 1: Understand What They Need
56
+
57
+ When a user asks for help with something, identify:
58
+
59
+ 1. The domain (e.g., React, testing, design, deployment)
60
+ 2. The specific task (e.g., writing tests, creating animations, reviewing PRs)
61
+ 3. Whether this is a common enough task that a skill likely exists
62
+
63
+ ### Step 2: Check the Leaderboard First
64
+
65
+ Before running a CLI search, check the [skills.sh](https://skills.sh/) leaderboard to see if a well-known skill already exists for the domain. The leaderboard ranks skills by total installs, surfacing the most popular and battle-tested options.
66
+
67
+ For example, top skills for web development include:
68
+
69
+ - `vercel-labs/agent-skills` — React, Next.js, web design (100K+ installs each)
70
+ - `anthropics/skills` — Frontend design, document processing (100K+ installs)
71
+
72
+ ### Step 3: Search for Skills
73
+
74
+ If the leaderboard doesn't cover the user's need, run the find command:
75
+
76
+ ```bash
77
+ npx skills find [query]
78
+ ```
79
+
80
+ For example:
81
+
82
+ - User asks "how do I make my React app faster?" → `npx skills find react performance`
83
+ - User asks "can you help me with PR reviews?" → `npx skills find pr review`
84
+ - User asks "I need to create a changelog" → `npx skills find changelog`
85
+
86
+ ### Step 4: Verify Quality Before Recommending
87
+
88
+ **Do not recommend a skill based solely on search results.** Always verify:
89
+
90
+ 1. **Install count** — Prefer skills with 1K+ installs. Be cautious with anything under 100.
91
+ 2. **Source reputation** — Official sources (`vercel-labs`, `anthropics`, `microsoft`) are more trustworthy than unknown authors.
92
+ 3. **GitHub stars** — Check the source repository. A skill from a repo with fewer than 100 stars should be treated with skepticism.
93
+
94
+ ### Step 5: Present Options to the User
95
+
96
+ When you find relevant skills, present them to the user with:
97
+
98
+ 1. The skill name and what it does
99
+ 2. The install count and source
100
+ 3. The install command they can run
101
+ 4. A link to learn more at skills.sh
102
+
103
+ Example response:
104
+
105
+ ```text
106
+ I found a skill that might help! The "react-best-practices" skill provides
107
+ React and Next.js performance optimization guidelines from Vercel Engineering.
108
+ (185K installs)
109
+
110
+ To install it:
111
+ npx skills add vercel-labs/agent-skills@react-best-practices
112
+
113
+ Learn more: https://skills.sh/vercel-labs/agent-skills/react-best-practices
114
+ ```
115
+
116
+ ### Step 6: Offer to Install
117
+
118
+ If the user wants to proceed, run install from the **workspace root** (OpenPaw `bash` already uses it as cwd). For OpenPaw, use **project** install into `./.agents/skills` via the **`universal`** agent target:
119
+
120
+ ```bash
121
+ npx skills add <owner/repo> --skill <skill-name> -a universal -y
122
+ ```
123
+
124
+ - **Do not** use `-g` for OpenPaw’s workspace skills — that targets the user-level agent dirs instead of this workspace.
125
+ - `-y` skips confirmation when appropriate.
126
+
127
+ ## Common Skill Categories
128
+
129
+ When searching, consider these common categories:
130
+
131
+ | Category | Example Queries |
132
+ | --------------- | ---------------------------------------- |
133
+ | Web Development | react, nextjs, typescript, css, tailwind |
134
+ | Testing | testing, jest, playwright, e2e |
135
+ | DevOps | deploy, docker, kubernetes, ci-cd |
136
+ | Documentation | docs, readme, changelog, api-docs |
137
+ | Code Quality | review, lint, refactor, best-practices |
138
+ | Design | ui, ux, design-system, accessibility |
139
+ | Productivity | workflow, automation, git |
140
+
141
+ ## Tips for Effective Searches
142
+
143
+ 1. **Use specific keywords**: "react testing" is better than just "testing"
144
+ 2. **Try alternative terms**: If "deploy" doesn't work, try "deployment" or "ci-cd"
145
+ 3. **Check popular sources**: Many skills come from `vercel-labs/agent-skills` or `ComposioHQ/awesome-claude-skills`
146
+
147
+ ## When No Skills Are Found
148
+
149
+ If no relevant skills exist:
150
+
151
+ 1. Acknowledge that no existing skill was found
152
+ 2. Offer to help with the task directly using your general capabilities
153
+ 3. Suggest the user could create their own skill with `npx skills init`
154
+
155
+ Example:
156
+
157
+ ```text
158
+ I searched for skills related to "xyz" but didn't find any matches.
159
+ I can still help you with this task directly! Would you like me to proceed?
160
+
161
+ If this is something you do often, you could create your own skill:
162
+ npx skills init my-xyz-skill
163
+ ```