@chinhae/atw-cli 0.2.3 → 0.2.5

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 (37) hide show
  1. package/README.md +34 -0
  2. package/dist/commands/channel/store/filter.d.ts +1 -1
  3. package/dist/commands/channel/store/filter.d.ts.map +1 -1
  4. package/dist/commands/channel/store/filter.js +1 -1
  5. package/dist/commands/channel/store/filter.js.map +1 -1
  6. package/dist/commands/channel/store/schema.d.ts +2 -11
  7. package/dist/commands/channel/store/schema.d.ts.map +1 -1
  8. package/dist/commands/channel/store/schema.js +1 -12
  9. package/dist/commands/channel/store/schema.js.map +1 -1
  10. package/dist/commands/channel/store/thread-state.d.ts +2 -2
  11. package/dist/commands/channel/store/thread-state.d.ts.map +1 -1
  12. package/dist/commands/channel/store/thread-state.js +1 -1
  13. package/dist/commands/channel/store/thread-state.js.map +1 -1
  14. package/dist/migrations/manifests/0.2.4.json +9 -0
  15. package/dist/migrations/manifests/0.2.5.json +9 -0
  16. package/dist/templates/atw/workflow.md +17 -0
  17. package/dist/templates/common/bundled-skills/dejargonizer/SKILL.md +133 -0
  18. package/dist/templates/common/bundled-skills/noob-mode/SKILL.md +175 -0
  19. package/dist/templates/common/bundled-skills/noob-mode/references/examples.md +418 -0
  20. package/dist/templates/common/bundled-skills/noob-mode/references/glossary.md +368 -0
  21. package/dist/templates/common/bundled-skills/oxy-explanation/SKILL.md +80 -0
  22. package/dist/templates/common/bundled-skills/oxy-learning-hub/SKILL.md +179 -0
  23. package/dist/templates/common/bundled-skills/oxy-learning-hub/assets/course.css +1044 -0
  24. package/dist/templates/common/bundled-skills/oxy-learning-hub/assets/course.js +184 -0
  25. package/dist/templates/common/bundled-skills/oxy-learning-hub/assets/lesson-template.html +125 -0
  26. package/dist/templates/common/bundled-skills/oxy-learning-hub/assets/summary-template.html +659 -0
  27. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/publishing.md +64 -0
  28. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/summary-mode.md +96 -0
  29. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/teaching/GLOSSARY-FORMAT.md +30 -0
  30. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/teaching/LEARNING-RECORD-FORMAT.md +42 -0
  31. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/teaching/MISSION-FORMAT.md +50 -0
  32. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/teaching/RESOURCES-FORMAT.md +40 -0
  33. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/teaching-mode.md +251 -0
  34. package/dist/templates/common/bundled-skills/oxy-learning-hub/references/workspace.md +112 -0
  35. package/dist/templates/common/bundled-skills/oxy-learning-hub/scripts/validate_html.py +198 -0
  36. package/dist/templates/common/bundled-skills/show-me/SKILL.md +127 -0
  37. package/package.json +2 -2
