adspecs 0.1.23 → 0.1.24

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.
@@ -0,0 +1,178 @@
1
+ ---
2
+ name: adspecs-save-session
3
+ description: "保存当前 AI 会话为结构化 Markdown 日志。生成含摘要、产物清单、决策记录的 .log 文件到 docs/80-development/800-log/。Use when user asks to save session, log session, or before /clear."
4
+ argument-hint: "[--summary-only]"
5
+ user-invocable: true
6
+ compatibility: 需要 .adspecs/ 目录结构
7
+ ---
8
+
9
+ # AI 会话日志保存
10
+
11
+ 将当前 Claude Code 会话内容生成结构化摘要,写入 `docs/80-development/800-log/` 目录下的 `.log` Markdown 文件。
12
+
13
+ ## 适用场景
14
+
15
+ - 用户显式输入「保存会话」「记录会话」「save session」「log session」
16
+ - 会话即将结束(任务完成、用户表示结束)
17
+ - 长会话节点(完成系统设计、任务清单等重要阶段)
18
+ - 用户执行 `/clear` 前
19
+ - PreCompact 触发(上下文即将压缩)
20
+ - 上次会话未保存的恢复场景
21
+
22
+ ## 用户输入
23
+
24
+ ```text
25
+ $ARGUMENTS
26
+ ```
27
+
28
+ ### 参数说明
29
+
30
+ | 参数 | 必填 | 说明 | 示例 |
31
+ |------|------|------|------|
32
+ | `--summary-only` | 否 | 仅生成 Summary,跳过 Key Artifacts 和 Decisions | `--summary-only` |
33
+
34
+ ## 执行步骤
35
+
36
+ ### 1. 读取配置
37
+
38
+ 读取以下文件(缺失时使用默认值):
39
+
40
+ - `.adspecs/paths.json` → `paths.session_log_dir`(默认 `docs/80-development/800-log`)
41
+ - `.adspecs/feature.json` → `active` 字段(提取模块 ID)
42
+ - `.adspecs/session-logger.json` → 用户自定义配置
43
+
44
+ **模块 ID 提取规则**:
45
+ - `active` 为空 → 使用 `GEN`
46
+ - `active = docs/20-prd/003-user-auth` → 取末段 `003-user-auth`
47
+ - 正则 `/^([a-z0-9]+(?:-[a-z0-9]+)*)/i` 提取编号前缀
48
+
49
+ ### 2. 计算文件名
50
+
51
+ 格式:`{YYYYMMDD-HHmmss}_{module-id}_ai-session.log`
52
+
53
+ 示例:
54
+ - `20260730-143522_003-user-auth_ai-session.log`
55
+ - `20260730-150000_GEN_ai-session.log`(无 active 模块时)
56
+ - `20260730-160000_003-user-auth_ai-session-recovery.log`(恢复场景)
57
+
58
+ ### 3. 生成 Markdown 日志
59
+
60
+ 使用以下模板:
61
+
62
+ ```markdown
63
+ # AI Session Log
64
+
65
+ - Date: YYYY-MM-DD HH:mm:ss
66
+ - Module: {id} ({name})
67
+ - Trigger: manual | pre_compact | session_end | recovery
68
+ - Duration: ~Nmin
69
+ - Turns: N
70
+ - Skills invoked: skill1, skill2, ...
71
+
72
+ ## Summary
73
+
74
+ (200 字以内,实质性摘要,禁止空洞描述)
75
+
76
+ **必须包含**:
77
+ - 本次会话解决的核心问题
78
+ - 关键决策及其理由
79
+ - 重要产出物概述
80
+
81
+ **禁止**:
82
+ - "本次会话讨论了需求"等空洞描述
83
+ - 重复用户问题
84
+ - 无实质内容的总结
85
+
86
+ ## Key Artifacts
87
+
88
+ - docs/20-prd/003-user-auth/003-user-auth_产品需求说明书.md (created)
89
+ - docs/30-system-design/003-user-auth_system-design.md (created)
90
+ - docs/30-system-design/003-user-auth_schema.sql (created)
91
+
92
+ **规则**:
93
+ - 列出本次会话创建或修改的真实文件路径
94
+ - 每个文件标注 `(created)` 或 `(modified)`
95
+ - 最多列出 20 个文件(按重要性排序)
96
+ - 若使用 `--summary-only`,跳过此节
97
+
98
+ ## Decisions & Open Issues
99
+
100
+ - [决策] 采用 JWT 而非 Session 认证,原因:无状态、易扩展
101
+ - [决策] 数据库使用 PostgreSQL,理由:团队熟悉、JSON 支持好
102
+ - [待定] 第三方 OAuth 接入范围待用户确认
103
+ - [待定] 性能指标(QPS 目标)需与运维对齐
104
+
105
+ **规则**:
106
+ - `[决策]`:已确定的技术方案、架构选择、工具选型等
107
+ - `[待定]`:未解决的问题、待确认的需求、待对齐的指标
108
+ - 若使用 `--summary-only`,跳过此节
109
+ ```
110
+
111
+ ### 4. 写入文件
112
+
113
+ 使用 Write 工具将生成的 Markdown 内容写入计算出的文件路径。
114
+
115
+ ### 5. 更新 marker
116
+
117
+ 读取 `.claude/.session-save-marker`,更新以下字段:
118
+ - `saved: true`
119
+ - `saveCount: saveCount + 1`
120
+ - `timestamp: 当前 ISO 时间戳`
121
+
122
+ 若 marker 不存在,创建新 marker:
123
+
124
+ ```json
125
+ {
126
+ "type": "session_started",
127
+ "module": "{module-id}",
128
+ "moduleName": "{module-name}",
129
+ "timestamp": "ISO",
130
+ "startedAt": "ISO",
131
+ "saved": true,
132
+ "saveCount": 1,
133
+ "compactRequestedAt": null,
134
+ "missedAt": null
135
+ }
136
+ ```
137
+
138
+ ### 6. 输出确认
139
+
140
+ ```
141
+ [session-logger] Saved: {filename}
142
+ [session-logger] Location: {logDir}/{filename}
143
+ [session-logger] Save count: {saveCount}
144
+ ```
145
+
146
+ ## 多次保存规则
147
+
148
+ 同一会话可多次保存(时间戳区分文件):
149
+
150
+ - **第 1 次保存**:Summary 覆盖整个会话
151
+ - **第 N 次保存**(N > 1):Summary 聚焦「上次保存后的进展」
152
+ - 每次保存的 Key Artifacts 列出**本次新增/修改**的文件
153
+
154
+ 通过 marker 的 `saveCount` 字段判断当前是第几次保存。
155
+
156
+ ## 恢复场景
157
+
158
+ 当 marker 文件存在且 `type == session_missed` 时:
159
+
160
+ 1. SessionStart 注入恢复提醒
161
+ 2. 用户确认恢复后,调用本 skill
162
+ 3. 文件名后缀加 `-recovery`(如 `20260730-160000_003-user-auth_ai-session-recovery.log`)
163
+ 4. Summary 基于用户描述的上次会话要点生成
164
+
165
+ ## 注意事项
166
+
167
+ - Summary 必须实质性,禁止空洞描述
168
+ - Key Artifacts 必须是真实存在的文件路径(可用 Glob 验证)
169
+ - 日志文件使用 `.log` 扩展名(纯文本 Markdown)
170
+ - 日志文件应纳入 git 跟踪(作为开发审计轨迹)
171
+ - 若 `.adspecs/` 目录不存在,提示用户先执行 `/project-init`
172
+
173
+ ## 相关文件
174
+
175
+ - `hooks/session-logger.js` — Hook 脚本(触发信号)
176
+ - `.claude/.session-save-marker` — 状态 marker 文件
177
+ - `.adspecs/session-logger.json` — 用户配置
178
+ - `.adspecs/paths.json` — 路径配置
@@ -933,6 +933,7 @@ find "$TARGET/front-demo" -type f | wc -l
933
933
  ├── extensions.yml
