x-ipe 1.0.23__py3-none-any.whl → 1.0.25__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. x_ipe/app.py +32 -1
  2. x_ipe/handlers/terminal_handlers.py +6 -0
  3. x_ipe/handlers/voice_handlers.py +5 -0
  4. x_ipe/resources/copilot-instructions.md +19 -6
  5. x_ipe/resources/skills/lesson-learned/SKILL.md +208 -0
  6. x_ipe/resources/skills/lesson-learned/references/examples.md +238 -0
  7. x_ipe/resources/skills/project-quality-board-management/SKILL.md +135 -298
  8. x_ipe/resources/skills/project-quality-board-management/references/evaluation-principles.md +213 -0
  9. x_ipe/resources/skills/project-quality-board-management/references/evaluation-procedures.md +214 -0
  10. x_ipe/resources/skills/project-quality-board-management/templates/quality-report.md +70 -18
  11. x_ipe/resources/skills/task-execution-guideline/SKILL.md +2 -2
  12. x_ipe/resources/skills/task-execution-guideline/templates/task-record.yaml +1 -1
  13. x_ipe/resources/skills/task-type-code-implementation/SKILL.md +72 -270
  14. x_ipe/resources/skills/task-type-code-implementation/references/implementation-guidelines.md +432 -0
  15. x_ipe/resources/skills/task-type-code-refactor-v2/SKILL.md +127 -353
  16. x_ipe/resources/skills/task-type-code-refactor-v2/references/refactoring-techniques.md +373 -0
  17. x_ipe/resources/skills/task-type-feature-breakdown/SKILL.md +31 -243
  18. x_ipe/resources/skills/task-type-feature-breakdown/references/breakdown-guidelines.md +330 -0
  19. x_ipe/resources/skills/task-type-feature-refinement/SKILL.md +27 -180
  20. x_ipe/resources/skills/task-type-feature-refinement/references/specification-writing-guide.md +267 -0
  21. x_ipe/resources/skills/task-type-idea-mockup/SKILL.md +38 -276
  22. x_ipe/resources/skills/task-type-idea-mockup/references/mockup-guidelines.md +299 -0
  23. x_ipe/resources/skills/task-type-idea-to-architecture/SKILL.md +20 -218
  24. x_ipe/resources/skills/task-type-idea-to-architecture/references/architecture-patterns.md +342 -0
  25. x_ipe/resources/skills/task-type-ideation/SKILL.md +10 -266
  26. x_ipe/resources/skills/task-type-ideation/references/folder-naming-guide.md +55 -0
  27. x_ipe/resources/skills/task-type-ideation/references/tool-usage-guide.md +236 -0
  28. x_ipe/resources/skills/task-type-ideation-v2/SKILL.md +488 -0
  29. x_ipe/resources/skills/task-type-ideation-v2/references/examples.md +377 -0
  30. x_ipe/resources/skills/task-type-ideation-v2/references/folder-naming-guide.md +74 -0
  31. x_ipe/resources/skills/task-type-ideation-v2/references/tool-usage-guide.md +145 -0
  32. x_ipe/resources/skills/task-type-ideation-v2/references/visualization-guide.md +160 -0
  33. x_ipe/resources/skills/task-type-ideation-v2/templates/idea-summary.md +86 -0
  34. x_ipe/resources/skills/task-type-refactoring-analysis/SKILL.md +83 -145
  35. x_ipe/resources/skills/task-type-refactoring-analysis/references/output-schema.md +172 -0
  36. x_ipe/resources/skills/task-type-technical-design/SKILL.md +28 -214
  37. x_ipe/resources/skills/task-type-technical-design/references/design-templates.md +422 -0
  38. x_ipe/resources/skills/task-type-test-generation/SKILL.md +47 -332
  39. x_ipe/resources/skills/task-type-test-generation/references/test-patterns.md +368 -0
  40. x_ipe/resources/skills/tool-tracing-creator/SKILL.md +312 -0
  41. x_ipe/resources/skills/tool-tracing-creator/references/examples.md +324 -0
  42. x_ipe/resources/skills/tool-tracing-instrumentation/SKILL.md +373 -0
  43. x_ipe/resources/skills/tool-tracing-instrumentation/references/examples.md +264 -0
  44. x_ipe/resources/skills/x-ipe-skill-creator-v3/SKILL.md +486 -0
  45. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/10. example-gate-conditions.md +73 -0
  46. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/11. reference-quality-standards.md +127 -0
  47. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/2. reference-section-order.md +127 -0
  48. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/3. example-step-based-code-review.md +84 -0
  49. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/4. example-step-based-feature-implementation.md +113 -0
  50. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/5. example-function-based-validation.md +73 -0
  51. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/6. example-function-based-analysis.md +94 -0
  52. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/7. example-task-io-code-implementation.md +36 -0
  53. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/8. example-structured-summary.md +43 -0
  54. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/9. example-dor-dod.md +77 -0
  55. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/examples.md +429 -0
  56. x_ipe/resources/skills/x-ipe-skill-creator-v3/references/skill-general-guidelines-v2.md +611 -0
  57. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-meta.md +153 -0
  58. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-task-based.md +324 -0
  59. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-task-category.md +109 -0
  60. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/skill-meta-x-ipe-tool.md +205 -0
  61. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-meta.md +334 -0
  62. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-task-based.md +279 -0
  63. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-tool.md +175 -0
  64. x_ipe/resources/skills/x-ipe-skill-creator-v3/templates/x-ipe-workflow-orchestration.md +329 -0
  65. x_ipe/resources/skills/x-ipe-task-based-ideation/SKILL.md +487 -0
  66. x_ipe/resources/skills/x-ipe-task-based-ideation/references/examples.md +377 -0
  67. x_ipe/resources/skills/x-ipe-task-based-ideation/references/folder-naming-guide.md +74 -0
  68. x_ipe/resources/skills/x-ipe-task-based-ideation/references/tool-usage-guide.md +145 -0
  69. x_ipe/resources/skills/x-ipe-task-based-ideation/references/visualization-guide.md +160 -0
  70. x_ipe/resources/skills/x-ipe-task-based-ideation/templates/idea-summary.md +86 -0
  71. x_ipe/routes/__init__.py +2 -0
  72. x_ipe/routes/ideas_routes.py +289 -0
  73. x_ipe/routes/kb_routes.py +80 -0
  74. x_ipe/routes/main_routes.py +18 -0
  75. x_ipe/routes/project_routes.py +7 -0
  76. x_ipe/routes/proxy_routes.py +10 -2
  77. x_ipe/routes/quality_evaluation_routes.py +193 -0
  78. x_ipe/routes/settings_routes.py +6 -0
  79. x_ipe/routes/tools_routes.py +6 -0
  80. x_ipe/routes/tracing_routes.py +232 -0
  81. x_ipe/routes/uiux_feedback_routes.py +50 -0
  82. x_ipe/services/__init__.py +5 -0
  83. x_ipe/services/config_service.py +6 -0
  84. x_ipe/services/file_service.py +20 -0
  85. x_ipe/services/homepage_service.py +160 -0
  86. x_ipe/services/ideas_service.py +535 -2
  87. x_ipe/services/kb_service.py +378 -0
  88. x_ipe/services/proxy_service.py +37 -7
  89. x_ipe/services/settings_service.py +13 -0
  90. x_ipe/services/skills_service.py +4 -0
  91. x_ipe/services/terminal_service.py +24 -0
  92. x_ipe/services/themes_service.py +4 -0
  93. x_ipe/services/tools_config_service.py +4 -0
  94. x_ipe/services/tracing_service.py +333 -0
  95. x_ipe/services/uiux_feedback_service.py +148 -1
  96. x_ipe/services/voice_input_service_v2.py +11 -0
  97. x_ipe/static/css/base.css +7 -0
  98. x_ipe/static/css/homepage-infinity.css +330 -0
  99. x_ipe/static/css/kb-core.css +301 -0
  100. x_ipe/static/css/quality-evaluation.css +345 -0
  101. x_ipe/static/css/sidebar.css +14 -4
  102. x_ipe/static/css/terminal.css +23 -0
  103. x_ipe/static/css/tracing-dashboard.css +796 -0
  104. x_ipe/static/css/uiux-feedback.css +7 -1
  105. x_ipe/static/css/workplace.css +636 -0
  106. x_ipe/static/img/homepage-infinity-loop.png +0 -0
  107. x_ipe/static/js/features/confirm-dialog.js +169 -0
  108. x_ipe/static/js/features/folder-view.js +742 -0
  109. x_ipe/static/js/features/homepage-infinity.js +314 -0
  110. x_ipe/static/js/features/kb-core.js +371 -0
  111. x_ipe/static/js/features/quality-evaluation.js +387 -0
  112. x_ipe/static/js/features/sidebar.js +255 -12
  113. x_ipe/static/js/features/tracing-dashboard.js +855 -0
  114. x_ipe/static/js/features/tracing-graph.js +1031 -0
  115. x_ipe/static/js/features/tree-drag.js +227 -0
  116. x_ipe/static/js/features/tree-search.js +228 -0
  117. x_ipe/static/js/features/workplace.js +661 -33
  118. x_ipe/static/js/init.js +76 -0
  119. x_ipe/static/js/terminal-v2.js +45 -14
  120. x_ipe/static/js/terminal.js +50 -49
  121. x_ipe/static/js/uiux-feedback.js +75 -16
  122. x_ipe/templates/base.html +24 -0
  123. x_ipe/templates/index.html +10 -1
  124. x_ipe/templates/knowledge-base.html +110 -0
  125. x_ipe/templates/workplace.html +4 -0
  126. x_ipe/tracing/__init__.py +37 -0
  127. x_ipe/tracing/buffer.py +135 -0
  128. x_ipe/tracing/context.py +125 -0
  129. x_ipe/tracing/decorator.py +288 -0
  130. x_ipe/tracing/middleware.py +197 -0
  131. x_ipe/tracing/parser.py +235 -0
  132. x_ipe/tracing/redactor.py +111 -0
  133. x_ipe/tracing/writer.py +122 -0
  134. {x_ipe-1.0.23.dist-info → x_ipe-1.0.25.dist-info}/METADATA +2 -2
  135. {x_ipe-1.0.23.dist-info → x_ipe-1.0.25.dist-info}/RECORD +138 -65
  136. x_ipe/app.py.bak +0 -1333
  137. x_ipe/resources/skills/x-ipe-skill-creator/SKILL.md +0 -329
  138. x_ipe/resources/skills/x-ipe-skill-creator/references/output-patterns.md +0 -169
  139. x_ipe/resources/skills/x-ipe-skill-creator/references/skill-structure.md +0 -162
  140. x_ipe/resources/skills/x-ipe-skill-creator/references/workflows.md +0 -110
  141. x_ipe/resources/skills/x-ipe-skill-creator/templates/references/examples.md +0 -113
  142. x_ipe/resources/skills/x-ipe-skill-creator/templates/skill-category-skill.md +0 -296
  143. x_ipe/resources/skills/x-ipe-skill-creator/templates/task-type-skill.md +0 -269
  144. {x_ipe-1.0.23.dist-info → x_ipe-1.0.25.dist-info}/WHEEL +0 -0
  145. {x_ipe-1.0.23.dist-info → x_ipe-1.0.25.dist-info}/entry_points.txt +0 -0
  146. {x_ipe-1.0.23.dist-info → x_ipe-1.0.25.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,160 @@
1
+ # Visualization Guide
2
+
3
+ This reference document describes how to use visualization tools in idea summaries.
4
+
5
+ ---
6
+
7
+ ## Config-Driven Visualization
8
+
9
+ Check `x-ipe-docs/config/tools.json` before choosing visualization method:
10
+
11
+ ```yaml
12
+ decision_tree:
13
+ - check: "config.stages.ideation.ideation.antv-infographic"
14
+ if_true: "Use infographic DSL"
15
+ use_for: "Feature lists, roadmaps, comparisons"
16
+
17
+ - check: "config.stages.ideation.ideation.mermaid"
18
+ if_true: "Use mermaid diagrams"
19
+ use_for: "Flowcharts, sequences, state diagrams"
20
+
21
+ - check: "config.stages.ideation.ideation.tool-architecture-dsl"
22
+ if_true: "Use architecture DSL"
23
+ use_for: "Layered architecture, module views"
24
+
25
+ - fallback: "Use standard markdown"
26
+ use_for: "Bullet lists, tables"
27
+ ```
28
+
29
+ ---
30
+
31
+ ## Infographic Templates
32
+
33
+ | Use Case | Template | When to Use |
34
+ |----------|----------|-------------|
35
+ | Feature List | `list-grid-badge-card` | Listing key features with icons |
36
+ | Roadmap | `sequence-roadmap-vertical-simple` | Implementation phases |
37
+ | Comparison | `compare-binary-horizontal-badge-card-arrow` | Comparing options |
38
+
39
+ ### Feature List Example
40
+
41
+ ```infographic
42
+ infographic list-grid-badge-card
43
+ data
44
+ title Key Features
45
+ lists
46
+ - label Feature 1
47
+ desc Description of feature 1
48
+ icon flash
49
+ - label Feature 2
50
+ desc Description of feature 2
51
+ icon shield
52
+ ```
53
+
54
+ ### Roadmap Example
55
+
56
+ ```infographic
57
+ infographic sequence-roadmap-vertical-simple
58
+ data
59
+ title Implementation Phases
60
+ lists
61
+ - label Phase 1
62
+ desc MVP with core features
63
+ - label Phase 2
64
+ desc User feedback integration
65
+ - label Phase 3
66
+ desc Scale and optimize
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Mermaid Diagrams
72
+
73
+ | Use Case | Diagram Type | When to Use |
74
+ |----------|--------------|-------------|
75
+ | User Flow | flowchart | Step-by-step user journey |
76
+ | Process | sequenceDiagram | System interactions |
77
+ | States | stateDiagram | State transitions |
78
+
79
+ ### Flowchart Example
80
+
81
+ ```mermaid
82
+ flowchart TD
83
+ A[User Action] --> B[Feature 1]
84
+ B --> C[Feature 2]
85
+ C --> D[Result]
86
+ ```
87
+
88
+ ### Sequence Example
89
+
90
+ ```mermaid
91
+ sequenceDiagram
92
+ User->>App: Request
93
+ App->>API: Process
94
+ API-->>App: Response
95
+ App-->>User: Display
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Architecture DSL
101
+
102
+ Use for layered architecture when `tool-architecture-dsl` is enabled:
103
+
104
+ ```architecture-dsl
105
+ @startuml module-view
106
+ title "System Architecture"
107
+ theme "theme-default"
108
+ direction top-to-bottom
109
+ grid 12 x 6
110
+
111
+ layer "Frontend" {
112
+ color "#fce7f3"
113
+ border-color "#ec4899"
114
+ rows 2
115
+ module "Web" { cols 12, rows 2, grid 1 x 1, component "React App" { cols 1, rows 1 } }
116
+ }
117
+
118
+ layer "Backend" {
119
+ color "#dbeafe"
120
+ border-color "#3b82f6"
121
+ rows 2
122
+ module "Services" { cols 12, rows 2, grid 2 x 1, component "API" { cols 1, rows 1 }, component "Workers" { cols 1, rows 1 } }
123
+ }
124
+
125
+ @enduml
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Fallback (No Tools Enabled)
131
+
132
+ When all visualization tools are disabled, use standard markdown:
133
+
134
+ ### Feature List (Fallback)
135
+ ```markdown
136
+ ## Key Features
137
+
138
+ - **Feature 1:** Description of feature 1
139
+ - **Feature 2:** Description of feature 2
140
+ - **Feature 3:** Description of feature 3
141
+ ```
142
+
143
+ ### Comparison (Fallback)
144
+ ```markdown
145
+ | Option | Pros | Cons |
146
+ |--------|------|------|
147
+ | Option A | Fast, cheap | Limited features |
148
+ | Option B | Full features | Slower, expensive |
149
+ ```
150
+
151
+ ### Process (Fallback)
152
+ ```markdown
153
+ ## Process Flow
154
+
155
+ 1. User logs in
156
+ 2. Dashboard loads
157
+ 3. User selects action
158
+ 4. System processes
159
+ 5. Result displayed
160
+ ```
@@ -0,0 +1,86 @@
1
+ # Idea Summary Template
2
+
3
+ > Use this template when creating `idea-summary-vN.md` files.
4
+
5
+ ```markdown
6
+ # Idea Summary
7
+
8
+ > Idea ID: IDEA-XXX
9
+ > Folder: {folder_name}
10
+ > Version: vN
11
+ > Created: {date}
12
+ > Status: Refined
13
+
14
+ ## Overview
15
+ {Brief description of the refined idea}
16
+
17
+ ## Problem Statement
18
+ {What problem does this idea solve?}
19
+
20
+ ## Target Users
21
+ {Who will benefit?}
22
+
23
+ ## Proposed Solution
24
+ {High-level description of the solution}
25
+
26
+ ## Key Features
27
+
28
+ {IF antv-infographic enabled → use infographic DSL}
29
+ {IF mermaid enabled → use mermaid for flow}
30
+ {IF both disabled → use bullet list}
31
+
32
+ <!-- Example if antv-infographic: true -->
33
+ ```infographic
34
+ infographic list-grid-badge-card
35
+ data
36
+ title Key Features
37
+ lists
38
+ - label Feature 1
39
+ desc Description of feature 1
40
+ icon flash
41
+ - label Feature 2
42
+ desc Description of feature 2
43
+ icon shield
44
+ ```
45
+
46
+ <!-- Example if mermaid: true (for user flow) -->
47
+ ```mermaid
48
+ flowchart TD
49
+ A[User Action] --> B[Feature 1]
50
+ B --> C[Feature 2]
51
+ ```
52
+
53
+ ## Success Criteria
54
+ - [ ] Criterion 1
55
+ - [ ] Criterion 2
56
+
57
+ ## Constraints & Considerations
58
+ - Constraint 1
59
+ - Constraint 2
60
+
61
+ ## Brainstorming Notes
62
+ {Key insights from brainstorming session}
63
+
64
+ ## Ideation Artifacts (If Tools Used)
65
+ {Link to any mockups, prototypes, or visual artifacts created during brainstorming}
66
+ - Mockup: {path or description}
67
+ - Prototype: {path or URL}
68
+
69
+ ## Source Files
70
+ - file1.md
71
+ - file2.txt
72
+
73
+ ## Next Steps
74
+ - [ ] Proceed to Idea Mockup / Idea to Architecture / Requirement Gathering
75
+
76
+ ## References & Common Principles
77
+ {Include if the idea involves common/established topics}
78
+
79
+ ### Applied Principles
80
+ - **Principle 1:** {Description} - [Source](URL)
81
+ - **Principle 2:** {Description} - [Source](URL)
82
+
83
+ ### Further Reading
84
+ - [Resource 1](URL) - {Brief description}
85
+ - [Resource 2](URL) - {Brief description}
86
+ ```
x_ipe/routes/__init__.py CHANGED
@@ -10,6 +10,7 @@ from .project_routes import project_bp
10
10
  from .ideas_routes import ideas_bp
11
11
  from .tools_routes import tools_bp
12
12
  from .proxy_routes import proxy_bp
13
+ from .kb_routes import kb_bp
13
14
 
14
15
  __all__ = [
15
16
  'main_bp',
@@ -18,4 +19,5 @@ __all__ = [
18
19
  'ideas_bp',
19
20
  'tools_bp',
20
21
  'proxy_bp',
22
+ 'kb_bp',
21
23
  ]
@@ -15,11 +15,13 @@ import os
15
15
  from flask import Blueprint, jsonify, request, current_app
16
16
 
17
17
  from x_ipe.services import IdeasService, SkillsService
18
+ from x_ipe.tracing import x_ipe_tracing
18
19
 
19
20
  ideas_bp = Blueprint('ideas', __name__)
20
21
 
21
22
 
22
23
  @ideas_bp.route('/api/ideas/tree', methods=['GET'])
24
+ @x_ipe_tracing()
23
25
  def get_ideas_tree():
24
26
  """
25
27
  GET /api/ideas/tree
@@ -47,6 +49,7 @@ def get_ideas_tree():
47
49
 
48
50
 
49
51
  @ideas_bp.route('/api/ideas/upload', methods=['POST'])
52
+ @x_ipe_tracing()
50
53
  def upload_ideas():
51
54
  """
52
55
  POST /api/ideas/upload
@@ -91,7 +94,51 @@ def upload_ideas():
91
94
  return jsonify(result), 400
92
95
 
93
96
 
97
+ @ideas_bp.route('/api/ideas/create-folder', methods=['POST'])
98
+ @x_ipe_tracing()
99
+ def create_idea_folder():
100
+ """
101
+ POST /api/ideas/create-folder
102
+
103
+ Create a new empty folder in ideas directory.
104
+
105
+ Request body:
106
+ - folder_name: string - Name for the new folder
107
+ - parent_folder: string (optional) - Parent folder path
108
+
109
+ Response:
110
+ - success: true/false
111
+ - folder_name: string
112
+ - folder_path: string
113
+ """
114
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
115
+ service = IdeasService(project_root)
116
+
117
+ if not request.is_json:
118
+ return jsonify({
119
+ 'success': False,
120
+ 'error': 'JSON required'
121
+ }), 400
122
+
123
+ data = request.get_json()
124
+ folder_name = data.get('folder_name')
125
+ parent_folder = data.get('parent_folder')
126
+
127
+ if not folder_name:
128
+ return jsonify({
129
+ 'success': False,
130
+ 'error': 'folder_name is required'
131
+ }), 400
132
+
133
+ result = service.create_folder(folder_name, parent_folder)
134
+
135
+ if result['success']:
136
+ return jsonify(result)
137
+ return jsonify(result), 400
138
+
139
+
94
140
  @ideas_bp.route('/api/ideas/rename', methods=['POST'])
141
+ @x_ipe_tracing()
95
142
  def rename_idea_folder():
96
143
  """
97
144
  POST /api/ideas/rename
@@ -135,6 +182,7 @@ def rename_idea_folder():
135
182
 
136
183
 
137
184
  @ideas_bp.route('/api/ideas/rename-file', methods=['POST'])
185
+ @x_ipe_tracing()
138
186
  def rename_idea_file():
139
187
  """
140
188
  POST /api/ideas/rename-file
@@ -178,6 +226,7 @@ def rename_idea_file():
178
226
 
179
227
 
180
228
  @ideas_bp.route('/api/ideas/delete', methods=['POST'])
229
+ @x_ipe_tracing()
181
230
  def delete_idea_item():
182
231
  """
183
232
  POST /api/ideas/delete
@@ -218,6 +267,7 @@ def delete_idea_item():
218
267
 
219
268
 
220
269
  @ideas_bp.route('/api/ideas/toolbox', methods=['GET'])
270
+ @x_ipe_tracing()
221
271
  def get_ideas_toolbox():
222
272
  """
223
273
  GET /api/ideas/toolbox
@@ -238,6 +288,7 @@ def get_ideas_toolbox():
238
288
 
239
289
 
240
290
  @ideas_bp.route('/api/ideas/toolbox', methods=['POST'])
291
+ @x_ipe_tracing()
241
292
  def save_ideas_toolbox():
242
293
  """
243
294
  POST /api/ideas/toolbox
@@ -264,6 +315,243 @@ def save_ideas_toolbox():
264
315
  return jsonify(result), 400
265
316
 
266
317
 
318
+ # ==========================================================================
319
+ # CR-006: Folder Tree UX Enhancement API Endpoints
320
+ # ==========================================================================
321
+
322
+ @ideas_bp.route('/api/ideas/move', methods=['POST'])
323
+ @x_ipe_tracing()
324
+ def move_idea_item():
325
+ """
326
+ POST /api/ideas/move
327
+
328
+ Move a file or folder to a new location.
329
+
330
+ Request body:
331
+ - source_path: string - Path of item to move
332
+ - target_folder: string - Destination folder path
333
+
334
+ Response:
335
+ - success: true/false
336
+ - new_path: string
337
+ """
338
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
339
+ service = IdeasService(project_root)
340
+
341
+ if not request.is_json:
342
+ return jsonify({'success': False, 'error': 'JSON required'}), 400
343
+
344
+ data = request.get_json()
345
+ source_path = data.get('source_path')
346
+ target_folder = data.get('target_folder')
347
+
348
+ if source_path is None:
349
+ return jsonify({'success': False, 'error': 'source_path is required'}), 400
350
+
351
+ if target_folder is None:
352
+ return jsonify({'success': False, 'error': 'target_folder is required'}), 400
353
+
354
+ result = service.move_item(source_path, target_folder)
355
+
356
+ if result['success']:
357
+ return jsonify(result)
358
+ return jsonify(result), 400
359
+
360
+
361
+ @ideas_bp.route('/api/ideas/duplicate', methods=['POST'])
362
+ @x_ipe_tracing()
363
+ def duplicate_idea_item():
364
+ """
365
+ POST /api/ideas/duplicate
366
+
367
+ Duplicate a file or folder with -copy suffix.
368
+
369
+ Request body:
370
+ - path: string - Path of item to duplicate
371
+
372
+ Response:
373
+ - success: true/false
374
+ - new_path: string
375
+ """
376
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
377
+ service = IdeasService(project_root)
378
+
379
+ if not request.is_json:
380
+ return jsonify({'success': False, 'error': 'JSON required'}), 400
381
+
382
+ data = request.get_json()
383
+ path = data.get('path')
384
+
385
+ if not path:
386
+ return jsonify({'success': False, 'error': 'path is required'}), 400
387
+
388
+ result = service.duplicate_item(path)
389
+
390
+ if result['success']:
391
+ return jsonify(result)
392
+ return jsonify(result), 400
393
+
394
+
395
+ @ideas_bp.route('/api/ideas/download', methods=['GET'])
396
+ @x_ipe_tracing()
397
+ def download_idea_file():
398
+ """
399
+ GET /api/ideas/download?path=...
400
+
401
+ Download a file from ideas folder.
402
+
403
+ Query params:
404
+ - path: string - Path of file to download
405
+
406
+ Response:
407
+ File download with appropriate Content-Type
408
+ """
409
+ from flask import send_file
410
+ import io
411
+
412
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
413
+ service = IdeasService(project_root)
414
+
415
+ path = request.args.get('path')
416
+
417
+ if not path:
418
+ return jsonify({'success': False, 'error': 'path is required'}), 400
419
+
420
+ result = service.get_download_info(path)
421
+
422
+ if not result['success']:
423
+ # Return 404 for file not found
424
+ status_code = 404 if 'not found' in result['error'].lower() else 400
425
+ return jsonify(result), status_code
426
+
427
+ # Handle both string and bytes content
428
+ content = result['content']
429
+ if isinstance(content, str):
430
+ content = content.encode('utf-8')
431
+
432
+ return send_file(
433
+ io.BytesIO(content),
434
+ mimetype=result['mime_type'],
435
+ as_attachment=True,
436
+ download_name=result['filename']
437
+ )
438
+
439
+
440
+ @ideas_bp.route('/api/ideas/folder-contents', methods=['GET'])
441
+ @x_ipe_tracing()
442
+ def get_folder_contents():
443
+ """
444
+ GET /api/ideas/folder-contents?path=...
445
+
446
+ Get contents of a specific folder.
447
+
448
+ Query params:
449
+ - path: string - Folder path (optional, defaults to ideas root)
450
+
451
+ Response:
452
+ - success: true/false
453
+ - items: array of file/folder objects
454
+ """
455
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
456
+ service = IdeasService(project_root)
457
+
458
+ path = request.args.get('path', '')
459
+
460
+ result = service.get_folder_contents(path)
461
+
462
+ if result['success']:
463
+ return jsonify(result)
464
+ return jsonify(result), 400
465
+
466
+
467
+ @ideas_bp.route('/api/ideas/search', methods=['GET'])
468
+ @x_ipe_tracing()
469
+ def search_ideas():
470
+ """
471
+ GET /api/ideas/search?q=...
472
+
473
+ Search/filter ideas tree by query.
474
+
475
+ Query params:
476
+ - q: string - Search query
477
+
478
+ Response:
479
+ - success: true/false
480
+ - tree: filtered tree structure
481
+ """
482
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
483
+ service = IdeasService(project_root)
484
+
485
+ query = request.args.get('q', '')
486
+
487
+ try:
488
+ tree = service.filter_tree(query)
489
+ return jsonify({'success': True, 'tree': tree})
490
+ except Exception as e:
491
+ return jsonify({'success': False, 'error': str(e)}), 500
492
+
493
+
494
+ @ideas_bp.route('/api/ideas/delete-info', methods=['GET'])
495
+ @x_ipe_tracing()
496
+ def get_delete_info():
497
+ """
498
+ GET /api/ideas/delete-info?path=...
499
+
500
+ Get item info for delete confirmation dialog.
501
+
502
+ Query params:
503
+ - path: string - Path of item to delete
504
+
505
+ Response:
506
+ - success: true/false
507
+ - name: string
508
+ - type: 'file' | 'folder'
509
+ - item_count: number (for folders)
510
+ """
511
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
512
+ service = IdeasService(project_root)
513
+
514
+ path = request.args.get('path')
515
+
516
+ if not path:
517
+ return jsonify({'success': False, 'error': 'path is required'}), 400
518
+
519
+ result = service.get_delete_info(path)
520
+
521
+ if result['success']:
522
+ return jsonify(result)
523
+ return jsonify(result), 400
524
+
525
+
526
+ @ideas_bp.route('/api/ideas/validate-drop', methods=['POST'])
527
+ @x_ipe_tracing()
528
+ def validate_drop_target():
529
+ """
530
+ POST /api/ideas/validate-drop
531
+
532
+ Validate if drop target is valid for drag source.
533
+
534
+ Request body:
535
+ - source_path: string - Path being dragged
536
+ - target_folder: string - Drop target folder
537
+
538
+ Response:
539
+ - valid: true/false
540
+ """
541
+ project_root = current_app.config.get('PROJECT_ROOT', os.getcwd())
542
+ service = IdeasService(project_root)
543
+
544
+ if not request.is_json:
545
+ return jsonify({'valid': False}), 400
546
+
547
+ data = request.get_json()
548
+ source_path = data.get('source_path')
549
+ target_folder = data.get('target_folder', '')
550
+
551
+ valid = service.is_valid_drop_target(source_path, target_folder)
552
+ return jsonify({'valid': valid})
553
+
554
+
267
555
  # ==========================================================================
268
556
  # SKILLS API
269
557
  #
@@ -271,6 +559,7 @@ def save_ideas_toolbox():
271
559
  # ==========================================================================
272
560
 
273
561
  @ideas_bp.route('/api/skills', methods=['GET'])
562
+ @x_ipe_tracing()
274
563
  def get_skills():
275
564
  """
276
565
  GET /api/skills
@@ -0,0 +1,80 @@
1
+ """
2
+ FEATURE-025-A: KB Core Infrastructure
3
+
4
+ KB Routes: REST API endpoints for Knowledge Base operations.
5
+ """
6
+ from flask import Blueprint, jsonify, current_app
7
+
8
+ from x_ipe.services.kb_service import KBService
9
+ from x_ipe.tracing import x_ipe_tracing
10
+
11
+ kb_bp = Blueprint('kb', __name__, url_prefix='/api/kb')
12
+
13
+
14
+ def _get_kb_service() -> KBService:
15
+ """Get KBService instance using project root from app config."""
16
+ project_root = current_app.config.get('PROJECT_ROOT', '.')
17
+ return KBService(project_root)
18
+
19
+
20
+ @kb_bp.route('/index', methods=['GET'])
21
+ @x_ipe_tracing(level="INFO")
22
+ def get_index():
23
+ """
24
+ Get current file index.
25
+
26
+ Returns:
27
+ JSON: File index with version, last_updated, and files list
28
+ """
29
+ service = _get_kb_service()
30
+ index = service.get_index()
31
+ return jsonify(index)
32
+
33
+
34
+ @kb_bp.route('/index/refresh', methods=['POST'])
35
+ @x_ipe_tracing(level="INFO")
36
+ def refresh_index():
37
+ """
38
+ Rebuild file index from file system.
39
+
40
+ Returns:
41
+ JSON: Updated file index
42
+ """
43
+ service = _get_kb_service()
44
+ index = service.refresh_index()
45
+ return jsonify(index)
46
+
47
+
48
+ @kb_bp.route('/topics', methods=['GET'])
49
+ @x_ipe_tracing(level="INFO")
50
+ def get_topics():
51
+ """
52
+ Get list of all topics.
53
+
54
+ Returns:
55
+ JSON: { "topics": ["topic1", "topic2", ...] }
56
+ """
57
+ service = _get_kb_service()
58
+ topics = service.get_topics()
59
+ return jsonify({"topics": topics})
60
+
61
+
62
+ @kb_bp.route('/topics/<name>', methods=['GET'])
63
+ @x_ipe_tracing(level="INFO")
64
+ def get_topic_metadata(name: str):
65
+ """
66
+ Get metadata for a specific topic.
67
+
68
+ Args:
69
+ name: Topic folder name
70
+
71
+ Returns:
72
+ JSON: Topic metadata or 404 if not found
73
+ """
74
+ service = _get_kb_service()
75
+ metadata = service.get_topic_metadata(name)
76
+
77
+ if metadata is None:
78
+ return jsonify({"error": f"Topic '{name}' not found"}), 404
79
+
80
+ return jsonify(metadata)