Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/logseq-asset-linker/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Produce copy-pasteable asset links relative to a page in `pages/`.
- Relative links into `assets/` are formed from a typical page location (`logseq/pages/somepage.md`), so they start `../assets/...`.
- Image link: `![name](../assets/path)`. File link: `[name](../assets/path)`. Folder link: `[name](../assets/folder)`.
- Use `file:/absolute/path` only when the user explicitly wants a direct file link.
- For namespaced assets, convert `/` → `__` (double underscore) in the **filename**, and sanitize non-alphanumeric chars to `_`.
- Read `[[Logseq/Entity/Asset]]` for page ownership and filename mapping; for B2 uploads also read `[[Logseq/Entity/Asset/B2]]`. Derive a flat filename from the full asset page namespace: `/` becomes `___` and the final format segment becomes the extension. Keep spelling inside segments unchanged, and validate names using the entity definition so the mapping is reversible. Local remote copies use `assets/.remote/<filename>`; B2 uploads use the filename at the bucket root. Do not invent another path layout.
- Always return the result as a code snippet for easy copying.

Read [references/asset-link-construction.md](./references/asset-link-construction.md) for the full use cases, examples, and the `file:///` handling rules.
Read [references/asset-link-construction.md](./references/asset-link-construction.md) for link construction and `file:///` handling. The graph entity definition governs filenames; this reference covers link syntax.
Original file line number Diff line number Diff line change
@@ -1,92 +1,38 @@
# Constructing a Logseq Asset Link
# Constructing a Logseq asset link

This is an extension to the LFM formatting rules describing how to construct links to assets in the `assets/` directory and its subdirectories.
Read `Logseq/Entity/Asset` for filename mapping and `Logseq/Entity/Asset/B2`
for remote locations. Keep one naming authority in those graph pages.

### Description
## Existing file paths

Convert macOS file paths into relative Markdown links for Logseq.
Calculate the path relative to the page's `pages/` directory. A file at
`<garden>/assets/Folder/File.pdf` becomes:

Logseq uses **namespaces**: page titles that use namespaces (e.g., `[[Work/Projects/Logseq]]`) are converted to filenames by replacing slashes (`/`) with double underscores (`__`), resulting in `Work__Projects__Logseq.md`. Any namespace structure like `[[Parent/Child/Grandchild]]` becomes a single file named `Parent__Child__Grandchild.md`.
```markdown
[File](../assets/Folder/File.pdf)
```

> Note on underscores: **asset filenames** derived from namespaces use **double** underscores (`__`) as in this rule's examples. Page files on disk use **triple** underscores (`___`). Keep them distinct.
Use `![label](location)` for images, audio, and video; use `[label](location)`
for downloadable documents and presets. Percent-encode URL characters in link
locations without changing the file's name.

### Use Case 1: Path Name to Markdown Asset Link
## New asset pages

Given a full file path to an asset:
- Identify the Logseq folder within the path.
- Format a relative link starting from a typical page location (`logseq/pages/`), assuming the page is `logseq/pages/somepage.md`.
- Generate Markdown that can be directly copied into Logseq with correct relative paths.
- Always format the response as a code snippet.
Derive the flat filename from the asset page using the entity definition.
For remotely stored files, the optional local copy is under `assets/.remote/`
and the B2 URL uses that filename directly beneath the garden's bucket.

#### Example
- **USER:** Can you give me the link for `/a/b/c/logseq/assets/Course-101/assignments/week3/notes/course101__assignment__03__notes.pdf`?
```markdown
![course101__assignment__03__notes.pdf](../assets/Course-101/assignments/week3/notes/course101__assignment__03__notes.pdf)
```
```markdown
![September 24 episode recording](../assets/.remote/GitP___A___Session___26___09___24-Thu___Asset___Synth___Full.mp3)
```

### Use Case 2: Logseq Namespace Name to Asset Path
## Direct file links

- Turn a Logseq page reference from a namespaced name into a filename and an asset path.
- Given `[[A/B/C/D]]`, generate filename `A__B__C__D` of the appropriate type (png, pdf, etc.) and expected location `../assets/A/B/C/D/A__B__C__D`.
- Replace all non-alphanumeric characters with underscores in filenames.
When explicitly requested for a file outside the garden, use a direct file URL:

