gm-gc 2.0.46 → 2.0.47

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/agents/gm.md CHANGED
@@ -226,6 +226,38 @@ Never report work complete while uncommitted changes exist. Never leave unpushed
226
226
 
227
227
  This policy applies to ALL platforms (Claude Code, Gemini CLI, OpenCode, Kilo CLI, Codex, and all IDE extensions). Platform-specific git enforcement hooks will verify compliance, but the responsibility lies with you to execute the commit and push before completion.
228
228
 
229
+ ## CHARTER 9: PROCESS MANAGEMENT
230
+
231
+ Scope: Runtime process execution. Governs how all applications are started, monitored, and cleaned up.
232
+
233
+ **ALL APPLICATIONS MUST RUN VIA PM2.** Direct invocations (node, bun, python, npx) are forbidden for any process that produces output or has a lifecycle. This applies to servers, workers, agents, and background services.
234
+
235
+ **PRE-START CHECK (MANDATORY)**: Before starting any process, execute `pm2 jlist`. If the process exists with `online` status: observe it with `pm2 logs <name>`. If `stopped`: restart it. Only start new if not found. Never create duplicate processes.
236
+
237
+ **Standard configuration** — all PM2 processes must use:
238
+ - `autorestart: false` — no crash recovery, explicit control only
239
+ - `watch: ["src", "config"]` — file-change restarts scoped to source directories
240
+ - `ignore_watch: ["node_modules", ".git", "logs", "*.log"]` — never watch these
241
+ - `watch_delay: 1000` — debounce rapid multi-file changes
242
+
243
+ **Cross-platform requirements**:
244
+ - Windows: cannot spawn `.cmd` shims — use `interpreter: "cmd", interpreter_args: "/c"` for npm scripts; resolve actual `.js` path for globally installed CLIs
245
+ - WSL watching `/mnt/c/...` paths: set `watch_options: { usePolling: true, interval: 1000 }`
246
+ - Windows 11+: `spawn wmic ENOENT` in daemon logs is cosmetic — app processes work; fix with `npm install -g pm2@latest`
247
+ - Linux watch exhaustion: `echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p`
248
+
249
+ **Log monitoring**:
250
+ ```bash
251
+ pm2 logs <name> # stream live output
252
+ pm2 logs <name> --lines 100 # last N lines then stream
253
+ pm2 logs <name> --err # errors only
254
+ pm2 logs <name> --nostream --lines 200 # dump without follow
255
+ ```
256
+
257
+ **Lifecycle cleanup**: When work is complete, always run `pm2 delete <name>`. Never leave orphaned processes. `pm2 stop` on a watched process is not sufficient — use `pm2 delete`.
258
+
259
+ See `process-management` skill for full reference, ecosystem config templates, and Windows/Linux specifics.
260
+
229
261
  ## CONSTRAINTS
230
262
 
231
263
  Scope: Global prohibitions and mandates applying across all charters. Precedence cascade: CONSTRAINTS > charter-specific rules > prior habits or examples. When conflict arises, higher-precedence source wins and lower source must be revised.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.46",
