Skip to content

Commit b152ada

Browse files
authored
Implement decision graph tool (#1)
1 parent 95e8cb7 commit b152ada

27 files changed

Lines changed: 1721 additions & 34 deletions

File tree

.config/lingo.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ADR
66
ADRs
77
Agilab
88
CD
9+
CLI
910
CRICOS
1011
Curtin
1112
EECMS

.config/spellcheck.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ skip_os_lookups = true
3535
# for topic specific lingo.
3636
use_builtin = true
3737

38-
3938
[Hunspell.quirks]
4039
# Transforms words that are provided by the tokenizer
4140
# into word fragments based on the capture groups which are to

.dg/org.kdl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org "edge-toolkit" {
2+
name "edge-toolkit"
3+
}

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ indent_style = space
88
max_line_length = 120
99
trim_trailing_whitespace = true
1010

11+
[SKILL.md]
12+
max_line_length = 200
13+
14+
[AGENTS.md]
15+
max_line_length = 300
16+
17+
[CLAUDE.md]
18+
max_line_length = 300
19+
1120
# Markdown files can have flexible indentation for lists
1221
[*.md]
1322
indent_size = unset
23+
24+
[.cache.json]
25+
end_of_line = unset
26+
insert_final_newline = unset

.gemini/hooks/check-code.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
# Check if edited files match decision doc code_paths.
3+
# Delegates to dg hooks check-code for the actual logic.
4+
if [ -n "$1" ]; then
5+
exec dg hooks check-code "$1"
6+
fi

.gemini/hooks/check-fixme.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
# Minimal wrapper - delegates to dg hooks check-fixme
3+
# This allows upgrading dg to get new functionality
4+
exec dg hooks check-fixme "$@"

.gemini/settings.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"context": {
3+
"fileName": ["AGENTS.md", "GEMINI.md"]
4+
},
5+
"hooks": {
6+
"AfterTool": [
7+
{
8+
"matcher": "^(Edit|WriteFile)$",
9+
"hooks": [
10+
{
11+
"type": "command",
12+
"command": ".gemini/hooks/check-fixme.sh"
13+
},
14+
{
15+
"type": "command",
16+
"command": ".gemini/hooks/check-code.sh"
17+
}
18+
]
19+
}
20+
]
21+
}
22+
}

.gemini/skills/adr/SKILL.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: adr
3+
description: Create architecture decision records using MADR 4.0 format
4+
---
5+
6+
# Create Architecture Decision Record
7+
8+
Capture a technical architecture decision using MADR 4.0 format.
9+
10+
## When to Use
11+
12+
- Technical architecture choices (database, framework, protocol)
13+
- Infrastructure decisions (hosting, CI/CD, deployment)
14+
- Code organization choices (monorepo vs multi-repo, module structure)
15+
- API design decisions
16+
17+
## Workflow
18+
19+
1. **Check existing context**:
20+
```bash
21+
dg list
22+
dg validate
23+
```
24+
25+
2. **Link to OPP when applicable**: If this ADR implements a business opportunity, reference it.
26+
27+
3. **Create the ADR**:
28+
```bash
29+
dg new adr "Use Ruby on Rails with PostgreSQL"
30+
```
31+
32+
4. **Fill in the document**:
33+
- **Context and Problem Statement**: What is the issue?
34+
- **Decision Drivers**: What factors matter?
35+
- **Considered Options**: At least 2-3 alternatives
36+
- **Decision Outcome**: Which option and why
37+
- **Consequences**: Good, bad, and neutral
38+
39+
## Status Lifecycle
40+
41+
- `draft` — Incomplete, not ready for review
42+
- `proposed` — Under discussion, not yet decided
43+
- `accepted` — Decision is final and active
44+
- `deprecated` — No longer relevant
45+
- `superseded` — Replaced by a newer ADR (link to it)
46+
- `rejected` — Decision was considered but rejected (link to alternatives)
47+
48+
## Tips
49+
50+
- Good title: "Use Ruby on Rails with PostgreSQL"
51+
- Bad title: "Tech stack decision"
52+
- Always document rejected alternatives — they prevent revisiting the same discussion
53+
- Link to OPPs this decision realizes using `implements:` field
54+
- Link to POLs that constrain this decision using `implements:` or `conflicts_with:` fields
55+
- Use `depends_on:` for decisions that block or are blocked by other docs
56+
- Use `<!-- FIXME: ... -->` for information gaps that need follow-up