#### Examples
- PDF filename for `[[Course-101/homework/03/04 linear equations]]`:
```markdown
Course-101__homework__03__04_linear_equations.pdf
```
- Asset path for the same:
```markdown
../assets/Course-101/homework/03/04/Course-101__homework__03__04_linear_equations.pdf
```
- Link for `[[Projects/Research/Notes]]`:
```markdown
[Notes](../assets/Projects/Research/Projects__Research__Notes)
```
- As a PDF link:
```markdown
![Notes](../assets/Projects/Research/Projects__Research__Notes.pdf)
```
- As a folder link:
```markdown
[assets in Projects/Research](../assets/Projects/Research)
```
- PNG asset link for `[[Course-101/homework/03/04 linear equations]]`:
```markdown
![04_linear_equations.png](../assets/Course-101/homework/03/04/Course-101__homework__03__04_linear_equations.png)
```
```markdown
[Recording](file:///Users/username/Documents/recording.wav)
```

### Handling File Links

#### 1. File Links with `file:///` Scheme
When a user provides an absolute file path (e.g., `/Users/username/path/to/file.json`), generate a Markdown link with the `file:///` protocol for direct access.
- Input: `/Users/username/documents/projects/example-docs/example-docs_1234567890.json`
```markdown
[example-docs_1234567890.json](file:/Users/username/documents/projects/example-docs/example-docs_1234567890.json)
```

#### 2. Logseq Asset Links for Files
If a file is part of a Logseq project and a relative link is requested:
- Identify the file's location relative to the Logseq folder structure (typically `logseq/assets/` or `logseq/pages/`).
- Format relative to a typical page location (`logseq/pages/somepage.md`).
- Use Markdown syntax `[name](relative/path/to/file)`.
- Input: `/Users/username/dev/clones/logseq/assets/Folder/File.ext`
```markdown
[File.ext](../assets/Folder/File.ext)
```

#### 3. Consistent Formatting for Namespaced Assets
- Replace `/` in the namespace with `__` (double underscores).
- Sanitize filenames by replacing non-alphanumeric characters with `_`.
- Generate paths corresponding to the Logseq folder structure.
- Input namespace `[[Folder/Subfolder/File]]` → filename `Folder__Subfolder__File.ext`, path `../assets/Folder/Subfolder/Folder__Subfolder__File.ext`:
```markdown
[File](../assets/Folder/Subfolder/Folder__Subfolder__File.ext)
```

### Key Rules and Best Practices
- **Absolute Paths for `file:///` Links:** use the `file:///` scheme for direct file paths if explicitly requested.
- **Relative Paths for Logseq Assets:** always calculate relative paths for files in `assets/`.
- **Namespace Conversion:** convert `/` to `__` in asset filenames.
- **Filename Sanitization:** replace non-alphanumeric characters with `_`.
- **Markdown Link Syntax:** `[name](relative/path)` for Logseq links; `[name](file:/absolute/path)` for direct file links.
Return copyable link syntax when asked to construct a link. When writing an asset
page, write the usable link directly into its body.
4 changes: 2 additions & 2 deletions .claude/skills/logseq-asset-linker/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Produce copy-pasteable asset links relative to a page in `pages/`.
- Relative links into `assets/` are formed from a typical page location (`logseq/pages/somepage.md`), so they start `../assets/...`.
- Image link: `![name](../assets/path)`. File link: `[name](../assets/path)`. Folder link: `[name](../assets/folder)`.
- Use `file:/absolute/path` only when the user explicitly wants a direct file link.
- For namespaced assets, convert `/` → `__` (double underscore) in the **filename**, and sanitize non-alphanumeric chars to `_`.
- Read `[[Logseq/Entity/Asset]]` for page ownership and filename mapping; for B2 uploads also read `[[Logseq/Entity/Asset/B2]]`. Derive a flat filename from the full asset page namespace: `/` becomes `___` and the final format segment becomes the extension. Keep spelling inside segments unchanged, and validate names using the entity definition so the mapping is reversible. Local remote copies use `assets/.remote/<filename>`; B2 uploads use the filename at the bucket root. Do not invent another path layout.
- Always return the result as a code snippet for easy copying.

