Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
30 changes: 15 additions & 15 deletions .kiro/specs/document-outliner-with-lsp/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This implementation plan breaks down the feature into discrete, actionable codin

## Task List

- [ ] 1. Set up project structure and core interfaces
- [x] 1. Set up project structure and core interfaces

- Create directory structure for VS Code extension (`extensions/doctk-outliner/`)
- Create directory structure for language server (`src/doctk/lsp/`)
Expand All @@ -13,86 +13,86 @@ This implementation plan breaks down the feature into discrete, actionable codin
- Set up build configuration (tsconfig.json, package.json for extension)
- _Requirements: 15, 20_

- [ ] 2. Implement core document manipulation API
- [x] 2. Implement core document manipulation API

- [ ] 2.1 Create StructureOperations class with promote/demote operations
- [x] 2.1 Create StructureOperations class with promote/demote operations

- Implement `promote()` method that decreases heading level
- Implement `demote()` method that increases heading level
- Add validation to ensure heading levels stay within 1-6 range
- _Requirements: 3.2, 3.3, 20_

- [ ] 2.2 Add move operations (move_up, move_down)
- [x] 2.2 Add move operations (move_up, move_down)

- Implement `move_up()` to reorder sections among siblings
- Implement `move_down()` to reorder sections among siblings
- Handle edge cases (first/last sibling)
- _Requirements: 3.4, 3.5, 20_

- [ ] 2.3 Implement nest and unnest operations
- [x] 2.3 Implement nest and unnest operations

- Implement `nest()` to move section under a new parent
- Implement `unnest()` to move section up one level
- Validate parent-child relationships
- _Requirements: 2.2, 2.3, 20_

- [ ] 2.4 Write unit tests for structure operations
- [x] 2.4 Write unit tests for structure operations

- Test promote/demote with various heading levels
- Test move operations with different sibling positions
- Test nest/unnest with complex hierarchies
- _Requirements: 20_

- [ ] 3. Create ExtensionBridge for TypeScript-Python communication
- [x] 3. Create ExtensionBridge for TypeScript-Python communication

- [ ] 3.1 Implement JSON-RPC bridge in Python
- [x] 3.1 Implement JSON-RPC bridge in Python

- Create `ExtensionBridge` class that accepts JSON-RPC requests
- Implement stdin/stdout communication protocol
- Add request/response handling with proper error serialization
- _Requirements: 20_

- [ ] 3.2 Implement TypeScript PythonBridge client
- [x] 3.2 Implement TypeScript PythonBridge client

- Create `PythonBridge` class that spawns Python process
- Implement JSON-RPC request/response handling
- Add promise-based API for async operations
- Handle process lifecycle (start, stop, restart)
- _Requirements: 18, 20_

- [ ] 3.3 Write integration tests for bridge communication
- [x] 3.3 Write integration tests for bridge communication

- Test request/response round-trip
- Test error handling and serialization
- Test process restart on failure
- _Requirements: 18_

- [ ] 4. Implement tree data provider for VS Code
- [x] 4. Implement tree data provider for VS Code

- [ ] 4.1 Create DocumentOutlineProvider class
- [x] 4.1 Create DocumentOutlineProvider class

- Implement `TreeDataProvider<OutlineNode>` interface
- Implement `getTreeItem()` to create tree items from nodes
- Implement `getChildren()` to build tree hierarchy
- Implement `getParent()` for navigation
- _Requirements: 1.1, 1.2, 1.3_

- [ ] 4.2 Add document parsing to build tree structure
- [x] 4.2 Add document parsing to build tree structure

- Parse Markdown document to extract headings
- Build OutlineNode tree from heading hierarchy
- Assign unique IDs to each node
- Track node ranges (line/column positions)
- _Requirements: 1.1, 1.2, 1.3_

- [ ] 4.3 Implement tree refresh and update mechanisms
- [x] 4.3 Implement tree refresh and update mechanisms

- Add `refresh()` method to trigger tree re-render
- Implement `updateFromDocument()` to sync with editor changes
- Add debouncing to prevent excessive updates
- _Requirements: 1.4, 16.1, 16.2, 16.3_

- [ ] 4.4 Write unit tests for tree provider
- [x] 4.4 Write unit tests for tree provider

