atlas-project-harness 0.3.0-beta.3 → 0.3.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/_support/__pycache__/ac_coverage.cpython-312.pyc +0 -0
- package/_support/__pycache__/ac_crosswalk.cpython-312.pyc +0 -0
- package/_support/__pycache__/auth_state.cpython-312.pyc +0 -0
- package/_support/__pycache__/case_block.cpython-312.pyc +0 -0
- package/_support/__pycache__/case_id.cpython-312.pyc +0 -0
- package/_support/__pycache__/evidence_archive.cpython-312.pyc +0 -0
- package/_support/__pycache__/layout.cpython-312.pyc +0 -0
- package/_support/__pycache__/manual_block.cpython-312.pyc +0 -0
- package/_support/__pycache__/pw_runner.cpython-312.pyc +0 -0
- package/_support/__pycache__/review_policy.cpython-312.pyc +0 -0
- package/_support/__pycache__/review_scope_core.cpython-312.pyc +0 -0
- package/_support/__pycache__/run_workspace.cpython-312.pyc +0 -0
- package/_support/__pycache__/semver.cpython-312.pyc +0 -0
- package/_support/__pycache__/siblings.cpython-312.pyc +0 -0
- package/_support/__pycache__/solution.cpython-312.pyc +0 -0
- package/_support/__pycache__/solution_e2e.cpython-312.pyc +0 -0
- package/_support/__pycache__/solution_seal.cpython-312.pyc +0 -0
- package/_support/__pycache__/solution_seal_ops.cpython-312.pyc +0 -0
- package/_support/__pycache__/solution_task.cpython-312.pyc +0 -0
- package/_support/__pycache__/stack_profile.cpython-312.pyc +0 -0
- package/_support/__pycache__/url_merge.cpython-312.pyc +0 -0
- package/_support/solution.py +25 -197
- package/_support/solution_seal_ops.py +215 -0
- package/adapters/__pycache__/_graph.cpython-312.pyc +0 -0
- package/adapters/__pycache__/_jpa.cpython-312.pyc +0 -0
- package/adapters/__pycache__/_lib.cpython-312.pyc +0 -0
- package/adapters/ac/__pycache__/__init__.cpython-312.pyc +0 -0
- package/adapters/ac/__pycache__/command.cpython-312.pyc +0 -0
- package/adapters/ac/__pycache__/js.cpython-312.pyc +0 -0
- package/adapters/ac/__pycache__/junit.cpython-312.pyc +0 -0
- package/adapters/ac/__pycache__/pytest.cpython-312.pyc +0 -0
- package/bin/atlas.js +79 -4
- package/extensions/pi.ts +76 -13
- package/package.json +1 -1
- package/patches/project-wiring/__pycache__/apply-wiring.cpython-312.pyc +0 -0
- package/scripts/__pycache__/ablation.cpython-312.pyc +0 -0
- package/scripts/__pycache__/atlas_check.cpython-312.pyc +0 -0
- package/scripts/__pycache__/atlas_report.cpython-312.pyc +0 -0
- package/scripts/__pycache__/atlas_review.cpython-312.pyc +0 -0
- package/scripts/__pycache__/atlas_solution.cpython-312.pyc +0 -0
- package/scripts/__pycache__/backflow.cpython-312.pyc +0 -0
- package/scripts/__pycache__/changelog_guard.cpython-312.pyc +0 -0
- package/scripts/__pycache__/closeout_derive.cpython-312.pyc +0 -0
- package/scripts/__pycache__/e2e_console.cpython-312.pyc +0 -0
- package/scripts/__pycache__/gen_e2e_scripts.cpython-312.pyc +0 -0
- package/scripts/__pycache__/gen_fixture_schemas.cpython-312.pyc +0 -0
- package/scripts/__pycache__/gen_testid_stub.cpython-312.pyc +0 -0
- package/scripts/__pycache__/ledger_snapshot.cpython-312.pyc +0 -0
- package/scripts/__pycache__/make_review_inputs.cpython-312.pyc +0 -0
- package/scripts/__pycache__/mutation_proof.cpython-312.pyc +0 -0
- package/scripts/__pycache__/pkg_digest.cpython-312.pyc +0 -0
- package/scripts/__pycache__/preflight.cpython-312.pyc +0 -0
- package/scripts/__pycache__/refresh_structure.cpython-312.pyc +0 -0
- package/scripts/__pycache__/release.cpython-312.pyc +0 -0
- package/scripts/__pycache__/validate_review_report.cpython-312.pyc +0 -0
- package/scripts/__pycache__/write_claim.cpython-312.pyc +0 -0
- package/shared/gates.md +1 -1
- package/shared/global-rules.md +1 -1
- package/validators/__pycache__/validate_ac_alignment.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_adr.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_apply_record.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_design_exemptions.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_e2e_index.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_e2e_mocks.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_prd.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_stack_profile.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_structure.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_task_card.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_testids.cpython-312.pyc +0 -0
- package/validators/__pycache__/validate_walkthrough.cpython-312.pyc +0 -0
- package/scripts/__pycache__/atlas_verify.cpython-312.pyc +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [v0.3.0-beta.5] - 2026-11-19
|
|
8
|
+
|
|
9
|
+
### 🛡 Pi 宿主扩展:turn_end 门禁告警按失败签名去重
|
|
10
|
+
|
|
11
|
+
* 项目里存在历史遗留的门禁失败时,`turn_end` 原先裸看退出码,每个带工具调用的回合都复读同一句「可能触发门禁异常」,真新增反而被淹没(issue #67)。现在消费 `atlas_check.py --fast --json` 的失败集,以 sha256(门名+退出码+详情) 为签名,与 `.atlas/runs/pi-turn-failures.json` 基线差分:只有新增/变化的失败才告警(点名新红门),同一失败复读静默;首轮静默建基线(升级后第一轮不提示历史失败);失败集合收缩也回写基线,修复后复发能再提醒一次;`--json` 输出不可解析时静默且不动基线,执行异常不伪装成门禁回归。执行级判据挂假宿主真扩展跑通 issue 全部六场景 + 升级路径。
|
|
12
|
+
|
|
13
|
+
## [v0.3.0-beta.4] - 2026-11-17
|
|
14
|
+
|
|
15
|
+
### 🧭 `atlas upgrade` 跟着运行路径装,不再诱导 sudo
|
|
16
|
+
|
|
17
|
+
* 机器上有两份安装时(例如用户 prefix `~/n` 与系统 `/usr/local`),`upgrade` 原先固定按 npm 默认 prefix 安装,撞上 root 所有的目录报 EACCES,并建议 `sudo npm install -g`。现在优先升级**正在运行的那份**(按它所在的 prefix 传 `--prefix`);检测到默认 prefix 不一致时打印两份路径、标明哪份生效,只动正在运行的那份;目标不可写时给出非 sudo 处置(用户级 prefix / nvm/fnm / install.sh)。源码树运行时明确提示会按 npm 默认 prefix 新增一份。
|
|
18
|
+
|
|
7
19
|
## [v0.3.0-beta.3] - 2026-11-17
|
|
8
20
|
|
|
9
21
|
### 🛡 清单版本门:0.3.0 预发布不再被误判成旧读者
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Atlas — 践行 Project Harness 的全流程 AI 编程工作流
|
|
2
2
|
|
|
3
3
|
<p align="left">
|
|
4
|
-
<img src="https://img.shields.io/badge/version-0.3.0--beta.
|
|
4
|
+
<img src="https://img.shields.io/badge/version-0.3.0--beta.5-blue.svg" alt="Version" />
|
|
5
5
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License" />
|
|
6
6
|
<img src="https://img.shields.io/badge/tests-passing-success.svg" alt="Tests" />
|
|
7
7
|
<a href="https://sunwenzhe-git.github.io/atlas/"><img src="https://img.shields.io/badge/docs-VitePress-green.svg" alt="Docs" /></a>
|
|
@@ -194,7 +194,7 @@ atlas init --assets-root docs
|
|
|
194
194
|
5. *(pi 宿主专有)* 落地 `/atlas` 控制台扩展——`/atlas status` 会报**开户态**(「装配 ≠ 开户」),未开户时直接告诉你去跑 `adopt`。非 pi 项目不创建 `.pi/`。
|
|
195
195
|
|
|
196
196
|
> 🔄 **升级与更新**:
|
|
197
|
-
> - **全局 CLI 自身升级**:运行 `atlas upgrade
|
|
197
|
+
> - **全局 CLI 自身升级**:运行 `atlas upgrade`(升级**当前正在运行的那份**安装:按它所在的 npm prefix 安装,不会去改系统目录里的另一份;检测到两份时会打印两边路径与生效那份,目标不可写会退出并给非 sudo 处置。支持 `--tag beta` 或 `--dry-run`)。
|
|
198
198
|
> - **项目内工程线束刷新**:在项目目录下运行 `atlas update`(安全刷新 `.atlas/` 资产与平台 Skills 瘦桩,版本戳对账更新,业务配置严格保护不覆盖)。
|
|
199
199
|
|
|
200
200
|
### 3. 核对技术栈画像 (`stack-profile.yaml`,默认在 `product/`)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/_support/solution.py
CHANGED
|
@@ -28,7 +28,7 @@ CI 按锁还原由流水线自行 clone + checkout 承担(见 `shared/solution
|
|
|
28
28
|
§7 status status / 锁成员与 acceptance_cutover 检查
|
|
29
29
|
§8 B-0 ⓪ 层错误类型 / path_at / 历史前缀纯函数
|
|
30
30
|
§9 D 批 check_solution / AC crosswalk / 契约检查
|
|
31
|
-
§10 封条写侧 select_seal_path / freeze_seal / render_
|
|
31
|
+
§10 封条写侧 已迁出 `solution_seal_ops.py`(select_seal_path / freeze_seal / render_*,本文件只做注入装配)
|
|
32
32
|
"""
|
|
33
33
|
from __future__ import annotations
|
|
34
34
|
|
|
@@ -3815,202 +3815,30 @@ def has_apply_seal(root: Path) -> bool:
|
|
|
3815
3815
|
return any(base.rglob("*.seal.json"))
|
|
3816
3816
|
|
|
3817
3817
|
|
|
3818
|
-
# ----------------------------------------------------------------
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
def _write_lock_doc(root: Path, doc: dict) -> Path:
|
|
3835
|
-
path = lock_path(root)
|
|
3836
|
-
tmp = path.with_suffix(path.suffix + ".tmp")
|
|
3837
|
-
tmp.write_text(json.dumps(doc, ensure_ascii=False, indent=2) + "\n",
|
|
3838
|
-
encoding="utf-8")
|
|
3839
|
-
tmp.replace(path)
|
|
3840
|
-
return path
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
def freeze_seal(root: Path, seal_path: str, at: str) -> dict:
|
|
3844
|
-
"""`seal freeze`:只写锁的 `state` / `frozen_at`,不碰封条字节(S-38)。"""
|
|
3845
|
-
path = select_seal_path(root, seal_path)
|
|
3846
|
-
if not _SEAL.is_seal_path(path):
|
|
3847
|
-
raise SolutionError(f"--seal 不是合法封条路径: {path}")
|
|
3848
|
-
if _SEAL.head_blob(root, path) is None:
|
|
3849
|
-
raise SolutionError(f"HEAD 无封条文件: {path}")
|
|
3850
|
-
hist = _SEAL.seal_history(root, path)
|
|
3851
|
-
if hist["error"] or at not in hist["commits"]:
|
|
3852
|
-
raise SolutionError(f"--at={at} 不是 {path} 的封条提交")
|
|
3853
|
-
if at != hist["commits"][-1]:
|
|
3854
|
-
raise SolutionError(
|
|
3855
|
-
f"--at 必须是该路径最后一枚封条提交 L[-1]={hist['commits'][-1]}")
|
|
3856
|
-
lock = read_lock(root)
|
|
3857
|
-
if lock is None:
|
|
3858
|
-
raise SolutionError(f"缺少 {LOCK_NAME};先 lock --update")
|
|
3859
|
-
anchors = lock.get("seal_anchors")
|
|
3860
|
-
if not isinstance(anchors, dict) or path not in anchors:
|
|
3861
|
-
raise SolutionError(f"锁内没有该路径键(先 lock --update): {path}")
|
|
3862
|
-
anchor = dict(anchors[path])
|
|
3863
|
-
anchor["state"] = "frozen"
|
|
3864
|
-
anchor["frozen_at"] = at
|
|
3865
|
-
anchors[path] = anchor
|
|
3866
|
-
lock["seal_anchors"] = anchors
|
|
3867
|
-
_write_lock_doc(root, lock)
|
|
3868
|
-
return {"seal": path, "state": "frozen", "frozen_at": at}
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
def reanchor_seal(root: Path, seal_path: str, review: str, from_a: str) -> dict:
|
|
3872
|
-
"""`seal reanchor`:重写纪元起点 + 同步 `exemption_started_at` + append 审计项。"""
|
|
3873
|
-
cause, detail = _SEAL.repo_shape(root)
|
|
3874
|
-
if cause:
|
|
3875
|
-
raise SolutionError(f"拒绝 reanchor:{detail}({cause})")
|
|
3876
|
-
path = select_seal_path(root, seal_path)
|
|
3877
|
-
if not _SEAL.is_seal_path(path):
|
|
3878
|
-
raise SolutionError(f"--seal 不是合法封条路径: {path}")
|
|
3879
|
-
raw = _SEAL.head_blob(root, path)
|
|
3880
|
-
if raw is None:
|
|
3881
|
-
raise SolutionError(f"HEAD 无封条文件: {path}")
|
|
3882
|
-
try:
|
|
3883
|
-
head_doc = _SEAL.parse_seal(raw)
|
|
3884
|
-
except _SEAL.SealError as exc:
|
|
3885
|
-
raise SolutionError(str(exc)) from exc
|
|
3886
|
-
if not re.fullmatch(r"[0-9a-f]{40}", str(from_a or "")):
|
|
3887
|
-
raise SolutionError(f"--from-a 必须是 40 位提交 SHA: {from_a!r}")
|
|
3888
|
-
if _SEAL._has_object(root, from_a):
|
|
3889
|
-
raise SolutionError(
|
|
3890
|
-
f"reanchor_not_allowed: from_a={from_a[:12]} 仍可达;"
|
|
3891
|
-
"唯一可用路径是在未拉过旧历史的 fresh clone 上执行")
|
|
3892
|
-
lock = read_lock(root)
|
|
3893
|
-
if lock is None:
|
|
3894
|
-
raise SolutionError(f"缺少 {LOCK_NAME};先 lock --update")
|
|
3895
|
-
anchors = lock.get("seal_anchors")
|
|
3896
|
-
if not isinstance(anchors, dict) or path not in anchors:
|
|
3897
|
-
raise SolutionError(f"reanchor_anchor_missing: 锁内没有该路径键 {path}")
|
|
3898
|
-
anchor = dict(anchors[path])
|
|
3899
|
-
# v49/项 1:`moved_to` 与 `reanchor` 互斥——键已 `retired`(带 `moved_to`)或
|
|
3900
|
-
# 封条本身带 `moved_to` 时,写侧拒绝、exit 2、不写任何文件。
|
|
3901
|
-
if "moved_to" in anchor or "moved_to" in head_doc:
|
|
3902
|
-
raise SolutionError(
|
|
3903
|
-
"seal_move_reanchor_conflict: 该键 / 封条已带 moved_to(retired),"
|
|
3904
|
-
"不得再写 reanchor")
|
|
3905
|
-
hist = _SEAL.seal_history(root, path)
|
|
3906
|
-
N = hist["N"]
|
|
3907
|
-
if anchor.get("renewal_seq") != head_doc.get("renewal_seq") \
|
|
3908
|
-
or anchor.get("n") != N:
|
|
3909
|
-
raise SolutionError(
|
|
3910
|
-
"seal_anchor_stale: 锁锚与 HEAD 封条 / N 不同步;先 lock --update")
|
|
3911
|
-
if anchor.get("epoch_origin") != from_a:
|
|
3912
|
-
raise SolutionError(
|
|
3913
|
-
"reanchor_anchor_mismatch: from_a != seal_anchors[S].epoch_origin")
|
|
3914
|
-
try:
|
|
3915
|
-
payload = _SEAL.reanchor_payload(head_doc, from_a=from_a, review=review)
|
|
3916
|
-
except _SEAL.SealError as exc:
|
|
3917
|
-
raise SolutionError(str(exc)) from exc
|
|
3918
|
-
payload["reanchor"]["base_seq"] = int(anchor.get("renewal_seq") or 0) + 1
|
|
3919
|
-
payload["reanchor"]["base_n"] = int(anchor.get("n") or 0)
|
|
3920
|
-
# 先验后写:审计链必须可从当前 origin 接续
|
|
3921
|
-
chain = list(anchor.get("exemption_start_history") or [])
|
|
3922
|
-
origin = anchor.get("exemption_start_origin")
|
|
3923
|
-
old_started = anchor.get("exemption_started_at")
|
|
3924
|
-
if chain:
|
|
3925
|
-
if chain[-1].get("to") != old_started:
|
|
3926
|
-
raise SolutionError(
|
|
3927
|
-
"exemption_start_history_broken: 末项 to 与 exemption_started_at 不等")
|
|
3928
|
-
prev_to = chain[-1].get("to")
|
|
3929
|
-
else:
|
|
3930
|
-
if origin != old_started:
|
|
3931
|
-
raise SolutionError(
|
|
3932
|
-
"exemption_start_history_broken: 无重指时 origin 必须等于 started_at")
|
|
3933
|
-
prev_to = origin
|
|
3934
|
-
target = Path(root) / path
|
|
3935
|
-
target.parent.mkdir(parents=True, exist_ok=True)
|
|
3936
|
-
target.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
|
|
3937
|
-
encoding="utf-8")
|
|
3938
|
-
new_started = payload["signed_at"]
|
|
3939
|
-
chain.append({"from": prev_to, "to": new_started, "commit": _head(root)})
|
|
3940
|
-
anchor["exemption_started_at"] = new_started
|
|
3941
|
-
anchor["exemption_start_history"] = chain
|
|
3942
|
-
anchor["renewal_seq"] = payload["renewal_seq"]
|
|
3943
|
-
anchors[path] = anchor
|
|
3944
|
-
lock["seal_anchors"] = anchors
|
|
3945
|
-
_write_lock_doc(root, lock)
|
|
3946
|
-
return {"seal": path, "renewal_seq": payload["renewal_seq"],
|
|
3947
|
-
"reanchor": payload["reanchor"],
|
|
3948
|
-
"exemption_started_at": new_started,
|
|
3949
|
-
"next": "提交封条与本锁(reanchor 提交 R),再独立跑 lock --update 并提交 R2"}
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
def render_status(data: dict) -> str:
|
|
3953
|
-
lines = [f"solution: {data['solution']} ({data['mode']})", "members:"]
|
|
3954
|
-
for s in data["members"]:
|
|
3955
|
-
head = (s.get("head") or "—")[:12]
|
|
3956
|
-
dirty_n = s.get("dirty_count")
|
|
3957
|
-
dirty = "clean" if dirty_n == 0 else (f"dirty:{dirty_n}" if dirty_n else "n/a")
|
|
3958
|
-
ignored = "ignored" if s.get("ignored") else "ok"
|
|
3959
|
-
if s.get("head_drift"):
|
|
3960
|
-
drift = "drift"
|
|
3961
|
-
elif s.get("locked_head"):
|
|
3962
|
-
drift = "locked"
|
|
3963
|
-
else:
|
|
3964
|
-
drift = "no-lock"
|
|
3965
|
-
lines.append(
|
|
3966
|
-
f" {s['name']:<16} {s['path']:<20} git={str(s['git']).lower():<5} "
|
|
3967
|
-
f"branch={s.get('branch') or '—':<12} head={head:<12} {dirty:<8} "
|
|
3968
|
-
f"{drift:<7} atlas={'yes' if s['atlas_assets'] else 'no':<3} {ignored}")
|
|
3969
|
-
lines.append(f"lock: {'present' if data['lock']['present'] else 'missing'}"
|
|
3970
|
-
+ (f" ({data['lock']['locked_at']})" if data['lock'].get('locked_at') else ""))
|
|
3971
|
-
return "\n".join(lines)
|
|
3972
|
-
|
|
3818
|
+
# ---------------------------------------------------------------- 封条写侧装配(§10 已迁出)
|
|
3819
|
+
# 2026-11-17 P4/§10:`select_seal_path` / `freeze_seal` / `reanchor_seal` / `render_*`
|
|
3820
|
+
# 无入边,迁到 `solution_seal_ops.py`。它需要的辅助函数仍在本模块,故在本文件定义完成后
|
|
3821
|
+
# 加载并注入依赖(不反向 import,避免环)。模块名带本实例名,避免同一进程内不同加载器
|
|
3822
|
+
# (`_atlas_solution_core` / `_atlas_solution_test`)互相覆盖。
|
|
3823
|
+
def _install_seal_ops():
|
|
3824
|
+
name = f"{__name__}__seal_ops"
|
|
3825
|
+
spec = importlib.util.spec_from_file_location(
|
|
3826
|
+
name, Path(__file__).with_name("solution_seal_ops.py"))
|
|
3827
|
+
mod = importlib.util.module_from_spec(spec)
|
|
3828
|
+
sys.modules[name] = mod
|
|
3829
|
+
spec.loader.exec_module(mod)
|
|
3830
|
+
for dep in ("SolutionError", "_assets_root", "_SEAL", "read_lock", "lock_path",
|
|
3831
|
+
"LOCK_NAME", "_head"):
|
|
3832
|
+
setattr(mod, dep, globals()[dep])
|
|
3833
|
+
return mod
|
|
3973
3834
|
|
|
3974
|
-
def render_check(data: dict) -> str:
|
|
3975
|
-
lines = [f"solution check: {data['overall']}"]
|
|
3976
|
-
for r in data["checks"]:
|
|
3977
|
-
lines.append(f" [{r['status']}] {r['check']}: {r['detail']}")
|
|
3978
|
-
return "\n".join(lines)
|
|
3979
3835
|
|
|
3836
|
+
_SEAL_OPS = _install_seal_ops()
|
|
3980
3837
|
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
lines.append(
|
|
3989
|
-
f" [{m['name']}] {m['path']} branch={m.get('branch') or '—'} "
|
|
3990
|
-
f"head={(m.get('head') or '—')[:12]} locked={locked}")
|
|
3991
|
-
if not m.get("locked_head"):
|
|
3992
|
-
lines.append(" lock=—(未锁定,仅显示工作区)")
|
|
3993
|
-
elif m.get("lock_commit_present") is False:
|
|
3994
|
-
lines.append(" ! 锁中 commit 不在本地;请先 fetch 对应成员")
|
|
3995
|
-
elif m["commits"]:
|
|
3996
|
-
lines.append(f" 自锁以来提交 {len(m['commits'])} 条:")
|
|
3997
|
-
lines += [f" {c}" for c in m["commits"]]
|
|
3998
|
-
if m["diffstat"]:
|
|
3999
|
-
lines.append(" 自锁以来 diffstat:")
|
|
4000
|
-
lines += [f" {c}" for c in m["diffstat"]]
|
|
4001
|
-
if m["staged"]:
|
|
4002
|
-
lines.append(" 已暂存:")
|
|
4003
|
-
lines += [f" {c}" for c in m["staged"]]
|
|
4004
|
-
if m["unstaged"]:
|
|
4005
|
-
lines.append(" 未暂存:")
|
|
4006
|
-
lines += [f" {c}" for c in m["unstaged"]]
|
|
4007
|
-
if m["worktree"]:
|
|
4008
|
-
lines.append(f" 工作区 {len(m['worktree'])} 项:")
|
|
4009
|
-
lines += [f" {c}" for c in m["worktree"][:30]]
|
|
4010
|
-
if len(m["worktree"]) > 30:
|
|
4011
|
-
lines.append(f" …(其余 {len(m['worktree']) - 30} 项省略)")
|
|
4012
|
-
if m.get("worktree_ok") is False:
|
|
4013
|
-
lines.append(" ! git status 失败,无法判断工作区")
|
|
4014
|
-
if not any((m["commits"], m["staged"], m["unstaged"], m["worktree"])):
|
|
4015
|
-
lines.append(" clean(相对锁无差异)")
|
|
4016
|
-
return "\n".join(lines)
|
|
3838
|
+
select_seal_path = _SEAL_OPS.select_seal_path
|
|
3839
|
+
_write_lock_doc = _SEAL_OPS._write_lock_doc
|
|
3840
|
+
freeze_seal = _SEAL_OPS.freeze_seal
|
|
3841
|
+
reanchor_seal = _SEAL_OPS.reanchor_seal
|
|
3842
|
+
render_status = _SEAL_OPS.render_status
|
|
3843
|
+
render_check = _SEAL_OPS.render_check
|
|
3844
|
+
render_diff = _SEAL_OPS.render_diff
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""封条写侧(§10,2026-11-17 从 `solution.py` 迁出)。
|
|
2
|
+
|
|
3
|
+
职责:多封条选择、`seal freeze` / `seal reanchor` 的锁写入,以及 status / check / diff
|
|
4
|
+
的文本渲染。对外入口:`select_seal_path` / `freeze_seal` / `reanchor_seal` /
|
|
5
|
+
`render_status` / `render_check` / `render_diff`。
|
|
6
|
+
|
|
7
|
+
依赖由 `solution.py` 在加载后注入(`SolutionError` / `_assets_root` / `_SEAL` /
|
|
8
|
+
`read_lock` / `lock_path` / `LOCK_NAME` / `_head`);本模块**不得反向 import** `solution.py`,
|
|
9
|
+
否则形成环。
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
import re
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def select_seal_path(root: Path, requested: str | None = None) -> str:
|
|
20
|
+
"""多封条选择:`--seal` 显式;否则唯一 HEAD 封条;多枚 ⇒ exit 2 候选。"""
|
|
21
|
+
lock = read_lock(root)
|
|
22
|
+
anchors = (lock or {}).get("seal_anchors")
|
|
23
|
+
by_path = {k: v for k, v in anchors.items()
|
|
24
|
+
if isinstance(v, dict)} if isinstance(anchors, dict) else {}
|
|
25
|
+
asset_root = (lock or {}).get("layout_assets_root") or _assets_root(root)
|
|
26
|
+
heads = _SEAL.head_seals(root, [asset_root])
|
|
27
|
+
try:
|
|
28
|
+
return _SEAL.select_seal(root, by_path, requested, heads)
|
|
29
|
+
except _SEAL.SealError as exc:
|
|
30
|
+
raise SolutionError(str(exc)) from exc
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _write_lock_doc(root: Path, doc: dict) -> Path:
|
|
34
|
+
path = lock_path(root)
|
|
35
|
+
tmp = path.with_suffix(path.suffix + ".tmp")
|
|
36
|
+
tmp.write_text(json.dumps(doc, ensure_ascii=False, indent=2) + "\n",
|
|
37
|
+
encoding="utf-8")
|
|
38
|
+
tmp.replace(path)
|
|
39
|
+
return path
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def freeze_seal(root: Path, seal_path: str, at: str) -> dict:
|
|
43
|
+
"""`seal freeze`:只写锁的 `state` / `frozen_at`,不碰封条字节(S-38)。"""
|
|
44
|
+
path = select_seal_path(root, seal_path)
|
|
45
|
+
if not _SEAL.is_seal_path(path):
|
|
46
|
+
raise SolutionError(f"--seal 不是合法封条路径: {path}")
|
|
47
|
+
if _SEAL.head_blob(root, path) is None:
|
|
48
|
+
raise SolutionError(f"HEAD 无封条文件: {path}")
|
|
49
|
+
hist = _SEAL.seal_history(root, path)
|
|
50
|
+
if hist["error"] or at not in hist["commits"]:
|
|
51
|
+
raise SolutionError(f"--at={at} 不是 {path} 的封条提交")
|
|
52
|
+
if at != hist["commits"][-1]:
|
|
53
|
+
raise SolutionError(
|
|
54
|
+
f"--at 必须是该路径最后一枚封条提交 L[-1]={hist['commits'][-1]}")
|
|
55
|
+
lock = read_lock(root)
|
|
56
|
+
if lock is None:
|
|
57
|
+
raise SolutionError(f"缺少 {LOCK_NAME};先 lock --update")
|
|
58
|
+
anchors = lock.get("seal_anchors")
|
|
59
|
+
if not isinstance(anchors, dict) or path not in anchors:
|
|
60
|
+
raise SolutionError(f"锁内没有该路径键(先 lock --update): {path}")
|
|
61
|
+
anchor = dict(anchors[path])
|
|
62
|
+
anchor["state"] = "frozen"
|
|
63
|
+
anchor["frozen_at"] = at
|
|
64
|
+
anchors[path] = anchor
|
|
65
|
+
lock["seal_anchors"] = anchors
|
|
66
|
+
_write_lock_doc(root, lock)
|
|
67
|
+
return {"seal": path, "state": "frozen", "frozen_at": at}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def reanchor_seal(root: Path, seal_path: str, review: str, from_a: str) -> dict:
|
|
71
|
+
"""`seal reanchor`:重写纪元起点 + 同步 `exemption_started_at` + append 审计项。"""
|
|
72
|
+
cause, detail = _SEAL.repo_shape(root)
|
|
73
|
+
if cause:
|
|
74
|
+
raise SolutionError(f"拒绝 reanchor:{detail}({cause})")
|
|
75
|
+
path = select_seal_path(root, seal_path)
|
|
76
|
+
if not _SEAL.is_seal_path(path):
|
|
77
|
+
raise SolutionError(f"--seal 不是合法封条路径: {path}")
|
|
78
|
+
raw = _SEAL.head_blob(root, path)
|
|
79
|
+
if raw is None:
|
|
80
|
+
raise SolutionError(f"HEAD 无封条文件: {path}")
|
|
81
|
+
try:
|
|
82
|
+
head_doc = _SEAL.parse_seal(raw)
|
|
83
|
+
except _SEAL.SealError as exc:
|
|
84
|
+
raise SolutionError(str(exc)) from exc
|
|
85
|
+
if not re.fullmatch(r"[0-9a-f]{40}", str(from_a or "")):
|
|
86
|
+
raise SolutionError(f"--from-a 必须是 40 位提交 SHA: {from_a!r}")
|
|
87
|
+
if _SEAL._has_object(root, from_a):
|
|
88
|
+
raise SolutionError(
|
|
89
|
+
f"reanchor_not_allowed: from_a={from_a[:12]} 仍可达;"
|
|
90
|
+
"唯一可用路径是在未拉过旧历史的 fresh clone 上执行")
|
|
91
|
+
lock = read_lock(root)
|
|
92
|
+
if lock is None:
|
|
93
|
+
raise SolutionError(f"缺少 {LOCK_NAME};先 lock --update")
|
|
94
|
+
anchors = lock.get("seal_anchors")
|
|
95
|
+
if not isinstance(anchors, dict) or path not in anchors:
|
|
96
|
+
raise SolutionError(f"reanchor_anchor_missing: 锁内没有该路径键 {path}")
|
|
97
|
+
anchor = dict(anchors[path])
|
|
98
|
+
# v49/项 1:`moved_to` 与 `reanchor` 互斥——键已 `retired`(带 `moved_to`)或
|
|
99
|
+
# 封条本身带 `moved_to` 时,写侧拒绝、exit 2、不写任何文件。
|
|
100
|
+
if "moved_to" in anchor or "moved_to" in head_doc:
|
|
101
|
+
raise SolutionError(
|
|
102
|
+
"seal_move_reanchor_conflict: 该键 / 封条已带 moved_to(retired),"
|
|
103
|
+
"不得再写 reanchor")
|
|
104
|
+
hist = _SEAL.seal_history(root, path)
|
|
105
|
+
N = hist["N"]
|
|
106
|
+
if anchor.get("renewal_seq") != head_doc.get("renewal_seq") \
|
|
107
|
+
or anchor.get("n") != N:
|
|
108
|
+
raise SolutionError(
|
|
109
|
+
"seal_anchor_stale: 锁锚与 HEAD 封条 / N 不同步;先 lock --update")
|
|
110
|
+
if anchor.get("epoch_origin") != from_a:
|
|
111
|
+
raise SolutionError(
|
|
112
|
+
"reanchor_anchor_mismatch: from_a != seal_anchors[S].epoch_origin")
|
|
113
|
+
try:
|
|
114
|
+
payload = _SEAL.reanchor_payload(head_doc, from_a=from_a, review=review)
|
|
115
|
+
except _SEAL.SealError as exc:
|
|
116
|
+
raise SolutionError(str(exc)) from exc
|
|
117
|
+
payload["reanchor"]["base_seq"] = int(anchor.get("renewal_seq") or 0) + 1
|
|
118
|
+
payload["reanchor"]["base_n"] = int(anchor.get("n") or 0)
|
|
119
|
+
# 先验后写:审计链必须可从当前 origin 接续
|
|
120
|
+
chain = list(anchor.get("exemption_start_history") or [])
|
|
121
|
+
origin = anchor.get("exemption_start_origin")
|
|
122
|
+
old_started = anchor.get("exemption_started_at")
|
|
123
|
+
if chain:
|
|
124
|
+
if chain[-1].get("to") != old_started:
|
|
125
|
+
raise SolutionError(
|
|
126
|
+
"exemption_start_history_broken: 末项 to 与 exemption_started_at 不等")
|
|
127
|
+
prev_to = chain[-1].get("to")
|
|
128
|
+
else:
|
|
129
|
+
if origin != old_started:
|
|
130
|
+
raise SolutionError(
|
|
131
|
+
"exemption_start_history_broken: 无重指时 origin 必须等于 started_at")
|
|
132
|
+
prev_to = origin
|
|
133
|
+
target = Path(root) / path
|
|
134
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
135
|
+
target.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n",
|
|
136
|
+
encoding="utf-8")
|
|
137
|
+
new_started = payload["signed_at"]
|
|
138
|
+
chain.append({"from": prev_to, "to": new_started, "commit": _head(root)})
|
|
139
|
+
anchor["exemption_started_at"] = new_started
|
|
140
|
+
anchor["exemption_start_history"] = chain
|
|
141
|
+
anchor["renewal_seq"] = payload["renewal_seq"]
|
|
142
|
+
anchors[path] = anchor
|
|
143
|
+
lock["seal_anchors"] = anchors
|
|
144
|
+
_write_lock_doc(root, lock)
|
|
145
|
+
return {"seal": path, "renewal_seq": payload["renewal_seq"],
|
|
146
|
+
"reanchor": payload["reanchor"],
|
|
147
|
+
"exemption_started_at": new_started,
|
|
148
|
+
"next": "提交封条与本锁(reanchor 提交 R),再独立跑 lock --update 并提交 R2"}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def render_status(data: dict) -> str:
|
|
152
|
+
lines = [f"solution: {data['solution']} ({data['mode']})", "members:"]
|
|
153
|
+
for s in data["members"]:
|
|
154
|
+
head = (s.get("head") or "—")[:12]
|
|
155
|
+
dirty_n = s.get("dirty_count")
|
|
156
|
+
dirty = "clean" if dirty_n == 0 else (f"dirty:{dirty_n}" if dirty_n else "n/a")
|
|
157
|
+
ignored = "ignored" if s.get("ignored") else "ok"
|
|
158
|
+
if s.get("head_drift"):
|
|
159
|
+
drift = "drift"
|
|
160
|
+
elif s.get("locked_head"):
|
|
161
|
+
drift = "locked"
|
|
162
|
+
else:
|
|
163
|
+
drift = "no-lock"
|
|
164
|
+
lines.append(
|
|
165
|
+
f" {s['name']:<16} {s['path']:<20} git={str(s['git']).lower():<5} "
|
|
166
|
+
f"branch={s.get('branch') or '—':<12} head={head:<12} {dirty:<8} "
|
|
167
|
+
f"{drift:<7} atlas={'yes' if s['atlas_assets'] else 'no':<3} {ignored}")
|
|
168
|
+
lines.append(f"lock: {'present' if data['lock']['present'] else 'missing'}"
|
|
169
|
+
+ (f" ({data['lock']['locked_at']})" if data['lock'].get('locked_at') else ""))
|
|
170
|
+
return "\n".join(lines)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def render_check(data: dict) -> str:
|
|
174
|
+
lines = [f"solution check: {data['overall']}"]
|
|
175
|
+
for r in data["checks"]:
|
|
176
|
+
lines.append(f" [{r['status']}] {r['check']}: {r['detail']}")
|
|
177
|
+
return "\n".join(lines)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def render_diff(data: dict) -> str:
|
|
181
|
+
lines = [f"solution diff: {data['solution']} ({data['mode']})"]
|
|
182
|
+
for m in data["members"]:
|
|
183
|
+
if not m["git"]:
|
|
184
|
+
lines.append(f" [{m['name']}] {m['path']} ! 不是 git 仓")
|
|
185
|
+
continue
|
|
186
|
+
locked = (m.get("locked_head") or "—")[:12]
|
|
187
|
+
lines.append(
|
|
188
|
+
f" [{m['name']}] {m['path']} branch={m.get('branch') or '—'} "
|
|
189
|
+
f"head={(m.get('head') or '—')[:12]} locked={locked}")
|
|
190
|
+
if not m.get("locked_head"):
|
|
191
|
+
lines.append(" lock=—(未锁定,仅显示工作区)")
|
|
192
|
+
elif m.get("lock_commit_present") is False:
|
|
193
|
+
lines.append(" ! 锁中 commit 不在本地;请先 fetch 对应成员")
|
|
194
|
+
elif m["commits"]:
|
|
195
|
+
lines.append(f" 自锁以来提交 {len(m['commits'])} 条:")
|
|
196
|
+
lines += [f" {c}" for c in m["commits"]]
|
|
197
|
+
if m["diffstat"]:
|
|
198
|
+
lines.append(" 自锁以来 diffstat:")
|
|
199
|
+
lines += [f" {c}" for c in m["diffstat"]]
|
|
200
|
+
if m["staged"]:
|
|
201
|
+
lines.append(" 已暂存:")
|
|
202
|
+
lines += [f" {c}" for c in m["staged"]]
|
|
203
|
+
if m["unstaged"]:
|
|
204
|
+
lines.append(" 未暂存:")
|
|
205
|
+
lines += [f" {c}" for c in m["unstaged"]]
|
|
206
|
+
if m["worktree"]:
|
|
207
|
+
lines.append(f" 工作区 {len(m['worktree'])} 项:")
|
|
208
|
+
lines += [f" {c}" for c in m["worktree"][:30]]
|
|
209
|
+
if len(m["worktree"]) > 30:
|
|
210
|
+
lines.append(f" …(其余 {len(m['worktree']) - 30} 项省略)")
|
|
211
|
+
if m.get("worktree_ok") is False:
|
|
212
|
+
lines.append(" ! git status 失败,无法判断工作区")
|
|
213
|
+
if not any((m["commits"], m["staged"], m["unstaged"], m["worktree"])):
|
|
214
|
+
lines.append(" clean(相对锁无差异)")
|
|
215
|
+
return "\n".join(lines)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/atlas.js
CHANGED
|
@@ -109,6 +109,48 @@ function exitWithResult(res, tool) {
|
|
|
109
109
|
process.exit(typeof res.status === 'number' ? res.status : 1);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* 从正在运行的安装路径反推 npm 全局 prefix。
|
|
114
|
+
* POSIX: `<prefix>/lib/node_modules/<pkg>`;Windows: `<prefix>/node_modules/<pkg>`。
|
|
115
|
+
* 源码树(不在 node_modules 下)返回 null。
|
|
116
|
+
*/
|
|
117
|
+
function installPrefixFrom(pkgRoot) {
|
|
118
|
+
const marker = `${path.sep}node_modules${path.sep}`;
|
|
119
|
+
const idx = pkgRoot.lastIndexOf(marker);
|
|
120
|
+
if (idx < 0) return null;
|
|
121
|
+
const parts = pkgRoot.slice(0, idx).split(path.sep);
|
|
122
|
+
if (parts[parts.length - 1] === 'lib') parts.pop();
|
|
123
|
+
const prefix = parts.join(path.sep);
|
|
124
|
+
return prefix || path.sep;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function npmGlobalPrefix(npmCmd) {
|
|
128
|
+
const res = spawnSync(npmCmd, ['config', 'get', 'prefix'], {
|
|
129
|
+
encoding: 'utf8',
|
|
130
|
+
env: process.env,
|
|
131
|
+
});
|
|
132
|
+
if (res.status !== 0 || !res.stdout) return null;
|
|
133
|
+
const out = res.stdout.trim();
|
|
134
|
+
return out || null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function samePath(a, b) {
|
|
138
|
+
try {
|
|
139
|
+
return fs.realpathSync(a) === fs.realpathSync(b);
|
|
140
|
+
} catch (_) {
|
|
141
|
+
return path.resolve(a) === path.resolve(b);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function isWritableDir(dir) {
|
|
146
|
+
try {
|
|
147
|
+
fs.accessSync(dir, fs.constants.W_OK);
|
|
148
|
+
return true;
|
|
149
|
+
} catch (_) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
112
154
|
switch (command) {
|
|
113
155
|
case 'init': {
|
|
114
156
|
const passthroughArgs = args.slice(1);
|
|
@@ -286,7 +328,8 @@ Atlas upgrade — 自动拉取 npm 最新全局包升级全局 Atlas CLI
|
|
|
286
328
|
-h, --help 查看帮助信息
|
|
287
329
|
|
|
288
330
|
说明:
|
|
289
|
-
atlas upgrade
|
|
331
|
+
atlas upgrade 默认升级"当前正在运行的那份"安装(按它所在的 npm prefix 安装),
|
|
332
|
+
不会因为机器上另有一份全局包就去改系统目录;不会建议或要求 sudo。
|
|
290
333
|
升级成功后,可进入项目目录运行 atlas update 刷新项目内的工程线束与模板。
|
|
291
334
|
`);
|
|
292
335
|
process.exit(0);
|
|
@@ -301,13 +344,44 @@ Atlas upgrade — 自动拉取 npm 最新全局包升级全局 Atlas CLI
|
|
|
301
344
|
|
|
302
345
|
const pkg = require(path.join(PKG_ROOT, 'package.json'));
|
|
303
346
|
const targetPkg = `${pkg.name}@${tag}`;
|
|
347
|
+
const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
348
|
+
|
|
349
|
+
// 目标 prefix 以「正在运行的这份」为准;npm 默认 prefix 只用于诊断,
|
|
350
|
+
// 避免机器上有两份安装时把包装到另一份(常见是 root 所有的 /usr/local)。
|
|
351
|
+
const ownPrefix = installPrefixFrom(PKG_ROOT);
|
|
352
|
+
const npmPrefix = npmGlobalPrefix(npmCmd);
|
|
304
353
|
|
|
305
354
|
console.log(`\n[Atlas Upgrade] 准备升级全局 CLI (${pkg.name})...`);
|
|
306
355
|
console.log(` 当前版本 : v${pkg.version}`);
|
|
307
356
|
console.log(` 目标包 : ${targetPkg}`);
|
|
357
|
+
console.log(` 安装路径 : ${PKG_ROOT}`);
|
|
358
|
+
if (ownPrefix) {
|
|
359
|
+
console.log(` 生效 prefix: ${ownPrefix}`);
|
|
360
|
+
if (npmPrefix && !samePath(npmPrefix, ownPrefix)) {
|
|
361
|
+
console.log(` 注意: npm 默认 prefix 是 ${npmPrefix},与正在运行的这份不一致(可能有两份安装)。`);
|
|
362
|
+
console.log(` 本次只升级正在运行的那份,不动 ${npmPrefix}。`);
|
|
363
|
+
}
|
|
364
|
+
} else {
|
|
365
|
+
console.log(` 注意: 当前运行的是源码树而非 npm 全局安装;将按 npm 默认 prefix`
|
|
366
|
+
+ `${npmPrefix ? `(${npmPrefix})` : ''}安装,可能新增一份。`);
|
|
367
|
+
}
|
|
308
368
|
|
|
309
|
-
const
|
|
310
|
-
|
|
369
|
+
const installArgs = ['install', '-g'];
|
|
370
|
+
if (ownPrefix) {
|
|
371
|
+
const modulesDir = path.dirname(PKG_ROOT);
|
|
372
|
+
if (!isWritableDir(modulesDir)) {
|
|
373
|
+
console.error(`\n[Atlas Upgrade] ❌ 目标目录不可写: ${modulesDir}`);
|
|
374
|
+
console.error(` 不要用 sudo:那会把包装进系统目录,和当前运行的这份形成两份安装。`);
|
|
375
|
+
console.error(` 可选处置:`);
|
|
376
|
+
console.error(` 1) 若用 nvm/fnm 管理 node,重装后直接执行: ${npmCmd} install -g ${targetPkg}`);
|
|
377
|
+
console.error(` 2) 改用用户级 prefix: npm config set prefix ~/.npm-global,`
|
|
378
|
+
+ `并把 ~/.npm-global/bin 加入 PATH 后重装`);
|
|
379
|
+
console.error(` 3) 若这份由 install.sh 安装,改用 install.sh 更新\n`);
|
|
380
|
+
process.exit(2);
|
|
381
|
+
}
|
|
382
|
+
installArgs.push('--prefix', ownPrefix);
|
|
383
|
+
}
|
|
384
|
+
installArgs.push(targetPkg);
|
|
311
385
|
|
|
312
386
|
if (isDryRun) {
|
|
313
387
|
console.log(` [dry-run] 将执行命令: ${npmCmd} ${installArgs.join(' ')}\n`);
|
|
@@ -327,7 +401,8 @@ Atlas upgrade — 自动拉取 npm 最新全局包升级全局 Atlas CLI
|
|
|
327
401
|
} else {
|
|
328
402
|
console.error(`\n[Atlas Upgrade] ❌ 升级失败 (退出码: ${res.status})。`);
|
|
329
403
|
console.error(`常见原因与排查建议:`);
|
|
330
|
-
console.error(` 1. 权限不足:
|
|
404
|
+
console.error(` 1. 权限不足: 不要用 sudo(会装到系统目录、与当前运行的那份并存);`
|
|
405
|
+
+ `改用用户级 prefix(npm config set prefix ~/.npm-global)或 nvm/fnm 后重试`);
|
|
331
406
|
console.error(` 2. 网络或代理问题: 请检查 npm 源或网络代理设置(如 http_proxy)\n`);
|
|
332
407
|
}
|
|
333
408
|
|
package/extensions/pi.ts
CHANGED
|
@@ -14,9 +14,10 @@ import type {
|
|
|
14
14
|
ExtensionCommandContext,
|
|
15
15
|
ExtensionContext,
|
|
16
16
|
} from "@earendil-works/pi-coding-agent";
|
|
17
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
17
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
18
18
|
import { join } from "node:path";
|
|
19
19
|
import { spawnSync } from "node:child_process";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
20
21
|
|
|
21
22
|
const EXTENSION_NAME = "atlasharness";
|
|
22
23
|
|
|
@@ -304,22 +305,84 @@ export default function (pi: ExtensionAPI) {
|
|
|
304
305
|
const checkScript = join(ctx.cwd, ".atlas", "scripts", "atlas_check.py");
|
|
305
306
|
if (!existsSync(checkScript)) return;
|
|
306
307
|
|
|
307
|
-
//
|
|
308
|
+
// 只做轻量校验。失败判据 = **失败签名差分**(issue #67):裸看退出码会把「历史遗留
|
|
309
|
+
// 的 FAIL」在每一轮重复告警,真新增反而被淹没。签名 = sha256(门名+退出码+详情),
|
|
310
|
+
// 基线落 `.atlas/runs/pi-turn-failures.json`(运行态目录,不入库):
|
|
311
|
+
// * 基线缺失/损坏 ⇒ 静默落基线(升级后第一轮不提示历史失败 —— 消噪声的代价);
|
|
312
|
+
// * 当前相对基线**新增/变化** ⇒ 提示(只点名新红的门);
|
|
313
|
+
// * 失败集合不变 ⇒ 静默;集合收缩 ⇒ 静默但回写基线(修复后复发才能再提醒一次);
|
|
314
|
+
// * `--json` 输出不可解析 ⇒ 静默且不动基线(执行异常不得伪装成门禁回归)。
|
|
308
315
|
try {
|
|
309
|
-
const res = await pi.exec(PYTHON, [checkScript, "--root", ctx.cwd, "--fast"], {
|
|
316
|
+
const res = await pi.exec(PYTHON, [checkScript, "--root", ctx.cwd, "--fast", "--json"], {
|
|
310
317
|
timeout: 10_000,
|
|
311
318
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
" 若这道门挡的是合情合理的业务形态(不是你的实现 bug)⇒ 那是流水线缺陷:" +
|
|
318
|
-
"按 `.atlas/shared/global-rules.md` §15 用 `atlas report` 沉淀现场," +
|
|
319
|
-
"别静默豁免 / 注释规则 / `--no-verify`。",
|
|
320
|
-
"warning",
|
|
321
|
-
);
|
|
319
|
+
let payload: any;
|
|
320
|
+
try {
|
|
321
|
+
payload = JSON.parse(res.stdout || "");
|
|
322
|
+
} catch {
|
|
323
|
+
return; // 不可解析 ⇒ 检查本身没跑成,不判失败、不写基线
|
|
322
324
|
}
|
|
325
|
+
if (!Array.isArray(payload?.failures)) return; // 形态不对同上:宁静默,不误报
|
|
326
|
+
|
|
327
|
+
const current = new Map<string, { name: string; code: unknown }>();
|
|
328
|
+
for (const f of payload.failures) {
|
|
329
|
+
const sig = createHash("sha256")
|
|
330
|
+
.update(`${f?.name ?? ""}\n${String(f?.code ?? "")}\n${f?.detail ?? ""}`)
|
|
331
|
+
.digest("hex")
|
|
332
|
+
.slice(0, 16);
|
|
333
|
+
current.set(sig, { name: String(f?.name ?? "未知门"), code: f?.code });
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const baselinePath = join(ctx.cwd, ".atlas", "runs", "pi-turn-failures.json");
|
|
337
|
+
const writeBaseline = () => {
|
|
338
|
+
try {
|
|
339
|
+
mkdirSync(join(ctx.cwd, ".atlas", "runs"), { recursive: true });
|
|
340
|
+
writeFileSync(
|
|
341
|
+
baselinePath,
|
|
342
|
+
JSON.stringify({ v: 1, signatures: Object.fromEntries(current) }, null, 2),
|
|
343
|
+
);
|
|
344
|
+
} catch {
|
|
345
|
+
// 写失败不阻断:最坏结果 = 下一轮重新静默建一次基线
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
let baseline: Map<string, { name: string; code: unknown }> | null = null;
|
|
350
|
+
try {
|
|
351
|
+
const raw = JSON.parse(readFileSync(baselinePath, "utf-8"));
|
|
352
|
+
if (raw && typeof raw === "object" && raw.signatures && typeof raw.signatures === "object") {
|
|
353
|
+
baseline = new Map(Object.entries(raw.signatures));
|
|
354
|
+
}
|
|
355
|
+
} catch {
|
|
356
|
+
baseline = null; // 缺失 / 损坏 ⇒ 视同首次
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (baseline === null) {
|
|
360
|
+
writeBaseline(); // 首轮建基线:静默
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const base = baseline;
|
|
364
|
+
|
|
365
|
+
const fresh = [...current.entries()].filter(([sig]) => !base.has(sig));
|
|
366
|
+
if (fresh.length === 0) {
|
|
367
|
+
const sameSet = base.size === current.size &&
|
|
368
|
+
[...base.keys()].every((sig) => current.has(sig));
|
|
369
|
+
if (!sameSet) writeBaseline(); // 有失败被修掉 ⇒ 回写,复发才能再提醒
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
writeBaseline();
|
|
374
|
+
const shown = fresh.slice(0, 3).map(([, m]) => `「${m.name}」`).join("、");
|
|
375
|
+
const more = fresh.length > 3 ? ` 等 ${fresh.length} 道` : "";
|
|
376
|
+
// 撞门时刻 = `global-rules.md` §15 的交付面之一:门**新增**红的那一刻把「这可能是
|
|
377
|
+
// 流水线缺陷」的出口递到手边 —— 只写在契约正文里时,流程中段等不到任何提醒。
|
|
378
|
+
ctx.ui.notify(
|
|
379
|
+
"⚠️ Atlas 提示:检测到新增/变化的机器门禁失败" + more + ":" + shown +
|
|
380
|
+
",建议使用 `/atlas check` 查看详情。\n" +
|
|
381
|
+
" 与上一轮基线相同的历史失败不再重复提醒。若这道门挡的是合情合理的业务形态(不是你的实现 bug)⇒ " +
|
|
382
|
+
"那是流水线缺陷:按 `.atlas/shared/global-rules.md` §15 用 `atlas report` 沉淀现场," +
|
|
383
|
+
"别静默豁免 / 注释规则 / `--no-verify`。",
|
|
384
|
+
"warning",
|
|
385
|
+
);
|
|
323
386
|
} catch {
|
|
324
387
|
// 容错不阻断
|
|
325
388
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/shared/gates.md
CHANGED
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
|---|---|---|---|---|---|
|
|
94
94
|
| `install.py` 自检(**〔数:自检声明=66〕 条 `c()` 声明**;含 skill 循环;2026-10-23 D143 +`_support/manual_block.py`;2026-10-26 D153 +`_support/ac_coverage.py`;2026-11-04 RFC-20261104-01 S1 +`_support/evidence_archive.py`) | 装配动作 ⇔ 包内件 | `[机器]` 它声称会落下的每个文件是否真的落下 | 包内件**该不该存在**(那是下面那道门);副本侧无 `install.sh` ⇒ 本项不适用 | **新项目开户时**(最晚 = 开户那一刻,否则开户失败) | `出厂级(本轮实测)`:修前空目录装配实测 `exit 1` + 4 条 `[FAIL]`(`3509 §112`;2026-10-05 图谱批 1 复核计数,顺带修复 `$PATCH_DIR` 未定义变量在 `set -u` 下的必炸;2026-10-12 单源批 +4:共享内核 ×3 + 回灌助手;2026-10-15 +1:`extensions/` 纳入装配 ⇒ pi 宿主扩展;2026-10-17 两枚——+`_support/pw_runner.py`(新件,issue #24)**与 +`_support/case_id.py`(存量漏登记的包内件——它一直在装配面上、却不在自检清单里,issue #24 同批顺手补上)**;2026-10-21 D129 +1:`_support/review_policy.py`(审查策略单源内核——**新件即登记**,不重演 `case_id.py` 那种「在装配面上、却不在自检清单里」的漏);同批 +1:`templates/reviews/README.md`(按域审查指引模板——`independent-review.md` §10.5 已引用它,引用面必须随包在);2026-11-03 +1:`scripts/run_python.js`(钩子平台中立启动器,RFC-20261103-04 §6)) |
|
|
95
95
|
| `tests/test_install_selfcheck.py` | 装配面 ⇔ 包面 ⇔ 契约面 | `[机器]` ① 自检引用存在 ② 骨架不含已退役目录(口径 = `layout.md` 的「已退役」标记)③ skill 瘦桩的 `.atlas/` 引用可达(源包与副本两种态都跑)④ `$var` 紧邻非 ASCII 必须写 `${var}` ⑤ **环退役对称**(`rings/<r>/reference.md` ⇔ `skills/atlas-<r>/`;非环 skill 白名单 = apply / design-review / grill / release)⑥ **首建提示**(`say` 行:无退役环名残留 `原型` / `prototype` + 存量 `atlas-apply adopt` 与全新 `atlas-apply all` 两条开户入口齐备) | 契约正文的**语义**是否自洽(那是 2.6 的文档面,仍属缺口);提示的**措辞好坏**(只判「退役名 / 入口缺没缺」,判不了读起来顺不顺) | 改任一包内件 / 瘦桩 / 骨架 / 增删环时(含改 `install.sh` 的用户可见输出) | `出厂级(本轮实测)`:M1–M4(`3509 §112`)+ **M5/M6**(幽灵环 / 幽灵瘦桩,`3509 §115`)+ **M50**(2026-10-15 首建提示:a 把退役环的历史括注回填进 `say` 行 ⇒ 红 / b 抹掉 `atlas-apply adopt` 入口 ⇒ 红;两片注入前锚点断言恰好命中、还原后逐字节复绿)+ **F54/F55**(2026-10-16,issue #21/#22,`DESIGN.md` D92/D93:子进程集成各 +1 条= **M77** 摘干跑闸 ⇒ `test_f54_…` 红 / **M78** 未跟踪桶改指脏桶 ⇒ `test_f55_…` 前半红(后半为 F34 回归钉);两枚还原逐字节一致;F34 的拒路径文案逐字节保留,旧钉一并回归绿) |
|
|
96
|
-
| `patches/project-wiring/apply-wiring.py`(项目接线:AGENTS.md 指针 / `after_archive` hook(D159)/ 测试配置兜底(由 extractor 提供 hook) / `.gitignore` 追加 `.adapter-out/` / pi 宿主扩展;2026-10-15 补登记——此前**不在门面**,故它往用户仓库里写入的动静无门可查) | 目标仓库的五个接线触点 ⇔ 源包片段 | `[机器]` 五件各自幂等(重跑字节不变;指针段恒在 `TRELLIS:END` **之外**);hook 前缀识别(旧 `--apply` 原位升级,不得叠成双行);**测试配置探测只认声明**(注释不算——出厂模板的 `backend_test:` 是注释示例);误建的测试配置走退役对称清理(仅当内容**逐字节相等**于兜底内容);**`.gitignore` 触点(第 5,2026-10-15,issue #8)**:文件**存在才追加**一行 `.adapter-out/`、`.adapter-out` 子串幂等、`!.adapter-out` 负模式跳过(不与用户规则打架)、无文件不首创;**无退役对称**(`.gitignore` 不是本项目建的文件,追加单向不回收——盲区明示);pi 扩展**只插一行**进 `extensions[]` 且插入后 JSON 合法、缺数组/空数组一律跳过不猜 | 这次写入**该不该发生**(判据本身错 ⇒ 会把不该有的文件写进用户仓库,2026-10-15 存量事故即此;「写对了没有」归各触点各自的语义);指针正文的措辞;(`extensions/pi.ts` 的**运行时语义**已由执行级判据覆盖(挂假宿主跑真扩展,见末条),无 `bun` 的机器降级为形态钉) | 每次 `atlas init`(`install.py` 第 6 步)与 `atlas update` | `出厂级(2026-10-15 实测)`:`tests/test_apply_wiring.py` **〔数:用例数.test_apply_wiring.py=
|
|
96
|
+
| `patches/project-wiring/apply-wiring.py`(项目接线:AGENTS.md 指针 / `after_archive` hook(D159)/ 测试配置兜底(由 extractor 提供 hook) / `.gitignore` 追加 `.adapter-out/` / pi 宿主扩展;2026-10-15 补登记——此前**不在门面**,故它往用户仓库里写入的动静无门可查) | 目标仓库的五个接线触点 ⇔ 源包片段 | `[机器]` 五件各自幂等(重跑字节不变;指针段恒在 `TRELLIS:END` **之外**);hook 前缀识别(旧 `--apply` 原位升级,不得叠成双行);**测试配置探测只认声明**(注释不算——出厂模板的 `backend_test:` 是注释示例);误建的测试配置走退役对称清理(仅当内容**逐字节相等**于兜底内容);**`.gitignore` 触点(第 5,2026-10-15,issue #8)**:文件**存在才追加**一行 `.adapter-out/`、`.adapter-out` 子串幂等、`!.adapter-out` 负模式跳过(不与用户规则打架)、无文件不首创;**无退役对称**(`.gitignore` 不是本项目建的文件,追加单向不回收——盲区明示);pi 扩展**只插一行**进 `extensions[]` 且插入后 JSON 合法、缺数组/空数组一律跳过不猜 | 这次写入**该不该发生**(判据本身错 ⇒ 会把不该有的文件写进用户仓库,2026-10-15 存量事故即此;「写对了没有」归各触点各自的语义);指针正文的措辞;(`extensions/pi.ts` 的**运行时语义**已由执行级判据覆盖(挂假宿主跑真扩展,见末条),无 `bun` 的机器降级为形态钉) | 每次 `atlas init`(`install.py` 第 6 步)与 `atlas update` | `出厂级(2026-10-15 实测)`:`tests/test_apply_wiring.py` **〔数:用例数.test_apply_wiring.py=28〕 条** + `tests/test_project_wiring.py` **〔数:用例数.test_project_wiring.py=16〕 条**;**M51a** 探测退回 raw 文本匹配 ⇒ 模板夹具回归红 / **M51b** 摘「内容相等」护栏 ⇒ 误删用户文件的钉子红(两片还原后逐字节复绿);**M65**(2026-10-15)摘 `.gitignore` 触点 ⇒ `test_gitignore_fifth_touchpoint_appends_idempotently` 红(还原逐字节一致);`pi.ts` 侧 = **执行级**(假宿主跑真扩展:三开户态各自的提示注入 / `--fast` 闸 / 失败签名去重——新增/变化才提示、复读静默、首轮静默建基线(issue #67)/ `/atlas status` 输出;无 `bun` ⇒ 显式 skip、不是通过)+ 形态片段钉 |
|
|
97
97
|
|
|
98
98
|
### 2.4 运行期门(生成物内的检查)
|
|
99
99
|
|
package/shared/global-rules.md
CHANGED
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
2. 自动调用 `atlas report` 命令行(或执行 `python3 .atlas/scripts/atlas_report.py`)将结构化记录静默上报;
|
|
133
133
|
3. 上报后向用户明确说明已沉淀现场,并给出当前阶段的最优临时推进方案。
|
|
134
134
|
- **用户开口才算数 = 漏认**:用户主动要求上报时,说明本轮模型没自己认出来——照办之外,回头把同一轮的同类现场一并认一遍(上报带 `--trigger user`:池子里的来源分布就是本契约的体检表,全 `user` 即自动路径没在工作)。本契约的价值在**上游**感知,不在事后补录。
|
|
135
|
-
- **交付面(提醒靠这三处落地,不靠模型自发回忆)**:① 项目指针段(`patches/project-wiring/agent-pointer.md` → 目标仓库 `AGENTS.md`,会话内常在上下文);② 宿主扩展的撞门提示(`extensions/pi.ts` 的 `turn_end
|
|
135
|
+
- **交付面(提醒靠这三处落地,不靠模型自发回忆)**:① 项目指针段(`patches/project-wiring/agent-pointer.md` → 目标仓库 `AGENTS.md`,会话内常在上下文);② 宿主扩展的撞门提示(`extensions/pi.ts` 的 `turn_end`:机器门失败签名相对上一轮基线**新增/变化**时同段提示——基线落 `.atlas/runs/pi-turn-failures.json` 去重,历史失败不逐轮复读,issue #67);③ 收口扫描(`shared/closeout.md` 触发表「开发流程/宿主适配摩擦」行)。三处之外无机器门:**「这是不是流水线缺陷」是语义判断**,机器只能保证提醒出现在正确的时点。
|
|
136
136
|
|
|
137
137
|
## 16. 变更后只重验受影响项(2026-10-23,`RFC-20261023-02` ③)
|
|
138
138
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|