@orderful/droid 0.24.0 → 0.25.1

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 (47) hide show
  1. package/.eslintrc.json +6 -4
  2. package/AGENTS.md +58 -0
  3. package/CHANGELOG.md +35 -0
  4. package/README.md +11 -6
  5. package/dist/bin/droid.js +384 -170
  6. package/dist/commands/config.d.ts +15 -1
  7. package/dist/commands/config.d.ts.map +1 -1
  8. package/dist/commands/exec.d.ts +10 -0
  9. package/dist/commands/exec.d.ts.map +1 -0
  10. package/dist/commands/tui.d.ts.map +1 -1
  11. package/dist/index.js +171 -33
  12. package/dist/lib/migrations.d.ts.map +1 -1
  13. package/dist/lib/skills.d.ts.map +1 -1
  14. package/dist/tools/codex/TOOL.yaml +1 -1
  15. package/dist/tools/codex/skills/droid-codex/SKILL.md +92 -72
  16. package/dist/tools/codex/skills/droid-codex/references/creating.md +13 -51
  17. package/dist/tools/codex/skills/droid-codex/references/decisions.md +15 -19
  18. package/dist/tools/codex/skills/droid-codex/references/topics.md +14 -12
  19. package/dist/tools/codex/skills/droid-codex/scripts/git-finish-write.d.ts +31 -0
  20. package/dist/tools/codex/skills/droid-codex/scripts/git-finish-write.d.ts.map +1 -0
  21. package/dist/tools/codex/skills/droid-codex/scripts/git-finish-write.ts +236 -0
  22. package/dist/tools/codex/skills/droid-codex/scripts/git-preamble.d.ts +20 -0
  23. package/dist/tools/codex/skills/droid-codex/scripts/git-preamble.d.ts.map +1 -0
  24. package/dist/tools/codex/skills/droid-codex/scripts/git-preamble.ts +156 -0
  25. package/dist/tools/codex/skills/droid-codex/scripts/git-scripts.test.ts +364 -0
  26. package/dist/tools/codex/skills/droid-codex/scripts/git-start-write.d.ts +23 -0
  27. package/dist/tools/codex/skills/droid-codex/scripts/git-start-write.d.ts.map +1 -0
  28. package/dist/tools/codex/skills/droid-codex/scripts/git-start-write.ts +172 -0
  29. package/package.json +1 -1
  30. package/src/bin/droid.ts +9 -0
  31. package/src/commands/config.ts +38 -4
  32. package/src/commands/exec.ts +96 -0
  33. package/src/commands/install.ts +1 -1
  34. package/src/commands/setup.ts +6 -6
  35. package/src/commands/tui.tsx +254 -175
  36. package/src/lib/migrations.ts +103 -10
  37. package/src/lib/quotes.ts +6 -6
  38. package/src/lib/skills.ts +168 -45
  39. package/src/tools/codex/TOOL.yaml +1 -1
  40. package/src/tools/codex/skills/droid-codex/SKILL.md +92 -72
  41. package/src/tools/codex/skills/droid-codex/references/creating.md +13 -51
  42. package/src/tools/codex/skills/droid-codex/references/decisions.md +15 -19
  43. package/src/tools/codex/skills/droid-codex/references/topics.md +14 -12
  44. package/src/tools/codex/skills/droid-codex/scripts/git-finish-write.ts +236 -0
  45. package/src/tools/codex/skills/droid-codex/scripts/git-preamble.ts +156 -0
  46. package/src/tools/codex/skills/droid-codex/scripts/git-scripts.test.ts +364 -0
  47. package/src/tools/codex/skills/droid-codex/scripts/git-start-write.ts +172 -0
@@ -35,15 +35,54 @@ If prerequisites fail, guide user to fix:
35
35
  - Repo missing: `git clone git@github.com:orderful/orderful-codex.git {path}`
36
36
  - gh missing: `brew install gh && gh auth login`
37
37
 
38
- ## Sync Before Reading
38
+ ## Git Hygiene (CRITICAL)
39
39
 
