@orderful/droid 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/tools/codex/TOOL.yaml +2 -1
- package/dist/tools/codex/agents/codex-document-processor.md +145 -0
- package/dist/tools/codex/skills/droid-codex/SKILL.md +76 -1
- package/package.json +1 -1
- package/src/tools/codex/TOOL.yaml +2 -1
- package/src/tools/codex/agents/codex-document-processor.md +145 -0
- package/src/tools/codex/skills/droid-codex/SKILL.md +76 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @orderful/droid
|
|
2
2
|
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#113](https://github.com/Orderful/droid/pull/113) [`37245c2`](https://github.com/Orderful/droid/commit/37245c2a54427dc57f54ec80399d827997089e0a) Thanks [@frytyler](https://github.com/frytyler)! - Add `/codex artifact` command for adding supplementary documents to projects. Artifacts are supporting materials like customer interviews, research notes, and meeting summaries that live in `projects/{name}/artifacts/`.
|
|
8
|
+
|
|
9
|
+
## 0.21.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#111](https://github.com/Orderful/droid/pull/111) [`c14a3e2`](https://github.com/Orderful/droid/commit/c14a3e2acbf7a87052c9d5dba251502b8be067f9) Thanks [@frytyler](https://github.com/frytyler)! - Add codex-document-processor agent for importing documents to the codex. The agent handles PDF/markdown processing, frontmatter generation, and file writing - keeping the main conversation context lean during document imports.
|
|
14
|
+
|
|
3
15
|
## 0.20.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codex-document-processor
|
|
3
|
+
description: "Process documents (PDF, markdown) into codex-ready markdown with proper frontmatter. Use when importing files to the codex - handles extraction, formatting, and writing to the correct location."
|
|
4
|
+
tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Write
|
|
7
|
+
- Glob
|
|
8
|
+
color: yellow
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are a document processor for the Orderful codex. Your job is to transform source documents (PDFs, markdown files) into properly structured codex entries.
|
|
12
|
+
|
|
13
|
+
## Input
|
|
14
|
+
|
|
15
|
+
You will receive:
|
|
16
|
+
1. **File path** - The source document to process
|
|
17
|
+
2. **Document type** - One of: `prd`, `tech-design`, `topic`, `pattern`, `artifact`
|
|
18
|
+
3. **Project/entry name** - Where this should be stored in the codex
|
|
19
|
+
4. **Codex repo path** - The local path to orderful-codex repository
|
|
20
|
+
5. **Artifact filename** (optional, for artifacts) - Name for the artifact file
|
|
21
|
+
|
|
22
|
+
## Validation (Do This First)
|
|
23
|
+
|
|
24
|
+
Before processing, validate all inputs:
|
|
25
|
+
|
|
26
|
+
1. **Document type** - Must be one of: `prd`, `tech-design`, `topic`, `pattern`, `artifact`. Reject anything else.
|
|
27
|
+
2. **File path** - Must exist and be readable. Use Read tool to verify.
|
|
28
|
+
3. **Project/entry name** - Must be safe for filesystem paths:
|
|
29
|
+
- Only allow: alphanumeric, dashes, underscores
|
|
30
|
+
- **Reject** if contains: `..`, `/`, `\`, or any shell metacharacters (`$`, backtick, `|`, `;`, `&`, `>`, `<`)
|
|
31
|
+
- If invalid, return error immediately (do not attempt to sanitize)
|
|
32
|
+
4. **Codex repo path** - Must exist and contain expected structure
|
|
33
|
+
|
|
34
|
+
If any validation fails, return an error (see Error Handling below).
|
|
35
|
+
|
|
36
|
+
## Process
|
|
37
|
+
|
|
38
|
+
### 1. Read Source Document
|
|
39
|
+
|
|
40
|
+
Read the file at the provided path. For PDFs, extract all text content. For markdown, read as-is.
|
|
41
|
+
|
|
42
|
+
### 2. Extract Key Information
|
|
43
|
+
|
|
44
|
+
From the content, identify:
|
|
45
|
+
- **Title** - The document/feature name
|
|
46
|
+
- **Main content** - The substantive information
|
|
47
|
+
- **Codebase paths** (if tech-design) - Any code paths mentioned
|
|
48
|
+
- **Source** - Default based on type:
|
|
49
|
+
- PRD/tech-design: `confluence`
|
|
50
|
+
- Topic/pattern: `exploration`
|
|
51
|
+
- Artifact: infer from content (`interview`, `transcript`, `notes`, `meeting`, `research`, `spike`, `analysis`)
|
|
52
|
+
- **Status** - Default based on type:
|
|
53
|
+
- PRD/tech-design: `draft` (new imports start as drafts)
|
|
54
|
+
- Topic/pattern/artifact: `active`
|
|
55
|
+
|
|
56
|
+
### 3. Read and Apply Frontmatter Template
|
|
57
|
+
|
|
58
|
+
**Read the template from the codex repo** - don't hardcode frontmatter structure:
|
|
59
|
+
|
|
60
|
+
| Type | Template Path |
|
|
61
|
+
|------|---------------|
|
|
62
|
+
| `prd` | `{codex_repo}/templates/PRD.md` |
|
|
63
|
+
| `tech-design` | `{codex_repo}/templates/TECH-DESIGN.md` |
|
|
64
|
+
| `topic` | `{codex_repo}/templates/TOPIC.md` |
|
|
65
|
+
| `pattern` | `{codex_repo}/templates/PATTERN.md` |
|
|
66
|
+
| `artifact` | `{codex_repo}/templates/ARTIFACT.md` |
|
|
67
|
+
|
|
68
|
+
1. Read the appropriate template file
|
|
69
|
+
2. Extract its frontmatter structure
|
|
70
|
+
3. Fill in the values:
|
|
71
|
+
- `title` → extracted title
|
|
72
|
+
- `created` / `explored` → today's date (YYYY-MM-DD)
|
|
73
|
+
- `updated` → today's date (YYYY-MM-DD)
|
|
74
|
+
- `status` → `draft` for PRD/tech-design, `active` for topic/pattern
|
|
75
|
+
- `codebase_paths` → extracted paths, or omit if none found
|
|
76
|
+
- Keep other fields from template as-is
|
|
77
|
+
|
|
78
|
+
This ensures frontmatter stays in sync with the codex repo's templates.
|
|
79
|
+
|
|
80
|
+
### 4. Structure Content
|
|
81
|
+
|
|
82
|
+
Transform the source content into the codex format:
|
|
83
|
+
- Preserve the original information and structure where sensible
|
|
84
|
+
- Use markdown headings, lists, and tables appropriately
|
|
85
|
+
- Remove any PDF artifacts or formatting noise
|
|
86
|
+
- Keep the content substantive - don't pad with empty template sections
|
|
87
|
+
|
|
88
|
+
### 5. Write Output
|
|
89
|
+
|
|
90
|
+
Write the processed markdown to the correct location:
|
|
91
|
+
|
|
92
|
+
| Type | Output Path |
|
|
93
|
+
|------|-------------|
|
|
94
|
+
| `prd` | `{codex_repo}/projects/{name}/PRD.md` |
|
|
95
|
+
| `tech-design` | `{codex_repo}/projects/{name}/TECH-DESIGN.md` |
|
|
96
|
+
| `topic` | `{codex_repo}/topics/{name}.md` |
|
|
97
|
+
| `pattern` | `{codex_repo}/patterns/{name}.md` |
|
|
98
|
+
| `artifact` | `{codex_repo}/projects/{name}/artifacts/{filename}.md` |
|
|
99
|
+
|
|
100
|
+
For artifacts, derive `{filename}` from the artifact filename input or the source file's name (slugified).
|
|
101
|
+
|
|
102
|
+
Create the directory if it doesn't exist.
|
|
103
|
+
|
|
104
|
+
**If file already exists:** Return an error. Do not overwrite without explicit confirmation from the main conversation. The error response should indicate the file exists so the user can decide whether to proceed.
|
|
105
|
+
|
|
106
|
+
### 6. Return Result
|
|
107
|
+
|
|
108
|
+
Return a brief JSON summary:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"status": "success",
|
|
113
|
+
"file_path": "/path/to/written/file.md",
|
|
114
|
+
"title": "Extracted document title",
|
|
115
|
+
"type": "prd",
|
|
116
|
+
"summary": "One sentence describing what was processed"
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Important Notes
|
|
121
|
+
|
|
122
|
+
- **Preserve substance over form** - The goal is to capture the document's information, not perfectly replicate its layout
|
|
123
|
+
- **Don't invent content** - Only include information that exists in the source document
|
|
124
|
+
- **Handle missing sections gracefully** - If the source doesn't have a section (e.g., no "Testing Strategy"), omit it rather than leaving empty placeholders
|
|
125
|
+
- **Omit empty frontmatter fields** - If `codebase_paths` can't be determined, omit the field entirely rather than using placeholders
|
|
126
|
+
- **Canadian spelling** - Use behaviour, colour, etc.
|
|
127
|
+
|
|
128
|
+
## Error Handling
|
|
129
|
+
|
|
130
|
+
If anything fails, return an error response instead of the success format:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"status": "error",
|
|
135
|
+
"error_type": "validation_failed" | "file_not_found" | "extraction_failed" | "file_exists" | "write_failed",
|
|
136
|
+
"message": "Human-readable description of what went wrong"
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Error types:**
|
|
141
|
+
- `validation_failed` - Invalid document type, unsafe name, or missing codex repo
|
|
142
|
+
- `file_not_found` - Source file doesn't exist or isn't readable
|
|
143
|
+
- `extraction_failed` - Couldn't extract meaningful content from the document
|
|
144
|
+
- `file_exists` - Target file already exists (user must confirm overwrite)
|
|
145
|
+
- `write_failed` - Couldn't write to target location (permissions, disk space, etc.)
|
|
@@ -122,7 +122,8 @@ The codex has three categories:
|
|
|
122
122
|
| `/codex search {query}` | Search across everything |
|
|
123
123
|
| `/codex new {name}` | Scaffold new project from templates |
|
|
124
124
|
| `/codex decision {text}` | Append to active project's DECISIONS.md |
|
|
125
|
-
| `/codex snapshot {file} {name}` | Import PDF/markdown to
|
|
125
|
+
| `/codex snapshot {type} {file} {name}` | Import PDF/markdown to codex (uses agent) |
|
|
126
|
+
| `/codex artifact {file} {project}` | Add supporting artifact to project (uses agent) |
|
|
126
127
|
| `/codex add topic {name}` | Add explored topic with freshness metadata |
|
|
127
128
|
|
|
128
129
|
## Loading an Entry
|
|
@@ -153,6 +154,7 @@ All codex files have frontmatter:
|
|
|
153
154
|
---
|
|
154
155
|
title: Feature Name
|
|
155
156
|
type: prd | tech-design | context | decisions | pattern | topic
|
|
157
|
+
status: draft | active | complete | archived
|
|
156
158
|
created: 2026-01-07
|
|
157
159
|
updated: 2026-01-07
|
|
158
160
|
confidence: high | medium | low
|
|
@@ -162,6 +164,14 @@ codebase_paths:
|
|
|
162
164
|
---
|
|
163
165
|
```
|
|
164
166
|
|
|
167
|
+
**Status values:**
|
|
168
|
+
- `draft` - Initial capture, not ready for consumption
|
|
169
|
+
- `active` - Current, being used for implementation
|
|
170
|
+
- `complete` - Project shipped, kept for reference
|
|
171
|
+
- `archived` - No longer relevant, kept for history
|
|
172
|
+
|
|
173
|
+
Note: Topics use `draft | active | archived` (no "complete"). Patterns use `active | archived` (no draft phase).
|
|
174
|
+
|
|
165
175
|
**When loading any file:**
|
|
166
176
|
|
|
167
177
|
1. Parse frontmatter for `updated` date
|
|
@@ -222,6 +232,71 @@ Full procedure: `references/decisions.md`
|
|
|
222
232
|
|
|
223
233
|
Full procedure: `references/topics.md`
|
|
224
234
|
|
|
235
|
+
## Importing Documents
|
|
236
|
+
|
|
237
|
+
**Trigger:** `/codex snapshot {type} {file} {name}` or user wants to add a file to the codex
|
|
238
|
+
|
|
239
|
+
**IMPORTANT:** Always use the `codex-document-processor` agent to process documents. This keeps the main conversation context lean by offloading heavy document processing.
|
|
240
|
+
|
|
241
|
+
**Procedure:**
|
|
242
|
+
|
|
243
|
+
1. Determine the document type (required): `prd`, `tech-design`, `topic`, or `pattern`
|
|
244
|
+
2. Spawn the `codex-document-processor` agent with:
|
|
245
|
+
- File path to the source document
|
|
246
|
+
- Document type
|
|
247
|
+
- Project/entry name
|
|
248
|
+
- Codex repo path from config
|
|
249
|
+
3. Agent processes the document:
|
|
250
|
+
- Reads and extracts content
|
|
251
|
+
- Applies appropriate frontmatter template
|
|
252
|
+
- Writes to correct location in codex repo
|
|
253
|
+
- Returns file path and summary
|
|
254
|
+
4. **Back in main conversation:** Handle git workflow
|
|
255
|
+
- Create branch: `codex/snapshot-{name}`
|
|
256
|
+
- Commit the new file
|
|
257
|
+
- Push and create PR via `gh pr create`
|
|
258
|
+
5. Share PR link with user
|
|
259
|
+
|
|
260
|
+
**Example invocations:**
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Explicit snapshot command
|
|
264
|
+
/codex snapshot prd ~/Downloads/transaction-templates-prd.pdf transaction-templates
|
|
265
|
+
|
|
266
|
+
# Natural language (still uses the agent)
|
|
267
|
+
"Add this PRD to the transaction-templates project" + attach file
|
|
268
|
+
"Import this tech design to generic-scenario-testing"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The agent handles: PDF reading, content extraction, frontmatter generation, file writing.
|
|
272
|
+
The main conversation handles: git branch, commit, PR creation, user interaction.
|
|
273
|
+
|
|
274
|
+
## Adding Artifacts
|
|
275
|
+
|
|
276
|
+
**Trigger:** `/codex artifact {file} {project}` or user wants to add supporting material to a project
|
|
277
|
+
|
|
278
|
+
Artifacts are supplementary documents that support a project but aren't core document types (PRD, TECH-DESIGN, DECISIONS). Examples:
|
|
279
|
+
- Customer interviews / transcripts
|
|
280
|
+
- Research notes
|
|
281
|
+
- Meeting summaries
|
|
282
|
+
- Spike findings
|
|
283
|
+
- Competitor analysis
|
|
284
|
+
|
|
285
|
+
**Procedure:**
|
|
286
|
+
|
|
287
|
+
1. Use the `codex-document-processor` agent with type `artifact`
|
|
288
|
+
2. Agent writes to `{codex_repo}/projects/{project}/artifacts/{filename}.md`
|
|
289
|
+
3. Handle git workflow (branch, commit, PR)
|
|
290
|
+
|
|
291
|
+
**Example invocations:**
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
/codex artifact ~/Downloads/customer-interview-acme.pdf transaction-templates
|
|
295
|
+
/codex artifact ~/notes/spike-handlebars-perf.md partnership-automation
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Artifacts get lighter frontmatter with `type: artifact` and source like `interview`, `transcript`, `notes`, `meeting`, `research`, `spike`, or `analysis`.
|
|
299
|
+
|
|
225
300
|
## Creating New Projects
|
|
226
301
|
|
|
227
302
|
**Trigger:** `/codex new {name}` or user wants to start new project entry
|
package/package.json
CHANGED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codex-document-processor
|
|
3
|
+
description: "Process documents (PDF, markdown) into codex-ready markdown with proper frontmatter. Use when importing files to the codex - handles extraction, formatting, and writing to the correct location."
|
|
4
|
+
tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Write
|
|
7
|
+
- Glob
|
|
8
|
+
color: yellow
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are a document processor for the Orderful codex. Your job is to transform source documents (PDFs, markdown files) into properly structured codex entries.
|
|
12
|
+
|
|
13
|
+
## Input
|
|
14
|
+
|
|
15
|
+
You will receive:
|
|
16
|
+
1. **File path** - The source document to process
|
|
17
|
+
2. **Document type** - One of: `prd`, `tech-design`, `topic`, `pattern`, `artifact`
|
|
18
|
+
3. **Project/entry name** - Where this should be stored in the codex
|
|
19
|
+
4. **Codex repo path** - The local path to orderful-codex repository
|
|
20
|
+
5. **Artifact filename** (optional, for artifacts) - Name for the artifact file
|
|
21
|
+
|
|
22
|
+
## Validation (Do This First)
|
|
23
|
+
|
|
24
|
+
Before processing, validate all inputs:
|
|
25
|
+
|
|
26
|
+
1. **Document type** - Must be one of: `prd`, `tech-design`, `topic`, `pattern`, `artifact`. Reject anything else.
|
|
27
|
+
2. **File path** - Must exist and be readable. Use Read tool to verify.
|
|
28
|
+
3. **Project/entry name** - Must be safe for filesystem paths:
|
|
29
|
+
- Only allow: alphanumeric, dashes, underscores
|
|
30
|
+
- **Reject** if contains: `..`, `/`, `\`, or any shell metacharacters (`$`, backtick, `|`, `;`, `&`, `>`, `<`)
|
|
31
|
+
- If invalid, return error immediately (do not attempt to sanitize)
|
|
32
|
+
4. **Codex repo path** - Must exist and contain expected structure
|
|
33
|
+
|
|
34
|
+
If any validation fails, return an error (see Error Handling below).
|
|
35
|
+
|
|
36
|
+
## Process
|
|
37
|
+
|
|
38
|
+
### 1. Read Source Document
|
|
39
|
+
|
|
40
|
+
Read the file at the provided path. For PDFs, extract all text content. For markdown, read as-is.
|
|
41
|
+
|
|
42
|
+
### 2. Extract Key Information
|
|
43
|
+
|
|
44
|
+
From the content, identify:
|
|
45
|
+
- **Title** - The document/feature name
|
|
46
|
+
- **Main content** - The substantive information
|
|
47
|
+
- **Codebase paths** (if tech-design) - Any code paths mentioned
|
|
48
|
+
- **Source** - Default based on type:
|
|
49
|
+
- PRD/tech-design: `confluence`
|
|
50
|
+
- Topic/pattern: `exploration`
|
|
51
|
+
- Artifact: infer from content (`interview`, `transcript`, `notes`, `meeting`, `research`, `spike`, `analysis`)
|
|
52
|
+
- **Status** - Default based on type:
|
|
53
|
+
- PRD/tech-design: `draft` (new imports start as drafts)
|
|
54
|
+
- Topic/pattern/artifact: `active`
|
|
55
|
+
|
|
56
|
+
### 3. Read and Apply Frontmatter Template
|
|
57
|
+
|
|
58
|
+
**Read the template from the codex repo** - don't hardcode frontmatter structure:
|
|
59
|
+
|
|
60
|
+
| Type | Template Path |
|
|
61
|
+
|------|---------------|
|
|
62
|
+
| `prd` | `{codex_repo}/templates/PRD.md` |
|
|
63
|
+
| `tech-design` | `{codex_repo}/templates/TECH-DESIGN.md` |
|
|
64
|
+
| `topic` | `{codex_repo}/templates/TOPIC.md` |
|
|
65
|
+
| `pattern` | `{codex_repo}/templates/PATTERN.md` |
|
|
66
|
+
| `artifact` | `{codex_repo}/templates/ARTIFACT.md` |
|
|
67
|
+
|
|
68
|
+
1. Read the appropriate template file
|
|
69
|
+
2. Extract its frontmatter structure
|
|
70
|
+
3. Fill in the values:
|
|
71
|
+
- `title` → extracted title
|
|
72
|
+
- `created` / `explored` → today's date (YYYY-MM-DD)
|
|
73
|
+
- `updated` → today's date (YYYY-MM-DD)
|
|
74
|
+
- `status` → `draft` for PRD/tech-design, `active` for topic/pattern
|
|
75
|
+
- `codebase_paths` → extracted paths, or omit if none found
|
|
76
|
+
- Keep other fields from template as-is
|
|
77
|
+
|
|
78
|
+
This ensures frontmatter stays in sync with the codex repo's templates.
|
|
79
|
+
|
|
80
|
+
### 4. Structure Content
|
|
81
|
+
|
|
82
|
+
Transform the source content into the codex format:
|
|
83
|
+
- Preserve the original information and structure where sensible
|
|
84
|
+
- Use markdown headings, lists, and tables appropriately
|
|
85
|
+
- Remove any PDF artifacts or formatting noise
|
|
86
|
+
- Keep the content substantive - don't pad with empty template sections
|
|
87
|
+
|
|
88
|
+
### 5. Write Output
|
|
89
|
+
|
|
90
|
+
Write the processed markdown to the correct location:
|
|
91
|
+
|
|
92
|
+
| Type | Output Path |
|
|
93
|
+
|------|-------------|
|
|
94
|
+
| `prd` | `{codex_repo}/projects/{name}/PRD.md` |
|
|
95
|
+
| `tech-design` | `{codex_repo}/projects/{name}/TECH-DESIGN.md` |
|
|
96
|
+
| `topic` | `{codex_repo}/topics/{name}.md` |
|
|
97
|
+
| `pattern` | `{codex_repo}/patterns/{name}.md` |
|
|
98
|
+
| `artifact` | `{codex_repo}/projects/{name}/artifacts/{filename}.md` |
|
|
99
|
+
|
|
100
|
+
For artifacts, derive `{filename}` from the artifact filename input or the source file's name (slugified).
|
|
101
|
+
|
|
102
|
+
Create the directory if it doesn't exist.
|
|
103
|
+
|
|
104
|
+
**If file already exists:** Return an error. Do not overwrite without explicit confirmation from the main conversation. The error response should indicate the file exists so the user can decide whether to proceed.
|
|
105
|
+
|
|
106
|
+
### 6. Return Result
|
|
107
|
+
|
|
108
|
+
Return a brief JSON summary:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"status": "success",
|
|
113
|
+
"file_path": "/path/to/written/file.md",
|
|
114
|
+
"title": "Extracted document title",
|
|
115
|
+
"type": "prd",
|
|
116
|
+
"summary": "One sentence describing what was processed"
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Important Notes
|
|
121
|
+
|
|
122
|
+
- **Preserve substance over form** - The goal is to capture the document's information, not perfectly replicate its layout
|
|
123
|
+
- **Don't invent content** - Only include information that exists in the source document
|
|
124
|
+
- **Handle missing sections gracefully** - If the source doesn't have a section (e.g., no "Testing Strategy"), omit it rather than leaving empty placeholders
|
|
125
|
+
- **Omit empty frontmatter fields** - If `codebase_paths` can't be determined, omit the field entirely rather than using placeholders
|
|
126
|
+
- **Canadian spelling** - Use behaviour, colour, etc.
|
|
127
|
+
|
|
128
|
+
## Error Handling
|
|
129
|
+
|
|
130
|
+
If anything fails, return an error response instead of the success format:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"status": "error",
|
|
135
|
+
"error_type": "validation_failed" | "file_not_found" | "extraction_failed" | "file_exists" | "write_failed",
|
|
136
|
+
"message": "Human-readable description of what went wrong"
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Error types:**
|
|
141
|
+
- `validation_failed` - Invalid document type, unsafe name, or missing codex repo
|
|
142
|
+
- `file_not_found` - Source file doesn't exist or isn't readable
|
|
143
|
+
- `extraction_failed` - Couldn't extract meaningful content from the document
|
|
144
|
+
- `file_exists` - Target file already exists (user must confirm overwrite)
|
|
145
|
+
- `write_failed` - Couldn't write to target location (permissions, disk space, etc.)
|
|
@@ -122,7 +122,8 @@ The codex has three categories:
|
|
|
122
122
|
| `/codex search {query}` | Search across everything |
|
|
123
123
|
| `/codex new {name}` | Scaffold new project from templates |
|
|
124
124
|
| `/codex decision {text}` | Append to active project's DECISIONS.md |
|
|
125
|
-
| `/codex snapshot {file} {name}` | Import PDF/markdown to
|
|
125
|
+
| `/codex snapshot {type} {file} {name}` | Import PDF/markdown to codex (uses agent) |
|
|
126
|
+
| `/codex artifact {file} {project}` | Add supporting artifact to project (uses agent) |
|
|
126
127
|
| `/codex add topic {name}` | Add explored topic with freshness metadata |
|
|
127
128
|
|
|
128
129
|
## Loading an Entry
|
|
@@ -153,6 +154,7 @@ All codex files have frontmatter:
|
|
|
153
154
|
---
|
|
154
155
|
title: Feature Name
|
|
155
156
|
type: prd | tech-design | context | decisions | pattern | topic
|
|
157
|
+
status: draft | active | complete | archived
|
|
156
158
|
created: 2026-01-07
|
|
157
159
|
updated: 2026-01-07
|
|
158
160
|
confidence: high | medium | low
|
|
@@ -162,6 +164,14 @@ codebase_paths:
|
|
|
162
164
|
---
|
|
163
165
|
```
|
|
164
166
|
|
|
167
|
+
**Status values:**
|
|
168
|
+
- `draft` - Initial capture, not ready for consumption
|
|
169
|
+
- `active` - Current, being used for implementation
|
|
170
|
+
- `complete` - Project shipped, kept for reference
|
|
171
|
+
- `archived` - No longer relevant, kept for history
|
|
172
|
+
|
|
173
|
+
Note: Topics use `draft | active | archived` (no "complete"). Patterns use `active | archived` (no draft phase).
|
|
174
|
+
|
|
165
175
|
**When loading any file:**
|
|
166
176
|
|
|
167
177
|
1. Parse frontmatter for `updated` date
|
|
@@ -222,6 +232,71 @@ Full procedure: `references/decisions.md`
|
|
|
222
232
|
|
|
223
233
|
Full procedure: `references/topics.md`
|
|
224
234
|
|
|
235
|
+
## Importing Documents
|
|
236
|
+
|
|
237
|
+
**Trigger:** `/codex snapshot {type} {file} {name}` or user wants to add a file to the codex
|
|
238
|
+
|
|
239
|
+
**IMPORTANT:** Always use the `codex-document-processor` agent to process documents. This keeps the main conversation context lean by offloading heavy document processing.
|
|
240
|
+
|
|
241
|
+
**Procedure:**
|
|
242
|
+
|
|
243
|
+
1. Determine the document type (required): `prd`, `tech-design`, `topic`, or `pattern`
|
|
244
|
+
2. Spawn the `codex-document-processor` agent with:
|
|
245
|
+
- File path to the source document
|
|
246
|
+
- Document type
|
|
247
|
+
- Project/entry name
|
|
248
|
+
- Codex repo path from config
|
|
249
|
+
3. Agent processes the document:
|
|
250
|
+
- Reads and extracts content
|
|
251
|
+
- Applies appropriate frontmatter template
|
|
252
|
+
- Writes to correct location in codex repo
|
|
253
|
+
- Returns file path and summary
|
|
254
|
+
4. **Back in main conversation:** Handle git workflow
|
|
255
|
+
- Create branch: `codex/snapshot-{name}`
|
|
256
|
+
- Commit the new file
|
|
257
|
+
- Push and create PR via `gh pr create`
|
|
258
|
+
5. Share PR link with user
|
|
259
|
+
|
|
260
|
+
**Example invocations:**
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# Explicit snapshot command
|
|
264
|
+
/codex snapshot prd ~/Downloads/transaction-templates-prd.pdf transaction-templates
|
|
265
|
+
|
|
266
|
+
# Natural language (still uses the agent)
|
|
267
|
+
"Add this PRD to the transaction-templates project" + attach file
|
|
268
|
+
"Import this tech design to generic-scenario-testing"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The agent handles: PDF reading, content extraction, frontmatter generation, file writing.
|
|
272
|
+
The main conversation handles: git branch, commit, PR creation, user interaction.
|
|
273
|
+
|
|
274
|
+
## Adding Artifacts
|
|
275
|
+
|
|
276
|
+
**Trigger:** `/codex artifact {file} {project}` or user wants to add supporting material to a project
|
|
277
|
+
|
|
278
|
+
Artifacts are supplementary documents that support a project but aren't core document types (PRD, TECH-DESIGN, DECISIONS). Examples:
|
|
279
|
+
- Customer interviews / transcripts
|
|
280
|
+
- Research notes
|
|
281
|
+
- Meeting summaries
|
|
282
|
+
- Spike findings
|
|
283
|
+
- Competitor analysis
|
|
284
|
+
|
|
285
|
+
**Procedure:**
|
|
286
|
+
|
|
287
|
+
1. Use the `codex-document-processor` agent with type `artifact`
|
|
288
|
+
2. Agent writes to `{codex_repo}/projects/{project}/artifacts/{filename}.md`
|
|
289
|
+
3. Handle git workflow (branch, commit, PR)
|
|
290
|
+
|
|
291
|
+
**Example invocations:**
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
/codex artifact ~/Downloads/customer-interview-acme.pdf transaction-templates
|
|
295
|
+
/codex artifact ~/notes/spike-handlebars-perf.md partnership-automation
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Artifacts get lighter frontmatter with `type: artifact` and source like `interview`, `transcript`, `notes`, `meeting`, `research`, `spike`, or `analysis`.
|
|
299
|
+
|
|
225
300
|
## Creating New Projects
|
|
226
301
|
|
|
227
302
|
**Trigger:** `/codex new {name}` or user wants to start new project entry
|