dsh-ai-collab 0.5.0 → 0.6.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/AGENTS.template.md +6 -2
- package/CHANGELOG.md +24 -0
- package/README.md +21 -24
- package/docs/DETAIL.md +20 -11
- package/docs/MARKET.md +13 -5
- package/docs/index.html +16 -12
- package/index.js +74 -7
- package/lib/dashboard.js +187 -0
- package/lib/plan.js +334 -0
- package/lib/tasks.js +25 -25
- package/package.json +4 -4
package/AGENTS.template.md
CHANGED
|
@@ -78,9 +78,13 @@
|
|
|
78
78
|
| 历史补丁(可复现每一步改动) | `.ai\changelog\patches\` |
|
|
79
79
|
| 日志 / 状态格式与校验 | `.ai\LOG_FORMAT.md`、`.ai\schema\log.schema.json` |
|
|
80
80
|
| 敏感信息规则 | `.ai\SECURITY.md` |
|
|
81
|
-
|
|
|
81
|
+
| 执行计划 / 检查清单 / 风险应对 | `.ai\plan.json`(数据)、`.ai\PLAN.md`(渲染) |
|
|
82
|
+
| 项目文档(对外介绍 / 维护记录) | `.ai\docs\` |
|
|
83
|
+
| 维护脚本 | `.ai\scripts\` |
|
|
84
|
+
| 发布产物 | `.ai\dist\` |
|
|
85
|
+
| 跨项目看板 / 仪表盘 | `..\.ai\board.md`、`..\.ai\dashboard.html` |
|
|
82
86
|
| 工程内修改历史(对外) | 各工程 `readme.txt` |
|
|
83
|
-
|
|
|
87
|
+
| 任务记录清单(所有项目) | `TASKS.md`(自动生成)、`TASKS.html`(可视化) |
|
|
84
88
|
|
|
85
89
|
## 7. 多工具入口(严格单文件)
|
|
86
90
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
- Plan & task management: new `ai_plan` tool (show / set / done).
|
|
6
|
+
- `.ai/plan.json` stores a structured plan: a goal block, a checklist block, and a risk block.
|
|
7
|
+
Each risk has a severity (red/yellow/green), a mitigation, and an active/resolved flag.
|
|
8
|
+
- `appendRecord` auto-merges active plan risks into `status.json` → `blockers`.
|
|
9
|
+
- `lib/plan.js` renders three files atomically: `PLAN.md` (the plan itself), `TASKS.md` (three
|
|
10
|
+
sections: current plan → checklist → risk log, followed by the reverse-chronological log),
|
|
11
|
+
and `TASKS.html` (self-contained dashboard-style HTML, same visual language as
|
|
12
|
+
`dashboard.html`).
|
|
13
|
+
- `refreshTasks` no longer requires a manual `.ai/tasks-enabled` marker — the file is created
|
|
14
|
+
automatically on first write.
|
|
15
|
+
- Cross-project dashboard: `lib/dashboard.js` generates `F:\MyProject\.ai\dashboard.html` from
|
|
16
|
+
all sibling project statuses. Rows with active blockers are highlighted in red; each project
|
|
17
|
+
gets a sparkline bar of record counts from the last 7 log entries. Run automatically after
|
|
18
|
+
every `ai_log` and `ai_init`.
|
|
19
|
+
- Workspace cleanup: root directory reduced to `AGENTS.md` + `TASKS.md` + `dsh-ai-collab.html`;
|
|
20
|
+
everything else moved into `.ai/docs/`, `.ai/scripts/`, `.ai/dist/`, `.ai/market/`.
|
|
21
|
+
Stray `dsh-ai-collab-0.4.3.zip` deleted.
|
|
22
|
+
- Tests: 39 (14 new for plan I/O, checklist toggling, risk merging, Markdown/HTML rendering,
|
|
23
|
+
project scanning and dashboard generation; all old tests pass).
|
|
24
|
+
- Documentation: `AGENTS.template.md` §6 table now lists `plan.json`/`PLAN.md`, the three
|
|
25
|
+
sub-directories, `dashboard.html` and `TASKS.html`.
|
|
26
|
+
|
|
3
27
|
## 0.5.0
|
|
4
28
|
|
|
5
29
|
- Disciplines: global modules + project rules.
|
package/README.md
CHANGED
|
@@ -11,28 +11,25 @@ The point: any AI tool working in the repo (DSH, Claude Code, Cursor, Copilot, C
|
|
|
11
11
|
|
|
12
12
|
> **Visual introduction (中文):** <https://ZhuYw3927.github.io/dsh-ai-collab/>
|
|
13
13
|
|
|
14
|
-
> Status: **0.
|
|
15
|
-
|
|
16
|
-
## What's new in 0.
|
|
17
|
-
|
|
18
|
-
- **
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- **`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- **
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`.ai/backups/` (last 10). `ai_check` also fails on §8 drift.
|
|
34
|
-
- Verified by 25 tests (atomic/lock, discipline registry, §8 drift, handoff) and by a real burst:
|
|
35
|
-
12 concurrent writers → 12 records, one unique id each, `rev=12`.
|
|
14
|
+
> Status: **0.6.0, experimental**. Published on npm as [`dsh-ai-collab`](https://www.npmjs.com/package/dsh-ai-collab) and listed in the community plugin market — see [Known limitations](#known-limitations).
|
|
15
|
+
|
|
16
|
+
## What's new in 0.6.0
|
|
17
|
+
|
|
18
|
+
- **Plan & task management.** The new `ai_plan` tool (`show`/`set`/`done`) stores a structured plan
|
|
19
|
+
in `.ai/plan.json`: goals, checklists (with done/undone toggles), and risks (each with a
|
|
20
|
+
severity badge, a mitigation, and an active/resolved flag). Active risks are auto-merged into
|
|
21
|
+
`status.json` → `blockers` so they surface in every status readout.
|
|
22
|
+
- **`TASKS.md` is now three-section** (plan → checklist → risks → log) and also rendered as
|
|
23
|
+
**`TASKS.html`**, a self-contained dashboard-style page with status badges and risk colour
|
|
24
|
+
coding. The `.ai/tasks-enabled` marker is no longer needed — `refreshTasks` creates it
|
|
25
|
+
automatically on first use.
|
|
26
|
+
- **Cross-project dashboard**: `F:\MyProject\.ai\dashboard.html` is generated after every
|
|
27
|
+
`ai_log` and `ai_init`. It scans all sibling projects, highlights rows with active blockers in
|
|
28
|
+
red, and renders a sparkline bar of recent record counts per project.
|
|
29
|
+
- **Workspace layout cleaned**: root directory reduced to `AGENTS.md` + `TASKS.md` +
|
|
30
|
+
`dsh-ai-collab.html`; everything else now lives under `.ai/docs/`, `.ai/scripts/`,
|
|
31
|
+
`.ai/dist/` or `.ai/market/`. A stray `dsh-ai-collab-0.4.3.zip` was deleted.
|
|
32
|
+
- Tests: **39** (14 new for plan, checklist, risk merging and HTML rendering; all 25 old tests pass).
|
|
36
33
|
|
|
37
34
|
## Requirements
|
|
38
35
|
|
|
@@ -155,7 +152,7 @@ Get-Content "$DSH_HOME\logs\ai-collab-tools.log" -Tail 3 # tools=ai_status,…
|
|
|
155
152
|
```
|
|
156
153
|
|
|
157
154
|
- A fresh boot line means `apply()` ran in this process.
|
|
158
|
-
- A `tools=` line means all
|
|
155
|
+
- A `tools=` line means all eight tools registered; `spec` shows where `@deepseek-ai/dsh-tools` was loaded from.
|
|
159
156
|
- `load-failed` / `register-failed` lines carry the exact resolution errors.
|
|
160
157
|
|
|
161
158
|
The plugin is mounted from outside `app.asar` (a `link:`/absolute path), so the bare `@deepseek-ai/dsh-tools` specifier is not resolvable; it is loaded from the host's real `app.asar` path instead (see `asarRoots()` in `index.js`). `DSH_HOME` is read from the host environment and may be absent when the app is launched from Explorer — the plugin then falls back to `~/.dsh` (`home=homedir`).
|
|
@@ -253,7 +250,7 @@ get the mandatory "step 0" behaviour in every session:
|
|
|
253
250
|
|
|
254
251
|
```powershell
|
|
255
252
|
npm run check # node --check index.js + lib/*.js
|
|
256
|
-
npm test #
|
|
253
|
+
npm test # 39 tests: tool contract, config, task rendering, AGENTS.md preservation, atomic/lock/discipline/handoff/plan
|
|
257
254
|
npm pack --dry-run
|
|
258
255
|
```
|
|
259
256
|
|
package/docs/DETAIL.md
CHANGED
|
@@ -14,31 +14,34 @@ files that any tool can read: `AGENTS.md` for facts, `.ai/log.jsonl` for history
|
|
|
14
14
|
|
|
15
15
|
| Capability | Detail |
|
|
16
16
|
|---|---|
|
|
17
|
-
|
|
|
17
|
+
| Eight tools | `ai_status`, `ai_log`, `ai_check`, `ai_board`, `ai_init`, `ai_discipline`, `ai_handoff`, `ai_plan` |
|
|
18
18
|
| Auto-adoption | On `session/created` (`autoInit: true`) run `ai-ensure` in non-temp directories: scaffold when missing, upgrade when the template changed, refresh the board when stale |
|
|
19
19
|
| Zoned `AGENTS.md` | A `generated` zone (routing, permissions, commands, §8 discipline list) replaced on upgrade, and a `user` zone (project facts, sampling data, analysis methods, decisions) preserved byte-for-byte |
|
|
20
20
|
| Disciplines | Global modules in `$DSH_HOME/disciplines/` (migrate/toggle via `ai_discipline`) and project rules in `.ai/disciplines/`; enabled project rules are inlined into §8, disabled ones only listed |
|
|
21
21
|
| Handoff | `.ai/SESSION_BOOT.md` carries status, recent records, disciplines and an inheritance prompt; regenerated by `ai_log` / `ai_init` / `autoInit` |
|
|
22
22
|
| Protected files | An `AGENTS.md` without zone markers is treated as project-owned and never rewritten; the rendered reference goes to `.ai/AGENTS.generated.md`; rewrites are atomic and backed up |
|
|
23
|
-
| Task list |
|
|
24
|
-
| Cross-project board | When a sibling `.ai/board.md` exists, the board is refreshed after a record is written |
|
|
23
|
+
| Task list | `.ai/log.jsonl` drives a three-section `TASKS.md` (plan → checklist → risks → log) and a self-contained `TASKS.html` dashboard; `refreshTasks` auto-creates `.ai/tasks-enabled` on first write |
|
|
24
|
+
| Cross-project board | When a sibling `.ai/board.md` exists, the board is refreshed after a record is written; `dashboard.html` scans all projects with red-highlighted blocker rows |
|
|
25
|
+
| Plan & risk tracking | `.ai/plan.json` stores goals, checklists and risks; active risks merge into `status.json` → `blockers` on every `ai_log`; managed via `ai_plan` (show / set / done) |
|
|
25
26
|
| Concurrency | `lib/lock.js` cross-process lock + `lib/atomic.js` temp/fsync/rename; `status.json` has a `rev`; PowerShell `llm.ps1` mirrors both |
|
|
26
27
|
|
|
27
|
-
## What's new in 0.
|
|
28
|
+
## What's new in 0.6.0
|
|
28
29
|
|
|
29
30
|
| Change | Effect |
|
|
30
31
|
|---|---|
|
|
31
|
-
|
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
|
|
|
35
|
-
|
|
|
32
|
+
| `ai_plan` tool | Stores structured plans in `.ai/plan.json`: goals, checklists (with done/undone toggles), risks (severity-badged, each with mitigation and active/resolved). `show` / `set` (upsert any block) / `done` (toggle checklist items) |
|
|
33
|
+
| `TASKS.md` → three-section + `TASKS.html` | Plan, checklist and risk blocks precede the reverse-chronological log; a parallel `TASKS.html` renders the same data as a self-contained dashboard page with status badges |
|
|
34
|
+
| Cross-project `dashboard.html` | Scans sibling projects, highlights rows with active blockers in red, adds a sparkline bar from the last 7 record counts |
|
|
35
|
+
| Risk → blocker auto-merge | Every `ai_log` merges active plan risks into `status.json` → `blockers`, so they surface in `ai_status` |
|
|
36
|
+
| `.tasks-enabled` auto-created | `refreshTasks` creates the marker on first write; no manual step needed |
|
|
37
|
+
| `AGENTS.template.md` §6 updated | Lists `plan.json`/`PLAN.md`, `.ai/docs`/`.ai/scripts`/`.ai/dist`, `dashboard.html` and `TASKS.html` |
|
|
38
|
+
| Tests: 39 | 14 new (plan I/O, checklist toggling, risk merging, Markdown & HTML rendering, project scanning, dashboard generation) |
|
|
36
39
|
|
|
37
40
|
## Install
|
|
38
41
|
|
|
39
42
|
- **Plugin Manager (recommended):** Plugins → Add plugin → select this package directory.
|
|
40
43
|
- **CLI:** `dsh plugin --profile <profile> add <package path or npm name>`
|
|
41
|
-
- Restart DSH once; every session in the profile then exposes the
|
|
44
|
+
- Restart DSH once; every session in the profile then exposes the eight tools.
|
|
42
45
|
|
|
43
46
|
## Configuration
|
|
44
47
|
|
|
@@ -56,16 +59,22 @@ Values are normalised and invalid values are reported as warnings in
|
|
|
56
59
|
```
|
|
57
60
|
<project root>
|
|
58
61
|
├─ AGENTS.md generated zone + user zone
|
|
59
|
-
├─ TASKS.md
|
|
62
|
+
├─ TASKS.md three-section (plan → checklist → risks → log)
|
|
63
|
+
├─ TASKS.html self-contained dashboard-style task view
|
|
60
64
|
└─ .ai/
|
|
61
65
|
├─ llm.ps1 / llm.cmd status / tail / add / check / board / doctor / tasks
|
|
62
66
|
├─ log.jsonl append-only, UTF-8 without BOM, LF
|
|
63
67
|
├─ status.json current-state snapshot (overwritten, `rev` increments)
|
|
68
|
+
├─ plan.json structured plan: goals, checklists, risks
|
|
69
|
+
├─ PLAN.md rendered plan
|
|
64
70
|
├─ SESSION_BOOT.md cross-session handoff packet
|
|
65
71
|
├─ disciplines/ project discipline registry + rules/
|
|
66
72
|
├─ LOG_FORMAT.md / SECURITY.md / schema/log.schema.json
|
|
67
73
|
├─ changelog/ version-level notes and patches
|
|
68
74
|
├─ entries/ forwarding masters for Claude Code / Gemini CLI
|
|
75
|
+
├─ docs/ project documents (external intro / maintenance notes)
|
|
76
|
+
├─ scripts/ maintenance scripts
|
|
77
|
+
├─ dist/ release artifacts
|
|
69
78
|
└─ _archive/
|
|
70
79
|
```
|
|
71
80
|
|
package/docs/MARKET.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
# Market release checklist
|
|
1
|
+
# Market release checklist
|
|
2
2
|
|
|
3
|
-
Published as `dsh-ai-collab@0.
|
|
3
|
+
Published as `dsh-ai-collab@0.5.0`. The remaining steps take it to the
|
|
4
4
|
community plugin market (`dshmarket` / awesome-dsh-plugin) and, optionally, a self-hosted
|
|
5
5
|
format-1 index.
|
|
6
6
|
|
|
7
|
+
## Release log
|
|
8
|
+
|
|
9
|
+
| Version | npm | Git tag | Market entry PR |
|
|
10
|
+
|---|---|---|---|
|
|
11
|
+
| `0.5.0` (2026-11-23) | published | `v0.5.0` | #18120 — description refresh for disciplines / handoff / safe writes (open) |
|
|
12
|
+
| `0.4.4` (2026-11-20) | published | `v0.4.4` | #17234 — intro-page link in description (merged) |
|
|
13
|
+
| `0.4.3` (2026-11-17) | published | `v0.4.3` | #16419 — first listing (merged) |
|
|
14
|
+
|
|
7
15
|
## 0. Preconditions (already satisfied)
|
|
8
16
|
|
|
9
17
|
| Item | Status |
|
|
@@ -12,8 +20,8 @@ format-1 index.
|
|
|
12
20
|
| No build scripts, no native modules | yes (nothing to compile on install) |
|
|
13
21
|
| Package manifest complete | `engines.dsh`, `os`, `exports` (locale/icon), `files` whitelist |
|
|
14
22
|
| Display metadata | `locale/en.json`, `locale/zh.json`, `icon.svg`, `docs/DETAIL.md` |
|
|
15
|
-
| Tests | `npm test` (
|
|
16
|
-
| npm name `dsh-ai-collab` |
|
|
23
|
+
| Tests | `npm test` (25 cases) |
|
|
24
|
+
| npm name `dsh-ai-collab` | taken by this package |
|
|
17
25
|
| Local-only data | none: paths, hostnames and project names in examples are placeholders |
|
|
18
26
|
|
|
19
27
|
Still missing (needs the maintainer's accounts):
|
|
@@ -28,7 +36,7 @@ Still missing (needs the maintainer's accounts):
|
|
|
28
36
|
cd <package-dir>
|
|
29
37
|
npm run check
|
|
30
38
|
npm test
|
|
31
|
-
npm pack --dry-run # inspect the file list (
|
|
39
|
+
npm pack --dry-run # inspect the file list (37 files)
|
|
32
40
|
npm publish --access public --registry https://registry.npmjs.org
|
|
33
41
|
npm view dsh-ai-collab version
|
|
34
42
|
```
|
package/docs/index.html
CHANGED
|
@@ -484,7 +484,7 @@
|
|
|
484
484
|
<svg class="logo" viewBox="0 0 32 32" aria-hidden="true"><rect width="32" height="32" rx="8" fill="#0d6b5b"/><path d="M9 11h14M9 16h9M9 21h11" stroke="#8fe7d1" stroke-width="2.6" stroke-linecap="round"/></svg>
|
|
485
485
|
<span>dsh-ai-collab</span>
|
|
486
486
|
</a>
|
|
487
|
-
<span class="ver">v0.
|
|
487
|
+
<span class="ver">v0.6.0</span>
|
|
488
488
|
<nav class="top-nav" aria-label="页面导航">
|
|
489
489
|
<a href="#problem">问题</a>
|
|
490
490
|
<a href="#model">机制</a>
|
|
@@ -568,7 +568,7 @@
|
|
|
568
568
|
</ol>
|
|
569
569
|
</nav>
|
|
570
570
|
<div class="side-card">
|
|
571
|
-
<div class="sc-row"><span class="pulse" aria-hidden="true"></span>已发布 · 0.
|
|
571
|
+
<div class="sc-row"><span class="pulse" aria-hidden="true"></span>已发布 · 0.6.0</div>
|
|
572
572
|
<p>npm 已上架,社区市场已收录;脚手架当前支持 Windows。</p>
|
|
573
573
|
<button class="print-btn" type="button" id="printBtn" onclick="window.print()">打印 / 保存为 PDF</button>
|
|
574
574
|
</div>
|
|
@@ -1060,13 +1060,13 @@ dsh plugin --profile <profile> add "<包绝对路径>"</code></pre>
|
|
|
1060
1060
|
<section class="sec" id="status">
|
|
1061
1061
|
<p class="kicker"><span class="bar" aria-hidden="true"></span>09 · 边界与状态</p>
|
|
1062
1062
|
<h2>已发布,边界清晰</h2>
|
|
1063
|
-
<p class="lead">0.
|
|
1063
|
+
<p class="lead">0.6.0 已上 npm 并被社区插件市场收录;新增执行计划、检查清单、风险应对与跨项目仪表盘;脚手架目前仅支持 Windows,只读工具与任务渲染本身与平台无关。</p>
|
|
1064
1064
|
|
|
1065
1065
|
<div class="release">
|
|
1066
1066
|
<div class="rel">
|
|
1067
1067
|
<div class="rel-top"><span>npm</span><span class="badge-ok">已发布</span></div>
|
|
1068
|
-
<b>dsh-ai-collab@0.
|
|
1069
|
-
<span>2026-11-
|
|
1068
|
+
<b>dsh-ai-collab@0.6.0</b>
|
|
1069
|
+
<span>2026-11-27 上架,可直接安装</span>
|
|
1070
1070
|
</div>
|
|
1071
1071
|
<div class="rel">
|
|
1072
1072
|
<div class="rel-top"><span>GitHub</span><span class="badge-ok">已就绪</span></div>
|
|
@@ -1085,23 +1085,27 @@ dsh plugin --profile <profile> add "<包绝对路径>"</code></pre>
|
|
|
1085
1085
|
</div>
|
|
1086
1086
|
</div>
|
|
1087
1087
|
|
|
1088
|
-
<h3 class="subhead">0.
|
|
1088
|
+
<h3 class="subhead">0.6.0 更新摘要</h3>
|
|
1089
1089
|
<div class="rules">
|
|
1090
1090
|
<div class="rule">
|
|
1091
1091
|
<span class="rule-n">新</span>
|
|
1092
|
-
<div><h3
|
|
1092
|
+
<div><h3>执行计划与任务管理</h3><p>新工具 <code>ai_plan</code>(show / set / done)将目标、检查清单、风险写入 <code>.ai/plan.json</code>;活跃风险自动合并到 <code>status.json</code> → <code>blockers</code>,每次 <code>ai_status</code> 都能看到。</p></div>
|
|
1093
1093
|
</div>
|
|
1094
1094
|
<div class="rule">
|
|
1095
1095
|
<span class="rule-n">新</span>
|
|
1096
|
-
<div><h3
|
|
1096
|
+
<div><h3>TASKS.md 三段式 + 可视化仪表盘</h3><p><code>TASKS.md</code> 现在分「当前计划 → 检查清单 → 风险日志 → 工作记录」四区,并同步生成 <code>TASKS.html</code>(与 <code>dashboard.html</code> 同 CSS 风格,自动色彩标记)。</p></div>
|
|
1097
1097
|
</div>
|
|
1098
1098
|
<div class="rule">
|
|
1099
|
-
<span class="rule-n"
|
|
1100
|
-
<div><h3
|
|
1099
|
+
<span class="rule-n">新</span>
|
|
1100
|
+
<div><h3>跨项目仪表盘</h3><p><code>F:\MyProject\.ai\dashboard.html</code> 扫描所有兄弟项目状态,有活动阻塞器的项目高亮红色,并附最近记录数量趋势条;每次 <code>ai_log</code> 自动刷新。</p></div>
|
|
1101
|
+
</div>
|
|
1102
|
+
<div class="rule">
|
|
1103
|
+
<span class="rule-n">改</span>
|
|
1104
|
+
<div><h3>路径整理与归档子目录</h3><p>项目根精简为 <code>AGENTS.md</code> + <code>TASKS.md</code> + <code>dsh-ai-collab.html</code>;其余统一收进 <code>.ai/docs/</code> <code>.ai/scripts/</code> <code>.ai/dist/</code>;AGENTS.md §6 索引已同步。</p></div>
|
|
1101
1105
|
</div>
|
|
1102
1106
|
<div class="rule">
|
|
1103
1107
|
<span class="rule-n">测</span>
|
|
1104
|
-
<div><h3>验证</h3><p>
|
|
1108
|
+
<div><h3>验证</h3><p>39 个测试全通过;14 个新增覆盖规划 I/O、检查清单切换、风险合并、Markdown 与 HTML 渲染、项目扫描与仪表盘生成。</p></div>
|
|
1105
1109
|
</div>
|
|
1106
1110
|
</div>
|
|
1107
1111
|
|
|
@@ -1149,7 +1153,7 @@ dsh plugin --profile <profile> add "<包绝对路径>"</code></pre>
|
|
|
1149
1153
|
|
|
1150
1154
|
<footer class="site-footer">
|
|
1151
1155
|
<div class="foot-inner">
|
|
1152
|
-
<div>本文基于项目 <code>AGENTS.md</code>、<code>dsh-ai-collab.md</code>、插件 README 与发布记录整理 · 2026-11-
|
|
1156
|
+
<div>本文基于项目 <code>AGENTS.md</code>、<code>dsh-ai-collab.md</code>、插件 README 与发布记录整理 · 2026-11-27 · 对应版本 0.6.0</div>
|
|
1153
1157
|
<div class="foot-links">
|
|
1154
1158
|
<a href="https://www.npmjs.com/package/dsh-ai-collab" target="_blank" rel="noopener">npm</a>
|
|
1155
1159
|
<a href="https://github.com/ZhuYw3927/dsh-ai-collab" target="_blank" rel="noopener">GitHub</a>
|
package/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* 插件异常会影响 Host 启动,所以首次安装请用 --patch 隔离验证,见 README。
|
|
11
11
|
*/
|
|
12
12
|
import { existsSync, mkdirSync, appendFileSync, readFileSync, readdirSync, renameSync, statSync, rmSync, writeFileSync } from 'node:fs'
|
|
13
|
-
import { join, dirname } from 'node:path'
|
|
13
|
+
import { join, dirname, basename } from 'node:path'
|
|
14
14
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
15
15
|
import { homedir } from 'node:os'
|
|
16
16
|
import { spawn } from 'node:child_process'
|
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
renderGlobalFile, renderProjectSection, setGlobalEnabled, ID_RE,
|
|
25
25
|
} from './lib/disciplines.js'
|
|
26
26
|
import { buildHandoff, inheritPrompt, writeSessionBoot } from './lib/handoff.js'
|
|
27
|
+
import { activeRiskTitles, doneChecklistItem, PLAN_STATUSES, CHECKLIST_STATUSES, readPlan, setBlock, writePlan } from './lib/plan.js'
|
|
28
|
+
import { writeDashboard } from './lib/dashboard.js'
|
|
27
29
|
|
|
28
30
|
export const name = 'ai-collab'
|
|
29
31
|
// Only `tools` is required. `workingDirectory` is used when present
|
|
@@ -209,6 +211,16 @@ function appendRecord(root, input) {
|
|
|
209
211
|
const list = Array.isArray(st.blockers) ? st.blockers : []
|
|
210
212
|
st.blockers = [...new Set([rec.issue, ...list].filter(Boolean))]
|
|
211
213
|
}
|
|
214
|
+
// 将 plan.json 的 active 风险标题合并进 blockers(轻联动,去重)
|
|
215
|
+
try {
|
|
216
|
+
const titles = activeRiskTitles(readPlan(root))
|
|
217
|
+
if (titles.length > 0) {
|
|
218
|
+
const current = new Set((Array.isArray(st.blockers) ? st.blockers : []).filter((b) => !titles.includes(b)))
|
|
219
|
+
for (const t of titles) current.add(t)
|
|
220
|
+
const merged = [...current]
|
|
221
|
+
if (JSON.stringify(merged) !== JSON.stringify(st.blockers)) st.blockers = merged
|
|
222
|
+
}
|
|
223
|
+
} catch { /* plan.json 不可读时不阻塞状态更新 */ }
|
|
212
224
|
writeFileAtomic(statusPath(root), JSON.stringify(st, null, 2) + '\n')
|
|
213
225
|
}
|
|
214
226
|
return rec
|
|
@@ -266,25 +278,31 @@ function recentlyRefreshed(root, key, windowMs) {
|
|
|
266
278
|
return false
|
|
267
279
|
}
|
|
268
280
|
|
|
269
|
-
//
|
|
281
|
+
// 写日志后顺带刷新看板 + 仪表盘(仅当上级目录已有 .ai\board.md;走包内 ai-ensure,不执行工作区脚本)
|
|
270
282
|
function maybeRefreshBoard(root) {
|
|
271
283
|
try {
|
|
272
284
|
if (!existsSync(join(dirname(root), '.ai', 'board.md'))) return
|
|
273
285
|
if (recentlyRefreshed(root, 'board', 3000)) return
|
|
274
286
|
spawnEnsure(root, {}, ['-NoAgents'])
|
|
287
|
+
// 仪表盘与看板同频刷新(3s 节流,不阻塞记录写入)
|
|
288
|
+
try { writeDashboard(root) } catch (e) { appendLog('ai-collab-dashboard.log', `root=${root} throw ${e?.message || e}`) }
|
|
275
289
|
} catch { /* 看板刷新失败不影响记录 */ }
|
|
276
290
|
}
|
|
277
291
|
|
|
278
292
|
/**
|
|
279
|
-
*
|
|
293
|
+
* 写日志后刷新任务清单(TASKS.md + TASKS.html + PLAN.md)。
|
|
294
|
+
* 首次触发时自动创建 .ai\tasks-enabled(不再需要手动开)。
|
|
280
295
|
* 进程内渲染:不执行工作区自带的 .ai/llm.ps1,避免仓库脚本被插件执行。
|
|
281
296
|
*/
|
|
282
297
|
function refreshTasks(root) {
|
|
283
298
|
try {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
299
|
+
const marker = join(root, '.ai', 'tasks-enabled')
|
|
300
|
+
if (!existsSync(marker)) mkdirSync(marker, { recursive: true })
|
|
301
|
+
const st = readJson(statusPath(root))
|
|
302
|
+
const projectName = (st && st.project) || basename(root)
|
|
303
|
+
const result = withLock(join(root, '.ai', '.tasks.lock'), () => writeTasks(root, nowIso(), projectName))
|
|
304
|
+
if (!result.written) return
|
|
305
|
+
if (result.count === 0) appendLog('ai-collab-tasks.log', `root=${root} count=0`)
|
|
288
306
|
} catch (error) {
|
|
289
307
|
appendLog('ai-collab-tasks.log', `root=${root} throw ${error?.message || error}`)
|
|
290
308
|
}
|
|
@@ -701,6 +719,55 @@ function registerTools(ctx, opts, defineTool, spec) {
|
|
|
701
719
|
}
|
|
702
720
|
}))
|
|
703
721
|
|
|
722
|
+
registered.push('ai_plan')
|
|
723
|
+
ctx.tools.register(defineTool({
|
|
724
|
+
name: 'ai_plan',
|
|
725
|
+
description: '管理执行计划、检查清单与风险应对:数据存 .ai\\plan.json,渲染产物 .ai\\PLAN.md + TASKS.md + TASKS.html。show / set <plan|checklist|risks> / done <checklist-id>。',
|
|
726
|
+
parameters: {
|
|
727
|
+
action: { type: 'string', required: true, enum: ['show', 'set', 'done'], description: 'show 返回当前计划;set 覆盖 plan/checklist/risks 其中一块(传 key+items);done 勾选一条清单项' },
|
|
728
|
+
key: { type: 'string', description: 'set 时必填:plan / checklist / risks' },
|
|
729
|
+
items: { type: 'array', items: { type: 'json' }, description: 'set 时的项数组(JSON 对象列表)' },
|
|
730
|
+
id: { type: 'string', description: 'done 时的清单项 id' },
|
|
731
|
+
root: { type: 'string', description: '目标工作区,缺省为会话 cwd' },
|
|
732
|
+
},
|
|
733
|
+
output,
|
|
734
|
+
async execute(args, exec) {
|
|
735
|
+
const r = args?.root ? String(args.root) : await rootOf(exec)
|
|
736
|
+
const action = String(args?.action || 'show')
|
|
737
|
+
const now = nowIso()
|
|
738
|
+
|
|
739
|
+
if (action === 'show') {
|
|
740
|
+
const plan = readPlan(r)
|
|
741
|
+
return { root: r, plan, hasPlan: plan.plan.length > 0 || plan.checklist.length > 0 || plan.risks.length > 0 }
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (action === 'set') {
|
|
745
|
+
const key = String(args?.key || '')
|
|
746
|
+
const items = Array.isArray(args?.items) ? args.items : []
|
|
747
|
+
const result = setBlock(r, key, items, now)
|
|
748
|
+
refreshTasks(r)
|
|
749
|
+
maybeRefreshBoard(r)
|
|
750
|
+
return { root: r, ok: true, key, count: (result[key] || []).length, updated_at: result.updated_at }
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (action === 'done') {
|
|
754
|
+
const id = String(args?.id || '')
|
|
755
|
+
const { plan, item } = doneChecklistItem(r, id, now)
|
|
756
|
+
const rec = appendRecord(r, {
|
|
757
|
+
tool: 'ai_plan', action: 'task_done', status: 'ok',
|
|
758
|
+
summary: `清单项完成: ${item.item}`,
|
|
759
|
+
tags: ['plan', 'checklist'],
|
|
760
|
+
})
|
|
761
|
+
refreshTasks(r)
|
|
762
|
+
refreshSessionBoot(r)
|
|
763
|
+
maybeRefreshBoard(r)
|
|
764
|
+
return { root: r, ok: true, id, item, record: rec.id, plan: { ...plan, plan: undefined, checklist: undefined, risks: undefined } }
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
throw new Error(`未知 action: ${action}`)
|
|
768
|
+
}
|
|
769
|
+
}))
|
|
770
|
+
|
|
704
771
|
logToolRegistration(registered, spec)
|
|
705
772
|
}
|
|
706
773
|
|
package/lib/dashboard.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 跨项目仪表盘渲染:读取父目录下各项目 status.json + log.jsonl 行数,
|
|
3
|
+
* 生成 `board.md` 同级目录的 `dashboard.html`(自包含单文件,同 TASKS.html 风格)。
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, mkdirSync, readdirSync } from 'node:fs'
|
|
6
|
+
import { join, dirname } from 'node:path'
|
|
7
|
+
import { readText, writeFileAtomic } from './atomic.js'
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------- helpers
|
|
10
|
+
|
|
11
|
+
export function readdirSafe(dir) {
|
|
12
|
+
try { return readdirSync(dir) } catch { return [] }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function htmlEsc(s) {
|
|
16
|
+
return String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function readJsonFile(path) {
|
|
20
|
+
try { return JSON.parse(readText(path)) } catch { return null }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 读 `<root>/.ai/log.jsonl` 非空行数。 */
|
|
24
|
+
function logLineCount(root) {
|
|
25
|
+
try {
|
|
26
|
+
const raw = readText(join(root, '.ai', 'log.jsonl'))
|
|
27
|
+
return raw.split('\n').filter((l) => l.trim().length > 0).length
|
|
28
|
+
} catch { return 0 }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function phaseLabel(phase) {
|
|
32
|
+
const map = { init: '初始化', build: '构建', feature: '特性开发', 'attitude-validation': '姿态验证',
|
|
33
|
+
diagnosis: '诊断', maintain: '维护', deliver: '交付' }
|
|
34
|
+
return map[phase] || phase || '—'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------- scan
|
|
38
|
+
|
|
39
|
+
export function scanProjects(parent) {
|
|
40
|
+
const rows = []
|
|
41
|
+
for (const entry of readdirSafe(parent)) {
|
|
42
|
+
if (entry.startsWith('.') || entry.startsWith('_')) continue
|
|
43
|
+
const st = readJsonFile(join(parent, entry, '.ai', 'status.json'))
|
|
44
|
+
if (!st) continue
|
|
45
|
+
rows.push({
|
|
46
|
+
project: st.project || entry,
|
|
47
|
+
dir: entry,
|
|
48
|
+
phase: st.phase || '',
|
|
49
|
+
focus: st.focus || '',
|
|
50
|
+
blockers: st.blockers || [],
|
|
51
|
+
next: st.next || [],
|
|
52
|
+
updated_at: st.updated_at || '',
|
|
53
|
+
logCount: logLineCount(join(parent, entry)),
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
return rows.sort((a, b) => String(b.updated_at).localeCompare(String(a.updated_at)))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------- render: dashboard.html
|
|
60
|
+
|
|
61
|
+
export function renderDashboard(rows, parent, now) {
|
|
62
|
+
const dir = htmlEsc(parent)
|
|
63
|
+
const totalProjects = rows.length
|
|
64
|
+
const totalRecords = rows.reduce((s, r) => s + r.logCount, 0)
|
|
65
|
+
const blocking = rows.filter((r) => r.blockers.length > 0)
|
|
66
|
+
const maxLog = Math.max(1, ...rows.map((r) => r.logCount))
|
|
67
|
+
|
|
68
|
+
let tableHtml = ''
|
|
69
|
+
for (const r of rows) {
|
|
70
|
+
const hasBlock = r.blockers.length > 0
|
|
71
|
+
const blockText = hasBlock ? r.blockers.map((b) => htmlEsc(b)).join('; ') : '—'
|
|
72
|
+
const trClass = hasBlock ? ' style="background:#fff5f5"' : ''
|
|
73
|
+
tableHtml += `<tr${trClass}>
|
|
74
|
+
<td>${hasBlock ? '<span class="badge blocked">阻塞</span>' : ''}</td>
|
|
75
|
+
<td><strong>${htmlEsc(r.project)}</strong></td>
|
|
76
|
+
<td>${phaseLabel(r.phase)}</td>
|
|
77
|
+
<td>${htmlEsc(r.focus)}</td>
|
|
78
|
+
<td>${blockText}</td>
|
|
79
|
+
<td><a href="${htmlEsc(r.dir)}/TASKS.html" title="任务清单">${r.logCount} 条</a></td>
|
|
80
|
+
<td class="muted">${htmlEsc(r.updated_at)}</td>
|
|
81
|
+
</tr>`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let barHtml = ''
|
|
85
|
+
for (const r of rows) {
|
|
86
|
+
const pct = Math.round((r.logCount / maxLog) * 100)
|
|
87
|
+
const color = r.logCount >= 40 ? '#198754' : r.logCount >= 20 ? '#0d6efd' : '#6c757d'
|
|
88
|
+
barHtml += `<div class="bar-row">
|
|
89
|
+
<span class="bar-label">${htmlEsc(r.project)}</span>
|
|
90
|
+
<span class="bar-track"><span class="bar-fill" style="width:${pct}%;background:${color}"></span></span>
|
|
91
|
+
<span class="bar-count">${r.logCount}</span>
|
|
92
|
+
</div>`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let blockHtml = ''
|
|
96
|
+
if (blocking.length > 0) {
|
|
97
|
+
blockHtml = '<section class="blocking"><h2>🚨 当前阻塞</h2><ul>'
|
|
98
|
+
for (const r of blocking) {
|
|
99
|
+
for (const b of r.blockers) {
|
|
100
|
+
blockHtml += `<li><strong>${htmlEsc(r.project)}</strong>:${htmlEsc(b)}</li>`
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
blockHtml += '</ul></section>'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return `<!DOCTYPE html>
|
|
107
|
+
<html lang="zh-CN">
|
|
108
|
+
<head>
|
|
109
|
+
<meta charset="UTF-8">
|
|
110
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
111
|
+
<title>跨项目仪表盘</title>
|
|
112
|
+
<style>
|
|
113
|
+
:root { --bg:#f8f9fa; --card:#fff; --text:#212529; --muted:#6c757d; --border:#dee2e6; font-family:system-ui,-apple-system,sans-serif; }
|
|
114
|
+
body { background:var(--bg); color:var(--text); margin:0; padding:16px; }
|
|
115
|
+
.container { max-width:1100px; margin:0 auto; }
|
|
116
|
+
header { background:var(--card); border:1px solid var(--border); border-radius:8px; padding:16px 24px; margin-bottom:16px; display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px; }
|
|
117
|
+
header h1 { margin:0; font-size:20px; }
|
|
118
|
+
header .stats { display:flex; gap:16px; }
|
|
119
|
+
header .stat { text-align:center; }
|
|
120
|
+
header .stat .num { font-size:22px; font-weight:700; }
|
|
121
|
+
header .stat .label { font-size:11px; color:var(--muted); }
|
|
122
|
+
section { background:var(--card); border:1px solid var(--border); border-radius:8px; padding:16px 24px; margin-bottom:16px; }
|
|
123
|
+
section h2 { margin:0 0 12px; font-size:16px; }
|
|
124
|
+
section.blocking { border-color:#dc3545; }
|
|
125
|
+
section.blocking ul { margin:0; padding-left:20px; color:#dc3545; }
|
|
126
|
+
section.blocking li { margin-bottom:4px; }
|
|
127
|
+
section.blocking strong { color:var(--text); }
|
|
128
|
+
table { width:100%; border-collapse:collapse; font-size:13px; }
|
|
129
|
+
th, td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--border); vertical-align:top; }
|
|
130
|
+
th { background:#f1f3f5; font-weight:600; white-space:nowrap; }
|
|
131
|
+
tr:hover { background:#f8f9fa; }
|
|
132
|
+
.muted { color:var(--muted); font-size:12px; }
|
|
133
|
+
.badge { display:inline-block; padding:2px 6px; border-radius:3px; font-size:11px; font-weight:600; }
|
|
134
|
+
.badge.blocked { background:#dc3545; color:#fff; }
|
|
135
|
+
a { color:#0d6efd; text-decoration:none; }
|
|
136
|
+
a:hover { text-decoration:underline; }
|
|
137
|
+
.bar-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; font-size:13px; }
|
|
138
|
+
.bar-label { min-width:80px; text-align:right; font-weight:500; }
|
|
139
|
+
.bar-track { flex:1; height:18px; background:#e9ecef; border-radius:4px; overflow:hidden; }
|
|
140
|
+
.bar-fill { height:100%; border-radius:4px; transition:width .3s; }
|
|
141
|
+
.bar-count { min-width:30px; font-variant-numeric:tabular-nums; color:var(--muted); }
|
|
142
|
+
footer { text-align:center; color:var(--muted); font-size:12px; padding:12px; }
|
|
143
|
+
</style>
|
|
144
|
+
</head>
|
|
145
|
+
<body>
|
|
146
|
+
<div class="container">
|
|
147
|
+
<header>
|
|
148
|
+
<div><h1>📊 跨项目仪表盘</h1><div class="muted">扫描:${dir} · 共 ${totalProjects} 个项目 · ${now}</div></div>
|
|
149
|
+
<div class="stats">
|
|
150
|
+
<div class="stat"><div class="num">${totalProjects}</div><div class="label">项目</div></div>
|
|
151
|
+
<div class="stat"><div class="num">${totalRecords}</div><div class="label">记录</div></div>
|
|
152
|
+
<div class="stat"><div class="num" style="color:#dc3545">${blocking.length}</div><div class="label">阻塞</div></div>
|
|
153
|
+
</div>
|
|
154
|
+
</header>
|
|
155
|
+
${blockHtml}
|
|
156
|
+
<section><h2>记录趋势</h2>${barHtml}</section>
|
|
157
|
+
<section><h2>项目总览</h2>
|
|
158
|
+
<table>
|
|
159
|
+
<tr><th></th><th>项目</th><th>阶段</th><th>焦点</th><th>阻塞</th><th>记录</th><th class="muted">最后更新</th></tr>
|
|
160
|
+
${tableHtml}
|
|
161
|
+
</table>
|
|
162
|
+
</section>
|
|
163
|
+
<footer>自动生成 · 来源各项目 .ai/status.json + .ai/log.jsonl · 勿手动编辑</footer>
|
|
164
|
+
</div>
|
|
165
|
+
</body>
|
|
166
|
+
</html>
|
|
167
|
+
`
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ---------------------------------------------------------------- write
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 读父目录 `board.md` 的位置来确定仪表盘输出路径。
|
|
174
|
+
* 目标:`<board.md 所在目录>\dashboard.html`。
|
|
175
|
+
* 当父目录没有 board.md 时返回 null。
|
|
176
|
+
*/
|
|
177
|
+
export function writeDashboard(root) {
|
|
178
|
+
const parent = dirname(root)
|
|
179
|
+
const boardPath = join(parent, '.ai', 'board.md')
|
|
180
|
+
if (!existsSync(boardPath)) return null
|
|
181
|
+
const rows = scanProjects(parent)
|
|
182
|
+
const now = new Date().toISOString()
|
|
183
|
+
const outPath = join(parent, '.ai', 'dashboard.html')
|
|
184
|
+
mkdirSync(join(parent, '.ai'), { recursive: true })
|
|
185
|
+
writeFileAtomic(outPath, renderDashboard(rows, parent, now))
|
|
186
|
+
return { path: outPath, rows: rows.length, written: true }
|
|
187
|
+
}
|
package/lib/plan.js
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ai_plan` data layer: `.ai/plan.json` (structured plan/checklist/risks)
|
|
3
|
+
* and its rendered outputs `.ai/PLAN.md` and `TASKS.md` (three-section).
|
|
4
|
+
*
|
|
5
|
+
* plan.json 写入走原子写 + 项目级锁(与 appendRecord 同级保护)。
|
|
6
|
+
* TASKS.md / TASKS.html / PLAN.md 是渲染产物,不手改。
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, mkdirSync } from 'node:fs'
|
|
9
|
+
import { join } from 'node:path'
|
|
10
|
+
import { writeFileAtomic, readText } from './atomic.js'
|
|
11
|
+
import { withLock } from './lock.js'
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------- schema
|
|
14
|
+
|
|
15
|
+
export const PLAN_STATUSES = ['todo', 'in_progress', 'done', 'blocked']
|
|
16
|
+
export const CHECKLIST_STATUSES = ['open', 'done', 'na']
|
|
17
|
+
export const RISK_PROBABILITIES = ['高', '中', '低']
|
|
18
|
+
export const RISK_IMPACTS = ['高', '中', '低']
|
|
19
|
+
export const RISK_STRATEGIES = ['规避', '减轻', '接受', '转移']
|
|
20
|
+
export const RISK_STATUSES = ['active', 'resolved', 'expired']
|
|
21
|
+
|
|
22
|
+
/** 新建空 plan 的默认值。 */
|
|
23
|
+
export function emptyPlan() {
|
|
24
|
+
return {
|
|
25
|
+
schema_version: 1,
|
|
26
|
+
updated_at: '',
|
|
27
|
+
plan: [],
|
|
28
|
+
checklist: [],
|
|
29
|
+
risks: [],
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ---------------------------------------------------------------- paths
|
|
34
|
+
|
|
35
|
+
function planPath(root) { return join(root, '.ai', 'plan.json') }
|
|
36
|
+
function planMdPath(root) { return join(root, '.ai', 'PLAN.md') }
|
|
37
|
+
function tasksMdPath(root) { return join(root, 'TASKS.md') }
|
|
38
|
+
|
|
39
|
+
/** 需要锁保护的动作统一走这里。 */
|
|
40
|
+
function planLockPath(root) { return join(root, '.ai', '.plan.lock') }
|
|
41
|
+
|
|
42
|
+
// ---------------------------------------------------------------- read / write
|
|
43
|
+
|
|
44
|
+
export function readPlan(root) {
|
|
45
|
+
try {
|
|
46
|
+
const raw = readText(planPath(root))
|
|
47
|
+
const obj = JSON.parse(raw)
|
|
48
|
+
if (!obj || typeof obj !== 'object') return emptyPlan()
|
|
49
|
+
const p = emptyPlan()
|
|
50
|
+
if (Array.isArray(obj.plan)) p.plan = obj.plan
|
|
51
|
+
if (Array.isArray(obj.checklist)) p.checklist = obj.checklist
|
|
52
|
+
if (Array.isArray(obj.risks)) p.risks = obj.risks
|
|
53
|
+
if (typeof obj.schema_version === 'number') p.schema_version = obj.schema_version
|
|
54
|
+
if (typeof obj.updated_at === 'string') p.updated_at = obj.updated_at
|
|
55
|
+
return p
|
|
56
|
+
} catch {
|
|
57
|
+
return emptyPlan()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function writePlan(root, plan, now) {
|
|
62
|
+
mkdirSync(join(root, '.ai'), { recursive: true })
|
|
63
|
+
const payload = { ...plan, updated_at: now || new Date().toISOString() }
|
|
64
|
+
return withLock(planLockPath(root), () => {
|
|
65
|
+
writeFileAtomic(planPath(root), JSON.stringify(payload, null, 2) + '\n')
|
|
66
|
+
writeFileAtomic(planMdPath(root), renderPlanMarkdown(payload))
|
|
67
|
+
return payload
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ---------------------------------------------------------------- setters
|
|
72
|
+
|
|
73
|
+
/** 用一组项覆盖 plan/checklist/risks 中的一块。 */
|
|
74
|
+
export function setBlock(root, key, items, now) {
|
|
75
|
+
const plan = readPlan(root)
|
|
76
|
+
if (!['plan', 'checklist', 'risks'].includes(key)) throw new Error(`未知块: ${key}`)
|
|
77
|
+
if (!Array.isArray(items)) throw new Error(`${key} 必须为数组`)
|
|
78
|
+
plan[key] = items
|
|
79
|
+
return writePlan(root, plan, now)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** 勾选清单项。返回更新后的 plan 与该项。 */
|
|
83
|
+
export function doneChecklistItem(root, id, now) {
|
|
84
|
+
const plan = readPlan(root)
|
|
85
|
+
const target = plan.checklist.find((c) => c.id === id)
|
|
86
|
+
if (!target) throw new Error(`清单项不存在: ${id}`)
|
|
87
|
+
target.status = 'done'
|
|
88
|
+
return { plan: writePlan(root, plan, now), item: target }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** 收集当前 active 风险标题(用于联动 status.json.blockers)。 */
|
|
92
|
+
export function activeRiskTitles(plan) {
|
|
93
|
+
return (plan.risks || [])
|
|
94
|
+
.filter((r) => r.status === 'active')
|
|
95
|
+
.map((r) => r.risk)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ---------------------------------------------------------------- render: PLAN.md
|
|
99
|
+
|
|
100
|
+
function cell(value) {
|
|
101
|
+
return String(value ?? '').replace(/\|/g, '\\|').replace(/\n/g, ' ')
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function statusLabel(status) {
|
|
105
|
+
const map = { todo: '待办', in_progress: '进行中', done: '完成', blocked: '阻塞',
|
|
106
|
+
open: '待办', na: '不适用', active: '活跃', resolved: '已解决', expired: '已失效' }
|
|
107
|
+
return map[status] || status
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function renderPlanMarkdown(plan) {
|
|
111
|
+
const lines = [
|
|
112
|
+
'# 执行计划与清单',
|
|
113
|
+
'',
|
|
114
|
+
`> 自动生成:来源 \`.ai\\plan.json\`。最后更新 ${plan.updated_at || '—'}`,
|
|
115
|
+
'> 用工具 `ai_plan` 管理,不要手动编辑本文件。',
|
|
116
|
+
'',
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
if ((plan.plan || []).length > 0) {
|
|
120
|
+
lines.push('## 执行计划', '')
|
|
121
|
+
lines.push('| # | 步骤 | 验收标准 | 状态 | 负责人 | 截止 |')
|
|
122
|
+
lines.push('|---|---|---|---|---|---|')
|
|
123
|
+
for (const p of plan.plan) {
|
|
124
|
+
lines.push(`| ${cell(p.id)} | ${cell(p.step)} | ${cell(p.acceptance)} | ${statusLabel(p.status)} | ${cell(p.owner)} | ${cell(p.due)} |`)
|
|
125
|
+
}
|
|
126
|
+
lines.push('')
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if ((plan.checklist || []).length > 0) {
|
|
130
|
+
lines.push('## 检查清单', '')
|
|
131
|
+
lines.push('| # | 项 | 状态 | 关联记录 |')
|
|
132
|
+
lines.push('|---|---|---|---|')
|
|
133
|
+
for (const c of plan.checklist) {
|
|
134
|
+
lines.push(`| ${cell(c.id)} | ${cell(c.item)} | ${statusLabel(c.status)} | ${cell(c.link)} |`)
|
|
135
|
+
}
|
|
136
|
+
lines.push('')
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if ((plan.risks || []).length > 0) {
|
|
140
|
+
lines.push('## 风险与应对', '')
|
|
141
|
+
lines.push('| 风险 | 概率 | 影响 | 策略 | 状态 |')
|
|
142
|
+
lines.push('|---|---|---|---|---|')
|
|
143
|
+
for (const r of plan.risks) {
|
|
144
|
+
lines.push(`| ${cell(r.risk)} | ${cell(r.probability)} | ${cell(r.impact)} | ${cell(r.strategy)} | ${statusLabel(r.status)} |`)
|
|
145
|
+
}
|
|
146
|
+
lines.push('')
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return lines.join('\n')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ---------------------------------------------------------------- render: TASKS.md (three-section)
|
|
153
|
+
|
|
154
|
+
export function renderTasksMarkdown(root, records, plan, now) {
|
|
155
|
+
const lines = [
|
|
156
|
+
'# 任务记录清单',
|
|
157
|
+
'',
|
|
158
|
+
`> 自动生成:来自 \`.ai\\log.jsonl\`,共 ${records.length} 条;按时间倒序。最后更新 ${now}`,
|
|
159
|
+
'> 只读清单:要新增记录请用 `.ai\\llm.cmd add` 或工具 `ai_log`,不要直接编辑本文件。',
|
|
160
|
+
'',
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
// --- plan sections ---
|
|
164
|
+
if (plan && plan.plan.length > 0) {
|
|
165
|
+
lines.push('## 执行计划(来源:`.ai\\plan.json`)', '')
|
|
166
|
+
lines.push('| # | 步骤 | 验收标准 | 状态 | 负责人 | 截止 |')
|
|
167
|
+
lines.push('|---|---|---|---|---|---|')
|
|
168
|
+
for (const p of plan.plan) {
|
|
169
|
+
lines.push(`| ${cell(p.id)} | ${cell(p.step)} | ${cell(p.acceptance)} | ${statusLabel(p.status)} | ${cell(p.owner)} | ${cell(p.due)} |`)
|
|
170
|
+
}
|
|
171
|
+
lines.push('')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (plan && plan.checklist.length > 0) {
|
|
175
|
+
lines.push('## 检查清单(来源:`.ai\\plan.json`)', '')
|
|
176
|
+
lines.push('| # | 项 | 状态 | 关联记录 |')
|
|
177
|
+
lines.push('|---|---|---|---|')
|
|
178
|
+
for (const c of plan.checklist) {
|
|
179
|
+
lines.push(`| ${cell(c.id)} | ${cell(c.item)} | ${statusLabel(c.status)} | ${cell(c.link)} |`)
|
|
180
|
+
}
|
|
181
|
+
lines.push('')
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (plan && plan.risks.length > 0) {
|
|
185
|
+
lines.push('## 风险与应对(来源:`.ai\\plan.json`)', '')
|
|
186
|
+
lines.push('| 风险 | 概率 | 影响 | 策略 | 状态 |')
|
|
187
|
+
lines.push('|---|---|---|---|---|')
|
|
188
|
+
for (const r of plan.risks) {
|
|
189
|
+
lines.push(`| ${cell(r.risk)} | ${cell(r.probability)} | ${cell(r.impact)} | ${cell(r.strategy)} | ${statusLabel(r.status)} |`)
|
|
190
|
+
}
|
|
191
|
+
lines.push('')
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// --- log records ---
|
|
195
|
+
lines.push('## 工作日志(来源:`.ai\\log.jsonl`,只读)', '')
|
|
196
|
+
lines.push('| 时间 | 类型 | 状态 | 摘要 | 记录 id |')
|
|
197
|
+
lines.push('|---|---|---|---|---|')
|
|
198
|
+
const rows = records.map((r) => ({
|
|
199
|
+
ts: String(r.ts ?? ''),
|
|
200
|
+
action: String(r.action ?? ''),
|
|
201
|
+
status: String(r.status ?? ''),
|
|
202
|
+
summary: cell(r.summary),
|
|
203
|
+
id: String(r.id ?? ''),
|
|
204
|
+
}))
|
|
205
|
+
for (let i = rows.length - 1; i >= 0; i -= 1) {
|
|
206
|
+
const r = rows[i]
|
|
207
|
+
lines.push(`| ${r.ts} | ${r.action} | ${r.status} | ${r.summary} | \`${r.id}\` |`)
|
|
208
|
+
}
|
|
209
|
+
if (rows.length === 0) lines.push('| (暂无记录) | | | | |')
|
|
210
|
+
lines.push('')
|
|
211
|
+
|
|
212
|
+
return lines.join('\n')
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ---------------------------------------------------------------- render: TASKS.html (dashboard-style)
|
|
216
|
+
|
|
217
|
+
function htmlEsc(s) {
|
|
218
|
+
return String(s ?? '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function riskColor(p, i) {
|
|
222
|
+
// 高/高 → 红;高/中 或 中/高 → 橙;中/中 → 黄;其余 → 灰
|
|
223
|
+
if (p === '高' && i === '高') return '#dc3545'
|
|
224
|
+
if ((p === '高' && i === '中') || (p === '中' && i === '高')) return '#fd7e14'
|
|
225
|
+
if (p === '中' && i === '中') return '#ffc107'
|
|
226
|
+
return '#6c757d'
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function statusBadge(status) {
|
|
230
|
+
const colors = { todo: '#6c757d', in_progress: '#0d6efd', done: '#198754', blocked: '#dc3545',
|
|
231
|
+
open: '#6c757d', na: '#adb5bd', active: '#dc3545', resolved: '#198754', expired: '#adb5bd' }
|
|
232
|
+
return `<span style="background:${colors[status] || '#6c757d'};color:#fff;padding:2px 8px;border-radius:4px;font-size:12px">${htmlEsc(statusLabel(status))}</span>`
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function renderTasksHtml(root, records, plan, now, projectName) {
|
|
236
|
+
const name = htmlEsc(projectName || root.split(/[/\\]/).filter(Boolean).pop() || '')
|
|
237
|
+
const recordRows = records.map((r) => ({
|
|
238
|
+
ts: String(r.ts ?? ''),
|
|
239
|
+
action: String(r.action ?? ''),
|
|
240
|
+
status: String(r.status ?? ''),
|
|
241
|
+
summary: htmlEsc(r.summary),
|
|
242
|
+
id: htmlEsc(r.id ?? ''),
|
|
243
|
+
})).reverse()
|
|
244
|
+
|
|
245
|
+
let planHtml = ''
|
|
246
|
+
if (plan && plan.plan.length > 0) {
|
|
247
|
+
planHtml += '<section><h2>📋 执行计划</h2><table><tr><th>#</th><th>步骤</th><th>验收标准</th><th>状态</th><th>负责人</th><th>截止</th></tr>'
|
|
248
|
+
for (const p of plan.plan) {
|
|
249
|
+
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>`
|
|
250
|
+
}
|
|
251
|
+
planHtml += '</table></section>'
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let checklistHtml = ''
|
|
255
|
+
if (plan && plan.checklist.length > 0) {
|
|
256
|
+
checklistHtml += '<section><h2>✅ 检查清单</h2><table><tr><th>#</th><th>项</th><th>状态</th><th>关联记录</th></tr>'
|
|
257
|
+
for (const c of plan.checklist) {
|
|
258
|
+
checklistHtml += `<tr><td>${htmlEsc(c.id)}</td><td>${htmlEsc(c.item)}</td><td>${statusBadge(c.status)}</td><td>${htmlEsc(c.link)}</td></tr>`
|
|
259
|
+
}
|
|
260
|
+
checklistHtml += '</table></section>'
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
let risksHtml = ''
|
|
264
|
+
if (plan && plan.risks.length > 0) {
|
|
265
|
+
risksHtml += '<section><h2>⚠️ 风险与应对</h2><table><tr><th>风险</th><th>概率</th><th>影响</th><th>策略</th><th>状态</th></tr>'
|
|
266
|
+
for (const r of plan.risks) {
|
|
267
|
+
const dot = `<span style="display:inline-block;width:12px;height:12px;border-radius:50%;background:${riskColor(r.probability, r.impact)};margin-right:4px"></span>`
|
|
268
|
+
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>`
|
|
269
|
+
}
|
|
270
|
+
risksHtml += '</table></section>'
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
let logHtml = ''
|
|
274
|
+
if (recordRows.length > 0) {
|
|
275
|
+
logHtml += '<section><h2>📜 工作日志</h2><table><tr><th>时间</th><th>类型</th><th>状态</th><th>摘要</th><th>记录 id</th></tr>'
|
|
276
|
+
for (const r of recordRows) {
|
|
277
|
+
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>`
|
|
278
|
+
}
|
|
279
|
+
logHtml += '</table></section>'
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const hasPlan = plan && (plan.plan.length > 0 || plan.checklist.length > 0 || plan.risks.length > 0)
|
|
283
|
+
|
|
284
|
+
return `<!DOCTYPE html>
|
|
285
|
+
<html lang="zh-CN">
|
|
286
|
+
<head>
|
|
287
|
+
<meta charset="UTF-8">
|
|
288
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
289
|
+
<title>${name} · 任务清单</title>
|
|
290
|
+
<style>
|
|
291
|
+
:root { --bg:#f8f9fa; --card:#fff; --text:#212529; --muted:#6c757d; --border:#dee2e6; font-family:system-ui,-apple-system,sans-serif; }
|
|
292
|
+
body { background:var(--bg); color:var(--text); margin:0; padding:16px; }
|
|
293
|
+
.container { max-width:960px; margin:0 auto; }
|
|
294
|
+
header { background:var(--card); border:1px solid var(--border); border-radius:8px; padding:16px 24px; margin-bottom:16px; }
|
|
295
|
+
header h1 { margin:0 0 4px; font-size:20px; }
|
|
296
|
+
header .meta { color:var(--muted); font-size:13px; }
|
|
297
|
+
section { background:var(--card); border:1px solid var(--border); border-radius:8px; padding:16px 24px; margin-bottom:16px; }
|
|
298
|
+
section h2 { margin:0 0 12px; font-size:16px; }
|
|
299
|
+
table { width:100%; border-collapse:collapse; font-size:13px; }
|
|
300
|
+
th, td { text-align:left; padding:6px 8px; border-bottom:1px solid var(--border); vertical-align:top; }
|
|
301
|
+
th { background:#f1f3f5; font-weight:600; white-space:nowrap; }
|
|
302
|
+
tr:hover { background:#f8f9fa; }
|
|
303
|
+
.placeholder { color:var(--muted); font-style:italic; padding:12px 0; }
|
|
304
|
+
footer { text-align:center; color:var(--muted); font-size:12px; padding:12px; }
|
|
305
|
+
</style>
|
|
306
|
+
</head>
|
|
307
|
+
<body>
|
|
308
|
+
<div class="container">
|
|
309
|
+
<header>
|
|
310
|
+
<h1>${name} · 任务清单</h1>
|
|
311
|
+
<div class="meta">${hasPlan ? `计划更新: ${htmlEsc(plan.updated_at || '—')} · ` : ''}日志共 ${records.length} 条 · 生成: ${htmlEsc(now)}</div>
|
|
312
|
+
</header>
|
|
313
|
+
${planHtml}${checklistHtml}${risksHtml}${logHtml}
|
|
314
|
+
${records.length === 0 && !hasPlan ? '<div class="placeholder">暂无记录与计划。</div>' : ''}
|
|
315
|
+
<footer>自动生成 · 来源 .ai/log.jsonl + .ai/plan.json · 勿手动编辑</footer>
|
|
316
|
+
</div>
|
|
317
|
+
</body>
|
|
318
|
+
</html>
|
|
319
|
+
`
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// ---------------------------------------------------------------- write all renders
|
|
323
|
+
|
|
324
|
+
/** 一次写 TASKS.md + TASKS.html + PLAN.md(在锁内)。 */
|
|
325
|
+
export function writeAllRenders(root, records, now, projectName) {
|
|
326
|
+
mkdirSync(join(root, '.ai'), { recursive: true })
|
|
327
|
+
const plan = readPlan(root)
|
|
328
|
+
return withLock(planLockPath(root), () => {
|
|
329
|
+
writeFileAtomic(tasksMdPath(root), renderTasksMarkdown(root, records, plan, now))
|
|
330
|
+
writeFileAtomic(join(root, 'TASKS.html'), renderTasksHtml(root, records, plan, now, projectName))
|
|
331
|
+
writeFileAtomic(planMdPath(root), renderPlanMarkdown(plan))
|
|
332
|
+
return { plan, tasksMd: tasksMdPath(root), tasksHtml: join(root, 'TASKS.html'), planMd: planMdPath(root) }
|
|
333
|
+
})
|
|
334
|
+
}
|
package/lib/tasks.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Task-list renderer: reads `.ai/log.jsonl`, writes three-section `TASKS.md`
|
|
3
|
+
* + `TASKS.html` (dashboard-style) + `.ai/PLAN.md` (from .ai/plan.json).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* worked on, which is a supply-chain risk. Rendering happens here instead:
|
|
7
|
-
* no PowerShell, no workspace-provided script, identical output format.
|
|
5
|
+
* Plan-aware rendering is delegated to `lib/plan.js`; this module keeps the
|
|
6
|
+
* record parsing and provides `writeTasks` for index.js.
|
|
8
7
|
*/
|
|
9
8
|
import { existsSync, readFileSync, mkdirSync } from 'node:fs'
|
|
10
9
|
import { join } from 'node:path'
|
|
11
|
-
import {
|
|
10
|
+
import { writeAllRenders } from './plan.js'
|
|
12
11
|
|
|
13
12
|
/** Parse JSONL text into records, skipping blank or malformed lines. */
|
|
14
13
|
export function parseRecords(text) {
|
|
@@ -25,17 +24,32 @@ export function parseRecords(text) {
|
|
|
25
24
|
return out
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Write `<root>/TASKS.md` + `<root>/TASKS.html` + `.ai/PLAN.md`.
|
|
29
|
+
*
|
|
30
|
+
* When `.ai/plan.json` exists the TASKS files include plan/checklist/risks
|
|
31
|
+
* sections before the log table; otherwise they fall back to a log-only view.
|
|
32
|
+
*
|
|
33
|
+
* Returns `{ written, count, tasksMd, tasksHtml, planMd }`;
|
|
34
|
+
* never throws by design (caller logs).
|
|
35
|
+
*/
|
|
36
|
+
export function writeTasks(root, now, projectName) {
|
|
37
|
+
const logFile = join(root, '.ai', 'log.jsonl')
|
|
38
|
+
const outFile = join(root, 'TASKS.md')
|
|
39
|
+
if (!existsSync(logFile)) return { written: false, count: 0, path: outFile }
|
|
40
|
+
const records = parseRecords(readFileSync(logFile, 'utf8'))
|
|
41
|
+
mkdirSync(join(root, '.ai'), { recursive: true })
|
|
42
|
+
const result = writeAllRenders(root, records, now, projectName)
|
|
43
|
+
return { written: true, count: records.length, ...result }
|
|
30
44
|
}
|
|
31
45
|
|
|
32
|
-
|
|
46
|
+
// Keep the old `renderTasks` export for test compatibility (deprecated).
|
|
33
47
|
export function renderTasks(records, now) {
|
|
34
48
|
const rows = records.map((r) => ({
|
|
35
49
|
ts: String(r.ts ?? ''),
|
|
36
50
|
action: String(r.action ?? ''),
|
|
37
51
|
status: String(r.status ?? ''),
|
|
38
|
-
summary:
|
|
52
|
+
summary: String(r.summary ?? '').replace(/\|/g, '\\|').replace(/\n/g, ' '),
|
|
39
53
|
id: String(r.id ?? ''),
|
|
40
54
|
}))
|
|
41
55
|
const lines = [
|
|
@@ -53,18 +67,4 @@ export function renderTasks(records, now) {
|
|
|
53
67
|
}
|
|
54
68
|
if (rows.length === 0) lines.push('| (暂无记录) | | | | |')
|
|
55
69
|
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
|
-
}
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ai-collab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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) 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
|
}
|