40
- **Before any read operation** (loading, searching, listing), pull latest:
40
+ **Users should never see git complexity.** Use the deterministic scripts below - they handle all git operations silently and recover gracefully. Non-engineers use this tool - if they hit a git error, they're stuck.
41
+
42
+ ### Scripts
43
+
44
+ The codex skill includes three git scripts. **Always use these instead of raw git commands.**
45
+
46
+ | Script | Purpose | When to use |
47
+ |--------|---------|-------------|
48
+ | `git-preamble` | Ensure clean main + pull latest | Before ANY operation |
49
+ | `git-start-write` | Preamble + create branch | Before write operations |
50
+ | `git-finish-write` | Commit + PR + return to main | After write operations |
51
+
52
+ ### Read Operations (search, load, list)
41
53
 
42
54
  ```bash
43
- git -C {codex_repo} pull --rebase --quiet
55
+ droid config codex | droid exec droid-codex git-preamble --config -
56
+ # Then proceed with the read
44
57
  ```
45
58
 
46
- This ensures shared knowledge is always current. The pull is quiet to avoid noise, but if it fails (conflicts, network), warn the user.
59
+ ### Write Operations (new, decision, snapshot, artifact)
60
+
61
+ ```bash
62
+ # 1. Start write (runs preamble + creates branch)
63
+ droid config codex | droid exec droid-codex git-start-write --config - --branch codex/{action}-{name}
64
+
65
+ # 2. Make your changes (write files)
66
+
67
+ # 3. Finish write (commit + PR + return to main)
68
+ droid config codex | droid exec droid-codex git-finish-write --config - \
69
+ --message "{commit message}" \
70
+ --pr-title "{PR title}" \
71
+ --pr-body "{PR description}"
72
+ ```
73
+
74
+ The scripts return JSON with success/failure status. Check the result before proceeding.
75
+
76
+ ### Error Handling
77
+
78
+ The scripts handle errors internally:
79
+ - Silent recovery for transient issues
80
+ - Clear error messages in JSON output
81
+ - Automatic return to main even on partial failure
82
+
83
+ If a script fails, check the JSON `error` field and report a user-friendly message:
84
+ - "I hit a sync issue with the codex. Let me try again..."
85
+ - Only escalate as last resort: "The codex repo needs manual attention."
47
86
 
48
87
  ## Security
49
88
 
@@ -140,13 +179,17 @@ The codex has five categories:
140
179
 
141
180
  **Procedure:**
142
181
 
143
- 1. **Read `{codex_repo}/index.yaml`** - this contains all entry names and aliases for fast lookup
144
- 2. Match `{name}` against index keys and aliases (case-insensitive, partial match)
145
- 3. If multiple matches show list, let user pick
146
- 4. If single match → load directly from the matched path
147
- 5. For projects with multiple files show file list, let user pick which to load
148
- 6. Check freshness (see below)
149
- 7. Output loaded content
182
+ 1. **Run preamble first:**
183
+ ```bash
184
+ droid config codex | droid exec droid-codex git-preamble --config -
185
+ ```
186
+ 2. **Read `{codex_repo}/index.yaml`** - this contains all entry names and aliases for fast lookup
187
+ 3. Match `{name}` against index keys and aliases (case-insensitive, partial match)
188
+ 4. If multiple matches → show list, let user pick
189
+ 5. If single match → load directly from the matched path
190
+ 6. For projects with multiple files → show file list, let user pick which to load
191
+ 7. Check freshness (see below)
192
+ 8. Output loaded content
150
193
 
151
194
  **Why index?** Avoids expensive file-by-file searching. One read to find any entry by name or alias.
152
195
 
@@ -208,19 +251,10 @@ Scoped operations (`decision`, `snapshot`) require an active project:
208
251
  **Procedure:**
209
252
 
210
253
  1. Verify active project exists (if not, prompt to select)
211
- 2. Read `{codex_repo}/projects/{active}/DECISIONS.md`
212
- 3. Append new decision with today's date:
213
- ```markdown
214
- ## {YYYY-MM-DD}: {Decision summary from text}
215
-
216
- **Context:** {Extract from conversation}
217
-
218
- **Decision:** {The decision}
219
-
220
- **Rationale:** {Why this choice}
221
- ```
254
+ 2. **Run `git-start-write`** with branch `codex/decision-{short-summary}`
255
+ 3. Read and append to `{codex_repo}/projects/{active}/DECISIONS.md`
222
256
  4. Update `updated` date in frontmatter
