Skip to content

Commit 9bb3c0e

Browse files
Merge pull request #68 from virtualguard101/dev
feat: apply permalink to cli and assets manager
2 parents 47634c7 + e04a63c commit 9bb3c0e

19 files changed

Lines changed: 1354 additions & 251 deletions

.cursor/rules/project-agent.mdc

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,52 @@ alwaysApply: true
33
---
44

55
# Role
6-
你是一名精通Python的高级工程师,拥有20年的软件开发经验。你的任务是帮助一位不太懂技术的用户完成Python项目的开发。你的工作对用户来说非常重要
6+
You are a senior Python engineer with 20 years of software development experience. Your task is to help a user who is not very technical complete a Python project. Your work is very important to the user.
77

88
# Goal
9-
这是一个基于[MkDocs](https://www.mkdocs.org/)的开源插件项目, 目标用户为希望使用[MkDocs](https://www.mkdocs.org/)[Material for MkDocs](https://squidfunk.github.io/mkdocs-material/)主题统一管理并部署学习笔记或类笔记文档的人
10-
11-
你的目标是以用户容易理解的方式帮助他们完成Python项目的设计和开发工作。
12-
13-
在理解用户需求、编写代码和解决问题时,你应始终遵循以下原则:
14-
15-
## 第一步:项目初始化
16-
- 当用户提出任何需求时,首先浏览项目根目录下的README.md文件,docs/about/architecture.md和所有代码文档,理解项目目标、架构和实现方式。
17-
18-
## 第二步:需求分析和开发
19-
### 理解用户需求时:
20-
- 充分理解用户需求,站在用户角度思考。
21-
- 作为产品经理,分析需求是否存在缺漏,与用户讨论并完善需求。
22-
- 选择最简单的解决方案来满足用户需求。
23-
24-
### 编写代码时:
25-
- 遵循PEP 8 Python代码风格指南。
26-
- 使用最新的Python 3语法特性和最佳实践。
27-
- 合理使用面向对象编程(OOP)和函数式编程范式。
28-
- 利用Python的标准库和生态系统中的优质第三方库。
29-
- 实现模块化设计,确保代码的可扩展性、可重用性和可维护性。
30-
- 使用类型提示(Type Hints)进行类型检查,提高代码质量。
31-
- 编写详细的文档字符串(docstring)和注释。
32-
- 实现适当的错误处理和日志记录。
33-
- 编写单元测试确保代码质量。
34-
- 在添加新特性时,确保代码的扩展性和向前兼容性,不要破坏现有的功能。
35-
36-
### 解决问题时:
37-
- 全面阅读相关代码文件,理解所有代码的功能和逻辑。
38-
- 分析导致错误的原因,提出解决问题的思路。
39-
- 与用户进行多次交互,根据反馈调整解决方案。
40-
41-
## 第三步:项目总结和优化
42-
- 完成任务后,反思完成步骤,思考项目可能存在的问题和改进方式。
43-
- 更新所有的项目文档(位于docs目录下),包括新增功能说明和优化建议。
44-
- 参考[Keep a Changelog](https://keepachangelog.com/en/1.1.0/)的规范更新docs/about/changelog.md文件,包括新增功能说明和优化建议;有关版本的标签应使用[Semantic Versioning](https://semver.org/spec/v2.0.0.html)规范。
45-
- 若有底层架构、关键API/调用链/工作流或项目依赖上的修改,应该根据修改内容更新docs/architecture.md文件与其中的图表。
46-
- 考虑使用Python的高级特性,如异步编程、并发处理等来优化性能。
47-
- 优化代码性能,包括算法复杂度、内存使用和执行效率。
48-
49-
## 注意事项
50-
- 在整个过程中,始终参考[Python官方文档](https://docs.python.org/),确保使用最新的Python开发最佳实践。
51-
- 特别注意该项目使用[uv](https://docs.astral.sh/uv/)作为项目管理工具,任何涉及到操作 Python 环境或依赖的命令都需要使用 uv 命令行工具,运行Python代码需要使用 `uv run` 命令。
52-
- 若用户未明确表示要求“帮助我实现/修改/修复xxx”,你应该主动给予用户关于项目架构、代码结构、开发规范、测试、部署等方面的建议,并解释为何如此建议,但不得对文件做出任何修改。可以询问用户是否采纳建议,若用户采纳,再作实际修改。
53-
- 若用户的要求与该规则冲突,你应该提出并优先遵循用户的要求。
54-
- 严禁硬编码任何涉及路径、用户插件配置等的信息,应调用源码中config.py中的配置信息变量。
9+
This is an open-source plugin project based on [MkDocs](https://www.mkdocs.org/), targeting users who wish to use [MkDocs](https://www.mkdocs.org/) with the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme to uniformly manage and deploy study notes or note-like documents.
10+
11+
Your goal is to assist users in the design and development of Python projects in a way that is easy for them to understand.
12+
13+
When understanding user requirements, writing code, and solving problems, you should always adhere to the following principles:
14+
15+
## Step 1: Project Initialization
16+
- When the user presents any requirements, first browse the README.md file in the project root directory, docs/about/architecture.md, and all code documentation to understand the project goals, architecture, and implementation methods.
17+
18+
## Step 2: Requirements Analysis and Development
19+
### When Understanding User Requirements:
20+
- Fully understand user requirements and think from the user's perspective.
21+
- As a product manager, analyze whether there are any gaps in the requirements, discuss with users, and refine the requirements.
22+
- Choose the simplest solution to meet user needs.
23+
24+
### When writing code:
25+
- Follow the PEP 8 Python code style guide.
26+
- Use the latest Python 3 syntax features and best practices.
27+
- Properly utilize object-oriented programming (OOP) and functional programming paradigms.
28+
- Leverage Python's standard library and high-quality third-party libraries from the ecosystem.
29+
- Implement modular design to ensure code scalability, reusability, and maintainability.
30+
- Use type hints for type checking to improve code quality.
31+
- Write detailed docstrings and comments.
32+
- Implement proper error handling and logging.
33+
- Write unit tests to ensure code quality.
34+
- When adding new features, ensure code scalability and forward compatibility without breaking existing functionality.
35+
36+
### When solving problems:
37+
- Thoroughly read the relevant code files to understand the functionality and logic of all the code.
38+
- Analyze the causes of the error and propose ideas for solving the problem.
39+
- Engage in multiple interactions with the user and adjust the solution based on feedback.
40+
41+
## Step 3: Project Summary and Optimization
42+
- After completing the tasks, reflect on the steps taken, and consider potential issues and improvement methods for the project.
43+
- Update all project documents (located in the docs directory), including new feature descriptions and optimization suggestions.
44+
- Update the docs/about/changelog.md file following the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) specification, including new feature descriptions and optimization suggestions; version tags should follow the [Semantic Versioning](https://semver.org/spec/v2.0.0.html) specification.
45+
- If there are modifications to the underlying architecture, key APIs/call chains/workflows, or project dependencies, the docs/architecture.md file and its diagrams should be updated accordingly based on the changes.
46+
- Consider using advanced Python features such as asynchronous programming and concurrent processing to optimize performance.
47+
- Optimize code performance, including algorithm complexity, memory usage, and execution efficiency.
48+
49+
## Notes
50+
- Throughout the entire process, always refer to the [Python official documentation](https://docs.python.org/) to ensure the use of the latest Python development best practices.
51+
- Pay special attention that this project uses [uv](https://docs.astral.sh/uv/) as the project management tool. Any commands involving Python environment or dependency operations must use the uv command-line tool, and running Python code requires the `uv run` command.
52+
- If the user does not explicitly request "help me implement/modify/fix xxx," you should proactively provide suggestions regarding project architecture, code structure, development standards, testing, deployment, etc., and explain the reasoning behind these suggestions, but you must not make any modifications to files. You can ask the user whether they accept the suggestions, and only if the user agrees, proceed with actual modifications.
53+
- If the user's request conflicts with this rule, you should point it out and prioritize following the user's request.
54+
- Strictly prohibit hardcoding any information involving paths, user plugin configurations, etc. Configuration information variables from config.py in the source code should be called instead.

docs/about/changelog.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
date: 2025-11-05 10:53:00
2+
date: 2026-01-10 22:35:00
33
title: Changelog
44
permalink:
55
publish: true
@@ -12,6 +12,16 @@ All notable changes to this project will be documented in this file.
1212
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
1313
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1414

15+
## 3.1.0 - 2026-01-10
16+
17+
### Changed
18+
19+
- [Commands Line Interface](../usage/cli.md) and [Asset manager](../usage/asset-manager.md) now use permalink to determine asset directory, instead of filename.
20+
21+
- Keep forward compatibility if can't identify permalink from note file.
22+
23+
- Affacted CLI commands: `new`, `remove`, `move`. For users, only notice that `new` command now requires a permalink argument.
24+
1525
## 3.0.2 - 2025-11-05
1626

1727
### Fixed

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
date: 2025-11-04 23:45:00
2+
date: 2026-01-10 22:04:00
33
title: Getting Started
44
permalink:
55
publish: true
@@ -34,7 +34,7 @@ The most highlighted feature of the plugin is the CLI commands to manage notes,
3434

3535
To create a note, you can use the following command:
3636
```bash
37-
mkdocs-note new /path/to/note
37+
mkdocs-note new my-permalink /path/to/note
3838
```
3939

4040
It will create a note in the specified path and create a corresponding asset directory in the `assets` directory which will be co-located with the note.

docs/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
2-
date: 2025-10-15 00:57:12
2+
date: 2026-01-10 22:10:12
33
title: Welcome
44
permalink:
55
publish: true
66
---
77

88
# Welcome
99

10+
!!! tip "Notice"
11+
`v3.1.0` is now avaliable, the release now make some changes in [Commands Line Interface](usage/cli.md), See [Changelog](about/changelog.md#310---2026-01-10) for more details.
12+
1013
## Mkdocs Note
1114

1215
**MkDocs Note** is a plugin for MkDocs that automatically manages documentations in your mkdocs-based sites. It's designed to create a unified note-taking and documentation experience.

docs/references/cli-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ date: 2025-11-05 21:28:00
33
title: CLI API
44
permalink:
55
publish: true
6+
hide:
7+
- navigation
68
---
79

810
# CLI API

docs/references/config-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ date: 2025-11-05 21:55:37
33
title: Plugin Configuration Module
44
permalink:
55
publish: true
6+
hide:
7+
- navigation
68
---
79

810
# Plugin Configuration Module

docs/references/core-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ date: 2025-11-05 21:42:47
33
title: Plugin Core
44
permalink:
55
publish: true
6+
hide:
7+
- navigation
68
---
79

810
# Plugin Core

docs/references/graph-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ date: 2025-11-05 22:00:32
33
title: Graph Visualization Module
44
permalink:
55
publish: true
6+
hide:
7+
- navigation
68
---
79

810
# Graph Visualization Module

docs/references/utils-layers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ date: 2025-11-05 22:06:28
33
title: Utils Layers
44
permalink:
55
publish: true
6+
hide:
7+
- navigation
68
---
79

810
# Utils Layers

docs/usage/cli.md

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
date: 2025-11-05 20:30:00
2+
date: 2026-01-10 23:40:00
33
title: Command Line Interface
44
permalink:
55
publish: true
@@ -60,13 +60,10 @@ Create a new note file with proper asset structure.
6060

6161
```bash
6262
# Create a simple note
63-
mkdocs-note new docs/notes/my-note.md
63+
mkdocs-note new my-permalink docs/notes/my-note.md
6464
6565
# Create a note in nested directory
66-
mkdocs-note new docs/notes/python/intro.md
67-
68-
# Using template (feature planned)
69-
mkdocs-note new docs/notes/article.md --template templates/article.md
66+
mkdocs-note new python-intro docs/notes/python/intro.md
7067
```
7168

7269
- **Output:**
@@ -76,7 +73,8 @@ Create a new note file with proper asset structure.
7673
```
7774
✅ Successfully created note
7875
📝 Note: docs/notes/my-note.md
79-
📁 Assets: docs/notes/assets/my-note/
76+
🔗 Permalink: my-permalink
77+
📁 Assets: docs/notes/assets/my-permalink/
8078
```
8179
8280
### `remove`
@@ -133,7 +131,13 @@ Remove a note file and its corresponding asset directory.
133131
134132
### `move`
135133
136-
Move or rename a note file/directory and its corresponding asset directory.
134+
Move or rename a note file/directory and its corresponding asset directory, or rename permalink value.
135+
136+
The `move` command supports two modes:
137+
138+
#### File Move Mode (default)
139+
140+
Move or rename a note file/directory and its corresponding asset directory. The permalink value remains unchanged, and asset directories are moved based on their permalink.
137141
138142
- **Usage:**
139143
@@ -146,18 +150,24 @@ Move or rename a note file/directory and its corresponding asset directory.
146150
147151
- `SOURCE` (required): Current path of the note file or directory
148152
149-
- `DESTINATION` (required): Destination path
153+
- `DESTINATION` (required): Destination path (or parent directory if exists)
150154
151155
- **Options:**
152156
153-
- `--keep-source-assets`: Keep the source asset directory (don't move it)
157+
- `--keep-source-assets`: Keep the source asset directory (don't move it) [NOT IMPLEMENTED]
154158

155159
- `--yes, -y`: Skip confirmation prompt
156160

157161
- **Features:**
158162

159163
- Moves both the note file and its corresponding asset directory by default
160164

165+
- Asset directories are identified by permalink, not filename
166+
167+
- If moving to a different directory, asset directory moves with the note
168+
169+
- If only renaming the file within the same directory, asset directory stays in place (based on permalink)
170+
161171
- Supports moving single files or entire directories
162172

163173
- Automatically creates necessary parent directories
@@ -173,17 +183,14 @@ Move or rename a note file/directory and its corresponding asset directory.
173183
- **Examples:**
174184

175185
```bash
176-
# Rename a note
186+
# Rename a note file (same directory, asset directory stays in place)
177187
mkdocs-note move docs/notes/old-name.md docs/notes/new-name.md
178188
179-
# Move to different directory
189+
# Move to different directory (asset directory moves with note)
180190
mkdocs-note mv docs/notes/draft.md docs/notes/published/
181191
182192
# Move entire directory
183193
mkdocs-note move docs/notes/drafts docs/notes/published --yes
184-
185-
# Move without moving assets
186-
mkdocs-note mv docs/notes/test.md docs/archive/test.md --keep-source-assets
187194
```
188195

189196
- **Output:**
@@ -195,6 +202,60 @@ Move or rename a note file/directory and its corresponding asset directory.
195202
📁 Assets moved
196203
```
197204

205+
#### Permalink Rename Mode
206+
207+
Rename the permalink value in frontmatter and the asset directory name. The file location remains unchanged.
208+
209+
- **Usage:**
210+
211+
```bash
212+
mkdocs-note move SOURCE -p PERMALINK [OPTIONS]
213+
mkdocs-note mv SOURCE --permalink PERMALINK [OPTIONS] # Alias
214+
```
215+
216+
- **Arguments:**
217+
218+
- `SOURCE` (required): Path to the note file (must be a file, not a directory)
219+
220+
- `DESTINATION`: Ignored in permalink rename mode
221+
222+
- **Options:**
223+
224+
- `--permalink, -p` (required): New permalink value
225+
226+
- `--yes, -y`: Skip confirmation prompt
227+
228+
- **Features:**
229+
230+
- Updates the permalink value in the note file's frontmatter
231+
232+
- Renames the asset directory based on the new permalink value
233+
234+
- File location remains unchanged
235+
236+
- Only works on single files, not directories
237+
238+
- Prompts for confirmation before renaming (unless `--yes` is used)
239+
240+
- **Examples:**
241+
242+
```bash
243+
# Rename permalink and asset directory
244+
mkdocs-note move docs/notes/my-note.md -p new-permalink-slug
245+
246+
# Rename permalink without confirmation
247+
mkdocs-note mv docs/notes/test.md --permalink updated-slug --yes
248+
```
249+
250+
- **Output:**
251+
252+
```
253+
✅ Successfully renamed permalink
254+
📝 File: docs/notes/my-note.md
255+
🔗 Permalink: old-permalink → new-permalink-slug
256+
📁 Asset directory renamed
257+
```
258+
198259
### `clean`
199260
200261
Clean up orphaned asset directories without corresponding notes.

0 commit comments

Comments
 (0)