oh-my-codex-cli 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 (292) hide show
  1. package/.agent/skills/agent-kb/HOW_TO_USE.md +428 -0
  2. package/.agent/skills/agent-kb/README.md +46 -0
  3. package/.agent/skills/agent-kb/SKILL.md +128 -0
  4. package/.agent/skills/agent-kb/references/intelligent-analysis-explained.md +333 -0
  5. package/.agent/skills/agent-kb/references/query-optimization.md +225 -0
  6. package/.agent/skills/aireview/SKILL.md +704 -0
  7. package/.agent/skills/analyze/SKILL.md +81 -0
  8. package/.agent/skills/architect-planner/HOW_TO_USE.md +238 -0
  9. package/.agent/skills/architect-planner/README.md +41 -0
  10. package/.agent/skills/architect-planner/SKILL.md +539 -0
  11. package/.agent/skills/auto-mbti/SKILL.md +291 -0
  12. package/.agent/skills/autopilot/SKILL.md +222 -0
  13. package/.agent/skills/backend-patterns/SKILL.md +602 -0
  14. package/.agent/skills/bdd-generator/README.md +78 -0
  15. package/.agent/skills/bdd-generator/SKILL.md +436 -0
  16. package/.agent/skills/brainstorming/HOW_TO_USE.md +289 -0
  17. package/.agent/skills/brainstorming/README.md +41 -0
  18. package/.agent/skills/brainstorming/SKILL.md +165 -0
  19. package/.agent/skills/build-fix/SKILL.md +190 -0
  20. package/.agent/skills/cancel/SKILL.md +658 -0
  21. package/.agent/skills/checkpoint/SKILL.md +94 -0
  22. package/.agent/skills/code-review/SKILL.md +273 -0
  23. package/.agent/skills/coding-standards/SKILL.md +535 -0
  24. package/.agent/skills/conductor/SKILL.md +128 -0
  25. package/.agent/skills/conductor/commands/conductor/implement.toml +358 -0
  26. package/.agent/skills/conductor/commands/conductor/newTrack.toml +142 -0
  27. package/.agent/skills/conductor/commands/conductor/revert.toml +123 -0
  28. package/.agent/skills/conductor/commands/conductor/setup.toml +429 -0
  29. package/.agent/skills/conductor/commands/conductor/status.toml +57 -0
  30. package/.agent/skills/conductor/scripts/install.sh +89 -0
  31. package/.agent/skills/conductor/templates/code_styleguides/csharp.md +115 -0
  32. package/.agent/skills/conductor/templates/code_styleguides/dart.md +238 -0
  33. package/.agent/skills/conductor/templates/code_styleguides/general.md +23 -0
  34. package/.agent/skills/conductor/templates/code_styleguides/go.md +48 -0
  35. package/.agent/skills/conductor/templates/code_styleguides/html-css.md +49 -0
  36. package/.agent/skills/conductor/templates/code_styleguides/javascript.md +51 -0
  37. package/.agent/skills/conductor/templates/code_styleguides/python.md +37 -0
  38. package/.agent/skills/conductor/templates/code_styleguides/typescript.md +43 -0
  39. package/.agent/skills/conductor/templates/rules/README.md +23 -0
  40. package/.agent/skills/conductor/templates/rules/agents.md +49 -0
  41. package/.agent/skills/conductor/templates/rules/coding-style.md +70 -0
  42. package/.agent/skills/conductor/templates/rules/dev.md +20 -0
  43. package/.agent/skills/conductor/templates/rules/git-workflow.md +45 -0
  44. package/.agent/skills/conductor/templates/rules/hooks.md +6 -0
  45. package/.agent/skills/conductor/templates/rules/patterns.md +55 -0
  46. package/.agent/skills/conductor/templates/rules/performance.md +47 -0
  47. package/.agent/skills/conductor/templates/rules/research.md +26 -0
  48. package/.agent/skills/conductor/templates/rules/review.md +22 -0
  49. package/.agent/skills/conductor/templates/rules/security.md +36 -0
  50. package/.agent/skills/conductor/templates/rules/testing.md +30 -0
  51. package/.agent/skills/conductor/templates/workflow.md +333 -0
  52. package/.agent/skills/consensus/HOW_TO_USE.md +191 -0
  53. package/.agent/skills/consensus/README.md +41 -0
  54. package/.agent/skills/consensus/SKILL.md +317 -0
  55. package/.agent/skills/content-research-writer/SKILL.md +537 -0
  56. package/.agent/skills/debug-analysis/SKILL.md +331 -0
  57. package/.agent/skills/deepinit/SKILL.md +347 -0
  58. package/.agent/skills/deepsearch/SKILL.md +56 -0
  59. package/.agent/skills/doctor/SKILL.md +158 -0
  60. package/.agent/skills/drawio/EXAMPLES.md +382 -0
  61. package/.agent/skills/drawio/QUICK_START.md +237 -0
  62. package/.agent/skills/drawio/README.md +315 -0
  63. package/.agent/skills/drawio/SETUP_GUIDE.md +254 -0
  64. package/.agent/skills/drawio/SKILL.md +1176 -0
  65. package/.agent/skills/e2e/SKILL.md +396 -0
  66. package/.agent/skills/ecomode/SKILL.md +160 -0
  67. package/.agent/skills/electron-driver/SKILL.md +144 -0
  68. package/.agent/skills/electron-driver/scripts/driver-template.js +71 -0
  69. package/.agent/skills/eval/SKILL.md +140 -0
  70. package/.agent/skills/eval-harness/SKILL.md +242 -0
  71. package/.agent/skills/evolve/SKILL.md +213 -0
  72. package/.agent/skills/frontend-design/SKILL.md +42 -0
  73. package/.agent/skills/frontend-patterns/SKILL.md +646 -0
  74. package/.agent/skills/frontend-ui-ux/SKILL.md +70 -0
  75. package/.agent/skills/git-master/SKILL.md +75 -0
  76. package/.agent/skills/help/SKILL.md +89 -0
  77. package/.agent/skills/iterative-retrieval/SKILL.md +217 -0
  78. package/.agent/skills/local-skills-setup/SKILL.md +483 -0
  79. package/.agent/skills/log-analyzer/SKILL.md +187 -0
  80. package/.agent/skills/mcp-setup/SKILL.md +226 -0
  81. package/.agent/skills/multi-model-research/HOW_TO_USE.md +614 -0
  82. package/.agent/skills/multi-model-research/README.md +233 -0
  83. package/.agent/skills/multi-model-research/SKILL.md +541 -0
  84. package/.agent/skills/multi-model-research/references/troubleshooting.md +415 -0
  85. package/.agent/skills/note/SKILL.md +80 -0
  86. package/.agent/skills/omc-setup/SKILL.md +219 -0
  87. package/.agent/skills/orchestrate/SKILL.md +620 -0
  88. package/.agent/skills/patent-workflow/IMPLEMENTATION_SUMMARY.md +500 -0
  89. package/.agent/skills/patent-workflow/README.md +455 -0
  90. package/.agent/skills/patent-workflow/SKILL.md +1036 -0
  91. package/.agent/skills/patent-workflow/tools/irr_checker.py +260 -0
  92. package/.agent/skills/patent-workflow/tools/sample_terminology.json +49 -0
  93. package/.agent/skills/patent-workflow/tools/term_checker.py +355 -0
  94. package/.agent/skills/pattern-recognition/SKILL.md +792 -0
  95. package/.agent/skills/pipeline/SKILL.md +448 -0
  96. package/.agent/skills/plan/SKILL.md +309 -0
  97. package/.agent/skills/planning-methodology/SKILL.md +370 -0
  98. package/.agent/skills/planning-with-files/SKILL.md +210 -0
  99. package/.agent/skills/planning-with-files/examples.md +202 -0
  100. package/.agent/skills/planning-with-files/reference.md +218 -0
  101. package/.agent/skills/planning-with-files/scripts/check-complete.ps1 +42 -0
  102. package/.agent/skills/planning-with-files/scripts/check-complete.sh +44 -0
  103. package/.agent/skills/planning-with-files/scripts/init-session.ps1 +120 -0
  104. package/.agent/skills/planning-with-files/scripts/init-session.sh +120 -0
  105. package/.agent/skills/planning-with-files/scripts/session-catchup.py +208 -0
  106. package/.agent/skills/planning-with-files/templates/findings.md +95 -0
  107. package/.agent/skills/planning-with-files/templates/progress.md +114 -0
  108. package/.agent/skills/planning-with-files/templates/task_plan.md +132 -0
  109. package/.agent/skills/project-analyze/CLAUDE.md +18 -0
  110. package/.agent/skills/project-analyze/HOW_TO_USE.md +145 -0
  111. package/.agent/skills/project-analyze/README.md +42 -0
  112. package/.agent/skills/project-analyze/SKILL.md +289 -0
  113. package/.agent/skills/project-analyze/SKILL.md.backup +287 -0
  114. package/.agent/skills/project-analyze/SKILL.md.backup_20260105_093646 +287 -0
  115. package/.agent/skills/project-analyze/assets/analysis-report-template.md +433 -0
  116. package/.agent/skills/project-analyze/references/analysis-patterns.md +422 -0
  117. package/.agent/skills/project-analyze/references/projectmind-explained.md +535 -0
  118. package/.agent/skills/project-session-manager/SKILL.md +428 -0
  119. package/.agent/skills/project-session-manager/lib/config.sh +86 -0
  120. package/.agent/skills/project-session-manager/lib/parse.sh +121 -0
  121. package/.agent/skills/project-session-manager/lib/session.sh +132 -0
  122. package/.agent/skills/project-session-manager/lib/tmux.sh +103 -0
  123. package/.agent/skills/project-session-manager/lib/worktree.sh +171 -0
  124. package/.agent/skills/project-session-manager/psm.sh +629 -0
  125. package/.agent/skills/project-session-manager/templates/feature.md +56 -0
  126. package/.agent/skills/project-session-manager/templates/issue-fix.md +57 -0
  127. package/.agent/skills/project-session-manager/templates/pr-review.md +65 -0
  128. package/.agent/skills/project-session-manager/templates/projects.json +19 -0
  129. package/.agent/skills/quality-check/HOW_TO_USE.md +171 -0
  130. package/.agent/skills/quality-check/README.md +50 -0
  131. package/.agent/skills/quality-check/SKILL.md +240 -0
  132. package/.agent/skills/quality-check/SKILL.md.backup +238 -0
  133. package/.agent/skills/quality-check/SKILL.md.backup_20260105_093646 +238 -0
  134. package/.agent/skills/quality-check/assets/quality-report-template.md +437 -0
  135. package/.agent/skills/quality-check/references/refactoring-patterns.md +550 -0
  136. package/.agent/skills/quality-check/references/scoring-criteria.md +454 -0
  137. package/.agent/skills/quality-validation/SKILL.md +519 -0
  138. package/.agent/skills/quality-validation/SKILL.md.backup +573 -0
  139. package/.agent/skills/quality-validation/SKILL.md.backup_20260105_093646 +573 -0
  140. package/.agent/skills/ralph/SKILL.md +236 -0
  141. package/.agent/skills/ralph-init/SKILL.md +78 -0
  142. package/.agent/skills/ralplan/SKILL.md +58 -0
  143. package/.agent/skills/refactor-clean/SKILL.md +49 -0
  144. package/.agent/skills/release/SKILL.md +84 -0
  145. package/.agent/skills/research/SKILL.md +526 -0
  146. package/.agent/skills/research-methodology/SKILL.md +268 -0
  147. package/.agent/skills/review/SKILL.md +53 -0
  148. package/.agent/skills/security-review/SKILL.md +509 -0
  149. package/.agent/skills/security-review/cloud-infrastructure-security.md +361 -0
  150. package/.agent/skills/setup-pm/SKILL.md +102 -0
  151. package/.agent/skills/skill/SKILL.md +424 -0
  152. package/.agent/skills/skill-create/SKILL.md +209 -0
  153. package/.agent/skills/skill-debugger/HOW_TO_USE.md +244 -0
  154. package/.agent/skills/skill-debugger/README.md +44 -0
  155. package/.agent/skills/skill-debugger/SKILL.md +326 -0
  156. package/.agent/skills/skill-debugger/diagnostic_checklist.md +115 -0
  157. package/.agent/skills/skill-development/SKILL.md +661 -0
  158. package/.agent/skills/skill-development/references/skill-creator-original.md +209 -0
  159. package/.agent/skills/skill-doc-generator/README.md +37 -0
  160. package/.agent/skills/skill-doc-generator/SKILL.md +331 -0
  161. package/.agent/skills/skill-quality-analyzer/HOW_TO_USE.md +243 -0
  162. package/.agent/skills/skill-quality-analyzer/README.md +61 -0
  163. package/.agent/skills/skill-quality-analyzer/SKILL.md +247 -0
  164. package/.agent/skills/skill-quality-analyzer/analyzer.py +209 -0
  165. package/.agent/skills/skill-quality-analyzer/expected_output.json +81 -0
  166. package/.agent/skills/skill-quality-analyzer/sample_input.json +9 -0
  167. package/.agent/skills/skill-tester/README.md +46 -0
  168. package/.agent/skills/skill-tester/SKILL.md +345 -0
  169. package/.agent/skills/start-dev/SKILL.md +701 -0
  170. package/.agent/skills/swarm/SKILL.md +691 -0
  171. package/.agent/skills/task-kb-lookup/SKILL.md +211 -0
  172. package/.agent/skills/task-kb-record/SKILL.md +417 -0
  173. package/.agent/skills/tdd/SKILL.md +446 -0
  174. package/.agent/skills/tdd-generator/DEMO.md +516 -0
  175. package/.agent/skills/tdd-generator/README.md +89 -0
  176. package/.agent/skills/tdd-generator/SKILL.md +278 -0
  177. package/.agent/skills/tdd-workflow/SKILL.md +424 -0
  178. package/.agent/skills/test-coverage/SKILL.md +48 -0
  179. package/.agent/skills/thinkdeep/HOW_TO_USE.md +183 -0
  180. package/.agent/skills/thinkdeep/README.md +41 -0
  181. package/.agent/skills/thinkdeep/SKILL.md +343 -0
  182. package/.agent/skills/ui-ux-pro-max/SKILL.md +228 -0
  183. package/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
  184. package/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
  185. package/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
  186. package/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
  187. package/.agent/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  188. package/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  189. package/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  190. package/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  191. package/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  192. package/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  193. package/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  194. package/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  195. package/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  196. package/.agent/skills/ui-ux-pro-max/data/styles.csv +59 -0
  197. package/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
  198. package/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  199. package/.agent/skills/ui-ux-pro-max/scripts/core.py +236 -0
  200. package/.agent/skills/ui-ux-pro-max/scripts/search.py +61 -0
  201. package/.agent/skills/ultrapilot/SKILL.md +647 -0
  202. package/.agent/skills/ultraqa/SKILL.md +152 -0
  203. package/.agent/skills/ultrawork/SKILL.md +123 -0
  204. package/.agent/skills/update-codemaps/SKILL.md +38 -0
  205. package/.agent/skills/update-docs/SKILL.md +52 -0
  206. package/.agent/skills/verification-loop/SKILL.md +140 -0
  207. package/.agent/skills/verify/SKILL.md +80 -0
  208. package/.agent/skills/writer-memory/SKILL.md +459 -0
  209. package/.agent/skills/writer-memory/lib/character-tracker.ts +338 -0
  210. package/.agent/skills/writer-memory/lib/memory-manager.ts +804 -0
  211. package/.agent/skills/writer-memory/lib/relationship-graph.ts +400 -0
  212. package/.agent/skills/writer-memory/lib/scene-organizer.ts +544 -0
  213. package/.agent/skills/writer-memory/lib/synopsis-builder.ts +339 -0
  214. package/.agent/skills/writer-memory/templates/synopsis-template.md +46 -0
  215. package/.governance/skill-lint.allowlist +4 -0
  216. package/.governance/skill-llm.allowlist +4 -0
  217. package/AGENTS.md +59 -0
  218. package/LICENSE +21 -0
  219. package/README.md +169 -0
  220. package/README.zh.md +145 -0
  221. package/bin/omcodex.js +8 -0
  222. package/commands/conductor/implement.toml +358 -0
  223. package/commands/conductor/newTrack.toml +142 -0
  224. package/commands/conductor/revert.toml +123 -0
  225. package/commands/conductor/setup.toml +429 -0
  226. package/commands/conductor/status.toml +57 -0
  227. package/docs/ALIGNMENT.md +40 -0
  228. package/docs/CODEX.md +133 -0
  229. package/docs/NOTIFY.md +81 -0
  230. package/docs/SKILL_GOVERNANCE.md +72 -0
  231. package/docs/SKILL_GOVERNANCE_FRAMEWORK.md +182 -0
  232. package/docs/SKILL_GOVERNANCE_FRAMEWORK.zh.md +170 -0
  233. package/package.json +50 -0
  234. package/prompts/architect.md +105 -0
  235. package/prompts/executor.md +134 -0
  236. package/prompts/planner.md +113 -0
  237. package/scripts/check-skill-governance.sh +84 -0
  238. package/scripts/check-skill-llm-governance.js +302 -0
  239. package/scripts/eval-skills.js +217 -0
  240. package/scripts/generate-catalog-docs.js +95 -0
  241. package/scripts/generate-codex-mcp-config.sh +22 -0
  242. package/scripts/install-codex-force.sh +5 -0
  243. package/scripts/install-codex-incremental.sh +5 -0
  244. package/scripts/install-codex.sh +79 -0
  245. package/scripts/notify-dispatch.js +15 -0
  246. package/scripts/setup-package-manager.js +137 -0
  247. package/src/catalog/generated/public-catalog.json +547 -0
  248. package/src/catalog/manifest.json +542 -0
  249. package/src/catalog/reader.js +43 -0
  250. package/src/catalog/schema.js +79 -0
  251. package/src/cli/doctor.js +62 -0
  252. package/src/cli/index.js +85 -0
  253. package/src/cli/notify.js +127 -0
  254. package/src/cli/route.js +43 -0
  255. package/src/cli/setup.js +155 -0
  256. package/src/cli/team.js +125 -0
  257. package/src/config/generator.js +119 -0
  258. package/src/mcp/memory-server.js +241 -0
  259. package/src/mcp/state-server.js +112 -0
  260. package/src/mcp/trace-server.js +168 -0
  261. package/src/notify/dispatch.js +74 -0
  262. package/src/notify/extensibility/dispatcher.js +113 -0
  263. package/src/notify/extensibility/events.js +15 -0
  264. package/src/notify/extensibility/loader.js +54 -0
  265. package/src/router/skill-router.js +90 -0
  266. package/src/team/auto-advance.js +72 -0
  267. package/src/team/orchestrator.js +82 -0
  268. package/src/team/state-store.js +33 -0
  269. package/src/utils/paths.js +33 -0
  270. package/templates/AGENTS.md +15 -0
  271. package/templates/catalog-manifest.json +542 -0
  272. package/templates/code_styleguides/csharp.md +115 -0
  273. package/templates/code_styleguides/dart.md +238 -0
  274. package/templates/code_styleguides/general.md +23 -0
  275. package/templates/code_styleguides/go.md +48 -0
  276. package/templates/code_styleguides/html-css.md +49 -0
  277. package/templates/code_styleguides/javascript.md +51 -0
  278. package/templates/code_styleguides/python.md +37 -0
  279. package/templates/code_styleguides/typescript.md +43 -0
  280. package/templates/rules/README.md +23 -0
  281. package/templates/rules/agents.md +49 -0
  282. package/templates/rules/coding-style.md +70 -0
  283. package/templates/rules/dev.md +20 -0
  284. package/templates/rules/git-workflow.md +45 -0
  285. package/templates/rules/notify.md +6 -0
  286. package/templates/rules/patterns.md +55 -0
  287. package/templates/rules/performance.md +47 -0
  288. package/templates/rules/research.md +26 -0
  289. package/templates/rules/review.md +22 -0
  290. package/templates/rules/security.md +36 -0
  291. package/templates/rules/testing.md +30 -0
  292. package/templates/workflow.md +333 -0