Read [references/asset-link-construction.md](./references/asset-link-construction.md) for the full use cases, examples, and the `file:///` handling rules.
Read [references/asset-link-construction.md](./references/asset-link-construction.md) for link construction and `file:///` handling. The graph entity definition governs filenames; this reference covers link syntax.
Original file line number Diff line number Diff line change
@@ -1,92 +1,38 @@
# Constructing a Logseq Asset Link
# Constructing a Logseq asset link

This is an extension to the LFM formatting rules describing how to construct links to assets in the `assets/` directory and its subdirectories.
Read `Logseq/Entity/Asset` for filename mapping and `Logseq/Entity/Asset/B2`
for remote locations. Keep one naming authority in those graph pages.

### Description
## Existing file paths

Convert macOS file paths into relative Markdown links for Logseq.
Calculate the path relative to the page's `pages/` directory. A file at
`<garden>/assets/Folder/File.pdf` becomes:

Logseq uses **namespaces**: page titles that use namespaces (e.g., `[[Work/Projects/Logseq]]`) are converted to filenames by replacing slashes (`/`) with double underscores (`__`), resulting in `Work__Projects__Logseq.md`. Any namespace structure like `[[Parent/Child/Grandchild]]` becomes a single file named `Parent__Child__Grandchild.md`.
```markdown
[File](../assets/Folder/File.pdf)
```

> Note on underscores: **asset filenames** derived from namespaces use **double** underscores (`__`) as in this rule's examples. Page files on disk use **triple** underscores (`___`). Keep them distinct.
Use `![label](location)` for images, audio, and video; use `[label](location)`
for downloadable documents and presets. Percent-encode URL characters in link
locations without changing the file's name.

### Use Case 1: Path Name to Markdown Asset Link
## New asset pages

Given a full file path to an asset:
- Identify the Logseq folder within the path.
- Format a relative link starting from a typical page location (`logseq/pages/`), assuming the page is `logseq/pages/somepage.md`.
- Generate Markdown that can be directly copied into Logseq with correct relative paths.
- Always format the response as a code snippet.
Derive the flat filename from the asset page using the entity definition.
For remotely stored files, the optional local copy is under `assets/.remote/`
and the B2 URL uses that filename directly beneath the garden's bucket.

#### Example
- **USER:** Can you give me the link for `/a/b/c/logseq/assets/Course-101/assignments/week3/notes/course101__assignment__03__notes.pdf`?
```markdown
![course101__assignment__03__notes.pdf](../assets/Course-101/assignments/week3/notes/course101__assignment__03__notes.pdf)
```
```markdown
![September 24 episode recording](../assets/.remote/GitP___A___Session___26___09___24-Thu___Asset___Synth___Full.mp3)
```

### Use Case 2: Logseq Namespace Name to Asset Path
## Direct file links

- Turn a Logseq page reference from a namespaced name into a filename and an asset path.
- Given `[[A/B/C/D]]`, generate filename `A__B__C__D` of the appropriate type (png, pdf, etc.) and expected location `../assets/A/B/C/D/A__B__C__D`.
- Replace all non-alphanumeric characters with underscores in filenames.
When explicitly requested for a file outside the garden, use a direct file URL:

#### Examples
- PDF filename for `[[Course-101/homework/03/04 linear equations]]`:
```markdown
Course-101__homework__03__04_linear_equations.pdf
```
- Asset path for the same:
```markdown
../assets/Course-101/homework/03/04/Course-101__homework__03__04_linear_equations.pdf
```
- Link for `[[Projects/Research/Notes]]`:
```markdown
[Notes](../assets/Projects/Research/Projects__Research__Notes)
```
- As a PDF link:
```markdown
![Notes](../assets/Projects/Research/Projects__Research__Notes.pdf)
```
- As a folder link:
```markdown
[assets in Projects/Research](../assets/Projects/Research)
```
- PNG asset link for `[[Course-101/homework/03/04 linear equations]]`:
```markdown
![04_linear_equations.png](../assets/Course-101/homework/03/04/Course-101__homework__03__04_linear_equations.png)
```
```markdown
[Recording](file:///Users/username/Documents/recording.wav)
```