934
934
  ├── feature.json
935
935
  ├── project.json # 阶段 6 从 references 复制,阶段 6.5 用当前会话数据合并更新
936
+ ├── session-logger.json # AI 会话日志自动保存配置(hooks/session-logger.js 读取)
936
937
  ├── templates/
937
938
  │ ├── 01-业务需求分析模板.md
938
939
  │ ├── 02-产品需求说明书模板.md
@@ -1126,6 +1127,7 @@ mkdir -p "$TARGET/.adspecs"
1126
1127
  "prd_dir": "docs/20-prd",
1127
1128
  "design_dir": "docs/30-system-design",
1128
1129
  "test_report_dir": "docs/80-development",
1130
+ "session_log_dir": "docs/80-development/800-log",
1129
1131
  "export_dir": "docs/90-export",
1130
1132
  "wiki_dir": "wiki"
1131
1133
  }
@@ -1143,6 +1145,7 @@ mkdir -p "$TARGET/.adspecs"
1143
1145
  | `prd_dir` | `docs/20-prd` | adspecs-prd、adspecs-plan(输入)、adspecs-front-spec(输入)、wiki-update(源) |
1144
1146
  | `design_dir` | `docs/30-system-design` | adspecs-plan(输出)、adspecs-tasks、adspecs-front-spec(输出)、adspecs-front-tasks、adspecs-utest(输入)、wiki-update(源) |
