dsh-ai-collab 0.5.0 → 0.7.0

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/lib/plan.js ADDED
@@ -0,0 +1,336 @@
1
+ /**
2
+ * `ai_plan` data layer: `.ai/plan.json` (structured plan/checklist/risks)
3
+ * and its rendered outputs `.ai/PLAN.md` and `.ai/TASKS.md` (three-section,
4
+ * markdown archive) + `TASKS.html` (project-root visual page).
5
+ *
6
+ * plan.json 写入走原子写 + 项目级锁(与 appendRecord 同级保护)。
7
+ * 渲染产物(.ai/TASKS.md / .ai/PLAN.md / TASKS.html)不手改:根目录只留
8
+ * 用户要读的 AGENTS.md 与 HTML 页面,markdown 清单归 `.ai/`。
9
+ */
10
+ import { existsSync, mkdirSync } from 'node:fs'
11
+ import { join } from 'node:path'
12
+ import { writeFileAtomic, readText } from './atomic.js'
13
+ import { withLock } from './lock.js'
14
+
15
+ // ---------------------------------------------------------------- schema
16
+
17
+ export const PLAN_STATUSES = ['todo', 'in_progress', 'done', 'blocked']
18
+ export const CHECKLIST_STATUSES = ['open', 'done', 'na']
19
+ export const RISK_PROBABILITIES = ['高', '中', '低']
20
+ export const RISK_IMPACTS = ['高', '中', '低']
21
+ export const RISK_STRATEGIES = ['规避', '减轻', '接受', '转移']
22
+ export const RISK_STATUSES = ['active', 'resolved', 'expired']
23
+
24
+ /** 新建空 plan 的默认值。 */
25
+ export function emptyPlan() {
26
+ return {
27
+ schema_version: 1,
28
+ updated_at: '',
29
+ plan: [],
30
+ checklist: [],
31
+ risks: [],
32
+ }
33
+ }
34
+
35
+ // ---------------------------------------------------------------- paths
36
+
37
+ function planPath(root) { return join(root, '.ai', 'plan.json') }
38
+ function planMdPath(root) { return join(root, '.ai', 'PLAN.md') }
39
+ function tasksMdPath(root) { return join(root, '.ai', 'TASKS.md') }
40
+
41
+ /** 需要锁保护的动作统一走这里。 */
42
+ function planLockPath(root) { return join(root, '.ai', '.plan.lock') }
43
+
44
+ // ---------------------------------------------------------------- read / write
45
+
46
+ export function readPlan(root) {
47
+ try {
48
+ const raw = readText(planPath(root))
49
+ const obj = JSON.parse(raw)
50
+ if (!obj || typeof obj !== 'object') return emptyPlan()
51
+ const p = emptyPlan()
52
+ if (Array.isArray(obj.plan)) p.plan = obj.plan
53
+ if (Array.isArray(obj.checklist)) p.checklist = obj.checklist
54
+ if (Array.isArray(obj.risks)) p.risks = obj.risks
55
+ if (typeof obj.schema_version === 'number') p.schema_version = obj.schema_version
56
+ if (typeof obj.updated_at === 'string') p.updated_at = obj.updated_at
57
+ return p
58
+ } catch {
59
+ return emptyPlan()
60
+ }
61
+ }
62
+
63
+ export function writePlan(root, plan, now) {
64
+ mkdirSync(join(root, '.ai'), { recursive: true })
65
+ const payload = { ...plan, updated_at: now || new Date().toISOString() }
66
+ return withLock(planLockPath(root), () => {
67
+ writeFileAtomic(planPath(root), JSON.stringify(payload, null, 2) + '\n')
68
+ writeFileAtomic(planMdPath(root), renderPlanMarkdown(payload))
69
+ return payload
70
+ })
71
+ }
72
+
73
+ // ---------------------------------------------------------------- setters
74
+
75
+ /** 用一组项覆盖 plan/checklist/risks 中的一块。 */
76
+ export function setBlock(root, key, items, now) {
77
+ const plan = readPlan(root)
78
+ if (!['plan', 'checklist', 'risks'].includes(key)) throw new Error(`未知块: ${key}`)
79
+ if (!Array.isArray(items)) throw new Error(`${key} 必须为数组`)
80
+ plan[key] = items
81
+ return writePlan(root, plan, now)
82
+ }
83
+
84
+ /** 勾选清单项。返回更新后的 plan 与该项。 */
85
+ export function doneChecklistItem(root, id, now) {
86
+ const plan = readPlan(root)
87
+ const target = plan.checklist.find((c) => c.id === id)
88
+ if (!target) throw new Error(`清单项不存在: ${id}`)
89
+ target.status = 'done'
90
+ return { plan: writePlan(root, plan, now), item: target }
91
+ }
92
+
93
+ /** 收集当前 active 风险标题(用于联动 status.json.blockers)。 */
94
+ export function activeRiskTitles(plan) {
95
+ return (plan.risks || [])
96
+ .filter((r) => r.status === 'active')
97
+ .map((r) => r.risk)
98
+ }
99
+
100
+ // ---------------------------------------------------------------- render: PLAN.md
101
+
102
+ function cell(value) {
103
+ return String(value ?? '').replace(/\|/g, '\\|').replace(/\n/g, ' ')
104
+ }
105
+
106
+ function statusLabel(status) {
107
+ const map = { todo: '待办', in_progress: '进行中', done: '完成', blocked: '阻塞',
108
+ open: '待办', na: '不适用', active: '活跃', resolved: '已解决', expired: '已失效' }
109
+ return map[status] || status
110
+ }
111
+
112
+ export function renderPlanMarkdown(plan) {
113
+ const lines = [
114
+ '# 执行计划与清单',
115
+ '',
116
+ `> 自动生成:来源 \`.ai\\plan.json\`。最后更新 ${plan.updated_at || '—'}`,
117
+ '> 用工具 `ai_plan` 管理,不要手动编辑本文件。',
118
+ '',
119
+ ]
120
+
121
+ if ((plan.plan || []).length > 0) {
122
+ lines.push('## 执行计划', '')
123
+ lines.push('| # | 步骤 | 验收标准 | 状态 | 负责人 | 截止 |')
124
+ lines.push('|---|---|---|---|---|---|')
125
+ for (const p of plan.plan) {
126
+ lines.push(`| ${cell(p.id)} | ${cell(p.step)} | ${cell(p.acceptance)} | ${statusLabel(p.status)} | ${cell(p.owner)} | ${cell(p.due)} |`)
127
+ }
128
+ lines.push('')
129
+ }
130
+
131
+ if ((plan.checklist || []).length > 0) {
132
+ lines.push('## 检查清单', '')
133
+ lines.push('| # | 项 | 状态 | 关联记录 |')
134
+ lines.push('|---|---|---|---|')
135
+ for (const c of plan.checklist) {
136
+ lines.push(`| ${cell(c.id)} | ${cell(c.item)} | ${statusLabel(c.status)} | ${cell(c.link)} |`)
137
+ }
138
+ lines.push('')
139
+ }
140
+
141
+ if ((plan.risks || []).length > 0) {
142
+ lines.push('## 风险与应对', '')
143
+ lines.push('| 风险 | 概率 | 影响 | 策略 | 状态 |')
144
+ lines.push('|---|---|---|---|---|')
145
+ for (const r of plan.risks) {
146
+ lines.push(`| ${cell(r.risk)} | ${cell(r.probability)} | ${cell(r.impact)} | ${cell(r.strategy)} | ${statusLabel(r.status)} |`)
147
+ }
148
+ lines.push('')
149
+ }
150
+
151
+ return lines.join('\n')
152
+ }
153
+
154
+ // ---------------------------------------------------------------- render: TASKS.md (three-section)
155
+
156
+ export function renderTasksMarkdown(root, records, plan, now) {
157
+ const lines = [
158
+ '# 任务记录清单',
159
+ '',
160
+ `> 自动生成:来自 \`.ai\\log.jsonl\`,共 ${records.length} 条;按时间倒序。最后更新 ${now}`,
161
+ '> 只读清单:要新增记录请用 `.ai\\llm.cmd add` 或工具 `ai_log`,不要直接编辑本文件。',
162
+ '',
163
+ ]
164
+
165
+ // --- plan sections ---
166
+ if (plan && plan.plan.length > 0) {
167
+ lines.push('## 执行计划(来源:`.ai\\plan.json`)', '')
168
+ lines.push('| # | 步骤 | 验收标准 | 状态 | 负责人 | 截止 |')
169
+ lines.push('|---|---|---|---|---|---|')
170
+ for (const p of plan.plan) {
171
+ lines.push(`| ${cell(p.id)} | ${cell(p.step)} | ${cell(p.acceptance)} | ${statusLabel(p.status)} | ${cell(p.owner)} | ${cell(p.due)} |`)
172
+ }
173
+ lines.push('')
174
+ }
175
+
176
+ if (plan && plan.checklist.length > 0) {
177
+ lines.push('## 检查清单(来源:`.ai\\plan.json`)', '')
178
+ lines.push('| # | 项 | 状态 | 关联记录 |')
179
+ lines.push('|---|---|---|---|')
180
+ for (const c of plan.checklist) {
181
+ lines.push(`| ${cell(c.id)} | ${cell(c.item)} | ${statusLabel(c.status)} | ${cell(c.link)} |`)
182
+ }
183
+ lines.push('')
184
+ }
185
+
186
+ if (plan && plan.risks.length > 0) {
187
+ lines.push('## 风险与应对(来源:`.ai\\plan.json`)', '')
188
+ lines.push('| 风险 | 概率 | 影响 | 策略 | 状态 |')
189
+ lines.push('|---|---|---|---|---|')
190
+ for (const r of plan.risks) {
191
+ lines.push(`| ${cell(r.risk)} | ${cell(r.probability)} | ${cell(r.impact)} | ${cell(r.strategy)} | ${statusLabel(r.status)} |`)
192
+ }
193
+ lines.push('')
194
+ }
195
+
196
+ // --- log records ---
197
+ lines.push('## 工作日志(来源:`.ai\\log.jsonl`,只读)', '')
198
+ lines.push('| 时间 | 类型 | 状态 | 摘要 | 记录 id |')
199
+ lines.push('|---|---|---|---|---|')
200
+ const rows = records.map((r) => ({
201
+ ts: String(r.ts ?? ''),
202
+ action: String(r.action ?? ''),
203
+ status: String(r.status ?? ''),
204
+ summary: cell(r.summary),
205
+ id: String(r.id ?? ''),
206
+ }))
207
+ for (let i = rows.length - 1; i >= 0; i -= 1) {
208
+ const r = rows[i]
209
+ lines.push(`| ${r.ts} | ${r.action} | ${r.status} | ${r.summary} | \`${r.id}\` |`)
210
+ }
211
+ if (rows.length === 0) lines.push('| (暂无记录) | | | | |')
212
+ lines.push('')
213
+
214
+ return lines.join('\n')
215
+ }
216
+
217
+ // ---------------------------------------------------------------- render: TASKS.html (dashboard-style)
218
+
219
+ function htmlEsc(s) {
220
+ return String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
221
+ }
222
+
223
+ function riskColor(p, i) {
224
+ // 高/高 → 红;高/中 或 中/高 → 橙;中/中 → 黄;其余 → 灰
225
+ if (p === '高' && i === '高') return '#dc3545'
226
+ if ((p === '高' && i === '中') || (p === '中' && i === '高')) return '#fd7e14'
227
+ if (p === '中' && i === '中') return '#ffc107'
228
+ return '#6c757d'
229
+ }
230
+
231
+ function statusBadge(status) {
232
+ const colors = { todo: '#6c757d', in_progress: '#0d6efd', done: '#198754', blocked: '#dc3545',
233
+ open: '#6c757d', na: '#adb5bd', active: '#dc3545', resolved: '#198754', expired: '#adb5bd' }
234
+ return `<span style="background:${colors[status] || '#6c757d'};color:#fff;padding:2px 8px;border-radius:4px;font-size:12px">${htmlEsc(statusLabel(status))}</span>`
235
+ }
236
+
237
+ export function renderTasksHtml(root, records, plan, now, projectName) {
238
+ const name = htmlEsc(projectName || root.split(/[/\\]/).filter(Boolean).pop() || '')
239
+ const recordRows = records.map((r) => ({
240
+ ts: String(r.ts ?? ''),
241
+ action: String(r.action ?? ''),
242
+ status: String(r.status ?? ''),
243
+ summary: htmlEsc(r.summary),
244
+ id: htmlEsc(r.id ?? ''),
245
+ })).reverse()
246
+
247
+ let planHtml = ''
248
+ if (plan && plan.plan.length > 0) {
249
+ planHtml += '<section><h2>📋 执行计划</h2><table><tr><th>#</th><th>步骤</th><th>验收标准</th><th>状态</th><th>负责人</th><th>截止</th></tr>'
250
+ for (const p of plan.plan) {
251
+ planHtml += `<tr><td>${htmlEsc(p.id)}</td><td>${htmlEsc(p.step)}</td><td>${htmlEsc(p.acceptance)}</td><td>${statusBadge(p.status)}</td><td>${htmlEsc(p.owner)}</td><td>${htmlEsc(p.due)}</td></tr>`
252
+ }
253
+ planHtml += '</table></section>'
254
+ }
255
+
256
+ let checklistHtml = ''
257
+ if (plan && plan.checklist.length > 0) {
258
+ checklistHtml += '<section><h2>✅ 检查清单</h2><table><tr><th>#</th><th>项</th><th>状态</th><th>关联记录</th></tr>'
259
+ for (const c of plan.checklist) {
260
+ checklistHtml += `<tr><td>${htmlEsc(c.id)}</td><td>${htmlEsc(c.item)}</td><td>${statusBadge(c.status)}</td><td>${htmlEsc(c.link)}</td></tr>`
261
+ }
262
+ checklistHtml += '</table></section>'
263
+ }
264
+
265
+ let risksHtml = ''
266
+ if (plan && plan.risks.length > 0) {
267
+ risksHtml += '<section><h2>⚠️ 风险与应对</h2><table><tr><th>风险</th><th>概率</th><th>影响</th><th>策略</th><th>状态</th></tr>'
268
+ for (const r of plan.risks) {
269
+ const dot = `<span style="display:inline-block;width:12px;height:12px;border-radius:50%;background:${riskColor(r.probability, r.impact)};margin-right:4px"></span>`
270
+ risksHtml += `<tr><td>${dot}${htmlEsc(r.risk)}</td><td>${htmlEsc(r.probability)}</td><td>${htmlEsc(r.impact)}</td><td>${htmlEsc(r.strategy)}</td><td>${statusBadge(r.status)}</td></tr>`
271
+ }
272
+ risksHtml += '</table></section>'
273
+ }
274
+
275
+ let logHtml = ''
276
+ if (recordRows.length > 0) {
277
+ logHtml += '<section><h2>📜 工作日志</h2><table><tr><th>时间</th><th>类型</th><th>状态</th><th>摘要</th><th>记录 id</th></tr>'
278
+ for (const r of recordRows) {
279
+ logHtml += `<tr><td>${htmlEsc(r.ts)}</td><td>${htmlEsc(r.action)}</td><td>${statusBadge(r.status)}</td><td>${r.summary}</td><td><code>${r.id}</code></td></tr>`
280
+ }
281
+ logHtml += '</table></section>'
282
+ }
283
+
284
+ const hasPlan = plan && (plan.plan.length > 0 || plan.checklist.length > 0 || plan.risks.length > 0)
285
+
286
+ return `<!DOCTYPE html>
287
+ <html lang="zh-CN">
288
+ <head>
289
+ <meta charset="UTF-8">
290
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
291
+ <title>${name} · 任务清单</title>
292
+ <style>
293
+ :root { --bg:#f8f9fa; --card:#fff; --text:#212529; --muted:#6c757d; --border:#dee2e6; font-family:system-ui,-apple-system,sans-serif; }
294
+ body { background:var(--bg); color:var(--text); margin:0; padding:16px; }
295
+ .container { max-width:960px; margin:0 auto; }
296
+ header { background:var(--card); border:1px solid var(--border); border-radius:8px; padding:16px 24px; margin-bottom:16px; }
297
+ header h1 { margin:0 0 4px; font-size:20px; }
298
+ header .meta { color:var(--muted); font-size:13px; }
299
+ section { background:var(--card); border:1px solid var(--border); border-radius:8px; padding:16px 24px; margin-bottom:16px; }
300
+ section h2 { margin:0 0 12px; font-size:16px; }
301
+ table { width:100%; border-collapse:collapse; font-size:13px; }
302
+ th, td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--border); vertical-align:top; }
303
+ th { background:#f1f3f5; font-weight:600; white-space:nowrap; }
304
+ tr:hover { background:#f8f9fa; }
305
+ .placeholder { color:var(--muted); font-style:italic; padding:12px 0; }
306
+ footer { text-align:center; color:var(--muted); font-size:12px; padding:12px; }
307
+ </style>
308
+ </head>
309
+ <body>
310
+ <div class="container">
311
+ <header>
312
+ <h1>${name} · 任务清单</h1>
313
+ <div class="meta">${hasPlan ? `计划更新: ${htmlEsc(plan.updated_at || '—')} · ` : ''}日志共 ${records.length} 条 · 生成: ${htmlEsc(now)}</div>
314
+ </header>
315
+ ${planHtml}${checklistHtml}${risksHtml}${logHtml}
316
+ ${records.length === 0 && !hasPlan ? '<div class="placeholder">暂无记录与计划。</div>' : ''}
317
+ <footer>自动生成 · 来源 .ai/log.jsonl + .ai/plan.json · 勿手动编辑</footer>
318
+ </div>
319
+ </body>
320
+ </html>
321
+ `
322
+ }
323
+
324
+ // ---------------------------------------------------------------- write all renders
325
+
326
+ /** 一次写 .ai/TASKS.md + TASKS.html + .ai/PLAN.md(在锁内)。 */
327
+ export function writeAllRenders(root, records, now, projectName) {
328
+ mkdirSync(join(root, '.ai'), { recursive: true })
329
+ const plan = readPlan(root)
330
+ return withLock(planLockPath(root), () => {
331
+ writeFileAtomic(tasksMdPath(root), renderTasksMarkdown(root, records, plan, now))
332
+ writeFileAtomic(join(root, 'TASKS.html'), renderTasksHtml(root, records, plan, now, projectName))
333
+ writeFileAtomic(planMdPath(root), renderPlanMarkdown(plan))
334
+ return { plan, tasksMd: tasksMdPath(root), tasksHtml: join(root, 'TASKS.html'), planMd: planMdPath(root) }
335
+ })
336
+ }
package/lib/tasks.js CHANGED
@@ -1,14 +1,15 @@
1
1
  /**
2
- * Pure task-list renderer for the `.ai/` collaboration layer.
2
+ * Task-list renderer: reads `.ai/log.jsonl`, writes three-section `.ai/TASKS.md`
3
+ * (markdown archive) + root `TASKS.html` (dashboard-style visual page) +
4
+ * `.ai/PLAN.md` (from .ai/plan.json).
3
5
  *
4
- * Why this exists: the plugin used to refresh `TASKS.md` by spawning the
5
- * workspace's own `.ai/llm.ps1`. That executed code from the repository being
6
- * worked on, which is a supply-chain risk. Rendering happens here instead:
7
- * no PowerShell, no workspace-provided script, identical output format.
6
+ * 根目录只留用户要读的文件:AGENTS.md 与 HTML 页面;markdown 清单归档在 `.ai/`。
7
+ * Plan-aware rendering is delegated to `lib/plan.js`; this module keeps the
8
+ * record parsing and provides `writeTasks` for index.js.
8
9
  */
