@namewta/speculo 0.7.0 → 0.7.2
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/README.md +9 -6
- package/dist/src/cli.js +12 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +56 -58
- package/dist/src/index.js.map +1 -1
- package/dist/src/migrations.d.ts +23 -0
- package/dist/src/migrations.js +470 -0
- package/dist/src/migrations.js.map +1 -0
- package/package.json +2 -2
- package/template/.speculo/README.md +13 -6
- package/template/canonical/canonical-specdev-engineering-cognitive-mentor.md +178 -0
- package/template/canonical/canonical-specdev-goal-plan.md +386 -74
- package/template/canonical/canonical-specdev-grill-with-docs.md +178 -0
- package/template/canonical/canonical-specdev-spec.md +178 -0
- package/template/canonical/canonical-specdev-tickets.md +247 -21
- package/template/canonical/canonical-specdev-wayfinder.md +178 -0
- package/template/commands/migrate-runtime-state.md +43 -0
- package/template/skills/github-npm-ops/references/preflight-checklist.md +1 -1
- package/template/skills/migrate-runtime-state/SKILL.md +93 -0
- package/template/skills/migrate-runtime-state/references/migration-contract.md +58 -0
- package/template/skills/migrate-runtime-state/scripts/migrate-runtime-state.mjs +545 -0
- package/template/skills/optimize-codex-config/SKILL.md +81 -0
- package/template/skills/optimize-codex-config/references/configuration-contract.md +103 -0
- package/template/skills/optimize-codex-config/references/troubleshooting.md +79 -0
- package/template/skills/optimize-codex-config/scripts/audit-codex-config.mjs +747 -0
- package/template/workflows/specdev/I-implement/I-implement.md +11 -10
- package/template/workflows/specdev/I-implement/delegated-evidence-template.md +2 -1
- package/template/workflows/specdev/I-implement/execution-preflight.md +5 -3
- package/template/workflows/specdev/I-implement/merge-conflict-protocol.md +6 -5
- package/template/workflows/specdev/I-init-setup/I-init-setup.md +1 -1
- package/template/workflows/specdev/INDEX.md +13 -9
- package/template/workflows/specdev/P-goal-plan/P-goal-plan.md +27 -18
- package/template/workflows/specdev/P-goal-plan/completion-control.md +3 -3
- package/template/workflows/specdev/P-goal-plan/delegated-execution-template.md +6 -4
- package/template/workflows/specdev/P-goal-plan/delegated-execution.md +13 -7
- package/template/workflows/specdev/P-goal-plan/goal-plan-template.md +11 -2
- package/template/workflows/specdev/P-goal-plan/orchestration-protocol.md +7 -3
- package/template/workflows/specdev/P-goal-plan/planning-modes.md +23 -8
- package/template/workflows/specdev/P-goal-plan/workspace-execution-template.md +24 -0
- package/template/workflows/specdev/common/README.md +2 -2
- package/template/workflows/specdev/common/rules/change-completion.md +3 -2
- package/template/workflows/specdev/common/rules/path-ownership.md +2 -2
- package/template/workflows/specdev/common/schemas/change-status.schema.json +178 -0
- package/template/workflows/specdev/common/schemas/goal-plan.schema.json +10 -0
- package/template/workflows/specdev/common/skills/dev-worktree/SKILL.md +11 -11
- package/template/workflows/specdev/common/skills/dev-worktree/references/create.md +19 -4
- package/template/workflows/specdev/common/skills/dev-worktree/references/finalize.md +12 -5
- package/template/workflows/specdev/common/skills/subagent-delivery/SKILL.md +4 -3
- package/template/workflows/specdev/common/skills/subagent-delivery/references/external-web-subagent.md +1 -1
- package/template/workflows/specdev/common/skills/subagent-delivery/references/native-subagent.md +2 -3
- package/template/workflows/specdev/common/tools/validate-specdev.mjs +218 -5
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migrate-runtime-state
|
|
3
|
+
description: 迁移 Speculo pending 运行时状态;当 migrate-runtime-state command 需要盘点 back、修复配置或原子恢复 workflow/command 持久项时使用。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Migrate Runtime State
|
|
7
|
+
|
|
8
|
+
以**对账**为主导词:当前模板合同是目标,`back/` 是不可变来源,active runtime 是可能已产生新内容的目标。每个源文件必须得到唯一处置,不按目录整包盲目覆盖。
|
|
9
|
+
|
|
10
|
+
## 输入
|
|
11
|
+
|
|
12
|
+
调用方必须提供:
|
|
13
|
+
|
|
14
|
+
- 已解析的 project、Speculo、state 和 backup roots;
|
|
15
|
+
- pending marker 与 backup manifest;
|
|
16
|
+
- 允许写入的配置和 runtime state 边界;
|
|
17
|
+
- `dry-run | confirmed` 模式和 command 报告 owner;
|
|
18
|
+
- 用户对冲突、替换和删除的逐项决定。
|
|
19
|
+
|
|
20
|
+
缺少任一输入时返回 blocked,不自行推断 command 报告目录或扩大写入范围。
|
|
21
|
+
|
|
22
|
+
## 过程
|
|
23
|
+
|
|
24
|
+
### 1. 验证迁移现场
|
|
25
|
+
|
|
26
|
+
运行:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
node scripts/migrate-runtime-state.mjs inspect --project-root <project-root>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
核对输出中的 pending marker、源/目标版本、backup manifest 和每个文件 hash。读取所有已安装 workflow 的 INDEX、当前 schema、状态种子与 command state 合同。若 hash 不一致、存在符号链接、pending marker 缺失或另一个 staging/rollback 目录仍存在,停止。
|
|
33
|
+
|
|
34
|
+
**完成标准**:来源未变、roots 唯一、所有动态路径有 owner,backup 中每个条目均已枚举。
|
|
35
|
+
|
|
36
|
+
### 2. 建立逐项对账
|
|
37
|
+
|
|
38
|
+
读取 [`references/migration-contract.md`](references/migration-contract.md),为 manifest 中每个条目选择唯一动作。配置按字段合并;状态索引必须与真实 change/archive 目录重建一致;永久知识、sidecar、command cursor 和报告按 owner 恢复;未知项保持 `unresolved`,不得静默删除。
|
|
39
|
+
|
|
40
|
+
同时读取 active 目标。源和目标都发生变化时比较内容与 owner,不以 backup 或新骨架的时间先后自动决定覆盖。
|
|
41
|
+
|
|
42
|
+
**完成标准**:每个 backup 条目和每个将被覆盖/删除的 active 条目都有动作、理由、目标、风险、验证和用户决定;`unresolved` 为零才可执行。
|
|
43
|
+
|
|
44
|
+
### 3. 生成确定性计划
|
|
45
|
+
|
|
46
|
+
生成 schema v1 JSON plan。`backup_manifest_sha256` 锁定 inspect 现场;`source_decisions` 必须逐项覆盖 manifest 中的每个文件且不得包含 `unresolved`;`actions` 仅使用脚本支持的动作:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"schema_version": 1,
|
|
51
|
+
"backup_manifest_sha256": "<inspect 返回的 sha256>",
|
|
52
|
+
"source_decisions": [
|
|
53
|
+
{"path": "config.json", "disposition": "merge-json", "target": "config.json"},
|
|
54
|
+
{"path": "state/workspace.json", "disposition": "keep-current", "target": ".speculo/workspace.json"}
|
|
55
|
+
],
|
|
56
|
+
"actions": [
|
|
57
|
+
{"kind": "copy", "from": "state/specdev/context", "to": ".speculo/specdev/context", "expected_target": "absent"},
|
|
58
|
+
{"kind": "replace-json", "to": ".speculo/specdev/status.json", "value": {}, "expected_target": "file:<sha256>"},
|
|
59
|
+
{"kind": "keep-current", "to": "config.json", "expected_target": "file:<sha256>"}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`from` 必须相对 backup root;`to` 只能是 `config.json` 或 `.speculo/` 内非受保护路径。每个 action 都使用 `fingerprint` 输出锁定 `expected_target`;目标相互重叠时拆成不重叠动作。Plan 写入调用方声明的临时位置,报告保存等价 Markdown 表格;正式 state 不保存第二份 plan。
|
|
65
|
+
|
|
66
|
+
**完成标准**:计划可由脚本解析,路径均在授权边界内,受管理静态资产和 `back/` 不会成为目标。
|
|
67
|
+
|
|
68
|
+
### 4. Dry-run 门
|
|
69
|
+
|
|
70
|
+
默认在计划报告完成后停止。向调用方返回文件总数、各动作数量、冲突、阻塞、目标漂移 hash 和验证清单。未取得对当前完整计划的明确确认时,不调用 apply。
|
|
71
|
+
|
|
72
|
+
**完成标准**:除 command 报告外没有持久写入;用户看到全部覆盖、替换和删除动作。
|
|
73
|
+
|
|
74
|
+
### 5. 原子执行
|
|
75
|
+
|
|
76
|
+
仅在 `confirmed` 模式运行:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
node scripts/migrate-runtime-state.mjs apply \
|
|
80
|
+
--project-root <project-root> \
|
|
81
|
+
--plan <temporary-plan.json> \
|
|
82
|
+
--confirmed
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
脚本重验来源和目标后,在项目根的临时 staging 中构建完整 Speculo 安装,执行计划、验证 JSON 与核心状态合同、清除 staged pending marker,再通过 rename 替换 active `speculo/`。失败时恢复原 active 安装;backup 始终保留。
|
|
86
|
+
|
|
87
|
+
**完成标准**:脚本退出 0,active 目标已重读,pending marker 不存在,backup manifest hash 未变,无 staging/rollback 残留。
|
|
88
|
+
|
|
89
|
+
### 6. 返回审计结果
|
|
90
|
+
|
|
91
|
+
返回调用方:执行模式、源/目标版本、动作结果、验证、rollback 状态、backup 路径、未迁移项和残余风险。调用方把结果追加到原 command 报告。
|
|
92
|
+
|
|
93
|
+
**完成标准**:报告能够从 backup、plan 摘要和 active 结果重建迁移;失败不伪装成部分成功。
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Runtime migration contract
|
|
2
|
+
|
|
3
|
+
## 权威顺序
|
|
4
|
+
|
|
5
|
+
1. 当前模板中的 workspace、workflow INDEX、schema 和 `_state` 种子决定目标结构。
|
|
6
|
+
2. `back/` 保存刷新前事实,始终只读。
|
|
7
|
+
3. active runtime 中 pending 后产生的合法用户内容不能被静默覆盖。
|
|
8
|
+
4. 用户对真实冲突的当前明确决定优先,但不能授权路径逃逸、损坏 backup 或伪造 schema 成功。
|
|
9
|
+
|
|
10
|
+
## 动作选择
|
|
11
|
+
|
|
12
|
+
| 情况 | 动作 |
|
|
13
|
+
|---|---|
|
|
14
|
+
| backup 有、active 无、owner 仍存在 | `copy` |
|
|
15
|
+
| JSON schema 相同且只缺新默认字段 | `replace-json`,值为递归合并结果,旧用户值优先 |
|
|
16
|
+
| 状态 schema 可从目录事实确定性重建 | `replace-json`,报告逐字段来源 |
|
|
17
|
+
| active 是当前模板管理的 workspace/install metadata | `keep-current` |
|
|
18
|
+
| backup 与 active 内容相同 | `keep-current` |
|
|
19
|
+
| active 在 pending 后有新内容 | 比较后由用户选择 `keep-current`、`copy` 或 `replace-json` |
|
|
20
|
+
| owner 已删除但内容有历史价值 | 保持 `unresolved`,由用户选择归档目标;不得放入虚构 namespace |
|
|
21
|
+
| 文件损坏且无法从其他权威事实重建 | 保持 `unresolved` |
|
|
22
|
+
|
|
23
|
+
## SpecDev 对账
|
|
24
|
+
|
|
25
|
+
- 全局状态只恢复当前 schema 允许的字段。
|
|
26
|
+
- `active` 从仍位于 `changes/` 且 change 状态为 active/blocked/completed 的真实目录核对;不得创建虚假 change。
|
|
27
|
+
- `archived` 从 `archive/YYYY-MM/<change>/` 核对,active/archived 不得重叠。
|
|
28
|
+
- `config.json` 保留语言、Git、执行、验证与规划偏好,并补入当前 schema 的必需默认值。
|
|
29
|
+
- `.config/`、`adr/`、`context/`、`research/`、`changes/`、`archive/` 和声明的 sidecar 都是持久项。
|
|
30
|
+
- Command Markdown 报告和具有当前 owner 的 `state.json` 均迁移;未知 command state 保持 unresolved。
|
|
31
|
+
|
|
32
|
+
## 路径边界
|
|
33
|
+
|
|
34
|
+
允许目标:
|
|
35
|
+
|
|
36
|
+
- `config.json`
|
|
37
|
+
- `.speculo/commands/**`
|
|
38
|
+
- `.speculo/<installed-workflow>/**`
|
|
39
|
+
|
|
40
|
+
受保护目标:
|
|
41
|
+
|
|
42
|
+
- `.speculo/back/**`
|
|
43
|
+
- `.speculo/workspace.json`
|
|
44
|
+
- `.speculo/install.json`
|
|
45
|
+
- `.speculo/migration.json`(只由脚本在验证成功后清除)
|
|
46
|
+
- `commands/**`、`skills/**`、`workflows/**` 静态资产
|
|
47
|
+
|
|
48
|
+
所有路径必须使用 POSIX 相对路径,不得包含空段、`.`、`..`、绝对路径或符号链接逃逸。
|
|
49
|
+
|
|
50
|
+
## 验证
|
|
51
|
+
|
|
52
|
+
- backup manifest 的每个 file hash、size 和 symlink 条目与现场一致;存在 symlink 时阻塞。
|
|
53
|
+
- plan 的 `backup_manifest_sha256` 与现场一致,`source_decisions` 恰好覆盖 manifest 全部条目,且每个 action 的 `expected_target` 与 active 现场一致。
|
|
54
|
+
- 所有迁移后 JSON 可解析。
|
|
55
|
+
- workspace、install manifest、项目配置和已安装 workflow 全局状态满足当前版本。
|
|
56
|
+
- SpecDev active/archive 索引与目录一致;person 状态满足 schema v1。
|
|
57
|
+
- pending marker 只在全部验证通过后从 staged 安装删除。
|
|
58
|
+
- 执行后 backup manifest 与内容 hash 不变。
|