223
- 5. Create branch, commit, and open PR via `gh pr create`
257
+ 5. **Run `git-finish-write`** with appropriate commit message and PR title
224
258
 
225
259
  Full procedure: `references/decisions.md`
226
260
 
@@ -230,14 +264,11 @@ Full procedure: `references/decisions.md`
230
264
 
231
265
  **Procedure:**
232
266
 
233
- 1. Create `{codex_repo}/topics/{name}.md`
234
- 2. Use template from `{codex_repo}/templates/TOPIC.md`
235
- 3. Fill in frontmatter:
236
- - `explored`: today's date
237
- - `confidence`: ask user or infer from exploration depth
238
- - `codebase_paths`: paths that were explored
267
+ 1. **Run `git-start-write`** with branch `codex/topic-{name}`
268
+ 2. Create `{codex_repo}/topics/{name}.md` from template
269
+ 3. Fill in frontmatter (explored, confidence, codebase_paths)
239
270
  4. Fill in content from current exploration/conversation
240
- 5. Create branch, commit, and open PR via `gh pr create`
271
+ 5. **Run `git-finish-write`** with appropriate commit message and PR title
241
272
 
242
273
  Full procedure: `references/topics.md`
243
274
 
@@ -250,21 +281,15 @@ Full procedure: `references/topics.md`
250
281
  **Procedure:**
251
282
 
252
283
  1. Determine the document type (required): `prd`, `tech-design`, `topic`, or `pattern`
253
- 2. Spawn the `codex-document-processor` agent with:
284
+ 2. **Run `git-start-write`** with branch `codex/snapshot-{name}`
285
+ 3. Spawn the `codex-document-processor` agent with:
254
286
  - File path to the source document
255
287
  - Document type
256
288
  - Project/entry name
257
289
  - Codex repo path from config
258
- 3. Agent processes the document:
259
- - Reads and extracts content
260
- - Applies appropriate frontmatter template
261
- - Writes to correct location in codex repo
262
- - Returns file path and summary
263
- 4. **Back in main conversation:** Handle git workflow
264
- - Create branch: `codex/snapshot-{name}`
265
- - Commit the new file
266
- - Push and create PR via `gh pr create`
267
- 5. Share PR link with user
290
+ 4. Agent writes the processed document to codex repo
291
+ 5. **Run `git-finish-write`** with appropriate commit message and PR title
292
+ 6. Share PR link with user
268
293
 
269
294
  **Example invocations:**
270
295
 
@@ -293,9 +318,10 @@ Artifacts are supplementary documents that support a project but aren't core doc
293
318
 
294
319
  **Procedure:**
295
320
 
296
- 1. Use the `codex-document-processor` agent with type `artifact`
297
- 2. Agent writes to `{codex_repo}/projects/{project}/artifacts/{filename}.md`
298
- 3. Handle git workflow (branch, commit, PR)
321
+ 1. **Run `git-start-write`** with branch `codex/artifact-{project}-{filename}`
322
+ 2. Use the `codex-document-processor` agent with type `artifact`
323
+ 3. Agent writes to `{codex_repo}/projects/{project}/artifacts/{filename}.md`
324
+ 4. **Run `git-finish-write`** with appropriate commit message and PR title
299
325
 
300
326
  **Example invocations:**
301
327
 
@@ -325,13 +351,11 @@ The `/codex new` command scaffolds new entries from templates:
325
351
 
326
352
  **Procedure:**
327
353
 
328
- 1. Create `{codex_repo}/projects/{name}/`
329
- 2. Copy templates from `{codex_repo}/templates/`:
330
- - PRD.md
331
- - TECH-DESIGN.md
332
- - DECISIONS.md
333
- 3. Fill in frontmatter with today's date
334
- 4. Create branch, commit, and open PR via `gh pr create`
354
+ 1. **Run `git-start-write`** with branch `codex/new-{name}`
355
+ 2. Create `{codex_repo}/projects/{name}/`
356
+ 3. Copy templates: PRD.md, TECH-DESIGN.md, DECISIONS.md
357
+ 4. Fill in frontmatter with today's date
358
+ 5. **Run `git-finish-write`** with appropriate commit message and PR title
335
359
 
