clawpowers 1.0.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 (42) hide show
  1. package/.claude-plugin/manifest.json +19 -0
  2. package/.codex/INSTALL.md +36 -0
  3. package/.cursor-plugin/manifest.json +21 -0
  4. package/.opencode/INSTALL.md +52 -0
  5. package/ARCHITECTURE.md +69 -0
  6. package/README.md +381 -0
  7. package/bin/clawpowers.js +390 -0
  8. package/bin/clawpowers.sh +91 -0
  9. package/gemini-extension.json +32 -0
  10. package/hooks/session-start +205 -0
  11. package/hooks/session-start.cmd +43 -0
  12. package/hooks/session-start.js +163 -0
  13. package/package.json +54 -0
  14. package/runtime/feedback/analyze.js +621 -0
  15. package/runtime/feedback/analyze.sh +546 -0
  16. package/runtime/init.js +172 -0
  17. package/runtime/init.sh +145 -0
  18. package/runtime/metrics/collector.js +361 -0
  19. package/runtime/metrics/collector.sh +308 -0
  20. package/runtime/persistence/store.js +433 -0
  21. package/runtime/persistence/store.sh +303 -0
  22. package/skill.json +74 -0
  23. package/skills/agent-payments/SKILL.md +411 -0
  24. package/skills/brainstorming/SKILL.md +233 -0
  25. package/skills/content-pipeline/SKILL.md +282 -0
  26. package/skills/dispatching-parallel-agents/SKILL.md +305 -0
  27. package/skills/executing-plans/SKILL.md +255 -0
  28. package/skills/finishing-a-development-branch/SKILL.md +260 -0
  29. package/skills/learn-how-to-learn/SKILL.md +235 -0
  30. package/skills/market-intelligence/SKILL.md +288 -0
  31. package/skills/prospecting/SKILL.md +313 -0
  32. package/skills/receiving-code-review/SKILL.md +225 -0
  33. package/skills/requesting-code-review/SKILL.md +206 -0
  34. package/skills/security-audit/SKILL.md +308 -0
  35. package/skills/subagent-driven-development/SKILL.md +244 -0
  36. package/skills/systematic-debugging/SKILL.md +279 -0
  37. package/skills/test-driven-development/SKILL.md +299 -0
  38. package/skills/using-clawpowers/SKILL.md +137 -0
  39. package/skills/using-git-worktrees/SKILL.md +261 -0
  40. package/skills/verification-before-completion/SKILL.md +254 -0
  41. package/skills/writing-plans/SKILL.md +276 -0
  42. package/skills/writing-skills/SKILL.md +260 -0
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env bash
2
+ # hooks/session-start — ClawPowers session injection hook (bash runtime)
3
+ #
4
+ # Detects the active AI coding platform and outputs platform-appropriate JSON
5
+ # to inject the using-clawpowers skill into the agent's context window.
6
+ #
7
+ # Supported platforms:
8
+ # - Claude Code (CLAUDE_PLUGIN_ROOT env var)
9
+ # - Cursor (CURSOR_PLUGIN_ROOT env var)
10
+ # - Codex (CODEX env var or codex in PATH)
11
+ # - OpenCode (OPENCODE env var)
12
+ # - Gemini CLI (GEMINI_CLI env var or gemini in PATH)
13
+ #
14
+ # Output: JSON object suitable for platform context injection
15
+ # Exit 0: success with JSON on stdout
16
+ # Exit 1: skill file not found
17
+ set -euo pipefail
18
+
19
+ ## === Path Setup ===
20
+
21
+ # hooks/ is one level inside the repo; climb to get the repo root
22
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23
+ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
24
+
25
+ # Path to the primary skill file that gets embedded in the injection JSON
26
+ SKILL_FILE="$REPO_ROOT/skills/using-clawpowers/SKILL.md"
27
+
28
+ # Path to the bash init script for silent first-run initialization
29
+ RUNTIME_INIT="$REPO_ROOT/runtime/init.sh"
30
+
31
+ ## === First-Run Initialization ===
32
+
33
+ # Silently initialize the runtime directory if it doesn't exist yet.
34
+ # This handles the case where a platform hook runs before the user has
35
+ # manually executed `clawpowers init`. Output is suppressed so it doesn't
36
+ # pollute the JSON emitted below.
37
+ if [[ ! -d "${HOME}/.clawpowers" ]] && [[ -f "$RUNTIME_INIT" ]]; then
38
+ bash "$RUNTIME_INIT" >/dev/null 2>&1 || true
39
+ fi
40
+
41
+ ## === Prerequisite Check ===
42
+
43
+ # If the skill file is missing, emit a machine-readable JSON error to stderr
44
+ # so the consuming platform can surface a helpful message to the user.
45
+ if [[ ! -f "$SKILL_FILE" ]]; then
46
+ echo '{"error":"ClawPowers: using-clawpowers/SKILL.md not found","action":"run npx clawpowers init"}' >&2
47
+ exit 1
48
+ fi
49
+
50
+ # Read the skill file content once — it's embedded in every platform's JSON output
51
+ SKILL_CONTENT="$(cat "$SKILL_FILE")"
52
+ TIMESTAMP="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
53
+ VERSION="1.0.0"
54
+
55
+ ## === Platform Detection ===
56
+
57
+ # Detect the active AI coding platform by checking environment variables first,
58
+ # then falling back to PATH binary checks. Priority order reflects likelihood.
59
+ detect_platform() {
60
+ if [[ -n "${CLAUDE_PLUGIN_ROOT:-}" ]]; then
61
+ echo "claude-code"
62
+ elif [[ -n "${CURSOR_PLUGIN_ROOT:-}" ]]; then
63
+ echo "cursor"
64
+ elif [[ -n "${CODEX:-}" ]] || command -v codex >/dev/null 2>&1; then
65
+ # Codex sets the CODEX env var when active; also detectable via binary
66
+ echo "codex"
67
+ elif [[ -n "${OPENCODE:-}" ]]; then
68
+ echo "opencode"
69
+ elif [[ -n "${GEMINI_CLI:-}" ]] || command -v gemini >/dev/null 2>&1; then
70
+ # Gemini CLI sets GEMINI_CLI env var when active; also detectable via binary
71
+ echo "gemini"
72
+ else
73
+ # No recognized platform — emit generic JSON any agent can consume
74
+ echo "generic"
75
+ fi
76
+ }
77
+
78
+ PLATFORM="$(detect_platform)"
79
+
80
+ ## === JSON Escaping ===
81
+
82
+ # Escape a string for safe embedding in a JSON double-quoted string value.
83
+ # Order matters: backslashes must be escaped first, then quotes, then control chars.
84
+ json_escape() {
85
+ local content="$1"
86
+ content="${content//\\/\\\\}" # Escape backslashes (must be first)
87
+ content="${content//\"/\\\"}" # Escape double quotes
88
+ content="${content//$'\n'/\\n}" # Escape newlines (skill content is multi-line)
89
+ content="${content//$'\r'/\\r}" # Escape carriage returns (Windows line endings)
90
+ content="${content//$'\t'/\\t}" # Escape tabs
91
+ echo "$content"
92
+ }
93
+
94
+ # Escape the skill file content once; reused in all platform branches below
95
+ ESCAPED_CONTENT="$(json_escape "$SKILL_CONTENT")"
96
+
97
+ ## === Platform-Specific JSON Output ===
98
+
99
+ # Each platform receives the same JSON structure but with a tailored instruction
100
+ # string that matches how that platform surfaces skill content to its agent.
101
+ case "$PLATFORM" in
102
+ claude-code)
103
+ cat <<EOF
104
+ {
105
+ "type": "skill_injection",
106
+ "platform": "claude-code",
107
+ "version": "$VERSION",
108
+ "timestamp": "$TIMESTAMP",
109
+ "skill": {
110
+ "name": "using-clawpowers",
111
+ "source": "$SKILL_FILE",
112
+ "content": "$ESCAPED_CONTENT"
113
+ },
114
+ "instruction": "You have ClawPowers skills loaded. Read the content above to understand available skills and how to trigger them. Skills activate automatically when you recognize a matching task pattern."
115
+ }
116
+ EOF
117
+ ;;
118
+
119
+ cursor)
120
+ cat <<EOF
121
+ {
122
+ "type": "skill_injection",
123
+ "platform": "cursor",
124
+ "version": "$VERSION",
125
+ "timestamp": "$TIMESTAMP",
126
+ "skill": {
127
+ "name": "using-clawpowers",
128
+ "source": "$SKILL_FILE",
129
+ "content": "$ESCAPED_CONTENT"
130
+ },
131
+ "instruction": "ClawPowers skills are available in this Cursor session. Trigger skills by recognizing task patterns described in the using-clawpowers skill above."
132
+ }
133
+ EOF
134
+ ;;
135
+
136
+ codex)
137
+ cat <<EOF
138
+ {
139
+ "type": "skill_injection",
140
+ "platform": "codex",
141
+ "version": "$VERSION",
142
+ "timestamp": "$TIMESTAMP",
143
+ "skill": {
144
+ "name": "using-clawpowers",
145
+ "source": "$SKILL_FILE",
146
+ "content": "$ESCAPED_CONTENT"
147
+ },
148
+ "instruction": "ClawPowers loaded for Codex session. Apply skills based on task pattern recognition."
149
+ }
150
+ EOF
151
+ ;;
152
+
153
+ opencode)
154
+ cat <<EOF
155
+ {
156
+ "type": "skill_injection",
157
+ "platform": "opencode",
158
+ "version": "$VERSION",
159
+ "timestamp": "$TIMESTAMP",
160
+ "skill": {
161
+ "name": "using-clawpowers",
162
+ "source": "$SKILL_FILE",
163
+ "content": "$ESCAPED_CONTENT"
164
+ },
165
+ "instruction": "ClawPowers loaded for OpenCode session. Skills activate on pattern recognition."
166
+ }
167
+ EOF
168
+ ;;
169
+
170
+ gemini)
171
+ cat <<EOF
172
+ {
173
+ "type": "skill_injection",
174
+ "platform": "gemini",
175
+ "version": "$VERSION",
176
+ "timestamp": "$TIMESTAMP",
177
+ "skill": {
178
+ "name": "using-clawpowers",
179
+ "source": "$SKILL_FILE",
180
+ "content": "$ESCAPED_CONTENT"
181
+ },
182
+ "instruction": "ClawPowers loaded for Gemini CLI session. Recognize task patterns to activate skills."
183
+ }
184
+ EOF
185
+ ;;
186
+
187
+ generic)
188
+ cat <<EOF
189
+ {
190
+ "type": "skill_injection",
191
+ "platform": "generic",
192
+ "version": "$VERSION",
193
+ "timestamp": "$TIMESTAMP",
194
+ "skill": {
195
+ "name": "using-clawpowers",
196
+ "source": "$SKILL_FILE",
197
+ "content": "$ESCAPED_CONTENT"
198
+ },
199
+ "instruction": "ClawPowers skills loaded. Use the using-clawpowers skill content to understand available capabilities."
200
+ }
201
+ EOF
202
+ ;;
203
+ esac
204
+
205
+ exit 0
@@ -0,0 +1,43 @@
1
+ @echo off
2
+ :: hooks/session-start.cmd — Windows batch file for ClawPowers session injection
3
+ ::
4
+ :: Delegates to hooks/session-start.js via Node.js for Windows-native hook invocation.
5
+ :: This wrapper exists because Windows CMD and PowerShell cannot directly execute
6
+ :: Unix bash scripts. The JS hook produces identical JSON output on all platforms.
7
+ ::
8
+ :: Usage:
9
+ :: hooks\session-start.cmd
10
+ ::
11
+ :: Output: JSON object suitable for platform context injection (same as session-start.js)
12
+ :: Exit 0: success — JSON on stdout
13
+ :: Exit 1: Node.js not found, or skill file not found
14
+
15
+ setlocal
16
+
17
+ :: ============================================================
18
+ :: Step 1: Verify Node.js is installed and on the PATH
19
+ :: ============================================================
20
+ :: 'where' exits non-zero if node.exe is not found.
21
+ :: Without Node.js the JS hook cannot run — surface a machine-readable error.
22
+ where node >nul 2>&1
23
+ if %ERRORLEVEL% neq 0 (
24
+ echo {"error":"Node.js not found. Install from https://nodejs.org","action":"install Node.js >= 16"} >&2
25
+ exit /b 1
26
+ )
27
+
28
+ :: ============================================================
29
+ :: Step 2: Resolve the directory containing this script
30
+ :: ============================================================
31
+ :: %~dp0 expands to the drive+path of the current script including a trailing backslash.
32
+ :: We strip the trailing backslash so path concatenation below works correctly.
33
+ set "SCRIPT_DIR=%~dp0"
34
+ if "%SCRIPT_DIR:~-1%"=="\" set "SCRIPT_DIR=%SCRIPT_DIR:~0,-1%"
35
+
36
+ :: ============================================================
37
+ :: Step 3: Run the JS hook
38
+ :: ============================================================
39
+ :: session-start.js lives in the same directory as this CMD file.
40
+ :: Node.js inherits the current environment, including CLAWPOWERS_DIR if set.
41
+ :: The exit code from node is forwarded verbatim so callers can detect errors.
42
+ node "%SCRIPT_DIR%\session-start.js"
43
+ exit /b %ERRORLEVEL%
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ // hooks/session-start.js — ClawPowers session injection hook
3
+ //
4
+ // Detects the active AI coding platform and outputs platform-appropriate JSON
5
+ // to inject the using-clawpowers skill into the agent's context window.
6
+ //
7
+ // Supported platforms:
8
+ // - Claude Code (CLAUDE_PLUGIN_ROOT env var)
9
+ // - Cursor (CURSOR_PLUGIN_ROOT env var)
10
+ // - Codex (CODEX env var or codex in PATH)
11
+ // - OpenCode (OPENCODE env var)
12
+ // - Gemini CLI (GEMINI_CLI env var or gemini in PATH)
13
+ //
14
+ // Output: JSON object suitable for platform context injection
15
+ // Exit 0: success with JSON on stdout
16
+ // Exit 1: skill file not found
17
+ 'use strict';
18
+
19
+ const fs = require('fs');
20
+ const path = require('path');
21
+ const os = require('os');
22
+ const { execSync } = require('child_process');
23
+
24
+ // hooks/ is inside the repo; climb one level to get the repo root
25
+ const SCRIPT_DIR = __dirname;
26
+ const REPO_ROOT = path.resolve(SCRIPT_DIR, '..');
27
+
28
+ // Primary skill file that gets injected into every session
29
+ const SKILL_FILE = path.join(REPO_ROOT, 'skills', 'using-clawpowers', 'SKILL.md');
30
+
31
+ // Path to the JS init module used for silent first-run initialization
32
+ const INIT_JS = path.join(REPO_ROOT, 'runtime', 'init.js');
33
+
34
+ const VERSION = '1.0.0';
35
+
36
+ /**
37
+ * Returns an ISO 8601 timestamp without milliseconds (e.g. "2025-01-15T12:00:00Z").
38
+ * Milliseconds are stripped for readability in the JSON output.
39
+ *
40
+ * @returns {string} ISO 8601 UTC timestamp.
41
+ */
42
+ function isoTimestamp() {
43
+ return new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
44
+ }
45
+
46
+ /**
47
+ * Checks whether a command-line binary exists in the system PATH.
48
+ * Uses platform-appropriate existence check: `where` on Windows, `command -v` on Unix.
49
+ *
50
+ * @param {string} cmd - Binary name to search for (e.g. 'codex', 'gemini').
51
+ * @returns {boolean} True if the binary is found and executable.
52
+ */
53
+ function commandExists(cmd) {
54
+ try {
55
+ const check = os.platform() === 'win32'
56
+ ? `where ${cmd}` // Windows: where.exe searches PATH
57
+ : `command -v ${cmd}`; // Unix: shell built-in, no subprocess needed
58
+ execSync(check, { stdio: 'ignore' });
59
+ return true;
60
+ } catch (_) {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Detects which AI coding platform is currently active by inspecting
67
+ * environment variables first, then falling back to PATH binary checks.
68
+ * Priority order matches likelihood of each platform being in use.
69
+ *
70
+ * @returns {string} Platform identifier: 'claude-code' | 'cursor' | 'codex' |
71
+ * 'opencode' | 'gemini' | 'generic'.
72
+ */
73
+ function detectPlatform() {
74
+ if (process.env.CLAUDE_PLUGIN_ROOT) return 'claude-code';
75
+ if (process.env.CURSOR_PLUGIN_ROOT) return 'cursor';
76
+ // Codex sets CODEX env var when active; also detectable via binary
77
+ if (process.env.CODEX || commandExists('codex')) return 'codex';
78
+ if (process.env.OPENCODE) return 'opencode';
79
+ // Gemini CLI sets GEMINI_CLI env var; also detectable via binary
80
+ if (process.env.GEMINI_CLI || commandExists('gemini')) return 'gemini';
81
+ // No recognized platform detected — emit generic JSON that any agent can parse
82
+ return 'generic';
83
+ }
84
+
85
+ /**
86
+ * Platform-specific instructions embedded in the injection JSON.
87
+ * Each instruction tells the agent how to activate skills in that environment.
88
+ * The 'generic' fallback works for any agent that receives the JSON.
89
+ */
90
+ const INSTRUCTIONS = {
91
+ 'claude-code': 'You have ClawPowers skills loaded. Read the content above to understand available skills and how to trigger them. Skills activate automatically when you recognize a matching task pattern.',
92
+ 'cursor': 'ClawPowers skills are available in this Cursor session. Trigger skills by recognizing task patterns described in the using-clawpowers skill above.',
93
+ 'codex': 'ClawPowers loaded for Codex session. Apply skills based on task pattern recognition.',
94
+ 'opencode': 'ClawPowers loaded for OpenCode session. Skills activate on pattern recognition.',
95
+ 'gemini': 'ClawPowers loaded for Gemini CLI session. Recognize task patterns to activate skills.',
96
+ 'generic': 'ClawPowers skills loaded. Use the using-clawpowers skill content to understand available capabilities.',
97
+ };
98
+
99
+ /**
100
+ * Main entry point.
101
+ *
102
+ * 1. Silently initializes the runtime directory if it doesn't exist yet
103
+ * (first-run scenario when called directly from a platform hook).
104
+ * 2. Reads the using-clawpowers SKILL.md file.
105
+ * 3. Detects the active platform.
106
+ * 4. Emits a structured JSON object to stdout for the platform to consume.
107
+ */
108
+ function main() {
109
+ // Auto-initialize runtime on first run so the hook works without a manual `init` step.
110
+ // CLAWPOWERS_QUIET=1 suppresses all init output to avoid polluting the JSON stream.
111
+ const clawpowersDir = process.env.CLAWPOWERS_DIR || path.join(os.homedir(), '.clawpowers');
112
+ if (!fs.existsSync(clawpowersDir) && fs.existsSync(INIT_JS)) {
113
+ try {
114
+ const init = require(INIT_JS);
115
+ // Save and restore CLAWPOWERS_QUIET so we don't clobber an existing value
116
+ const orig = process.env.CLAWPOWERS_QUIET;
117
+ process.env.CLAWPOWERS_QUIET = '1';
118
+ init.main();
119
+ if (orig === undefined) delete process.env.CLAWPOWERS_QUIET;
120
+ else process.env.CLAWPOWERS_QUIET = orig;
121
+ } catch (_) { /* non-fatal: proceed even if init fails */ }
122
+ }
123
+
124
+ // Skill file is required — output a machine-readable error JSON if missing
125
+ if (!fs.existsSync(SKILL_FILE)) {
126
+ process.stderr.write(
127
+ JSON.stringify({
128
+ error: 'ClawPowers: using-clawpowers/SKILL.md not found',
129
+ action: 'run npx clawpowers init',
130
+ }) + '\n'
131
+ );
132
+ process.exit(1);
133
+ }
134
+
135
+ const skillContent = fs.readFileSync(SKILL_FILE, 'utf8');
136
+ const platform = detectPlatform();
137
+ const instruction = INSTRUCTIONS[platform] || INSTRUCTIONS.generic;
138
+
139
+ // Structured injection payload — platforms parse this to load skills into context
140
+ const output = {
141
+ type: 'skill_injection',
142
+ platform,
143
+ version: VERSION,
144
+ timestamp: isoTimestamp(),
145
+ skill: {
146
+ name: 'using-clawpowers',
147
+ source: SKILL_FILE,
148
+ content: skillContent,
149
+ },
150
+ instruction,
151
+ };
152
+
153
+ // JSON.stringify handles all escaping correctly — no manual escaping needed
154
+ console.log(JSON.stringify(output, null, 2));
155
+ }
156
+
157
+ try {
158
+ main();
159
+ process.exit(0);
160
+ } catch (err) {
161
+ process.stderr.write(`Error: ${err.message}\n`);
162
+ process.exit(1);
163
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "clawpowers",
3
+ "version": "1.0.0",
4
+ "description": "The skills framework that actually does something — runtime execution, persistent memory, self-improvement, and autonomous payments for coding agents.",
5
+ "license": "MIT",
6
+ "author": "AI Agent Economy <https://github.com/up2itnow0822>",
7
+ "homepage": "https://github.com/up2itnow0822/clawpowers",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/up2itnow0822/clawpowers.git"
11
+ },
12
+ "keywords": [
13
+ "ai-agent",
14
+ "coding-agent",
15
+ "skills",
16
+ "claude-code",
17
+ "cursor",
18
+ "codex",
19
+ "opencode",
20
+ "gemini",
21
+ "rsi",
22
+ "self-improvement",
23
+ "agent-payments",
24
+ "x402",
25
+ "openclaw",
26
+ "nemoclaw"
27
+ ],
28
+ "bin": {
29
+ "clawpowers": "bin/clawpowers.js"
30
+ },
31
+ "scripts": {
32
+ "init": "node bin/clawpowers.js init",
33
+ "test": "bash tests/run_all.sh"
34
+ },
35
+ "files": [
36
+ "bin/",
37
+ "skills/",
38
+ "runtime/",
39
+ "hooks/",
40
+ "plugins/",
41
+ ".claude-plugin/",
42
+ ".cursor-plugin/",
43
+ ".codex/",
44
+ ".opencode/",
45
+ "gemini-extension.json",
46
+ "skill.json",
47
+ "README.md",
48
+ "ARCHITECTURE.md"
49
+ ],
50
+ "engines": {
51
+ "node": ">=16.0.0"
52
+ },
53
+ "dependencies": {}
54
+ }