.gemini/skills/diagram/SKILL.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
name: diagram
3+
description: Create effective D2/Mermaid diagrams optimized for terminal display
4+
---
5+
6+
# Create Diagram
7+
8+
Create effective D2 or Mermaid diagrams optimized for terminal display.
9+
10+
## When to Use
11+
12+
- Architecture or infrastructure diagrams
13+
- System interaction flows (request paths, failure cascades)
14+
- Process flowcharts or state machines
15+
- Incident failure diagrams showing what went wrong
16+
17+
## Workflow
18+
19+
1. **Identify components**: Ask what nodes (services, databases, users) and edges (connections, data flows) to show
20+
2. **Draft the D2/Mermaid code**: Write a first version following the terminal best practices below
21+
3. **Review for readability**: Check label lengths, node count, layout direction
22+
4. **Place in document**: Add as a fenced code block in the appropriate section
23+
24+
## Terminal Best Practices
25+
26+
Diagrams render as ASCII art in the terminal. Follow these rules for clean output.
27+
28+
### Keep it small
29+
30+
Aim for **5-7 nodes** max. Terminals are typically 80-120 columns wide. More nodes = unreadable overlaps.
31+
32+
If you need more, use **containers** to group related nodes:
33+
34+
```d2
35+
vpc: VPC {
36+
api: API
37+
db: Database {shape: cylinder}
38+
api -> db
39+
}
40+
client: Client
41+
client -> vpc.api
42+
```
43+
44+
### Use short labels
45+
46+
Edge labels over ~15 characters get moved to a legend at the bottom, disconnecting them from context.
47+
48+
- Bad: `api -> db: "sends authenticated read requests for user data"`
49+
- Good: `api -> db: reads`
50+
51+
Node labels should also be concise. Use the key as short ID and label for display:
52+
53+
```d2
54+
pg: PostgreSQL {shape: cylinder}
55+
```
56+
57+
### Set direction
58+
59+
Default is top-to-bottom. For terminal, `direction: right` often works better as it uses horizontal space:
60+
61+
```d2
62+
direction: right
63+
a: Service A
64+
b: Service B
65+
a -> b: calls
66+
```
67+
68+
### Use shapes for meaning
69+
70+
Supported shapes that render distinctly:
71+
72+
- `shape: cylinder` — databases, connection pools, queues
73+
- `shape: diamond` — decision points
74+
- `shape: hexagon` — APIs or key services
75+
- `shape: circle` — users, external actors
76+
- Default rectangle — everything else
77+
78+
### Cycles are warned
79+
80+
A cycle like `A -> B -> C -> A` triggers a D002 warning. This is informational — cycles in incident/failure diagrams are often intentional. To avoid warnings on return paths, restructure as:
81+
82+
```d2
83+
# Instead of A -> B and B -> A, use:
84+
a <-> b: request/response
85+
```
86+
87+
### Mermaid vs D2
88+
89+
Both work. D2 is simpler for architecture diagrams. Mermaid is better for state machines and sequence diagrams.
90+
91+
```mermaid
92+
stateDiagram-v2
93+
proposed --> accepted
94+
proposed --> rejected
95+
accepted --> deprecated
96+
accepted --> superseded
97+
```
98+
99+
## Common Patterns
100+
101+
### Incident failure diagram
102+
103+
```d2
104+
users: Users {shape: circle}
105+
api: API
106+
db: Database {shape: cylinder}
107+
108+
users -> api: requests
109+
api -> db: queries
110+
api -> users: 503 errors
111+
```
112+
113+
### Architecture overview
114+
115+
```d2
116+
direction: right
117+
client: Browser
118+
api: API {shape: hexagon}
119+
db: PostgreSQL {shape: cylinder}
120+
cache: Redis {shape: cylinder}
121+
122+
client -> api: HTTPS
123+
api -> db: reads/writes
124+
api -> cache: cached reads
125+
```
126+
127+
### Decision flow
128+
129+
```d2
130+
direction: right
131+
start: Request
132+
auth: Authenticated? {shape: diamond}
133+
allow: Allow
134+
deny: Deny
135+
136+
start -> auth
137+
auth -> allow: yes
138+
auth -> deny: no
139+
```
140+
141+
## Tips
142+
143+
- Always test rendering width: `dg show DOC-ID` shows actual terminal output
144+
- If labels overflow to legend, shorten them — inline labels are always more readable
145+
- Use comments (`# ...` in D2) to document intent without affecting rendering
146+
- Prefer D2 for static architecture, Mermaid `stateDiagram-v2` for lifecycles