### Handling File Links

#### 1. File Links with `file:///` Scheme
When a user provides an absolute file path (e.g., `/Users/username/path/to/file.json`), generate a Markdown link with the `file:///` protocol for direct access.
- Input: `/Users/username/documents/projects/example-docs/example-docs_1234567890.json`
```markdown
[example-docs_1234567890.json](file:/Users/username/documents/projects/example-docs/example-docs_1234567890.json)
```

#### 2. Logseq Asset Links for Files
If a file is part of a Logseq project and a relative link is requested:
- Identify the file's location relative to the Logseq folder structure (typically `logseq/assets/` or `logseq/pages/`).
- Format relative to a typical page location (`logseq/pages/somepage.md`).
- Use Markdown syntax `[name](relative/path/to/file)`.
- Input: `/Users/username/dev/clones/logseq/assets/Folder/File.ext`
```markdown
[File.ext](../assets/Folder/File.ext)
```

#### 3. Consistent Formatting for Namespaced Assets
- Replace `/` in the namespace with `__` (double underscores).
- Sanitize filenames by replacing non-alphanumeric characters with `_`.
- Generate paths corresponding to the Logseq folder structure.
- Input namespace `[[Folder/Subfolder/File]]` → filename `Folder__Subfolder__File.ext`, path `../assets/Folder/Subfolder/Folder__Subfolder__File.ext`:
```markdown
[File](../assets/Folder/Subfolder/Folder__Subfolder__File.ext)
```

### Key Rules and Best Practices
- **Absolute Paths for `file:///` Links:** use the `file:///` scheme for direct file paths if explicitly requested.
- **Relative Paths for Logseq Assets:** always calculate relative paths for files in `assets/`.
- **Namespace Conversion:** convert `/` to `__` in asset filenames.
- **Filename Sanitization:** replace non-alphanumeric characters with `_`.
- **Markdown Link Syntax:** `[name](relative/path)` for Logseq links; `[name](file:/absolute/path)` for direct file links.
Return copyable link syntax when asked to construct a link. When writing an asset
page, write the usable link directly into its body.
3 changes: 3 additions & 0 deletions .dvc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/config.local
/tmp
/cache
5 changes: 5 additions & 0 deletions .dvc/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[core]
remote = garden
['remote "garden"']
url = s3://logseq-encode-garden/dvc/
endpointurl = https://s3.us-east-005.backblazeb2.com
3 changes: 3 additions & 0 deletions .dvcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add patterns of files dvc should ignore, which could improve
# the performance. Learn more at
# https://dvc.org/doc/user-guide/dvcignore
4 changes: 2 additions & 2 deletions .github/skills/logseq-asset-linker/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Produce copy-pasteable asset links relative to a page in `pages/`.
- Relative links into `assets/` are formed from a typical page location (`logseq/pages/somepage.md`), so they start `../assets/...`.
- Image link: `![name](../assets/path)`. File link: `[name](../assets/path)`. Folder link: `[name](../assets/folder)`.
- Use `file:/absolute/path` only when the user explicitly wants a direct file link.
- For namespaced assets, convert `/` → `__` (double underscore) in the **filename**, and sanitize non-alphanumeric chars to `_`.
- Read `[[Logseq/Entity/Asset]]` for page ownership and filename mapping; for B2 uploads also read `[[Logseq/Entity/Asset/B2]]`. Derive a flat filename from the full asset page namespace: `/` becomes `___` and the final format segment becomes the extension. Keep spelling inside segments unchanged, and validate names using the entity definition so the mapping is reversible. Local remote copies use `assets/.remote/<filename>`; B2 uploads use the filename at the bucket root. Do not invent another path layout.
- Always return the result as a code snippet for easy copying.

Read [references/asset-link-construction.md](./references/asset-link-construction.md) for the full use cases, examples, and the `file:///` handling rules.
Read [references/asset-link-construction.md](./references/asset-link-construction.md) for link construction and `file:///` handling. The graph entity definition governs filenames; this reference covers link syntax.
Loading