@nine-lab/nine-mu 0.1.324 β†’ 0.1.326

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nine-lab/nine-mu",
3
- "version": "0.1.324",
3
+ "version": "0.1.326",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -125,7 +125,8 @@ export class NineChat extends HTMLElement {
125
125
 
126
126
  const asis = await this.#manager.getRoutes();
127
127
 
128
- if (parsed?.selected_tool === "generator-menu") {
128
+ /**
129
+ if (parsed?.selected_tool === "generate-menu") {
129
130
  const hasCreated = parsed?.data.some(item => item.action === 'CREATE');
130
131
  const hasUpdated = parsed?.data.some(item => item.action === 'UPDATE');
131
132
  const hasDeleted = parsed?.data.some(item => item.action === 'DELETE');
@@ -140,7 +141,7 @@ export class NineChat extends HTMLElement {
140
141
  this.#showDiff(asis, tobe, "json");
141
142
  });
142
143
  }
143
- }
144
+ } */
144
145
 
145
146
  // πŸ’‘ λ§Œμ•½ intentκ°€ EXECUTE_TOOLμ΄κ±°λ‚˜ NAVIGATE일 λ•Œ ν”„λ‘ νŠΈμ—μ„œ
146
147
  // ν™”λ©΄ 이동(Routing)μ΄λ‚˜ μΆ”κ°€ μ•‘μ…˜μ„ ν•΄μ•Ό ν•œλ‹€λ©΄ μ—¬κΈ°μ„œ parsedData.target_path 등을 ν™œμš©ν•˜λ©΄ λ©λ‹ˆλ‹€!
@@ -1,12 +1,15 @@
1
1
  import { trace } from "@nopeer";
2
2
  import { api } from "@nine-lab/nine-util";
3
+ import {NineChatManager} from "./NineChatManager.js";
3
4
 
4
5
  export class NotificationHandler {
5
6
  #owner;
7
+ #manager;
6
8
  #collectedFiles = [];
7
9
 
8
10
  constructor(owner) {
9
11
  this.#owner = owner; // μ›Ή μ»΄ν¬λ„ŒνŠΈλ‚˜ UI DOM μΈμŠ€ν„΄μŠ€
12
+ this.#manager = new NineChatManager(owner);
10
13
  }
11
14
 
12
15
  /**
@@ -36,31 +39,39 @@ export class NotificationHandler {
36
39
  // 2. 🚨 [λ‚˜μ€‘μ— 100μ‹œκ°„μ§œλ¦¬ 완벽을 μ±„μšΈ 핡심 κΈΈλͺ©]
37
40
  // 데이터에 μ†ŒμŠ€μ½”λ“œ μ•Œλ§Ήμ΄(data.source)λ‚˜ 메타데이터가 μ‹€λ € 내렀왔을 λ•Œμ˜ ν–‰μœ„λ₯Ό μ—¬κΈ°μ„œ 격리 μ²˜λ¦¬ν•©λ‹ˆλ‹€.
38
41
 
42
+ /**
39
43
  switch (logger) {
40
44
  case "generate-source-brain":
41
- //if (data && data.source) {
42
- //trace.log(`[μ‹œκ·Έλ„ 감지] 섀계 μ™„λ£Œ`, data);
43
- this.#generateSource(data);
44
- //}
45
+ this.#generateSource(data);
45
46
  break;
46
47
 
47
48
  case "modify-source-brain":
48
- if (data && data.source) {
49
- this.#collectModifySource(data);
50
- }
49
+ this.#collectModifySource(data);
51
50
  break;
52
51
 
53
52
  case "modify-source-brain-completed":
54
- //trace.log(`[μ‹œκ·Έλ„ 감지] 섀계 μ™„λ£Œ`, data);
55
53
  this.#openDiffPopup();
56
54
  break;
57
- }
55
+ } */
56
+
57
+ // μžλ°”μ˜ -> 처럼 μžλ°”μŠ€ν¬λ¦½νŠΈμ˜ => (ν™”μ‚΄ν‘œ ν•¨μˆ˜)λ₯Ό ν™œμš©ν•œ λ§€ν•‘
58
+ const runAction = {
59
+ "generate-menu-completed": () => this.#generateMenu(data),
60
+ "generate-source-brain": () => this.#generateSource(data),
61
+ "modify-source-brain": () => this.#collectModifySource(data),
62
+ "modify-source-brain-completed": () => this.#openDiffPopup(),
63
+ }[logger];
64
+
65
+ runAction?.();
58
66
  }
59
67
 
60
68
  /**
61
69
  * λ ˆμ΄μ–΄λ³„λ‘œ 순차 λ„μ°©ν•˜λŠ” νŒŒμΌλ“€μ„ μœ μ‹€ 없이 λ°°μ—΄ 버퍼에 μˆ˜μ§‘
62
70
  */
63
71
  #collectModifySource = (data) => {
72
+
73
+ if (!data || !data.source) return;
74
+
64
75
  const filePayload = {
65
76
  layer: data.layer || "Unknown",
66
77
  full_path: data.full_path || "unknown_file",
@@ -78,9 +89,7 @@ export class NotificationHandler {
78
89
  if (this.#collectedFiles.length === 0) return;
79
90
 
80
91
  const $oldPopup = this.#owner.shadowRoot.querySelector('nine-diff-popup');
81
- if ($oldPopup) {
82
- $oldPopup.remove();
83
- }
92
+ if ($oldPopup) $oldPopup.remove();
84
93
 
85
94
  // DOM 상에 싱글톀 νŒμ—… μΈμŠ€ν„΄μŠ€ λ ˆμ΄μ•„μ›ƒ μΆ”μΆœ 및 λΉŒλ“œ
86
95
 
@@ -99,28 +108,60 @@ export class NotificationHandler {
99
108
  this.#collectedFiles = [];
100
109
  };
101
110
 
111
+ #openRouteDiffPopup = (asis, tobe, lang) => {
112
+ // 1. ν˜Ήμ‹œ μž”μƒμ΄ λ‚¨μ•„μžˆμ„μ§€ λͺ¨λ₯΄λ‹ˆ 기쑴에 μƒμ„±λœ νŒμ—…μ΄ μžˆλ‹€λ©΄ κ°•μ œ 제거
113
+ const $oldPopup = this.#owner.shadowRoot.querySelector('nine-menu-diff-popup');
114
+ if ($oldPopup) $oldPopup.remove();
115
+
116
+ // 2. λ™μ μœΌλ‘œ μ»€μŠ€ν…€ μ—˜λ¦¬λ¨ΌνŠΈ 생성
117
+ const $diffPopup = document.createElement('nine-menu-diff-popup');
118
+
119
+ // 3. 래퍼(wrapper) μ•ˆμ΄λ‚˜ shadowRoot 제일 λ°‘λ°”λ‹₯에 λΆ€μ°©
120
+ const container = this.#owner.shadowRoot.querySelector('.wrapper') || this.shadowRoot;
121
+ container.appendChild($diffPopup);
122
+
123
+ // 4. 데이터 μ£Όμž… 및 νŒμ—… μ‹€ν–‰
124
+ // πŸ’‘ νŒμ—…μ΄ λ„€μ΄ν‹°λΈŒ <dialog> 기반이라면 .popup() λ‚΄λΆ€μ—μ„œ showModal()이 싀행될 κ²λ‹ˆλ‹€.
125
+ $diffPopup.popup().data(asis, tobe, lang);
126
+ }
127
+
102
128
  /**
103
129
  * [뢄리 λΉ„μ¦ˆλ‹ˆμŠ€ 둜직 2] μˆ˜μ‹ λœ μ†ŒμŠ€μ½”λ“œ 데이터 μœ νš¨μ„± 검증 및 μΆ”ν›„ 파일 μ €μž₯ 연동
104
130
  */
105
131
  #generateSource = async (data) => {
106
132
 
107
- trace.log(data);
108
-
109
- return;
110
-
111
- // μ†ŒμŠ€μ½”λ“œ 데이터가 μ •μƒμ μœΌλ‘œ ν™•λ³΄λ˜μ—ˆλŠ”μ§€ 1%의 λˆ„λ½ 검증
112
- if (data.layer) {
113
- //trace.warn("⚠️ μ†ŒμŠ€ λ˜λŠ” 파일λͺ… λˆ„λ½ 데이터 μˆ˜μ‹ λ¨", data);
114
- //return;
115
- }
133
+ if (!data.path || !data.source) return;
116
134
 
117
135
  const res = await api.post("/nine-mu/source/generateRealFileSingle", {
118
136
  //package_path: data.path,
119
137
  //file_name: data.file_name,
120
- currentPath: location.pathname,
138
+ currentPath: data.path,
121
139
  contents: data.source
122
140
  });
123
141
 
124
- trace.log(res)
142
+ trace.log(res);
143
+ }
144
+
145
+ #generateMenu = async (data) => {
146
+
147
+ if (!data) return;
148
+
149
+ const hasCreated = data.some(item => item.action === 'CREATE');
150
+ const hasUpdated = data.some(item => item.action === 'UPDATE');
151
+ const hasDeleted = data.some(item => item.action === 'DELETE');
152
+
153
+ if (hasUpdated || hasCreated || hasDeleted) {
154
+
155
+ const asis = await this.#manager.getRoutes();
156
+
157
+ // μ§„μ§œ 메뉴λͺ… λ³€κ²½μ΄λ‚˜ μ΄λ™λ§Œ μš”μ²­ν•œ 경우
158
+ nine.alert("메뉴 정리λ₯Ό μœ„ν•œ λΌμš°ν„° 정보 μ €μž₯ ν™”λ©΄μœΌλ‘œ μ΄λ™ν•©λ‹ˆλ‹€.").then(res => {
159
+ const tobe = (data || [])
160
+ .filter(item => item.action !== 'DELETE')
161
+ .map(({ isNew, action, ...rest }) => rest);
162
+
163
+ this.#openRouteDiffPopup(asis, tobe, "json");
164
+ });
165
+ }
125
166
  }
126
167
  }