@@ -0,0 +1,428 @@
1
+ ---
2
+ name: project-session-manager
3
+ description: Manage isolated dev environments with git worktrees and tmux sessions
4
+ aliases: [psm]
5
+ ---
6
+
7
+ # Project Session Manager (PSM) Skill
8
+
9
+
10
+ ## Native Subagent Protocol (Codex)
11
+
12
+ Codex supports native subagents. Delegate with `spawn_agent`, coordinate with `send_input`, collect via `wait`, and clean up with `close_agent`.
13
+
14
+ Execution preference:
15
+ 1. Use native subagents first for independent workstreams (parallel when possible).
16
+ 2. Merge results in main thread and run final verification.
17
+ 3. Fallback only when delegation is blocked: use the `[ANALYST]`/`[ARCHITECT]`/`[EXECUTOR]`/`[REVIEWER]` structure in a single response.
18
+
19
+ Minimal orchestration pattern:
20
+ ```text
21
+ spawn_agent -> send_input (optional) -> wait -> close_agent
22
+ ```
23
+
24
+ > Codex invocation: use `$project-session-manager ...` or `project-session-manager: ...`
25
+
26
+
27
+ Automate isolated development environments using git worktrees and tmux sessions with Codex. Enables parallel work across multiple tasks, projects, and repositories.
28
+
29
+ ## Commands
30
+
31
+ | Command | Description | Example |
32
+ |---------|-------------|---------|
33
+ | `review <ref>` | PR review session | `$psm review omc#123` |
34
+ | `fix <ref>` | Issue fix session | `$psm fix omc#42` |
35
+ | `feature <proj> <name>` | Feature development | `$psm feature omc add-webhooks` |
36
+ | `list [project]` | List active sessions | `$psm list` |
37
+ | `attach <session>` | Attach to session | `$psm attach omc:pr-123` |
38
+ | `kill <session>` | Kill session | `$psm kill omc:pr-123` |
39
+ | `cleanup` | Clean merged/closed | `$psm cleanup` |
40
+ | `status` | Current session info | `$psm status` |
41
+
42
+ ## Project References
43
+
44
+ Supported formats:
45
+ - **Alias**: `omc#123` (requires `~/.psm/projects.json`)
46
+ - **Full**: `owner/repo#123`
47
+ - **URL**: `https://github.com/owner/repo/pull/123`
48
+ - **Current**: `#123` (uses current directory's repo)
49
+
50
+ ## Configuration
51
+
52
+ ### Project Aliases (`~/.psm/projects.json`)
53
+
54
+ ```json
55
+ {
56
+ "aliases": {
57
+ "omc": {
58
+ "repo": "Yeachan-Heo/oh-my-codex",
59
+ "local": "~/Workspace/oh-my-codex",
60
+ "default_base": "main"
61
+ }
62
+ },
63
+ "defaults": {
64
+ "worktree_root": "~/.psm/worktrees",
65
+ "cleanup_after_days": 14
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Directory Structure
71
+
72
+ ```
73
+ ~/.psm/
74
+ ├── projects.json # Project aliases
75
+ ├── sessions.json # Active session registry
76
+ └── worktrees/ # Worktree storage
77
+ └── <project>/
78
+ └── <type>-<id>/
79
+ ```
80
+
81
+ ## Session Naming
82
+
83
+ | Type | Tmux Session | Worktree Dir |
84
+ |------|--------------|--------------|
85
+ | PR Review | `psm:omc:pr-123` | `~/.psm/worktrees/omc/pr-123` |
86
+ | Issue Fix | `psm:omc:issue-42` | `~/.psm/worktrees/omc/issue-42` |
87
+ | Feature | `psm:omc:feat-auth` | `~/.psm/worktrees/omc/feat-auth` |
88
+
89
+ ---
90
+
91
+ ## Implementation Protocol
92
+
93
+ When the user invokes a PSM command, follow this protocol:
94
+
95
+ ### Parse Arguments
96
+
97
+ Parse `{{ARGUMENTS}}` to determine:
98
+ 1. **Subcommand**: review, fix, feature, list, attach, kill, cleanup, status
99
+ 2. **Reference**: project#number, URL, or session ID
100
+ 3. **Options**: --branch, --base, --no-codex, --no-tmux, etc.
101
+
102
+ ### Subcommand: `review <ref>`
103
+
104
+ **Purpose**: Create PR review session
105
+
106
+ **Steps**:
107
+
108
+ 1. **Resolve reference**:
109
+ ```bash
110
+ # Read project aliases
111
+ cat ~/.psm/projects.json 2>/dev/null || echo '{"aliases":{}}'
112
+
113
+ # Parse ref format: alias#num, owner/repo#num, or URL
114
+ # Extract: project_alias, repo (owner/repo), pr_number, local_path
115
+ ```
116
+
117
+ 2. **Fetch PR info**:
118
+ ```bash
119
+ gh pr view <pr_number> --repo <repo> --json number,title,author,headRefName,baseRefName,body,files,url
120
+ ```
121
+
122
+ 3. **Ensure local repo exists**:
123
+ ```bash
124
+ # If local path doesn't exist, clone
125
+ if [[ ! -d "$local_path" ]]; then
126
+ git clone "https://github.com/$repo.git" "$local_path"
127
+ fi
128
+ ```
129
+
130
+ 4. **Create worktree**:
131
+ ```bash
132
+ worktree_path="$HOME/.psm/worktrees/$project_alias/pr-$pr_number"
133
+
134
+ # Fetch PR branch
135
+ cd "$local_path"
136
+ git fetch origin "pull/$pr_number/head:pr-$pr_number-review"
137
+
138
+ # Create worktree
139
+ git worktree add "$worktree_path" "pr-$pr_number-review"
140
+ ```
141
+
142
+ 5. **Create session metadata**:
143
+ ```bash
144
+ cat > "$worktree_path/.psm-session.json" << EOF
145
+ {
146
+ "id": "$project_alias:pr-$pr_number",
147
+ "type": "review",
148
+ "project": "$project_alias",
149
+ "ref": "pr-$pr_number",
150
+ "branch": "<head_branch>",
151
+ "base": "<base_branch>",
152
+ "created_at": "$(date -Iseconds)",
153
+ "tmux_session": "psm:$project_alias:pr-$pr_number",
154
+ "worktree_path": "$worktree_path",
155
+ "source_repo": "$local_path",
156
+ "github": {
157
+ "pr_number": $pr_number,
158
+ "pr_title": "<title>",
159
+ "pr_author": "<author>",
160
+ "pr_url": "<url>"
161
+ },
162
+ "state": "active"
163
+ }
164
+ EOF
165
+ ```
166
+
167
+ 6. **Update sessions registry**:
168
+ ```bash
169
+ # Add to ~/.psm/sessions.json
170
+ ```
171
+
172
+ 7. **Create tmux session**:
173
+ ```bash
174
+ tmux new-session -d -s "psm:$project_alias:pr-$pr_number" -c "$worktree_path"
175
+ ```
176
+
177
+ 8. **Launch Codex** (unless --no-codex):
178
+ ```bash
179
+ tmux send-keys -t "psm:$project_alias:pr-$pr_number" "codex" Enter
180
+ ```
181
+
182
+ 9. **Output session info**:
183
+ ```
184
+ Session ready!
185
+
186
+ ID: omc:pr-123
187
+ Worktree: ~/.psm/worktrees/omc/pr-123
188
+ Tmux: psm:omc:pr-123
189
+
190
+ To attach: tmux attach -t psm:omc:pr-123
191
+ ```
192
+
193
+ ### Subcommand: `fix <ref>`
194
+
195
+ **Purpose**: Create issue fix session
196
+
197
+ **Steps**:
198
+
199
+ 1. **Resolve reference** (same as review)
200
+
201
+ 2. **Fetch issue info**:
202
+ ```bash
203
+ gh issue view <issue_number> --repo <repo> --json number,title,body,labels,url
204
+ ```
205
+
206
+ 3. **Create feature branch**:
207
+ ```bash
208
+ cd "$local_path"
209
+ git fetch origin main
210
+ branch_name="fix/$issue_number-$(echo "$title" | tr ' ' '-' | tr '[:upper:]' '[:lower:]' | head -c 30)"
211
+ git checkout -b "$branch_name" origin/main
212
+ ```
213
+
214
+ 4. **Create worktree**:
215
+ ```bash
216
+ worktree_path="$HOME/.psm/worktrees/$project_alias/issue-$issue_number"
217
+ git worktree add "$worktree_path" "$branch_name"
218
+ ```
219
+
220
+ 5. **Create session metadata** (similar to review, type="fix")
221
+
222
+ 6. **Update registry, create tmux, launch codex** (same as review)
223
+
224
+ ### Subcommand: `feature <project> <name>`
225
+
226
+ **Purpose**: Start feature development
227
+
228
+ **Steps**:
229
+
230
+ 1. **Resolve project** (from alias or path)
231
+
232
+ 2. **Create feature branch**:
233
+ ```bash
234
+ cd "$local_path"
235
+ git fetch origin main
236
+ branch_name="feature/$feature_name"
237
+ git checkout -b "$branch_name" origin/main
238
+ ```
239
+
240
+ 3. **Create worktree**:
241
+ ```bash
242
+ worktree_path="$HOME/.psm/worktrees/$project_alias/feat-$feature_name"
243
+ git worktree add "$worktree_path" "$branch_name"
244
+ ```
245
+
246
+ 4. **Create session, tmux, launch codex** (same pattern)
247
+
248
+ ### Subcommand: `list [project]`
249
+
250
+ **Purpose**: List active sessions
251
+
252
+ **Steps**:
253
+
254
+ 1. **Read sessions registry**:
255
+ ```bash
256
+ cat ~/.psm/sessions.json 2>/dev/null || echo '{"sessions":{}}'
257
+ ```
258
+
259
+ 2. **Check tmux sessions**:
260
+ ```bash
261
+ tmux list-sessions -F "#{session_name}" 2>/dev/null | grep "^psm:"
262
+ ```
263
+
264
+ 3. **Check worktrees**:
265
+ ```bash
266
+ ls -la ~/.psm/worktrees/*/ 2>/dev/null
267
+ ```
268
+
269
+ 4. **Format output**:
270
+ ```
271
+ Active PSM Sessions:
272
+
273
+ ID | Type | Status | Worktree
274
+ -------------------|---------|----------|---------------------------
275
+ omc:pr-123 | review | active | ~/.psm/worktrees/omc/pr-123
276
+ omc:issue-42 | fix | detached | ~/.psm/worktrees/omc/issue-42
277
+ ```
278
+
279
+ ### Subcommand: `attach <session>`
280
+
281
+ **Purpose**: Attach to existing session
282
+
283
+ **Steps**:
284
+
285
+ 1. **Parse session ID**: `project:type-number`
286
+
287
+ 2. **Verify session exists**:
288
+ ```bash
289
+ tmux has-session -t "psm:$session_id" 2>/dev/null
290
+ ```
291
+
292
+ 3. **Attach**:
293
+ ```bash
294
+ tmux attach -t "psm:$session_id"
295
+ ```
296
+
297
+ ### Subcommand: `kill <session>`
298
+
299
+ **Purpose**: Kill session and cleanup
300
+
301
+ **Steps**:
302
+
303
+ 1. **Kill tmux session**:
304
+ ```bash
305
+ tmux kill-session -t "psm:$session_id" 2>/dev/null
306
+ ```
307
+
308
+ 2. **Remove worktree**:
309
+ ```bash
310
+ worktree_path=$(jq -r ".sessions[\"$session_id\"].worktree" ~/.psm/sessions.json)
311
+ source_repo=$(jq -r ".sessions[\"$session_id\"].source_repo" ~/.psm/sessions.json)
312
+
313
+ cd "$source_repo"
314
+ git worktree remove "$worktree_path" --force
315
+ ```
316
+
317
+ 3. **Update registry**:
318
+ ```bash
319
+ # Remove from sessions.json
320
+ ```
321
+
322
+ ### Subcommand: `cleanup`
323
+
324
+ **Purpose**: Clean up merged PRs and closed issues
325
+
326
+ **Steps**:
327
+
328
+ 1. **Read all sessions**
329
+
330
+ 2. **For each PR session, check if merged**:
331
+ ```bash
332
+ gh pr view <pr_number> --repo <repo> --json merged,state
333
+ ```
334
+
335
+ 3. **For each issue session, check if closed**:
336
+ ```bash
337
+ gh issue view <issue_number> --repo <repo> --json closed,state
338
+ ```
339
+
340
+ 4. **Clean up merged/closed sessions**:
341
+ - Kill tmux session
342
+ - Remove worktree
343
+ - Update registry
344
+
345
+ 5. **Report**:
346
+ ```
347
+ Cleanup complete:
348
+ Removed: omc:pr-123 (merged)
349
+ Removed: omc:issue-42 (closed)
350
+ Kept: omc:feat-auth (active)
351
+ ```
352
+
353
+ ### Subcommand: `status`
354
+
355
+ **Purpose**: Show current session info
356
+
357
+ **Steps**:
358
+
359
+ 1. **Detect current session** from tmux or cwd:
360
+ ```bash
361
+ tmux display-message -p "#{session_name}" 2>/dev/null
362
+ # or check if cwd is inside a worktree
363
+ ```
364
+
365
+ 2. **Read session metadata**:
366
+ ```bash
367
+ cat .psm-session.json 2>/dev/null
368
+ ```
369
+
370
+ 3. **Show status**:
371
+ ```
372
+ Current Session: omc:pr-123
373
+ Type: review
374
+ PR: #123 - Add webhook support
375
+ Branch: feature/webhooks
376
+ Created: 2 hours ago
377
+ ```
378
+
379
+ ---
380
+
381
+ ## Error Handling
382
+
383
+ | Error | Resolution |
384
+ |-------|------------|
385
+ | Worktree exists | Offer: attach, recreate, or abort |
386
+ | PR not found | Verify URL/number, check permissions |
387
+ | No tmux | Warn and skip session creation |
388
+ | No gh CLI | Error with install instructions |
389
+
390
+ ## Requirements
391
+
392
+ - `git` with worktree support (v2.5+)
393
+ - `gh` CLI (authenticated)
394
+ - `tmux`
395
+ - `jq` for JSON parsing
396
+
397
+ ## Initialization
398
+
399
+ On first run, create default config:
400
+
401
+ ```bash
402
+ mkdir -p ~/.psm/worktrees ~/.psm/logs
403
+
404
+ # Create default projects.json if not exists
405
+ if [[ ! -f ~/.psm/projects.json ]]; then
406
+ cat > ~/.psm/projects.json << 'EOF'
407
+ {
408
+ "aliases": {
409
+ "omc": {
410
+ "repo": "Yeachan-Heo/oh-my-codex",
411
+ "local": "~/Workspace/oh-my-codex",
412
+ "default_base": "main"
413
+ }
414
+ },
415
+ "defaults": {
416
+ "worktree_root": "~/.psm/worktrees",
417
+ "cleanup_after_days": 14,
418
+ "auto_cleanup_merged": true
419
+ }
420
+ }
421
+ EOF
422
+ fi
423
+
424
+ # Create sessions.json if not exists
425
+ if [[ ! -f ~/.psm/sessions.json ]]; then
426
+ echo '{"version":1,"sessions":{},"stats":{"total_created":0,"total_cleaned":0}}' > ~/.psm/sessions.json
427
+ fi
428
+ ```
@@ -0,0 +1,86 @@
1
+ #!/bin/bash
2
+ # PSM Configuration Management
3
+
4
+ PSM_ROOT="${HOME}/.psm"
5
+ PSM_WORKTREES="${PSM_ROOT}/worktrees"
6
+ PSM_PROJECTS="${PSM_ROOT}/projects.json"
7
+ PSM_SESSIONS="${PSM_ROOT}/sessions.json"
8
+ PSM_LOGS="${PSM_ROOT}/logs"
9
+
10
+ # Initialize PSM directories and config files
11
+ psm_init() {
12
+ mkdir -p "$PSM_WORKTREES" "$PSM_LOGS"
13
+
14
+ # Create default projects.json if not exists
15
+ if [[ ! -f "$PSM_PROJECTS" ]]; then
16
+ cat > "$PSM_PROJECTS" << 'EOF'
17
+ {
18
+ "aliases": {
19
+ "omc": {
20
+ "repo": "Yeachan-Heo/oh-my-codex",
21
+ "local": "~/Workspace/oh-my-codex",
22
+ "default_base": "main"
23
+ }
24
+ },
25
+ "defaults": {
26
+ "worktree_root": "~/.psm/worktrees",
27
+ "cleanup_after_days": 14,
28
+ "auto_cleanup_merged": true
29
+ }
30
+ }
31
+ EOF
32
+ echo "Created default projects.json"
33
+ fi
34
+
35
+ # Create sessions.json if not exists
36
+ if [[ ! -f "$PSM_SESSIONS" ]]; then
37
+ echo '{"version":1,"sessions":{},"stats":{"total_created":0,"total_cleaned":0}}' > "$PSM_SESSIONS"
38
+ echo "Created sessions.json"
39
+ fi
40
+ }
41
+
42
+ # Get project config by alias
43
+ # Usage: psm_get_project "omc"
44
+ # Returns: repo|local|default_base
45
+ psm_get_project() {
46
+ local alias="$1"
47
+ if [[ ! -f "$PSM_PROJECTS" ]]; then
48
+ return 1
49
+ fi
50
+
51
+ local repo=$(jq -r ".aliases[\"$alias\"].repo // empty" "$PSM_PROJECTS")
52
+ local local_path=$(jq -r ".aliases[\"$alias\"].local // empty" "$PSM_PROJECTS")
53
+ local default_base=$(jq -r ".aliases[\"$alias\"].default_base // \"main\"" "$PSM_PROJECTS")
54
+
55
+ if [[ -z "$repo" ]]; then
56
+ return 1
57
+ fi
58
+
59
+ # Expand ~ to $HOME
60
+ local_path="${local_path/#\~/$HOME}"
61
+
62
+ echo "${repo}|${local_path}|${default_base}"
63
+ }
64
+
65
+ # Add or update project alias
66
+ psm_set_project() {
67
+ local alias="$1"
68
+ local repo="$2"
69
+ local local_path="$3"
70
+ local default_base="${4:-main}"
71
+
72
+ local tmp=$(mktemp)
73
+ jq ".aliases[\"$alias\"] = {\"repo\": \"$repo\", \"local\": \"$local_path\", \"default_base\": \"$default_base\"}" \
74
+ "$PSM_PROJECTS" > "$tmp" && mv "$tmp" "$PSM_PROJECTS"
75
+ }
76
+
77
+ # Get default worktree root
78
+ psm_get_worktree_root() {
79
+ local root=$(jq -r '.defaults.worktree_root // "~/.psm/worktrees"' "$PSM_PROJECTS")
80
+ echo "${root/#\~/$HOME}"
81
+ }
82
+
83
+ # Get cleanup days setting
84
+ psm_get_cleanup_days() {
85
+ jq -r '.defaults.cleanup_after_days // 14' "$PSM_PROJECTS"
86
+ }
@@ -0,0 +1,121 @@
1
+ #!/bin/bash
2
+ # PSM Reference Parser
3
+
4
+ # Parse a reference string into components
5
+ # Supports:
6
+ # omc#123 -> alias=omc, number=123
7
+ # owner/repo#123 -> repo=owner/repo, number=123
8
+ # https://... -> parsed from URL
9
+ # #123 -> number=123 (use current repo)
10
+ #
11
+ # Usage: psm_parse_ref "omc#123"
12
+ # Returns: type|alias|repo|number|local_path|base
13
+ psm_parse_ref() {
14
+ local ref="$1"
15
+ local type=""
16
+ local alias=""
17
+ local repo=""
18
+ local number=""
19
+ local local_path=""
20
+ local base="main"
21
+
22
+ # GitHub PR URL
23
+ if [[ "$ref" =~ ^https://github\.com/([^/]+)/([^/]+)/pull/([0-9]+) ]]; then
24
+ repo="${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
25
+ number="${BASH_REMATCH[3]}"
26
+ type="pr"
27
+ # Try to find alias for this repo
28
+ alias=$(psm_find_alias_for_repo "$repo")
29
+ if [[ -n "$alias" ]]; then
30
+ IFS='|' read -r _ local_path base <<< "$(psm_get_project "$alias")"
31
+ fi
32
+ echo "pr|${alias:-}|$repo|$number|${local_path:-}|$base"
33
+ return 0
34
+ fi
35
+
36
+ # GitHub Issue URL
37
+ if [[ "$ref" =~ ^https://github\.com/([^/]+)/([^/]+)/issues/([0-9]+) ]]; then
38
+ repo="${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
39
+ number="${BASH_REMATCH[3]}"
40
+ type="issue"
41
+ alias=$(psm_find_alias_for_repo "$repo")
42
+ if [[ -n "$alias" ]]; then
43
+ IFS='|' read -r _ local_path base <<< "$(psm_get_project "$alias")"
44
+ fi
45
+ echo "issue|${alias:-}|$repo|$number|${local_path:-}|$base"
46
+ return 0
47
+ fi
48
+
49
+ # alias#number format (e.g., omc#123)
50
+ if [[ "$ref" =~ ^([a-zA-Z][a-zA-Z0-9_-]*)#([0-9]+)$ ]]; then
51
+ alias="${BASH_REMATCH[1]}"
52
+ number="${BASH_REMATCH[2]}"
53
+
54
+ local project_info
55
+ project_info=$(psm_get_project "$alias")
56
+ if [[ $? -eq 0 ]]; then
57
+ IFS='|' read -r repo local_path base <<< "$project_info"
58
+ # Determine type from context (default to issue, caller specifies)
59
+ echo "ref|$alias|$repo|$number|$local_path|$base"
60
+ return 0
61
+ else
62
+ echo "error|Unknown project alias: $alias|||"
63
+ return 1
64
+ fi
65
+ fi
66
+
67
+ # owner/repo#number format
68
+ if [[ "$ref" =~ ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_.-]+)#([0-9]+)$ ]]; then
69
+ repo="${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
70
+ number="${BASH_REMATCH[3]}"
71
+ alias=$(psm_find_alias_for_repo "$repo")
72
+ if [[ -n "$alias" ]]; then
73
+ IFS='|' read -r _ local_path base <<< "$(psm_get_project "$alias")"
74
+ fi
75
+ echo "ref|${alias:-}|$repo|$number|${local_path:-}|$base"
76
+ return 0
77
+ fi
78
+
79
+ # Just #number (use current repo)
80
+ if [[ "$ref" =~ ^#([0-9]+)$ ]]; then
81
+ number="${BASH_REMATCH[1]}"
82
+ # Detect repo from current directory
83
+ if git rev-parse --git-dir > /dev/null 2>&1; then
84
+ local remote_url=$(git remote get-url origin 2>/dev/null)
85
+ if [[ "$remote_url" =~ github\.com[:/]([^/]+)/([^/.]+) ]]; then
86
+ repo="${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
87
+ local_path=$(git rev-parse --show-toplevel)
88
+ alias=$(psm_find_alias_for_repo "$repo")
89
+ fi
90
+ fi
91
+ echo "ref|${alias:-}|${repo:-}|$number|${local_path:-}|$base"
92
+ return 0
93
+ fi
94
+
95
+ echo "error|Cannot parse reference: $ref|||"
96
+ return 1
97
+ }
98
+
99
+ # Find project alias for a given repo
100
+ psm_find_alias_for_repo() {
101
+ local target_repo="$1"
102
+ if [[ ! -f "$PSM_PROJECTS" ]]; then
103
+ return 1
104
+ fi
105
+
106
+ jq -r ".aliases | to_entries[] | select(.value.repo == \"$target_repo\") | .key" "$PSM_PROJECTS" | head -1
107
+ }
108
+
109
+ # Sanitize a string for use in filenames/session names
110
+ psm_sanitize() {
111
+ local input="$1"
112
+ # Remove path traversal, convert to lowercase, replace spaces with dashes
113
+ echo "$input" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | head -c 30
114
+ }
115
+
116
+ # Generate a slug from title
117
+ psm_slugify() {
118
+ local title="$1"
119
+ local max_len="${2:-30}"
120
+ echo "$title" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | head -c "$max_len"
121
+ }