@marcfargas/skills 0.2.1 → 0.4.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.
package/LICENSE-CC0 ADDED
@@ -0,0 +1,118 @@
1
+ CC0 1.0 Universal
2
+
3
+ Statement of Purpose
4
+
5
+ The laws of most jurisdictions throughout the world automatically confer
6
+ exclusive Copyright and Related Rights (defined below) upon the creator and
7
+ subsequent owner(s) (each and all, an "owner") of an original work of
8
+ authorship and/or a database (each, a "Work").
9
+
10
+ Certain owners wish to permanently relinquish those rights to a Work for the
11
+ purpose of contributing to a commons of creative, cultural and scientific
12
+ works ("Commons") that the public can reliably and without fear of later
13
+ claims of infringement build upon, modify, incorporate in other works, reuse
14
+ and redistribute as freely as possible in any form whatsoever and for any
15
+ purposes, including without limitation commercial purposes. These owners may
16
+ contribute to the Commons to promote the ideal of a free culture and the
17
+ further production of creative, cultural and scientific works, or to gain
18
+ reputation or greater distribution for their Work in part through the use and
19
+ efforts of others.
20
+
21
+ For these and/or other purposes and motivations, and without any expectation
22
+ of additional consideration or compensation, the person associating CC0 with a
23
+ Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
+ and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
+ and publicly distribute the Work under its terms, with knowledge of his or her
26
+ Copyright and Related Rights in the Work and the meaning and intended legal
27
+ effect of CC0 on those rights.
28
+
29
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
30
+ protected by copyright and related or neighboring rights ("Copyright and
31
+ Related Rights"). Copyright and Related Rights include, but are not limited
32
+ to, the following:
33
+
34
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
+ and translate a Work;
36
+
37
+ ii. moral rights retained by the original author(s) and/or performer(s);
38
+
39
+ iii. publicity and privacy rights pertaining to a person's image or likeness
40
+ depicted in a Work;
41
+
42
+ iv. rights protecting against unfair competition in regards to a Work,
43
+ subject to the limitations in paragraph 4(a), below;
44
+
45
+ v. rights protecting the extraction, dissemination, use and reuse of data in
46
+ a Work;
47
+
48
+ vi. database rights (such as those arising under Directive 96/9/EC of the
49
+ European Parliament and of the Council of 11 March 1996 on the legal
50
+ protection of databases, and under any national implementation thereof,
51
+ including any amended or successor version of such directive); and
52
+
53
+ vii. other similar, equivalent or corresponding rights throughout the world
54
+ based on applicable law or treaty, and any national implementations
55
+ thereof.
56
+
57
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of,
58
+ applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
59
+ unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
60
+ and Related Rights and associated claims and causes of action, whether now
61
+ known or unknown (including existing as well as future claims and causes of
62
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum
63
+ duration provided by applicable law or treaty (including future time
64
+ extensions), (iii) in any current or future medium and for any number of
65
+ copies, and (iv) for any purpose whatsoever, including without limitation
66
+ commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
67
+ the Waiver for the benefit of each member of the public at large and to the
68
+ detriment of Affirmer's heirs and successors, fully intending that such Waiver
69
+ shall not be subject to revocation, rescission, cancellation, termination, or
70
+ any other legal or equitable action to disrupt the quiet enjoyment of the Work
71
+ by the public as contemplated by Affirmer's express Statement of Purpose.
72
+
73
+ 3. Public License Fallback. Should any part of the Waiver for any reason be
74
+ judged legally invalid or ineffective under applicable law, then the Waiver
75
+ shall be preserved to the maximum extent permitted taking into account
76
+ Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
77
+ is so judged Affirmer hereby grants to each affected person a royalty-free,
78
+ non transferable, non sublicensable, non exclusive, irrevocable and
79
+ unconditional license to exercise Affirmer's Copyright and Related Rights in
80
+ the Work (i) in all territories worldwide, (ii) for the maximum duration
81
+ provided by applicable law or treaty (including future time extensions), (iii)
82
+ in any current or future medium and for any number of copies, and (iv) for any
83
+ purpose whatsoever, including without limitation commercial, advertising or
84
+ promotional purposes (the "License"). The License shall be deemed effective as
85
+ of the date CC0 was applied by Affirmer to the Work. Should any part of the
86
+ License for any reason be judged legally invalid or ineffective under
87
+ applicable law, such partial invalidity or ineffectiveness shall not invalidate
88
+ the remainder of the License, and in such case Affirmer hereby affirms that he
89
+ or she will not (i) exercise any of his or her remaining Copyright and Related
90
+ Rights in the Work or (ii) assert any associated claims and causes of action
91
+ with respect to the Work, in either case contrary to Affirmer's express
92
+ Statement of Purpose.
93
+
94
+ 4. Limitations and Disclaimers.
95
+
96
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
97
+ surrendered, licensed or otherwise affected by this document.
98
+
99
+ b. Affirmer offers the Work as-is and makes no representations or warranties
100
+ of any kind concerning the Work, express, implied, statutory or otherwise,
101
+ including without limitation warranties of title, merchantability, fitness
102
+ for a particular purpose, non infringement, or the absence of latent or
103
+ other defects, accuracy, or the present or absence of errors, whether or
104
+ not discoverable, all to the greatest extent permissible under applicable
105
+ law.
106
+
107
+ c. Affirmer disclaims responsibility for clearing rights of other persons
108
+ that may apply to the Work or any use thereof, including without limitation
109
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
110
+ disclaims responsibility for obtaining any necessary consents, permissions
111
+ or other rights required for any use of the Work.
112
+
113
+ d. Affirmer understands and acknowledges that Creative Commons is not a party
114
+ to this document and has no duty or obligation with respect to this CC0 or
115
+ use of the Work.
116
+
117
+ For more information, please see
118
+ <http://creativecommons.org/publicdomain/zero/1.0/>
package/README.md CHANGED
@@ -7,6 +7,7 @@ Reusable skills for AI coding agents. Works with [pi](https://github.com/marioze
7
7
  | Category | Skill | Description |
8
8
  |----------|-------|-------------|
9
9
  | ☁️ Google Cloud | [gcloud](google-cloud/gcloud/) | GCP CLI with agent safety model — hub + 7 reference files |
10
+ | ⚙️ Process | [pm2](process/pm2/) | Process management — keep services alive, auto-restart, monitoring, ecosystem configs |
10
11
  | 🚀 Release | [pre-release](release/pre-release/) | Pre-release checklist + AI-written changesets via @changesets/cli |
11
12
  | 🔍 Search | [web-search](search/web-search/) | Web search + content extraction via [ddgs](https://github.com/deedy5/ddgs) — no API keys |
12
13
  | 🎬 Terminal | [vhs](terminal/vhs/) | Record terminal sessions as GIF/MP4 with [VHS](https://github.com/charmbracelet/vhs) |
@@ -70,6 +71,8 @@ Skills use a **hub + spoke** architecture. The SKILL.md hub is ~140 lines — ju
70
71
  skills/
71
72
  ├── google-cloud/
72
73
  │ └── gcloud/ # 8 files, ~1100 lines total
74
+ ├── process/
75
+ │ └── pm2/ # 1 file
73
76
  ├── release/
74
77
  │ └── pre-release/ # 1 file
75
78
  ├── search/
@@ -126,4 +129,8 @@ Building high-quality, multi-model-reviewed agent skills takes serious token bud
126
129
 
127
130
  ## License
128
131
 
129
- MIT
132
+ **Code** (scripts, tooling): [MIT](./LICENSE)
133
+
134
+ **Skill content** (`**/SKILL.md` and reference docs): [CC0 1.0 Universal](./LICENSE-CC0) — public domain, no attribution required.
135
+
136
+ Why CC0 for skills: Skill docs are consumed by AI agents and freely incorporated into any workflow. Attribution requirements create friction in agent contexts where provenance tracking is impractical.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marcfargas/skills",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Reusable AI agent skills for pi, Claude Code, Cursor, and any Agent Skills compatible agent",
5
5
  "license": "MIT",
6
6
  "author": "Marc Fargas <marc@marcfargas.com>",
@@ -13,16 +13,21 @@
13
13
  "agent-skills",
14
14
  "ai-agent",
15
15
  "skills",
16
+ "azcli",
16
17
  "gcloud",
18
+ "pm2",
17
19
  "pre-release",
18
20
  "vhs",
19
21
  "web-search"
20
22
  ],
21
23
  "pi": {
22
24
  "skills": [
25
+ "azure",
23
26
  "google-cloud",
27
+ "process",
24
28
  "release",
25
29
  "search",
30
+ "sheet-model",
26
31
  "terminal"
27
32
  ]
28
33
  },
@@ -36,11 +41,15 @@
36
41
  "@changesets/cli": "^2.29.8"
37
42
  },
38
43
  "files": [
44
+ "azure/",
39
45
  "google-cloud/",
46
+ "process/",
40
47
  "release/",
41
48
  "search/",
49
+ "sheet-model/",
42
50
  "terminal/",
43
51
  "README.md",
44
- "LICENSE"
52
+ "LICENSE",
53
+ "LICENSE-CC0"
45
54
  ]
46
55
  }
@@ -0,0 +1,240 @@
1
+ ---
2
+ name: pm2
3
+ description: >-
4
+ Process management with PM2 — start, stop, restart, monitor long-running
5
+ processes. Use when: keeping services alive, auto-restart on crash, managing
6
+ daemon processes, ecosystem configs, log management, startup scripts, process
7
+ monitoring. Triggers: pm2, process manager, keep alive, daemon, auto-restart,
8
+ ecosystem config, process monitoring.
9
+ ---
10
+
11
+ # PM2 — Process Manager
12
+
13
+ PM2 keeps processes alive, restarts them on crash, and provides monitoring/logging.
14
+ Use for long-running services, persistent agents, background workers.
15
+
16
+ > **Not for detached terminals** — use [holdpty](https://github.com/marcfargas/holdpty) when you need PTY output, attach/view, or interactive sessions.
17
+ > **Not for ephemeral tasks** — use `pi -p > file &` for quick fire-and-forget agent runs.
18
+
19
+ ## Quick Reference
20
+
21
+ ### Start a process
22
+
23
+ ```bash
24
+ # Simple
25
+ pm2 start server.js --name myapp
26
+
27
+ # With interpreter
28
+ pm2 start script.py --interpreter python3 --name worker
29
+
30
+ # With arguments (use -- to separate pm2 args from script args)
31
+ pm2 start app.js --name api -- --port 3000 --env production
32
+
33
+ # From ecosystem file
34
+ pm2 start ecosystem.config.cjs
35
+ ```
36
+
37
+ ### Manage processes
38
+
39
+ ```bash
40
+ pm2 list # List all processes (table)
41
+ pm2 jlist # List as JSON (for scripting)
42
+ pm2 info <name|id> # Detailed process info
43
+ pm2 restart <name|id|all> # Restart
44
+ pm2 stop <name|id|all> # Stop (keeps in list)
45
+ pm2 delete <name|id|all> # Stop + remove from list
46
+ pm2 restart <name> --update-env # Restart with refreshed env vars
47
+ ```
48
+
49
+ ### Logs
50
+
51
+ ```bash
52
+ pm2 logs # Tail all logs
53
+ pm2 logs <name> --lines 50 # Tail specific process, last 50 lines
54
+ pm2 flush # Clear all log files
55
+ ```
56
+
57
+ Log files location: `~/.pm2/logs/<name>-out.log` and `<name>-error.log`.
58
+
59
+ ### Monitoring
60
+
61
+ ```bash
62
+ pm2 monit # Real-time TUI: CPU, memory, logs
63
+ pm2 dash # Dashboard with monitoring + logs
64
+ ```
65
+
66
+ ## Ecosystem Config
67
+
68
+ For reproducible multi-process setups, use an `ecosystem.config.cjs` file:
69
+
70
+ ```javascript
71
+ // ecosystem.config.cjs
72
+ module.exports = {
73
+ apps: [
74
+ {
75
+ name: "api",
76
+ script: "dist/server.js",
77
+ instances: 2, // cluster mode
78
+ exec_mode: "cluster",
79
+ env: {
80
+ NODE_ENV: "production",
81
+ PORT: 3000,
82
+ },
83
+ max_memory_restart: "500M",
84
+ log_date_format: "YYYY-MM-DD HH:mm:ss",
85
+ },
86
+ {
87
+ name: "worker",
88
+ script: "dist/worker.js",
89
+ autorestart: true,
90
+ max_restarts: 10,
91
+ restart_delay: 5000,
92
+ exp_backoff_restart_delay: 100, // exponential backoff
93
+ watch: false,
94
+ },
95
+ ],
96
+ };
97
+ ```
98
+
99
+ ```bash
100
+ pm2 start ecosystem.config.cjs # Start all apps
101
+ pm2 start ecosystem.config.cjs --only api # Start specific app
102
+ pm2 restart ecosystem.config.cjs # Restart all
103
+ pm2 delete ecosystem.config.cjs # Stop + remove all
104
+ ```
105
+
106
+ ### Useful ecosystem options
107
+
108
+ | Option | Type | Description |
109
+ |--------|------|-------------|
110
+ | `script` | string | Script to run (required) |
111
+ | `interpreter` | string | Override interpreter (default: `node`) |
112
+ | `args` | string or string[] | Script arguments |
113
+ | `cwd` | string | Working directory |
114
+ | `instances` | number | Number of instances (cluster mode) |
115
+ | `exec_mode` | string | `"fork"` (default) or `"cluster"` |
116
+ | `autorestart` | boolean | Auto-restart on exit (default: `true`) |
117
+ | `max_restarts` | number | Max consecutive restarts before stopping |
118
+ | `restart_delay` | number | Delay between restarts (ms) |
119
+ | `exp_backoff_restart_delay` | number | Exponential backoff base (ms) |
120
+ | `max_memory_restart` | string | Restart if memory exceeds (e.g. `"500M"`) |
121
+ | `cron_restart` | string | Cron-based restart schedule |
122
+ | `watch` | boolean or string[] | Watch for file changes |
123
+ | `ignore_watch` | string[] | Paths to ignore when watching |
124
+ | `env` | object | Environment variables |
125
+ | `log_date_format` | string | Timestamp format for logs |
126
+ | `error_file` | string | Custom stderr log path |
127
+ | `out_file` | string | Custom stdout log path |
128
+ | `merge_logs` | boolean | Merge cluster instance logs |
129
+ | `stop_exit_codes` | number[] | Exit codes that skip auto-restart |
130
+
131
+ ## Persistence
132
+
133
+ ```bash
134
+ pm2 save # Save current process list
135
+ pm2 resurrect # Restore saved process list
136
+ pm2 startup # Generate OS startup script (auto-start on boot)
137
+ pm2 unstartup # Remove startup script
138
+ ```
139
+
140
+ After `pm2 startup`, run the command it outputs (may need admin/sudo).
141
+ Then `pm2 save` to snapshot current processes — they'll auto-start on reboot.
142
+
143
+ ## Windows Gotchas
144
+
145
+ ### `.cmd` wrapper resolution
146
+
147
+ PM2 tries to run `.cmd` files as Node.js scripts. **Never start a `.cmd` shim directly** with PM2.
148
+
149
+ ```bash
150
+ # ❌ WRONG — resolves to pi.cmd, crashes
151
+ pm2 start pi -- -p "prompt"
152
+
153
+ # ✅ CORRECT — point to the actual .js entry point
154
+ pm2 start /path/to/cli.js --interpreter node -- -p "prompt"
155
+ ```
156
+
157
+ For npm-installed CLIs, find the real script:
158
+
159
+ ```bash
160
+ # Find where the .cmd shim points
161
+ cat "$(which pi)" | head -5
162
+ # → Look for the .js path, then use that with --interpreter node
163
+ ```
164
+
165
+ In ecosystem configs, always use the resolved `.js` path:
166
+
167
+ ```javascript
168
+ module.exports = {
169
+ apps: [{
170
+ name: "my-agent",
171
+ // Resolve the actual cli.js, not the .cmd wrapper
172
+ script: "C:\\path\\to\\node_modules\\package\\dist\\cli.js",
173
+ interpreter: "node",
174
+ args: ["--mode", "json"],
175
+ }],
176
+ };
177
+ ```
178
+
179
+ ### Log paths
180
+
181
+ PM2 stores logs at `~/.pm2/logs/`. On Windows this is typically `C:\Users\<user>\.pm2\logs\`.
182
+
183
+ ### Daemon
184
+
185
+ PM2 daemon runs as a background Node.js process. `pm2 kill` stops the daemon and all managed processes. `pm2 ping` checks if the daemon is running.
186
+
187
+ ## Agent Patterns
188
+
189
+ ### Launch a pi agent as a persistent service
190
+
191
+ First, find the actual `cli.js` path (see Windows Gotchas above):
192
+
193
+ ```bash
194
+ # Find pi's real entry point
195
+ cat "$(which pi)" | head -5
196
+ # e.g. → /path/to/node_modules/@mariozechner/pi-coding-agent/dist/cli.js
197
+ ```
198
+
199
+ ```javascript
200
+ // ecosystem.config.cjs
201
+ module.exports = {
202
+ apps: [{
203
+ name: "my-agent",
204
+ // Use the resolved cli.js path — NOT the .cmd wrapper
205
+ script: "/path/to/node_modules/@mariozechner/pi-coding-agent/dist/cli.js",
206
+ interpreter: "node",
207
+ args: ["--mode", "json", "--cwd", "/path/to/project"],
208
+ autorestart: true,
209
+ max_restarts: 10,
210
+ restart_delay: 5000,
211
+ }],
212
+ };
213
+ ```
214
+
215
+ > **Note**: `pi -p` to non-TTY only outputs final text. Use `--mode json` for full event streaming to PM2 logs.
216
+
217
+ ### Check process health from an agent
218
+
219
+ ```bash
220
+ # Structured output for parsing
221
+ pm2 jlist | node -e "
222
+ const d = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
223
+ d.forEach(p => console.log(p.name, p.pm2_env.status, 'restarts:', p.pm2_env.restart_time));
224
+ "
225
+ ```
226
+
227
+ ### Rotate logs
228
+
229
+ ```bash
230
+ pm2 install pm2-logrotate # Install log rotation module
231
+ pm2 set pm2-logrotate:max_size 10M
232
+ pm2 set pm2-logrotate:retain 5
233
+ ```
234
+
235
+ ## When NOT to Use PM2
236
+
237
+ - **Detached terminal sessions** → use [holdpty](https://github.com/marcfargas/holdpty) (PTY output, attach/view)
238
+ - **Ephemeral agent runs** → use `pi -p > file &` (fire-and-forget with output capture)
239
+ - **Containers** → the container runtime manages lifecycle; PM2 inside Docker is usually redundant
240
+ - **Systemd environments** → use systemd service units natively on Linux