336
360
  ### Domains
337
361
 
@@ -339,11 +363,10 @@ The `/codex new` command scaffolds new entries from templates:
339
363
 
340
364
  **Procedure:**
341
365
 
342
- 1. Create `{codex_repo}/domains/{name}.md`
343
- 2. Use template from `{codex_repo}/templates/DOMAIN.md`
344
- 3. Fill in frontmatter with today's date
345
- 4. Guide user through sections: Overview, Key Concepts, Entities, Lifecycle/States, Integration Points, Related
346
- 5. Create branch, commit, and open PR via `gh pr create`
366
+ 1. **Run `git-start-write`** with branch `codex/domain-{name}`
367
+ 2. Create `{codex_repo}/domains/{name}.md` from template
368
+ 3. Fill in frontmatter, guide user through sections
369
+ 4. **Run `git-finish-write`** with appropriate commit message and PR title
347
370
 
348
371
  ### Proposals
349
372
 
@@ -351,11 +374,10 @@ The `/codex new` command scaffolds new entries from templates:
351
374
 
352
375
  **Procedure:**
353
376
 
354
- 1. Create `{codex_repo}/proposals/{name}.md`
355
- 2. Use template from `{codex_repo}/templates/PROPOSAL.md`
356
- 3. Fill in frontmatter with today's date
357
- 4. Guide user through sections: Summary, Problem, Proposed Solution, Alternatives Considered, Open Questions, Next Steps
358
- 5. Create branch, commit, and open PR via `gh pr create`
377
+ 1. **Run `git-start-write`** with branch `codex/proposal-{name}`
378
+ 2. Create `{codex_repo}/proposals/{name}.md` from template
379
+ 3. Fill in frontmatter, guide user through sections
380
+ 4. **Run `git-finish-write`** with appropriate commit message and PR title
359
381
 
360
382
  ### Patterns and Topics
361
383
 
@@ -363,10 +385,10 @@ The `/codex new` command scaffolds new entries from templates:
363
385
 
364
386
  **Procedure:**
365
387
 
366
- 1. Create file at `{codex_repo}/patterns/{name}.md` or `{codex_repo}/topics/{name}.md`
367
- 2. Use template from `{codex_repo}/templates/PATTERN.md` or `{codex_repo}/templates/TOPIC.md`
388
+ 1. **Run `git-start-write`** with branch `codex/{pattern|topic}-{name}`
389
+ 2. Create file from template
368
390
  3. Fill in frontmatter with today's date
369
- 4. Create branch, commit, and open PR via `gh pr create`
391
+ 4. **Run `git-finish-write`** with appropriate commit message and PR title
370
392
 
371
393
  Full procedure: `references/creating.md`
372
394
 
@@ -387,12 +409,10 @@ When user runs `/project create --from codex:{name}`:
387
409
 
388
410
  ## Git Workflow
389
411
 
390
- **All codex changes must go through PRs** (main branch is protected):
391
-
392
- 1. Create branch: `codex/{action}-{name}` (e.g., `codex/decision-uuid-format`)
393
- 2. Make changes
394
- 3. Commit with descriptive message
395
- 4. Push and create PR via `gh pr create`
396
- 5. Share PR link with user
412
+ **See "Git Hygiene (CRITICAL)" section above.** All codex changes go through PRs (main branch is protected).
397
413
 
398
- Safe changes (new files, decision appends) are auto-merged by GitHub Action. Modifications to existing content require review.
414
+ **Key points:**
415
+ - Always run the preamble before any operation (ensures clean main + latest)
416
+ - Write operations: branch → commit → PR → **return to main**
417
+ - Safe changes (new files, decision appends) auto-merge via GitHub Action
418
+ - Never leave the repo on a feature branch
@@ -28,15 +28,18 @@ A project named '{name}' already exists. Did you mean to load it?
28
28
  → /codex {name}
29
29
  ```
30
30
 
31
- ### 3. Create Project Directory
31
+ ### 3. Start Write Operation
32
32
 
33
33
  ```bash
