add timestamp to dirmd files
This commit is contained in:
@@ -142,6 +142,7 @@ Example output with `dirmd -o docs.md ~/repos/myproject --vertical-slices`:
|
|||||||
|
|
||||||
Output is designed for RAG ingestion and LLM context windows, not human presentation:
|
Output is designed for RAG ingestion and LLM context windows, not human presentation:
|
||||||
|
|
||||||
|
- **ISO 8601 Timestamp**: Added as a metadata line (`> Generated: ...`) immediately after the H1 header for every new file created.
|
||||||
- **ASCII tree format** (`+-` instead of Unicode box-drawing) to reduce token overhead
|
- **ASCII tree format** (`+-` instead of Unicode box-drawing) to reduce token overhead
|
||||||
- **Explicit file delimiters**: `--- FILE: ./path (bytes, lines) ---` and `--- END FILE ---`
|
- **Explicit file delimiters**: `--- FILE: ./path (bytes, lines) ---` and `--- END FILE ---`
|
||||||
- **Document type markers**: `[ROOT]` and `[SLICE]` in H1 headers
|
- **Document type markers**: `[ROOT]` and `[SLICE]` in H1 headers
|
||||||
@@ -218,15 +219,17 @@ For full documentation on the Proton Drive CLI, including installation, authenti
|
|||||||
Produces markdown with:
|
Produces markdown with:
|
||||||
|
|
||||||
1. Absolute path as H1 header with `[ROOT]` or `[SLICE]` marker
|
1. Absolute path as H1 header with `[ROOT]` or `[SLICE]` marker
|
||||||
2. ASCII directory tree (indented with `+-` and `|` characters)
|
2. **Timestamp metadata line** (ISO 8601) immediately after the H1 header (only for new files)
|
||||||
3. Vertical slices index table (sliced mode only)
|
3. ASCII directory tree (indented with `+-` and `|` characters)
|
||||||
4. All text files with content in fenced code blocks
|
4. Vertical slices index table (sliced mode only)
|
||||||
5. Explicit `--- FILE: ---` and `--- END FILE ---` delimiters with byte and line counts
|
5. All text files with content in fenced code blocks
|
||||||
6. Language detection from file extensions
|
6. Explicit `--- FILE: ---` and `--- END FILE ---` delimiters with byte and line counts
|
||||||
|
7. Language detection from file extensions
|
||||||
|
|
||||||
Example output structure (non-sliced mode):
|
Example output structure (non-sliced mode):
|
||||||
|
|
||||||
# /home/user/repos/myproject [ROOT]
|
# /home/user/repos/myproject [ROOT]
|
||||||
|
> Generated: 2026-09-02T14:30:00Z
|
||||||
|
|
||||||
## Directory Tree
|
## Directory Tree
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"git.flo.fo/FLO/dirmd/internal/tree"
|
"git.flo.fo/FLO/dirmd/internal/tree"
|
||||||
@@ -35,7 +36,12 @@ func Write(result *walker.Result, outputPath string, appendMode bool, singleFile
|
|||||||
h1Path = filepath.Join(result.AbsRoot, result.Entries[0].RelPath)
|
h1Path = filepath.Join(result.AbsRoot, result.Entries[0].RelPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(&sb, "# %s [ROOT]\n\n", h1Path)
|
fmt.Fprintf(&sb, "# %s [ROOT]\n", h1Path)
|
||||||
|
|
||||||
|
// Add timestamp only if creating a new file (not append mode)
|
||||||
|
if !appendMode {
|
||||||
|
fmt.Fprintf(&sb, "> Generated: %s\n\n", time.Now().Format(time.RFC3339))
|
||||||
|
}
|
||||||
|
|
||||||
if !singleFile {
|
if !singleFile {
|
||||||
root := tree.Build(result.Entries)
|
root := tree.Build(result.Entries)
|
||||||
@@ -162,7 +168,9 @@ func writeRootSlice(path, absRoot, rootName, repoName string, rootFiles []walker
|
|||||||
|
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
|
|
||||||
fmt.Fprintf(&sb, "# %s [ROOT]\n\n", absRoot)
|
fmt.Fprintf(&sb, "# %s [ROOT]\n", absRoot)
|
||||||
|
// Timestamp for new file creation
|
||||||
|
fmt.Fprintf(&sb, "> Generated: %s\n\n", time.Now().Format(time.RFC3339))
|
||||||
|
|
||||||
treeLines := buildTreeWithRefs(rootName, repoName, topLevelDirs, rootFiles)
|
treeLines := buildTreeWithRefs(rootName, repoName, topLevelDirs, rootFiles)
|
||||||
sb.WriteString("## Directory Tree\n\n")
|
sb.WriteString("## Directory Tree\n\n")
|
||||||
@@ -239,7 +247,9 @@ func writeDirSlice(path, absDir, absRoot, dirName string, treeEntries, fileEntri
|
|||||||
|
|
||||||
var sb strings.Builder
|
var sb strings.Builder
|
||||||
|
|
||||||
fmt.Fprintf(&sb, "# %s [SLICE]\n\n", absDir)
|
fmt.Fprintf(&sb, "# %s [SLICE]\n", absDir)
|
||||||
|
// Timestamp for new file creation
|
||||||
|
fmt.Fprintf(&sb, "> Generated: %s\n\n", time.Now().Format(time.RFC3339))
|
||||||
fmt.Fprintf(&sb, "Root document: %s\n\n", rootFileName)
|
fmt.Fprintf(&sb, "Root document: %s\n\n", rootFileName)
|
||||||
|
|
||||||
sb.WriteString("## Directory Tree\n\n")
|
sb.WriteString("## Directory Tree\n\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user