- Test tree building from various Markdown structures
- Test node ID generation and uniqueness
Expand Down
24 changes: 24 additions & 0 deletions extensions/doctk-outliner/language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"comments": {
"lineComment": "#"
},
"brackets": [
["[", "]"],
["(", ")"],
["{", "}"]
],
"autoClosingPairs": [
["[", "]"],
["(", ")"],
["{", "}"],
["\"", "\""],
["'", "'"]
],
"surroundingPairs": [
["[", "]"],
["(", ")"],
["{", "}"],
["\"", "\""],
["'", "'"]
]
}
216 changes: 216 additions & 0 deletions extensions/doctk-outliner/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"name": "doctk-outliner",
"displayName": "doctk Document Outliner",
"description": "Tree-based document outliner with LSP support for doctk",
"version": "0.1.0",
"publisher": "doctk",
"engines": {
"vscode": "^1.80.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onLanguage:markdown",
"onLanguage:doctk",
"onView:doctkOutline"
],
"main": "./out/extension.js",
"contributes": {
"views": {
"explorer": [
{
"id": "doctkOutline",
"name": "Document Outline",
"when": "resourceLangId == markdown"
}
]
},
"commands": [
{
"command": "doctk.promote",
"title": "doctk: Promote Section",
"icon": "$(arrow-up)"
},
{
"command": "doctk.demote",
"title": "doctk: Demote Section",
"icon": "$(arrow-down)"
},
{
"command": "doctk.moveUp",
"title": "doctk: Move Section Up",
"icon": "$(chevron-up)"
},
{
"command": "doctk.moveDown",
"title": "doctk: Move Section Down",
"icon": "$(chevron-down)"
},
{
"command": "doctk.delete",
"title": "doctk: Delete Section",
"icon": "$(trash)"
},
{
"command": "doctk.refresh",
"title": "doctk: Refresh Outline",
"icon": "$(refresh)"
}
],
"menus": {
"view/title": [
{
"command": "doctk.refresh",
"when": "view == doctkOutline",
"group": "navigation"
}
],
"view/item/context": [
{
"command": "doctk.promote",
"when": "view == doctkOutline",
"group": "structure@1"
},
{
"command": "doctk.demote",
"when": "view == doctkOutline",
"group": "structure@2"
},
{
"command": "doctk.moveUp",
"when": "view == doctkOutline",
"group": "reorder@1"
},
{
"command": "doctk.moveDown",
"when": "view == doctkOutline",
"group": "reorder@2"
},
{
"command": "doctk.delete",
"when": "view == doctkOutline",
"group": "edit@1"
}
]
},
"keybindings": [
{
"command": "doctk.promote",
"key": "ctrl+shift+up",
"mac": "cmd+shift+up",
"when": "focusedView == doctkOutline"
},
{
"command": "doctk.demote",
"key": "ctrl+shift+down",
"mac": "cmd+shift+down",
"when": "focusedView == doctkOutline"
},
{
"command": "doctk.moveUp",
"key": "alt+up",
"mac": "alt+up",
"when": "focusedView == doctkOutline"
},
{
"command": "doctk.moveDown",
"key": "alt+down",
"mac": "alt+down",
"when": "focusedView == doctkOutline"
},
{
"command": "doctk.delete",
"key": "delete",
"mac": "delete",
"when": "focusedView == doctkOutline"
}
],
"languages": [
{
"id": "doctk",
"extensions": [
".tk"
],
"aliases": [
"doctk",
"DocTK"
],
"configuration": "./language-configuration.json"
}
],
"configuration": {
"title": "doctk Outliner",
"properties": {
"doctk.outliner.autoRefresh": {
"type": "boolean",
"default": true,
"description": "Automatically refresh the outline when the document changes"
},
"doctk.outliner.refreshDelay": {
"type": "number",
"default": 300,
"description": "Delay in milliseconds before refreshing the outline"
},
"doctk.outliner.showContentPreview": {
"type": "boolean",
"default": false,
"description": "Show a preview of content in the outline"
},
"doctk.outliner.maxPreviewLength": {
"type": "number",
"default": 50,
"description": "Maximum length of content preview"
},
"doctk.lsp.enabled": {
"type": "boolean",
"default": true,
"description": "Enable the doctk language server"
},
"doctk.lsp.trace": {
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Trace LSP communication for debugging"
},
"doctk.lsp.maxCompletionItems": {
"type": "number",
"default": 50,
"description": "Maximum number of completion items to show"
},
"doctk.performance.largeDocumentThreshold": {
"type": "number",
"default": 1000,
"description": "Number of headings to consider a document 'large'"
},
"doctk.performance.enableVirtualization": {
"type": "boolean",
"default": true,
"description": "Enable virtualization for large documents"
}
}
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/node": "^20.0.0",
"@types/vscode": "^1.80.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.45.0",
"typescript": "^5.1.0"
},
"dependencies": {
"vscode-languageclient": "^9.0.0"
}
}
Loading
Loading