1145
1147
  | `test_report_dir` | `docs/80-development` | adspecs-utest(测试报告) |
1148
+ | `session_log_dir` | `docs/80-development/800-log` | session-logger(AI 会话日志) |
1146
1149
  | `export_dir` | `docs/90-export` | adspecs-export-word(Word 导出输出) |
1147
1150
  | `wiki_dir` | `wiki` | wiki-update(输出目标) |
1148
1151
 
@@ -15,6 +15,7 @@ const DEFAULT_PATHS = {
15
15
  prd_dir: 'docs/20-prd',
16
16
  design_dir: 'docs/30-system-design',
17
17
  test_report_dir: 'docs/80-development',
18
+ session_log_dir: 'docs/80-development/800-log',
18
19
  export_dir: 'docs/90-export',
19
20
  wiki_dir: 'wiki',
20
21
  };
@@ -55,7 +55,7 @@ async function scaffold(opts) {
55
55
  decisions,
56
56
  subDecisions = { conventions: 'skip', templates: {} },
57
57
  modeUpgrade = { detected: false, emptyDirs: [] },
58
- logger = () => {},
58
+ logger = () => { },
59
59
  } = opts;
60
60
 
61
61
  const report = {
@@ -545,7 +545,15 @@ function writePathsJson(targetDir) {
545
545
  * 根据前端演示源解析前端规范目录名
546
546
  */
547
547
  function resolveFrontendStandard(frontDemoSource) {
548
- return frontDemoSource === 'antd-front-demo' ? 'ant6-front-standard' : 'ecp-front-standard';
548
+ let nowFrontendStantard = 'antd-front-demo'
549
+ if (frontDemoSource === 'antd-front-demo') {
550
+ nowFrontendStantard = 'ant6-front-standard'
551
+ } else if (frontDemoSource === 'front-demo') {
552
+ nowFrontendStantard = 'ecp-front-standard'
553
+ } else if (frontDemoSource === 'vue3-front-standard') {
554
+ nowFrontendStantard = 'vue3-front-standard'
555
+ }
556
+ return nowFrontendStantard
549
557
  }
550
558
 
551
559
  module.exports = { scaffold };