codex-workflows 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 (85) hide show
  1. package/.agents/skills/ai-development-guide/SKILL.md +283 -0
  2. package/.agents/skills/ai-development-guide/agents/openai.yaml +7 -0
  3. package/.agents/skills/ai-development-guide/references/frontend.md +135 -0
  4. package/.agents/skills/coding-rules/SKILL.md +98 -0
  5. package/.agents/skills/coding-rules/agents/openai.yaml +7 -0
  6. package/.agents/skills/coding-rules/references/typescript.md +220 -0
  7. package/.agents/skills/documentation-criteria/SKILL.md +127 -0
  8. package/.agents/skills/documentation-criteria/agents/openai.yaml +7 -0
  9. package/.agents/skills/documentation-criteria/references/adr-template.md +64 -0
  10. package/.agents/skills/documentation-criteria/references/design-template.md +327 -0
  11. package/.agents/skills/documentation-criteria/references/plan-template.md +131 -0
  12. package/.agents/skills/documentation-criteria/references/prd-template.md +119 -0
  13. package/.agents/skills/documentation-criteria/references/task-template.md +38 -0
  14. package/.agents/skills/documentation-criteria/references/ui-spec-template.md +145 -0
  15. package/.agents/skills/implementation-approach/SKILL.md +145 -0
  16. package/.agents/skills/implementation-approach/agents/openai.yaml +7 -0
  17. package/.agents/skills/integration-e2e-testing/SKILL.md +125 -0
  18. package/.agents/skills/integration-e2e-testing/agents/openai.yaml +7 -0
  19. package/.agents/skills/integration-e2e-testing/references/e2e-design.md +86 -0
  20. package/.agents/skills/recipe-add-integration-tests/SKILL.md +128 -0
  21. package/.agents/skills/recipe-add-integration-tests/agents/openai.yaml +7 -0
  22. package/.agents/skills/recipe-build/SKILL.md +119 -0
  23. package/.agents/skills/recipe-build/agents/openai.yaml +7 -0
  24. package/.agents/skills/recipe-design/SKILL.md +90 -0
  25. package/.agents/skills/recipe-design/agents/openai.yaml +7 -0
  26. package/.agents/skills/recipe-diagnose/SKILL.md +187 -0
  27. package/.agents/skills/recipe-diagnose/agents/openai.yaml +7 -0
  28. package/.agents/skills/recipe-front-build/SKILL.md +127 -0
  29. package/.agents/skills/recipe-front-build/agents/openai.yaml +7 -0
  30. package/.agents/skills/recipe-front-design/SKILL.md +90 -0
  31. package/.agents/skills/recipe-front-design/agents/openai.yaml +7 -0
  32. package/.agents/skills/recipe-front-plan/SKILL.md +68 -0
  33. package/.agents/skills/recipe-front-plan/agents/openai.yaml +7 -0
  34. package/.agents/skills/recipe-front-review/SKILL.md +101 -0
  35. package/.agents/skills/recipe-front-review/agents/openai.yaml +7 -0
  36. package/.agents/skills/recipe-fullstack-build/SKILL.md +139 -0
  37. package/.agents/skills/recipe-fullstack-build/agents/openai.yaml +7 -0
  38. package/.agents/skills/recipe-fullstack-implement/SKILL.md +151 -0
  39. package/.agents/skills/recipe-fullstack-implement/agents/openai.yaml +7 -0
  40. package/.agents/skills/recipe-implement/SKILL.md +125 -0
  41. package/.agents/skills/recipe-implement/agents/openai.yaml +7 -0
  42. package/.agents/skills/recipe-plan/SKILL.md +73 -0
  43. package/.agents/skills/recipe-plan/agents/openai.yaml +7 -0
  44. package/.agents/skills/recipe-reverse-engineer/SKILL.md +212 -0
  45. package/.agents/skills/recipe-reverse-engineer/agents/openai.yaml +7 -0
  46. package/.agents/skills/recipe-review/SKILL.md +115 -0
  47. package/.agents/skills/recipe-review/agents/openai.yaml +7 -0
  48. package/.agents/skills/recipe-task/SKILL.md +74 -0
  49. package/.agents/skills/recipe-task/agents/openai.yaml +7 -0
  50. package/.agents/skills/recipe-update-doc/SKILL.md +156 -0
  51. package/.agents/skills/recipe-update-doc/agents/openai.yaml +7 -0
  52. package/.agents/skills/subagents-orchestration-guide/SKILL.md +354 -0
  53. package/.agents/skills/subagents-orchestration-guide/agents/openai.yaml +7 -0
  54. package/.agents/skills/subagents-orchestration-guide/references/monorepo-flow.md +124 -0
  55. package/.agents/skills/task-analyzer/SKILL.md +142 -0
  56. package/.agents/skills/task-analyzer/agents/openai.yaml +7 -0
  57. package/.agents/skills/task-analyzer/references/skills-index.yaml +162 -0
  58. package/.agents/skills/testing/SKILL.md +324 -0
  59. package/.agents/skills/testing/agents/openai.yaml +7 -0
  60. package/.agents/skills/testing/references/typescript.md +224 -0
  61. package/.codex/agents/acceptance-test-generator.toml +310 -0
  62. package/.codex/agents/code-reviewer.toml +228 -0
  63. package/.codex/agents/code-verifier.toml +231 -0
  64. package/.codex/agents/design-sync.toml +265 -0
  65. package/.codex/agents/document-reviewer.toml +367 -0
  66. package/.codex/agents/integration-test-reviewer.toml +178 -0
  67. package/.codex/agents/investigator.toml +197 -0
  68. package/.codex/agents/prd-creator.toml +250 -0
  69. package/.codex/agents/quality-fixer-frontend.toml +356 -0
  70. package/.codex/agents/quality-fixer.toml +249 -0
  71. package/.codex/agents/requirement-analyzer.toml +172 -0
  72. package/.codex/agents/rule-advisor.toml +186 -0
  73. package/.codex/agents/scope-discoverer.toml +248 -0
  74. package/.codex/agents/solver.toml +212 -0
  75. package/.codex/agents/task-decomposer.toml +262 -0
  76. package/.codex/agents/task-executor-frontend.toml +312 -0
  77. package/.codex/agents/task-executor.toml +314 -0
  78. package/.codex/agents/technical-designer-frontend.toml +492 -0
  79. package/.codex/agents/technical-designer.toml +474 -0
  80. package/.codex/agents/ui-spec-designer.toml +150 -0
  81. package/.codex/agents/verifier.toml +228 -0
  82. package/.codex/agents/work-planner.toml +251 -0
  83. package/README.md +365 -0
  84. package/bin/cli.js +249 -0
  85. package/package.json +35 -0