@@ -0,0 +1,198 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import re
5
+ import sys
6
+ from html.parser import HTMLParser
7
+ from pathlib import Path
8
+
9
+ PLACEHOLDER = re.compile(r"\{\{[A-Z_]+\}\}")
10
+ URI_SCHEME = re.compile(r"^[a-z][a-z0-9+.-]*:", re.IGNORECASE)
11
+
12
+
13
+ def is_local_reference(value: str) -> bool:
14
+ value = value.strip()
15
+ return bool(value) and not value.startswith("//") and not URI_SCHEME.match(value)
16
+
17
+
18
+ class HTMLStructureParser(HTMLParser):
19
+ """提取文档结构、本地资源和本地导航,不限制远程能力。"""
20
+
21
+ def __init__(self) -> None:
22
+ super().__init__(convert_charrefs=True)
23
+ self.in_head = False
24
+ self.in_title = False
25
+ self.html_has_lang = False
26
+ self.has_viewport = False
27
+ self.title_parts: list[str] = []
28
+ self.duplicate_attributes: list[str] = []
29
+ self.local_assets: list[str] = []
30
+ self.local_links: list[str] = []
31
+ self.ids: set[str] = set()
32
+
33
+ def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None:
34
+ tag = tag.lower()
35
+ attributes: dict[str, str] = {}
36
+ for name, value in attrs:
37
+ name = name.lower()
38
+ if name in attributes:
39
+ self.duplicate_attributes.append(f"{tag} 含重复属性 {name}")
40
+ continue
41
+ attributes[name] = value or ""
42
+
43
+ element_id = attributes.get("id", "").strip()
44
+ if element_id:
45
+ self.ids.add(element_id)
46
+
47
+ if tag == "html":
48
+ self.html_has_lang = bool(attributes.get("lang", "").strip())
49
+ elif tag == "head":
50
+ self.in_head = True
51
+ elif tag == "body":
52
+ self.in_head = False
53
+ self.in_title = False
54
+ elif tag == "title" and self.in_head:
55
+ self.in_title = True
56
+
57
+ if (
58
+ tag == "meta"
59
+ and self.in_head
60
+ and attributes.get("name", "").lower() == "viewport"
61
+ and attributes.get("content", "").strip()
62
+ ):
63
+ self.has_viewport = True
64
+
65
+ asset_attributes = {
66
+ "script": ("src",),
67
+ "link": ("href",),
68
+ "img": ("src", "srcset"),
69
+ "source": ("src", "srcset"),
70
+ "video": ("src", "poster"),
71
+ "audio": ("src",),
72
+ }
73
+ for name in asset_attributes.get(tag, ()):
74
+ for item in attributes.get(name, "").split(","):
75
+ candidate = item.strip().split()[0] if item.strip() else ""
76
+ if candidate and is_local_reference(candidate) and not candidate.startswith("#"):
77
+ self.local_assets.append(candidate)
78
+
79
+ if tag == "a":
80
+ href = attributes.get("href", "").strip()
81
+ if href and is_local_reference(href):
82
+ self.local_links.append(href)
83
+
84
+ def handle_endtag(self, tag: str) -> None:
85
+ tag = tag.lower()
86
+ if tag == "head":
87
+ self.in_head = False
88
+ elif tag == "title":
89
+ self.in_title = False
90
+
91
+ def handle_data(self, data: str) -> None:
92
+ if self.in_title:
93
+ self.title_parts.append(data)
94
+
95
+
96
+ def parse(text: str) -> HTMLStructureParser:
97
+ parser = HTMLStructureParser()
98
+ parser.feed(text)
99
+ return parser
100
+
101
+
102
+ def validate_text(text: str) -> list[str]:
103
+ """验证必要结构;远程资源、网络 API 和页面跳转均允许。"""
104
+ errors: list[str] = []
105
+ parser = parse(text)
106
+
107
+ if PLACEHOLDER.search(text):
108
+ errors.append("仍有未替换的模板占位符")
109
+ if parser.duplicate_attributes:
110
+ errors.extend(parser.duplicate_attributes)
111
+ if not parser.html_has_lang:
112
+ errors.append("html 根元素缺少非空 lang 属性")
113
+ if not parser.has_viewport:
114
+ errors.append("head 中缺少 viewport 元数据")
115
+ if not "".join(parser.title_parts).strip():
116
+ errors.append("head 中缺少非空 title")
117
+
118
+ return errors
119
+
120
+
121
+ def validate(path: Path) -> list[str]:
122
+ text = path.read_text(encoding="utf-8")
123
+ errors = validate_text(text)
124
+ parser = parse(text)
125
+
126
+ for asset in parser.local_assets:
127
+ clean = asset.split("?", 1)[0].split("#", 1)[0]
128
+ if clean and not (path.parent / clean).resolve().is_file():
129
+ errors.append(f"本地资源不存在:{asset}")
130
+
131
+ for link in parser.local_links:
132
+ target, _, fragment = link.partition("#")
133
+ target_path = path if not target else (path.parent / target).resolve()
134
+ if not target_path.is_file():
135
+ errors.append(f"本地链接目标不存在:{link}")
136
+ continue
137
+ if fragment and target_path.suffix.lower() in {".html", ".htm"}:
138
+ target_parser = parse(target_path.read_text(encoding="utf-8"))
139
+ if fragment not in target_parser.ids:
140
+ errors.append(f"本地链接锚点不存在:{link}")
141
+
142
+ return errors
143
+
144
+
145
+ def self_test() -> None:
146
+ """最小自检:远程资源和网络 API 可用,结构错误仍会被发现。"""
147
+ good = """<!doctype html><html lang="zh-CN"><head>
148
+ <meta name="viewport" content="width=device-width"><title>课程</title>
149
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Manrope">
150
+ </head><body><script>fetch('/lesson'); location.replace('#done')</script></body></html>"""
151
+ bad_cases = [
152
+ good.replace("课程", "{{TITLE}}"),
153
+ good.replace('<html lang="zh-CN">', "<html>"),
154
+ good.replace('<meta name="viewport" content="width=device-width">', ""),
155
+ good.replace("<title>课程</title>", "<title></title>"),
156
+ good.replace("<title>课程</title>", '<title id="a" id="b">课程</title>'),
157
+ ]
158
+
159
+ if validate_text(good):
160
+ raise RuntimeError("远程资源或网络 API 被错误拒绝")
161
+ if any(not validate_text(case) for case in bad_cases):
162
+ raise RuntimeError("占位符或文档结构检查未生效")
163
+
164
+
165
+ def main() -> int:
166
+ parser = argparse.ArgumentParser(description="验证 Oxy Learning Hub HTML 结构与本地引用")
167
+ parser.add_argument("files", nargs="*", type=Path)
168
+ parser.add_argument("--self-test", action="store_true")
169
+ args = parser.parse_args()
170
+
171
+ if args.self_test:
172
+ self_test()
173
+ print("自检通过")
174
+ return 0
175
+ if not args.files:
176
+ parser.error("请提供至少一个 HTML 文件,或使用 --self-test")
177
+
178
+ failed = False
179
+ for path in args.files:
180
+ if not path.is_file():
181
+ print(f"失败 {path}: 文件不存在")
182
+ failed = True
183
+ continue
184
+
185
+ errors = validate(path)
186
+ if errors:
187
+ failed = True
188
+ print(f"失败 {path}:")
189
+ for error in errors:
190
+ print(f" - {error}")
191
+ else:
192
+ print(f"通过 {path}")
193
+
194
+ return 1 if failed else 0
195
+
196
+
197
+ if __name__ == "__main__":
198
+ sys.exit(main())
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: show-me
3
+ description: 使用简洁的图表、代码形状草图和聚焦的HTML构件,帮助用户直观地理解当前主题。
4
+ ---
5
+
6
+ Help the user understand the current topic of conversation visually. Skip the preamble and keep prose brief. Pick the smallest view that makes the key point clear.
7
+
8
+ - Show logic or an algorithm as pseudocode:
9
+
10
+ ```text
11
+ on(save)
12
+ if content is unchanged
13
+ return cached result
14
+ write new content
15
+ return fresh result
16
+ ```
17
+
18
+ - Show runtime control flow as a call tree:
19
+
20
+ ```text
21
+ submitForm
22
+ createSession
23
+ persistPrompt
24
+ launchAgent
25
+ navigateToSession
26
+ ```
27
+
28
+ - Show UI structure as a component tree, including state and module boundaries that matter:
29
+
30
+ ```tsx
31
+ <SessionPage> (apps/example/src/routes/session.tsx)
32
+ useSessionEvents()
33
+ <SessionToolbar>
34
+ <RunSkillButton> (packages/ui)
35
+ ```
36
+
37
+ - Show file responsibility or a broad refactor as a shallow file tree:
38
+
39
+ ```text
40
+ src/
41
+ ├── commands/ # parses user actions
42
+ ├── sessions/ # owns session state
43
+ └── transport/ # sends API requests
44
+ ```
45
+
46
+ - Show component interaction, control flow, or data flow with Mermaid:
47
+
48
+ ```mermaid
49
+ sequenceDiagram
50
+ participant User
51
+ participant UI
52
+ participant Daemon
53
+ User->>UI: choose command
54
+ UI->>Daemon: send expanded prompt
55
+ Daemon-->>UI: stream result
56
+ ```
57
+
58
+ - Use `diff` when the point is what changes and the surrounding shape already exists. Match the diff shape to the topic.
59
+
60
+ For a component change:
61
+
62
+ ```diff
63
+ <SessionPage>
64
+ useSessionEvents()
65
+ <SessionToolbar>
66
+ + <RunSkillButton />
67
+ <SessionTimeline>
68
+ + <SkillResultCard />
69
+ ```
70
+
71
+ For a file-layout change:
72
+
73
+ ```diff
74
+ src/
75
+ ├── commands/
76
+ +│ └── show-me.ts # expands the slash command
77
+ ├── sessions/
78
+ -└── transport.ts
79
+ +└── transport/
80
+ + ├── client.ts
81
+ + └── stream.ts
82
+ ```
83
+
84
+ For a call-tree or call-stack change:
85
+
86
+ ```diff
87
+ submitForm
88
+ createSession
89
+ persistPrompt
90
+ + expandSkillMention
91
+ launchAgent
92
+ - navigateToSession
93
+ + navigateToSession
94
+ + subscribeToEvents
95
+ ```
96
+
97
+ For a state or control-flow change:
98
+
99
+ ```diff
100
+ on(save)
101
+ - write content
102
+ + if content is unchanged
103
+ + return cached result
104
+ + write new content
105
+ + invalidate cache
106
+ ```
107
+
108
+ - Show the whole block when most of it is new, when omitted context would hide ownership or order, or when the user needs a copyable target shape:
109
+
110
+ ```ts
111
+ function expandSkill(command: string): string {
112
+ const skillName = command.slice(1)
113
+ return `use the ${skillName} skill`
114
+ }
115
+ ```
116
+
117
+ - For a visual UI, layout, state comparison, or concept too dense for Mermaid, write one focused HTML file — a diagram, an infographic, or a short slide deck, whichever fits the point. Match the product's colors, type, spacing, and components; use real labels and data; support desktop and mobile. Then open it for the user:
118
+
119
+ ```
120
+ Bash(open path/to/show-me-{description}.html)
121
+ ```
122
+
123
+ ### guidance
124
+
125
+ Place each visual next to the short text it supports. Keep only the calls, files, props, states, and boundaries needed to answer the user's current question or the options to resolve the current discussion point.
126
+
127
+ You may use one of these, you may use several, it is unlikely you will use all of them. Use your judgement and don't overwhelm the user.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chinhae/atw-cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "A Team Workflow — an AI coding workflow framework that encodes your team's conventions into the process",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "inquirer": "^9.3.7",
34
34
  "undici": "^6.21.0",
35
35
  "zod": "^4.4.2",
36
- "@chinhae/atw-core": "0.2.3"
36
+ "@chinhae/atw-core": "0.2.5"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@eslint/js": "^9.18.0",