.gemini/skills/image/SKILL.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: image
3+
description: Add an image to a decision document — rename, move to docs/assets/, insert reference
4+
---
5+
6+
# Add Image to Document
7+
8+
Add an image to a decision document. Handles renaming, moving to docs/assets/, and inserting the markdown reference.
9+
10+
## When to Use
11+
12+
- User pastes or provides an image to include in a document
13+
- User asks to add a screenshot, diagram, or photo to a doc
14+
- User provides an image file path that needs to be moved to the correct location
15+
16+
## Workflow
17+
18+
1. **Identify the image source**: The user may paste an image (saved to a temp path), provide a file path, or provide a URL.
19+
20+
2. **Determine the target document**: Ask which document (e.g. ADR-001, OPP-002) the image belongs to, if not obvious from context.
21+
22+
3. **Name the image file**: Use a descriptive, kebab-case name based on content:
23+
- `architecture-overview.png`
24+
- `incident-timeline.png`
25+
- `deployment-flow.svg`
26+
- Format: `{doc-id-lowercase}-{description}.{ext}` e.g. `adr-001-architecture-overview.png`
27+
28+
4. **Ensure docs/assets/ exists**:
29+
```bash
30+
mkdir -p docs/assets
31+
```
32+
33+
5. **Move/copy the image**:
34+
```bash
35+
cp /path/to/source/image.png docs/assets/adr-001-architecture-overview.png
36+
```
37+
38+
6. **Insert markdown reference** in the target document using `dg set`:
39+
```bash
40+
dg set ADR-001 --section "Context and Problem Statement" --append '![Architecture overview](../assets/adr-001-architecture-overview.png)'
41+
```
42+
Or for documents that reference from project root:
43+
```markdown
44+
![Architecture overview](docs/assets/adr-001-architecture-overview.png)
45+
```
46+
47+
7. **Validate**:
48+
```bash
49+
dg validate
50+
```
51+
52+
## Image Path Rules
53+
54+
- All local images MUST be stored in `docs/assets/`
55+
- Reference from within docs/ subdirs: `../assets/filename.png`
56+
- Reference from project root: `docs/assets/filename.png`
57+
- External URLs (https://...) are allowed anywhere
58+
- `dg validate` will flag images stored outside docs/assets/ (error C002)
59+
60+
## Tips
61+
62+
- Prefer SVG for diagrams (scalable, small file size)
63+
- Prefer PNG for screenshots (lossless, good for text)
64+
- Keep file sizes reasonable — compress large screenshots
65+
- Use descriptive alt text for accessibility
66+
- Prefix image filenames with the doc ID to avoid naming collisions

0 commit comments

Comments
 (0)