package/README.md ADDED
@@ -0,0 +1,365 @@
1
+ # codex-workflows
2
+
3
+ [![Codex CLI](https://img.shields.io/badge/Codex%20CLI-Compatible-10a37f)](https://developers.openai.com/codex/cli)
4
+ [![Agent Skills](https://img.shields.io/badge/Agent%20Skills-Spec%20Compliant-blue)](https://developers.openai.com/codex/skills/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ **End-to-end AI coding workflows for [Codex CLI](https://developers.openai.com/codex/cli)** — specialized subagents handle requirements, design, implementation, and quality checks so you get code with explicit design docs, test coverage, and commit-level traceability — not just raw generations.
8
+
9
+ Built on the [Agent Skills specification](https://developers.openai.com/codex/skills/) and [Codex subagents](https://developers.openai.com/codex/subagents). Works with GPT-5.4 and GPT-5.3-Codex-Spark.
10
+
11
+ ---
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ cd your-project
17
+ npx codex-workflows install
18
+ ```
19
+
20
+ Then in Codex CLI:
21
+
22
+ ```
23
+ $recipe-implement Add user authentication with JWT
24
+ ```
25
+
26
+ `$` is Codex CLI's syntax for invoking a skill explicitly. Type `$recipe-` to see all available recipes via tab completion.
27
+
28
+ The framework runs a structured workflow — requirements → design → task decomposition → TDD implementation → quality gates — all through specialized subagents.
29
+
30
+ ---
31
+
32
+ ## Why codex-workflows?
33
+
34
+ **Without codex-workflows:**
35
+ - Code generation is inconsistent across large tasks
36
+ - Requirements and design decisions are implicit — lost after the session
37
+ - Refactoring and debugging become harder as context grows
38
+
39
+ **With codex-workflows:**
40
+ - Every change is traceable: PRD → Design Doc → Task → Commit
41
+ - Built-in TDD and quality gates catch regressions before commit
42
+ - Large tasks stay structured and reviewable through agent context separation
43
+
44
+ ---
45
+
46
+ ## What It Does
47
+
48
+ A single request becomes a structured development process:
49
+
50
+ 1. **Understand** the problem (scale, constraints, affected files)
51
+ 2. **Design** the solution (ADR, Design Doc with acceptance criteria)
52
+ 3. **Break it into tasks** (atomic, 1 commit each)
53
+ 4. **Implement with tests** (TDD per task)
54
+ 5. **Run quality checks** (lint, test, build — no failing checks)
55
+
56
+ Each step is handled by a specialized subagent in its own context, preventing context pollution and reducing error accumulation in long-running tasks:
57
+
58
+ ```
59
+ User Request
60
+
61
+ requirement-analyzer → Scale determination (Small / Medium / Large)
62
+
63
+ prd-creator → Product requirements (Large scale)
64
+
65
+ technical-designer → ADR + Design Doc with acceptance criteria
66
+
67
+ document-reviewer → Quality gate
68
+
69
+ acceptance-test-gen → Test skeletons from ACs
70
+
71
+ work-planner → Phased execution plan
72
+
73
+ task-decomposer → Atomic tasks (1 task = 1 commit)
74
+
75
+ task-executor → TDD implementation per task
76
+
77
+ quality-fixer → Lint, test, build — no failing checks
78
+
79
+ Ready to commit
80
+ ```
81
+
82
+ ### The Diagnosis Pipeline
83
+
84
+ ```
85
+ Problem → investigator → verifier (ACH + Devil's Advocate) → solver → Actionable solutions
86
+ ```
87
+
88
+ ### Reverse Engineering
89
+
90
+ ```
91
+ Existing code → scope-discoverer → prd-creator → code-verifier → document-reviewer → Design Docs
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Installation
97
+
98
+ ### Requirements
99
+
100
+ - [Codex CLI](https://developers.openai.com/codex/cli) (latest)
101
+ - Node.js >= 20
102
+
103
+ ### Install
104
+
105
+ ```bash
106
+ cd your-project
107
+ npx codex-workflows install
108
+ ```
109
+
110
+ This copies into your project:
111
+ - `.agents/skills/` — Codex skills (foundational + recipes)
112
+ - `.codex/agents/` — Subagent TOML definitions
113
+ - Manifest file for tracking managed files
114
+
115
+ ### Update
116
+
117
+ ```bash
118
+ # Preview what will change
119
+ npx codex-workflows update --dry-run
120
+
121
+ # Apply updates
122
+ npx codex-workflows update
123
+ ```
124
+
125
+ Files you've modified locally are preserved — the updater compares each file against its hash at install time and skips any file you've changed. New files from the update are added automatically.
126
+
127
+ ```bash
128
+ # Check installed version
129
+ npx codex-workflows status
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Recipe Workflows
135
+
136
+ Invoke recipes with `$recipe-name` in Codex. Type `$recipe-` and use tab completion to see all available recipes.
137
+
138
+ ### Backend & General
139
+
140
+ | Recipe | What it does | When to use |
141
+ |--------|-------------|-------------|
142
+ | `$recipe-implement` | Full lifecycle with layer routing (backend/frontend/fullstack) | New features — universal entry point |
143
+ | `$recipe-task` | Single task with rule selection | Bug fixes, small changes |
144
+ | `$recipe-design` | Requirements → ADR/Design Doc | Architecture planning |
145
+ | `$recipe-plan` | Design Doc → test skeletons → work plan | Planning phase |
146
+ | `$recipe-build` | Execute backend tasks autonomously | Resume backend implementation |
147
+ | `$recipe-review` | Design Doc compliance validation with auto-fixes | Post-implementation check |
148
+ | `$recipe-diagnose` | Problem investigation → verification → solution | Bug investigation |
149
+ | `$recipe-reverse-engineer` | Generate PRD + Design Docs from existing code | Legacy system documentation |
150
+ | `$recipe-add-integration-tests` | Add integration/E2E tests from Design Doc | Test coverage for existing code |
151
+ | `$recipe-update-doc` | Update existing Design Doc / PRD / ADR with review | Spec changes, document maintenance |
152
+
153
+ ### Frontend (React/TypeScript)
154
+
155
+ | Recipe | What it does | When to use |
156
+ |--------|-------------|-------------|
157
+ | `$recipe-front-design` | Requirements → UI Spec → frontend Design Doc | Frontend architecture planning |
158
+ | `$recipe-front-plan` | Frontend Design Doc → test skeletons → work plan | Frontend planning phase |
159
+ | `$recipe-front-build` | Execute frontend tasks with RTL + quality checks | Resume frontend implementation |
160
+ | `$recipe-front-review` | Frontend compliance validation with React-specific fixes | Frontend post-implementation check |
161
+
162
+ ### Fullstack (Cross-Layer)
163
+
164
+ | Recipe | What it does | When to use |
165
+ |--------|-------------|-------------|
166
+ | `$recipe-fullstack-implement` | Full lifecycle with separate Design Docs per layer | Cross-layer features |
167
+ | `$recipe-fullstack-build` | Execute tasks with layer-aware agent routing | Resume cross-layer implementation |
168
+
169
+ ### Examples
170
+
171
+ **Full feature development:**
172
+ ```
173
+ $recipe-implement Add user authentication with JWT and role-based access control
174
+ ```
175
+
176
+ **Quick fix with proper rule selection:**
177
+ ```
178
+ $recipe-task Fix validation error message in checkout form
179
+ ```
180
+
181
+ **Investigate a bug:**
182
+ ```
183
+ $recipe-diagnose API returns 500 error on user login after deployment
184
+ ```
185
+
186
+ **Document undocumented legacy code:**
187
+ ```
188
+ $recipe-reverse-engineer src/auth module
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Foundational Skills
194
+
195
+ These load automatically when the conversation context matches — no explicit invocation needed:
196
+
197
+ | Skill | What it provides |
198
+ |-------|-----------------|
199
+ | `coding-rules` | Code quality, function design, error handling, refactoring |
200
+ | `testing` | TDD Red-Green-Refactor, test types, AAA pattern, mocking |
201
+ | `ai-development-guide` | Anti-patterns, debugging (5 Whys), quality check workflow |
202
+ | `documentation-criteria` | Document creation rules and templates (PRD, ADR, Design Doc, Work Plan) |
203
+ | `implementation-approach` | Strategy selection: vertical / horizontal / hybrid slicing |
204
+ | `integration-e2e-testing` | Integration/E2E test design, ROI calculation, review criteria |
205
+ | `task-analyzer` | Task analysis, scale estimation, skill selection |
206
+ | `subagents-orchestration-guide` | Multi-agent coordination, workflow flows, autonomous execution |
207
+
208
+ Language-specific references are included for TypeScript/React projects (`coding-rules/references/typescript.md`, `testing/references/typescript.md`).
209
+
210
+ ---
211
+
212
+ ## Subagents
213
+
214
+ Codex spawns these as needed during recipe execution. Each agent runs in its own context with specialized instructions and skill configurations.
215
+
216
+ ### Document Creation Agents
217
+
218
+ | Agent | Role |
219
+ |-------|------|
220
+ | `requirement-analyzer` | Requirements analysis and work scale determination |
221
+ | `prd-creator` | PRD creation and structuring |
222
+ | `technical-designer` | ADR and Design Doc creation (backend) |
223
+ | `technical-designer-frontend` | Frontend ADR and Design Doc creation (React) |
224
+ | `ui-spec-designer` | UI Specification from PRD and optional prototype code |
225
+ | `work-planner` | Work plan creation from Design Docs |
226
+ | `document-reviewer` | Document consistency and approval |
227
+ | `design-sync` | Cross-document consistency verification |
228
+
229
+ ### Implementation Agents
230
+
231
+ | Agent | Role |
232
+ |-------|------|
233
+ | `task-decomposer` | Work plan → atomic task files |
234
+ | `task-executor` | TDD implementation following task files (backend) |
235
+ | `task-executor-frontend` | React implementation with Testing Library |
236
+ | `quality-fixer` | Quality checks and fixes until all pass (backend) |
237
+ | `quality-fixer-frontend` | React-specific quality checks (TypeScript, RTL, bundle) |
238
+ | `acceptance-test-generator` | Test skeleton generation from acceptance criteria |
239
+ | `integration-test-reviewer` | Test quality review |
240
+
241
+ ### Analysis Agents
242
+
243
+ | Agent | Role |
244
+ |-------|------|
245
+ | `code-reviewer` | Design Doc compliance validation |
246
+ | `code-verifier` | Document-code consistency verification |
247
+ | `rule-advisor` | Skill selection via metacognitive analysis |
248
+ | `scope-discoverer` | Codebase scope discovery for reverse docs |
249
+
250
+ ### Diagnosis Agents
251
+
252
+ | Agent | Role |
253
+ |-------|------|
254
+ | `investigator` | Evidence collection and hypothesis enumeration |
255
+ | `verifier` | Hypothesis validation (ACH + Devil's Advocate) |
256
+ | `solver` | Solution derivation with tradeoff analysis |
257
+
258
+ ---
259
+
260
+ ## How It Works
261
+
262
+ ### Scale-Based Workflow Selection
263
+
264
+ The framework automatically determines the right level of ceremony:
265
+
266
+ | Scale | File Count | What Happens |
267
+ |-------|------------|-------------|
268
+ | Small | 1-2 | Simplified plan → direct implementation |
269
+ | Medium | 3-5 | Design Doc → work plan → task execution |
270
+ | Large | 6+ | PRD → ADR → Design Doc → test skeletons → work plan → autonomous execution |
271
+
272
+ ### Autonomous Execution Mode
273
+
274
+ After work plan approval, the framework enters guided autonomous execution with escalation points:
275
+
276
+ 1. **task-executor** implements each task with TDD
277
+ 2. **quality-fixer** runs all checks (lint, tests, build) before every commit
278
+ 3. Escalation pauses execution when design deviation or ambiguity is detected
279
+ 4. Each task produces one commit — rollback-friendly granularity
280
+
281
+ ### Context Separation
282
+
283
+ Each subagent runs in a fresh context. This matters because:
284
+ - **document-reviewer** reviews without the author's bias
285
+ - **investigator** collects evidence without confirmation bias
286
+ - **code-reviewer** validates compliance without implementation context
287
+
288
+ ---
289
+
290
+ ## Project Structure
291
+
292
+ After installation, your project gets:
293
+
294
+ ```
295
+ your-project/
296
+ ├── .agents/skills/ # Codex skills
297
+ │ ├── coding-rules/ # Foundational (auto-loaded)
298
+ │ ├── testing/
299
+ │ ├── ai-development-guide/
300
+ │ ├── documentation-criteria/
301
+ │ ├── implementation-approach/
302
+ │ ├── integration-e2e-testing/
303
+ │ ├── task-analyzer/
304
+ │ ├── subagents-orchestration-guide/
305
+ │ ├── recipe-implement/ # Recipes ($recipe-*)
306
+ │ ├── recipe-design/
307
+ │ ├── recipe-build/
308
+ │ ├── recipe-plan/
309
+ │ ├── recipe-review/
310
+ │ ├── recipe-diagnose/
311
+ │ ├── recipe-task/
312
+ │ ├── recipe-update-doc/
313
+ │ ├── recipe-reverse-engineer/
314
+ │ └── recipe-add-integration-tests/
315
+ ├── .codex/agents/ # Subagent TOML definitions
316
+ │ ├── requirement-analyzer.toml
317
+ │ ├── technical-designer.toml
318
+ │ ├── task-executor.toml
319
+ │ └── ... (22 agents total)
320
+ └── docs/ # Created as you use the recipes
321
+ ├── prd/
322
+ ├── design/
323
+ ├── adr/
324
+ ├── ui-spec/
325
+ └── plans/
326
+ └── tasks/
327
+ ```
328
+
329
+ ---
330
+
331
+ ## FAQ
332
+
333
+ **Q: What models does this work with?**
334
+
335
+ A: Designed for GPT-5.4 (default). Subagents like rule-advisor use GPT-5.3-Codex-Spark for faster lightweight analysis. Models are configurable per agent in the TOML files.
336
+
337
+ **Q: Can I customize the agents?**
338
+
339
+ A: Yes. Edit the TOML files in `.codex/agents/` — change model, sandbox_mode, developer_instructions, or skills.config. Files you modify locally are preserved during `npx codex-workflows update`.
340
+
341
+ **Q: What's the difference between `$recipe-implement` and `$recipe-fullstack-implement`?**
342
+
343
+ A: `$recipe-implement` is the universal entry point. It runs requirement-analyzer first, detects affected layers from the codebase, and automatically routes to backend, frontend, or fullstack flow. `$recipe-fullstack-implement` skips the detection and goes straight into the fullstack flow (separate Design Docs per layer, design-sync, layer-aware task execution). Use `$recipe-implement` when you're not sure; use `$recipe-fullstack-implement` when you know upfront that the feature spans both layers.
344
+
345
+ **Q: How does this relate to Claude Code Workflows?**
346
+
347
+ A: codex-workflows is the Codex-native counterpart of [Claude Code Workflows](https://github.com/shinpr/claude-code-workflows). Same development philosophy, adapted for Codex CLI's subagent architecture and GPT model family.
348
+
349
+ **Q: Does this work with MCP servers?**
350
+
351
+ A: Yes. Codex skills and subagents work alongside [MCP](https://developers.openai.com/codex/mcp) — skills operate at the instruction layer while MCP operates at the tool transport layer. You can add MCP servers to any agent's TOML configuration.
352
+
353
+ **Q: What if a subagent gets stuck?**
354
+
355
+ A: Subagents escalate to the user when they encounter design deviations, ambiguous requirements, or specification conflicts. The framework stops autonomous execution and presents the issue with options.
356
+
357
+ ---
358
+
359
+ ## License
360
+
361
+ MIT License — free to use, modify, and distribute.
362
+
363
+ ---
364
+
365
+ Built and maintained by [@shinpr](https://github.com/shinpr)
package/bin/cli.js ADDED
@@ -0,0 +1,249 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const crypto = require("crypto");
6
+
7
+ const MANIFEST_FILE = ".codex-workflows-manifest.json";
8
+ const COPY_DIRS = [".agents", ".codex"];
9
+
10
+ function main(argv = process.argv, cwd = process.cwd()) {
11
+ const command = argv[2];
12
+ const targetDir = cwd;
13
+ const sourceDir = path.resolve(__dirname, "..");
14
+
15
+ function getVersion() {
16
+ try {
17
+ const pkg = JSON.parse(
18
+ fs.readFileSync(path.join(sourceDir, "package.json"), "utf8")
19
+ );
20
+ return pkg.version;
21
+ } catch (e) {
22
+ console.error(`Error reading package.json: ${e.message}`);
23
+ process.exit(2);
24
+ }
25
+ }
26
+
27
+ function fileHash(filePath) {
28
+ const content = fs.readFileSync(filePath);
29
+ return crypto.createHash("sha256").update(content).digest("hex");
30
+ }
31
+
32
+ function copyDirRecursive(src, dest) {
33
+ let copied = 0;
34
+ if (!fs.existsSync(src)) return copied;
35
+ fs.mkdirSync(dest, { recursive: true });
36
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
37
+ if (entry.isSymbolicLink()) continue;
38
+ const srcPath = path.join(src, entry.name);
39
+ const destPath = path.join(dest, entry.name);
40
+ if (entry.isDirectory()) {
41
+ copied += copyDirRecursive(srcPath, destPath);
42
+ } else {
43
+ fs.copyFileSync(srcPath, destPath);
44
+ copied++;
45
+ }
46
+ }
47
+ return copied;
48
+ }
49
+
50
+ function collectFiles(dir, base) {
51
+ const files = [];
52
+ if (!fs.existsSync(dir)) return files;
53
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
54
+ if (entry.isSymbolicLink()) continue;
55
+ const fullPath = path.join(dir, entry.name);
56
+ const relPath = path.join(base, entry.name);
57
+ if (entry.isDirectory()) {
58
+ files.push(...collectFiles(fullPath, relPath));
59
+ } else {
60
+ files.push(relPath);
61
+ }
62
+ }
63
+ return files;
64
+ }
65
+
66
+ function readManifest() {
67
+ const manifestPath = path.join(targetDir, MANIFEST_FILE);
68
+ if (!fs.existsSync(manifestPath)) return null;
69
+ try {
70
+ return JSON.parse(fs.readFileSync(manifestPath, "utf8"));
71
+ } catch (e) {
72
+ console.error(`Error: ${MANIFEST_FILE} is corrupt: ${e.message}`);
73
+ console.error("Delete the file and run 'install' again, or fix it manually.");
74
+ process.exit(2);
75
+ }
76
+ }
77
+
78
+ function writeManifest(fileHashes) {
79
+ const manifestPath = path.join(targetDir, MANIFEST_FILE);
80
+ const manifest = {
81
+ version: getVersion(),
82
+ installedAt: new Date().toISOString(),
83
+ files: fileHashes,
84
+ };
85
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
86
+ }
87
+
88
+ function install() {
89
+ const manifest = readManifest();
90
+ if (manifest) {
91
+ console.log(
92
+ `codex-workflows v${manifest.version} is already installed. Use 'update' to upgrade.`
93
+ );
94
+ process.exit(1);
95
+ }
96
+
97
+ const version = getVersion();
98
+ console.log(`Installing codex-workflows v${version}...\n`);
99
+
100
+ const fileHashes = {};
101
+ let totalCopied = 0;
102
+
103
+ for (const dir of COPY_DIRS) {
104
+ const src = path.join(sourceDir, dir);
105
+ const dest = path.join(targetDir, dir);
106
+ const copied = copyDirRecursive(src, dest);
107
+ totalCopied += copied;
108
+ for (const relPath of collectFiles(dest, dir)) {
109
+ fileHashes[relPath] = fileHash(path.join(targetDir, relPath));
110
+ }
111
+ if (copied > 0) console.log(` ${dir}/ — ${copied} files`);
112
+ }
113
+
114
+ writeManifest(fileHashes);
115
+ console.log(`\nDone. ${totalCopied} files installed.`);
116
+ }
117
+
118
+ function update(dryRun) {
119
+ const manifest = readManifest();
120
+ if (!manifest) {
121
+ console.log("codex-workflows is not installed. Run 'install' first.");
122
+ process.exit(1);
123
+ }
124
+
125
+ // Migrate old manifest format (array) to new format (hash map)
126
+ const installedHashes = Array.isArray(manifest.files)
127
+ ? Object.fromEntries(manifest.files.map(f => [f, null]))
128
+ : manifest.files;
129
+
130
+ const currentVersion = manifest.version;
131
+ const newVersion = getVersion();
132
+ console.log(
133
+ `${dryRun ? "[DRY RUN] " : ""}Updating codex-workflows v${currentVersion} → v${newVersion}\n`
134
+ );
135
+
136
+ let updated = 0;
137
+ let added = 0;
138
+ let skipped = 0;
139
+ let preserved = 0;
140
+ const preservedFiles = new Set();
141
+
142
+ for (const dir of COPY_DIRS) {
143
+ const src = path.join(sourceDir, dir);
144
+ if (!fs.existsSync(src)) continue;
145
+ const sourceFiles = collectFiles(src, dir);
146
+ for (const relPath of sourceFiles) {
147
+ const srcFile = path.join(sourceDir, relPath);
148
+ const destFile = path.join(targetDir, relPath);
149
+
150
+ // New file — always add
151
+ if (!fs.existsSync(destFile)) {
152
+ if (dryRun) console.log(` + ${relPath} (new)`);
153
+ else {
154
+ fs.mkdirSync(path.dirname(destFile), { recursive: true });
155
+ fs.copyFileSync(srcFile, destFile);
156
+ }
157
+ added++;
158
+ continue;
159
+ }
160
+
161
+ const srcContent = fs.readFileSync(srcFile);
162
+ const destContent = fs.readFileSync(destFile);
163
+
164
+ // Identical — skip
165
+ if (srcContent.equals(destContent)) { skipped++; continue; }
166
+
167
+ // Check if user modified the file since last install/update
168
+ const storedHash = installedHashes[relPath];
169
+ if (storedHash) {
170
+ const currentHash = crypto.createHash("sha256").update(destContent).digest("hex");
171
+ if (currentHash !== storedHash) {
172
+ // User modified this file — preserve their changes
173
+ console.log(` ~ ${relPath} (modified locally, skipping)`);
174
+ preservedFiles.add(relPath);
175
+ preserved++;
176
+ continue;
177
+ }
178
+ }
179
+
180
+ // File unchanged by user (or not previously tracked) — safe to update
181
+ if (dryRun) console.log(` * ${relPath} (updated)`);
182
+ else fs.copyFileSync(srcFile, destFile);
183
+ updated++;
184
+ }
185
+ }
186
+
187
+ if (!dryRun) {
188
+ const newHashes = {};
189
+ for (const dir of COPY_DIRS) {
190
+ for (const relPath of collectFiles(path.join(targetDir, dir), dir)) {
191
+ if (preservedFiles.has(relPath) && installedHashes[relPath]) {
192
+ // Keep original hash so preserved files stay protected on next update
193
+ newHashes[relPath] = installedHashes[relPath];
194
+ } else {
195
+ newHashes[relPath] = fileHash(path.join(targetDir, relPath));
196
+ }
197
+ }
198
+ }
199
+ writeManifest(newHashes);
200
+ }
201
+
202
+ const parts = [`${added} added`, `${updated} updated`, `${skipped} unchanged`];
203
+ if (preserved > 0) parts.push(`${preserved} preserved (local changes)`);
204
+ console.log(`\n${dryRun ? "[DRY RUN] " : ""}${parts.join(", ")}.`);
205
+ }
206
+
207
+ function status() {
208
+ const manifest = readManifest();
209
+ if (!manifest) {
210
+ console.log("codex-workflows is not installed.");
211
+ return;
212
+ }
213
+ const fileCount = Array.isArray(manifest.files)
214
+ ? manifest.files.length
215
+ : Object.keys(manifest.files).length;
216
+ console.log(`Version: ${manifest.version}`);
217
+ console.log(`Installed: ${manifest.installedAt}`);
218
+ console.log(`Files: ${fileCount} managed`);
219
+ }
220
+
221
+ function showHelp() {
222
+ console.log(`
223
+ codex-workflows — Agentic coding skills & subagents for Codex CLI
224
+
225
+ Usage:
226
+ npx codex-workflows install Install skills and agents
227
+ npx codex-workflows update Update managed files
228
+ npx codex-workflows update --dry-run Preview changes without applying
229
+ npx codex-workflows status Show installation info
230
+ npx codex-workflows --version Show version
231
+ npx codex-workflows --help Show this help
232
+ `);
233
+ }
234
+
235
+ switch (command) {
236
+ case "install": install(); break;
237
+ case "update": update(argv.includes("--dry-run")); break;
238
+ case "status": status(); break;
239
+ case "--version": case "-v": console.log(getVersion()); break;
240
+ case "--help": case "-h": case undefined: showHelp(); break;
241
+ default:
242
+ console.error(`Unknown command: ${command}`);
243
+ showHelp();
244
+ process.exit(1);
245
+ }
246
+ }
247
+
248
+ main();
249
+ module.exports = { main };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "codex-workflows",
3
+ "version": "0.1.0",
4
+ "description": "Task-oriented agentic coding framework for OpenAI Codex CLI — skills, recipes, and subagents for structured development workflows",
5
+ "license": "MIT",
6
+ "author": "Shinsuke Kagawa",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/shinpr/codex-workflows"
10
+ },
11
+ "bin": {
12
+ "codex-workflows": "./bin/cli.js"
13
+ },
14
+ "files": [
15
+ "bin/",
16
+ ".agents/",
17
+ ".codex/"
18
+ ],
19
+ "keywords": [
20
+ "codex",
21
+ "openai",
22
+ "agent-skills",
23
+ "agentic-coding",
24
+ "ai-coding",
25
+ "subagents",
26
+ "multi-agent",
27
+ "context-engineering",
28
+ "tdd",
29
+ "code-generation"
30
+ ],
31
+ "homepage": "https://github.com/shinpr/codex-workflows#readme",
32
+ "engines": {
33
+ "node": ">=20.0.0"
34
+ }
35
+ }