9
10
  import { existsSync, readFileSync, mkdirSync } from 'node:fs'
10
11
  import { join } from 'node:path'
11
- import { writeFileAtomic } from './atomic.js'
12
+ import { writeAllRenders } from './plan.js'
12
13
 
13
14
  /** Parse JSONL text into records, skipping blank or malformed lines. */
14
15
  export function parseRecords(text) {
@@ -25,17 +26,32 @@ export function parseRecords(text) {
25
26
  return out
26
27
  }
27
28
 
28
- function cell(value) {
29
- return String(value ?? '').replace(/\|/g, '\\|')
29
+ /**
30
+ * Write `.ai/TASKS.md` + `<root>/TASKS.html` + `.ai/PLAN.md`.
31
+ *
32
+ * When `.ai/plan.json` exists the TASKS files include plan/checklist/risks
33
+ * sections before the log table; otherwise they fall back to a log-only view.
34
+ *
35
+ * Returns `{ written, count, tasksMd, tasksHtml, planMd }`;
36
+ * never throws by design (caller logs).
37
+ */
38
+ export function writeTasks(root, now, projectName) {
39
+ const logFile = join(root, '.ai', 'log.jsonl')
40
+ const outFile = join(root, '.ai', 'TASKS.md')
41
+ if (!existsSync(logFile)) return { written: false, count: 0, path: outFile }
42
+ const records = parseRecords(readFileSync(logFile, 'utf8'))
43
+ mkdirSync(join(root, '.ai'), { recursive: true })
44
+ const result = writeAllRenders(root, records, now, projectName)
45
+ return { written: true, count: records.length, ...result }
30
46
  }
31
47
 
32
- /** Render the exact `TASKS.md` body used by `.ai\llm.cmd tasks`. */
48
+ // Keep the old `renderTasks` export for test compatibility (deprecated).
33
49
  export function renderTasks(records, now) {
34
50
  const rows = records.map((r) => ({
35
51
  ts: String(r.ts ?? ''),
36
52
  action: String(r.action ?? ''),
37
53
  status: String(r.status ?? ''),
38
- summary: cell(r.summary),
54
+ summary: String(r.summary ?? '').replace(/\|/g, '\\|').replace(/\n/g, ' '),
39
55
  id: String(r.id ?? ''),
40
56
  }))
41
57
  const lines = [
@@ -53,18 +69,4 @@ export function renderTasks(records, now) {
53
69
  }
54
70
  if (rows.length === 0) lines.push('| (暂无记录) | | | | |')
55
71
  return `${lines.join('\n')}\n`
56
- }
57
-
58
- /**
59
- * Write `<root>/TASKS.md` from `<root>/.ai/log.jsonl`.
60
- * Returns `{ written, count, path }`; never throws by design (caller logs).
61
- */
62
- export function writeTasks(root, now) {
63
- const logFile = join(root, '.ai', 'log.jsonl')
64
- const outFile = join(root, 'TASKS.md')
65
- if (!existsSync(logFile)) return { written: false, count: 0, path: outFile }
66
- const records = parseRecords(readFileSync(logFile, 'utf8'))
67
- mkdirSync(join(root, '.ai'), { recursive: true })
68
- writeFileAtomic(outFile, renderTasks(records, now))
69
- return { written: true, count: records.length, path: outFile }
70
- }
72
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "dsh-ai-collab",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "os": [
5
5
  "win32"
6
6
  ],
7
- "description": "DeepSeek Harness bundle: AI collaboration layer (status/log/check tools, disciplines, handoff, workspace scaffold) built around AGENTS.md and .ai/",
7
+ "description": "DeepSeek Harness bundle: AI collaboration layer (status/log/check/plan tools, disciplines, handoff, workspace scaffold, auto-rendered HTML views) built around AGENTS.md and .ai/",
8
8
  "type": "module",
9
9
  "main": "./index.js",
10
10
  "exports": {
@@ -63,7 +63,7 @@
63
63
  "dsh": ">=0.2.1"
64
64
  },
65
65
  "scripts": {
66
- "check": "node --check index.js && node --check lib/config.js && node --check lib/tasks.js && node --check lib/atomic.js && node --check lib/lock.js && node --check lib/disciplines.js && node --check lib/handoff.js",
67
- "test": "node --test test/smoke.test.mjs test/lib.test.mjs test/preservation.test.mjs test/discipline.test.mjs"
66
+ "check": "node --check index.js && node --check lib/config.js && node --check lib/tasks.js && node --check lib/atomic.js && node --check lib/lock.js && node --check lib/disciplines.js && node --check lib/handoff.js && node --check lib/plan.js && node --check lib/dashboard.js",
67
+ "test": "node --test test/smoke.test.mjs test/lib.test.mjs test/preservation.test.mjs test/discipline.test.mjs test/plan.test.mjs"
68
68
  }
69
69
  }
@@ -734,7 +734,8 @@ Record work through `.ai\llm.cmd` (status / tail / add / check). Never rewrite t
734
734
  }
735
735
 
736
736
  function Invoke-Tasks([string]$ProjectRoot) {
737
- # 生成人读的任务记录清单:<项目根>\TASKS.md(来源 log.jsonl,追加语义不变)
737
+ # 生成人读的任务记录清单:<项目根>\.ai\TASKS.md(来源 log.jsonl,追加语义不变)
738
+ # 根目录只留 AGENTS.md 与可视化 HTML(TASKS.html 由插件渲染),markdown 归 .ai\
738
739
  $rows = @()
739
740
  foreach ($line in (Get-LogLines $ProjectRoot)) {
740
741
  $rec = $null
@@ -763,7 +764,7 @@ function Invoke-Tasks([string]$ProjectRoot) {
763
764
  }
764
765
  if ($rows.Count -eq 0) { [void]$sb.AppendLine('| (暂无记录) | | | | |') }
765
766
 
766
- $out = Join-Path $ProjectRoot 'TASKS.md'
767
+ $out = Join-Path $ProjectRoot '.ai\TASKS.md'
767
768
  $lock = Join-Path $ProjectRoot '.ai\.tasks.lock'
768
769
  [void](Enter-ProjectLock $lock)
769
770
  try { Write-TextAtomic $out ($sb.ToString().Replace("`r`n", "`n")) }
@@ -987,7 +988,7 @@ AI 协作层 v2 — .ai\llm.ps1
987
988
  .ai\llm.ps1 archive [-Before yyyy-MM-dd] [-MaxMB 2] [-Force]
988
989
  .ai\llm.ps1 board [-Root <project-root>] [-Out <path>]
989
990
  .ai\llm.ps1 doctor
990
- .ai\llm.ps1 tasks # 生成 <项目根>\TASKS.md(任务记录清单)
991
+ .ai\llm.ps1 tasks # 生成 .ai\TASKS.md(任务记录清单;根目录 TASKS.html 由插件渲染)
991
992
 
992
993
  示例:
993
994
  & .ai\llm.ps1 add -Tool deepseek-harness -Action fix -Status ok `