3
+ "version": "2.0.47",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "homepage": "https://github.com/AnEntrypoint/gm",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-gc",
3
- "version": "2.0.46",
3
+ "version": "2.0.47",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: process-management
3
+ description: >-
4
+ PM2 process management for all running applications. Enforces: pre-check for
5
+ running processes before start, watch enabled, autorestart disabled, lifecycle
6
+ cleanup when done. Use for all servers, workers, agents, background processes.
7
+ Triggers: start server, run application, background process, pm2, keep alive,
8
+ process manager, daemon, monitor logs.
9
+ ---
10
+
11
+ # Process Management — PM2
12
+
13
+ All applications MUST run through PM2. Direct invocations (node, bun, python) are forbidden for any process that produces output or has a lifecycle.
14
+
15
+ ## Pre-Start Check (MANDATORY)
16
+
17
+ Before starting any process, check what is already running:
18
+
19
+ ```bash
20
+ pm2 jlist
21
+ ```
22
+
23
+ - `online` → already running, use `pm2 logs <name>` to observe
24
+ - `stopped` → use `pm2 restart <name>`
25
+ - Not in list → proceed to start
26
+
27
+ Never start a duplicate process. Always check first.
28
+
29
+ ## Start a Process
30
+
31
+ ```bash
32
+ # CLI (quick)
33
+ pm2 start app.js --name myapp --watch --no-autorestart
34
+
35
+ # With interpreter
36
+ pm2 start script.py --interpreter python3 --name worker --watch --no-autorestart
37
+
38
+ # From ecosystem config (preferred for reproducibility)
39
+ pm2 start ecosystem.config.cjs
40
+ ```
41
+
42
+ ## Ecosystem Config (Standard Template)
43
+
44
+ `autorestart: false` — process stops on crash, no automatic recovery
45
+ `watch: true` — restarts on file changes in watched directories only
46
+
47
+ ```javascript
48
+ // ecosystem.config.cjs
49
+ module.exports = {
50
+ apps: [{
51
+ name: "myapp",
52
+ script: "src/index.js",
53
+ watch: ["src", "config"],
54
+ watch_delay: 1000,
55
+ autorestart: false,
56
+ ignore_watch: [
57
+ "node_modules",
58
+ ".git",
59
+ "logs",
60
+ "*.log",
61
+ ".pm2",
62
+ "public",
63
+ "uploads"
64
+ ],
65
+ watch_options: {
66
+ followSymlinks: false,
67
+ usePolling: false
68
+ },
69
+ log_date_format: "YYYY-MM-DD HH:mm:ss",
70
+ out_file: "./logs/out.log",
71
+ error_file: "./logs/error.log"
72
+ }]
73
+ };
74
+ ```
75
+
76
+ ## Log Viewing
77
+
78
+ ```bash
79
+ pm2 logs <name> # stream live (Ctrl+C to stop)
80
+ pm2 logs <name> --lines 100 # last 100 lines then stream
81
+ pm2 logs <name> --err # errors only
82
+ pm2 logs <name> --out # stdout only
83
+ pm2 logs <name> --nostream --lines 200 # dump without follow
84
+ pm2 logs --json # structured JSON output
85
+ pm2 flush # clear all log files
86
+ ```
87
+
88
+ Log files: `~/.pm2/logs/<name>-out.log` / `<name>-error.log`
89
+ Windows path: `C:\Users\<user>\.pm2\logs\`
90
+
91
+ ## Lifecycle Management
92
+
93
+ ```bash
94
+ pm2 list # view all processes and status
95
+ pm2 jlist # JSON output for scripting
96
+ pm2 info <name> # detailed process info
97
+ pm2 stop <name> # stop (keeps in list)
98
+ pm2 restart <name> # restart
99
+ pm2 delete <name> # stop + remove from list
100
+ pm2 delete all # remove all processes
101
+ pm2 ping # check if PM2 daemon is alive
102
+ ```
103
+
104
+ **When work is complete: always `pm2 delete <name>` to clean up orphaned processes.**
105
+
106
+ Stopping a watched process: `pm2 stop` while watch is active restarts on next file change.
107
+ To fully halt: `pm2 delete <name>` (removes it entirely).
108
+
109
+ ## Windows vs Linux
110
+
111
+ ### File Watching
112
+
113
+ | Environment | Config |
114
+ |---|---|
115
+ | Linux native | `usePolling: false` (inotify kernel events) |
116
+ | WSL watching `/mnt/c/...` | `usePolling: true, interval: 1000` |
117
+ | Windows native | `usePolling: false` (ReadDirectoryChangesW) |
118
+ | Network / NFS / Docker volumes | `usePolling: true, interval: 1000` |
119
+
120
+ Linux inotify exhaustion fix (symptom: watch silently stops working):
121
+ ```bash
122
+ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
123
+ ```
124
+
125
+ ### Windows: npm Scripts and .cmd Wrappers
126
+
127
+ PM2 cannot spawn `.cmd` shims (npm, npx, etc.) directly — they require `cmd.exe`.
128
+
129
+ ```javascript
130
+ // ecosystem.config.cjs — Windows npm script
131
+ {
132
+ name: "myapp",
133
+ script: "npm",
134
+ args: "start",
135
+ interpreter: "cmd",
136
+ interpreter_args: "/c"
137
+ }
138
+ ```
139
+
140
+ For globally installed CLIs, find the real `.js` entry point:
141
+ ```bash
142
+ # Linux/macOS
143
+ cat "$(which myapp)" | head -5
144
+
145
+ # Windows PowerShell
146
+ Get-Command myapp | Select-Object -ExpandProperty Source
147
+ ```
148
+ Point `script` at the resolved `.js` file — never at the `.cmd` wrapper.
149
+
150
+ ### Windows 11+ wmic Error
151
+
152
+ PM2 uses `wmic` for process stats — removed in Windows 11+.
153
+ Symptom: `Error: spawn wmic ENOENT` in `~/.pm2/pm2.log`.
154
+ Fix: `npm install -g pm2@latest`. App processes continue working despite the error.
155
+
156
+ ### Persistence on Reboot
157
+
158
+ | Platform | Method |
159
+ |---|---|
160
+ | Linux | `pm2 startup && pm2 save` (auto-detects systemd/upstart/openrc) |
161
+ | Windows | [pm2-installer](https://github.com/jessety/pm2-installer) (Windows Service) |
162
+
163
+ ```bash
164
+ pm2 save # snapshot current process list to ~/.pm2/dump.pm2
165
+ pm2 resurrect # restore saved list after manual daemon restart
166
+ ```