34
- mkdir -p {codex_repo}/projects/{name}
34
+ droid config codex | droid exec droid-codex git-start-write --config - --branch codex/new-{name}
35
35
  ```
36
36
 
37
- ### 4. Copy Templates
37
+ This runs the git preamble (ensures clean main + pulls latest) and creates the branch.
38
+
39
+ ### 4. Create Project Directory and Copy Templates
38
40
 
39
41
  ```bash
42
+ mkdir -p {codex_repo}/projects/{name}
40
43
  cp {codex_repo}/templates/PRD.md {codex_repo}/projects/{name}/
41
44
  cp {codex_repo}/templates/TECH-DESIGN.md {codex_repo}/projects/{name}/
42
45
  cp {codex_repo}/templates/DECISIONS.md {codex_repo}/projects/{name}/
@@ -56,19 +59,17 @@ If user provides context, fill in what we know:
56
59
  - TECH-DESIGN.md: Any architectural decisions mentioned
57
60
  - DECISIONS.md: Leave as template (decisions come during impl)
58
61
 
59
- ### 7. Create Branch and PR
62
+ ### 7. Finish Write Operation
60
63
 
61
64
  ```bash
62
- cd {codex_repo}
63
- git checkout -b codex/new-{name}
64
- git add projects/{name}/
65
- git commit -F - <<EOF
66
- feat(codex): scaffold {name} project
67
- EOF
68
- git push -u origin codex/new-{name}
69
- gh pr create --title "New project: {name}" --body "Scaffold for {name} project"
65
+ droid config codex | droid exec droid-codex git-finish-write --config - \
66
+ --message "feat(codex): scaffold {name} project" \
67
+ --pr-title "New project: {name}" \
68
+ --pr-body "Scaffold for {name} project"
70
69
  ```
71
70
 
71
+ This commits, pushes, creates PR, and returns to main.
72
+
72
73
  ### 8. Confirm to User
73
74
 
74
75
  ```
@@ -109,42 +110,3 @@ Next steps:
109
110
 
110
111
  Want me to help fill in any of these based on what we've discussed?
111
112
  ```
112
-
113
- ## With Pre-Existing Context
114
-
115
- If the user has already discussed the feature:
116
-
117
- **User:** "We're building audit logging to track all API changes for compliance. It'll use an event sourcing pattern."
118
-
119
- **User:** `/codex new audit-logging`
120
-
121
- **Result:** (PRD.md pre-filled with discussed context)
122
-
123
- ```markdown
124
- ---
125
- title: Audit Logging
126
- type: prd
127
- created: 2026-01-07
128
- updated: 2026-01-07
129
- confidence: medium
130
- source: implementation
131
- ---
132
-
133
- # Audit Logging - PRD
134
-
135
- ## Problem Statement
136
-
137
- Need to track all API changes for compliance requirements.
138
-
139
- ## Goals
140
-
141
- - Track all API changes
142
- - Support compliance auditing
143
- - {More goals to be defined}
144
-
145
- ## Non-Goals
146
-
147
- - {To be defined}
148
-
149
- ...
150
- ```
@@ -39,15 +39,19 @@ I'll add this decision. Can you clarify:
39
39
  - Were there alternatives you considered?
40
40
  ```
41
41
 
42
- ### 3. Read Existing DECISIONS.md
42
+ ### 3. Start Write Operation
43
43
 
44
44
  ```bash
45
- cat {codex_repo}/projects/{active}/DECISIONS.md
45
+ droid config codex | droid exec droid-codex git-start-write --config - --branch codex/decision-{short-summary}
46
46
  ```
47
47
 
48
- ### 4. Append New Decision
48
+ ### 4. Read and Update DECISIONS.md
49
+
50
+ ```bash
51
+ cat {codex_repo}/projects/{active}/DECISIONS.md
52
+ ```
49
53
 
50
- Add at the end, before the template marker:
54
+ Append new decision at the end:
51
55
 
52
56
  ```markdown
53
57
  ---
@@ -68,26 +72,18 @@ Add at the end, before the template marker:
68
72
  - {Expected outcomes, trade-offs}
69
73
  ```
70
74
 
71
- ### 5. Update Frontmatter
72
-
73
- Update the `updated` field to today's date.
75
+ Update the `updated` field in frontmatter to today's date.
74
76
 
75
- ### 6. Create Branch and PR
77
+ ### 5. Finish Write Operation
76
78
 
77
79
  ```bash
78
- cd {codex_repo}
79
- git checkout -b codex/decision-{short-summary}
80
- git add projects/{active}/DECISIONS.md
81
- git commit -F - <<EOF
82
- decision({active}): {summary}
83
- EOF
84
- git push -u origin codex/decision-{short-summary}
85
- gh pr create --title "Decision: {summary}" --body-file - <<EOF
86
- {full decision text}
87
- EOF
80
+ droid config codex | droid exec droid-codex git-finish-write --config - \
81
+ --message "decision({active}): {summary}" \
82
+ --pr-title "Decision: {summary}" \
83
+ --pr-body "{full decision text}"
88
84
  ```
89
85
 
90
- ### 7. Confirm to User
86
+ ### 6. Confirm to User
91
87
 
92
88
  ```
93
89
  ✅ Added decision to {active}/DECISIONS.md:
@@ -43,13 +43,19 @@ Ask user or infer:
43
43
  - `low` - Quick exploration, definitely incomplete
44
44
  - **Codebase paths:** Which directories/files were explored?
45
45
 
46
- ### 4. Read Template
46
+ ### 4. Start Write Operation
47
+
48
+ ```bash
49
+ droid config codex | droid exec droid-codex git-start-write --config - --branch codex/topic-{name}
50
+ ```
51
+
52
+ ### 5. Read Template
47
53
 
48
54
  ```bash
49
55
  cat {codex_repo}/templates/TOPIC.md
50
56
  ```
51
57
 
52
- ### 5. Create Topic File
58
+ ### 6. Create Topic File
53
59
 
54
60
  ```bash
55
61
  # Create the file
@@ -115,20 +121,16 @@ codebase_paths:
115
121
  - {Links to related topics, PRDs, or external docs}
116
122
  ```
117
123
 
118
- ### 6. Create Branch and PR
124
+ ### 7. Finish Write Operation
119
125
 
120
126
  ```bash
121
- cd {codex_repo}
122
- git checkout -b codex/topic-{name}
123
- git add topics/{name}.md
124
- git commit -F - <<EOF
125
- topic: add {name}
126
- EOF
127
- git push -u origin codex/topic-{name}
128
- gh pr create --title "Topic: {name}" --body "New topic from codebase exploration"
127
+ droid config codex | droid exec droid-codex git-finish-write --config - \
128
+ --message "topic: add {name}" \
129
+ --pr-title "Topic: {name}" \
130
+ --pr-body "New topic from codebase exploration"
129
131
  ```
130
132
 
131
- ### 7. Confirm to User
133
+ ### 8. Confirm to User
132
134
 
133
135
  ```
134
136
  ✅ Added topic: {name}
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * codex git-finish-write
4
+ *
5
+ * Completes a write operation by committing, pushing, creating a PR,
6
+ * and returning to main.
7
+ *
8
+ * Usage:
9
+ * droid config codex | droid exec droid-codex git-finish-write --config - \
10
+ * --message "feat: add new topic" \
11
+ * --pr-title "New topic: caching" \
12
+ * --pr-body "Added exploration of caching patterns"
13
+ *
14
+ * Options:
15
+ * --config <json> Config with codex_repo path (required)
16
+ * --message <text> Commit message (required)
17
+ * --pr-title <text> PR title (required)
18
+ * --pr-body <text> PR body (optional, defaults to commit message)
19
+ *
20
+ * What it does:
21
+ * 1. Stage all changes
22
+ * 2. Commit with message
23
+ * 3. Push branch to origin
24
+ * 4. Create PR via gh CLI
25
+ * 5. Return to main branch
26
+ *
27
+ * Output (JSON):
28
+ * { "success": true, "pr_url": "https://github.com/...", "branch": "codex/topic-caching" }
29
+ */
30
+ export {};
31
+ //# sourceMappingURL=git-finish-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-finish-write.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/codex/skills/droid-codex/scripts/git-finish-write.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}