peaks-loop 4.1.11 → 4.1.12
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +35 -0
- package/README-en.md +1 -1
- package/README.md +1 -1
- package/dist/services/code/orchestrator-can-do-probes.d.ts +10 -0
- package/dist/services/code/orchestrator-can-do-probes.js +12 -2
- package/dist/services/scan/archetype-service.js +24 -8
- package/dist/services/scan/frontend-evidence.d.ts +19 -0
- package/dist/services/scan/frontend-evidence.js +142 -0
- package/dist/services/scan/scan-types.d.ts +8 -1
- package/package.json +5 -5
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"pluginRoot": ".",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.12"
|
|
5
5
|
},
|
|
6
6
|
"plugins": [
|
|
7
7
|
{
|
|
8
8
|
"name": "peaks-loop",
|
|
9
9
|
"description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
|
|
10
|
-
"version": "4.1.
|
|
10
|
+
"version": "4.1.12",
|
|
11
11
|
"author": {
|
|
12
12
|
"name": "SquabbyZ"
|
|
13
13
|
},
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.1.12 — 2026-10-20(macOS CI 红灯、frontend-only 正面证据制,与 Node 门槛声明修正)
|
|
4
|
+
|
|
5
|
+
**版本级别**: 未发布区间 `v4.1.11..HEAD` 共 **5 个 commit**(**3 fix / 1 docs / 1 chore**)。取 **patch**,依维护者 2026-07-22 的常设规则"默认版本新增采用最小的版本位"。`ProjectArchetype` 新增 `cli` 取值、`ArchetypeReport.detected` 新增 `hasBin` 与 `frontendEvidence` 两个字段,均为**追加**;既有 archetype 取值、`frontendOnly` 的布尔语义与全部 CLI 参数不变,无破坏性变更。
|
|
6
|
+
|
|
7
|
+
### 1. macOS CI 的唯一红灯来自 Q2 探针预算(`8e7a1cac`)
|
|
8
|
+
|
|
9
|
+
- 4.1.11 的 CI 在 `macos-latest` 上只有一条失败:`orchestrator-can-do.test.ts` 的 Q2 探针。用例耗时 **5035 ms**,而探针的 `execFile` 预算是 **5000 ms**——超时被 `catch` 统一读成 `false`,于是"慢"变成了"sub-agent dispatch 不可用"。
|
|
10
|
+
- 同一次 CI 里,Q4 探针用 10000 ms 预算并通过;这就是对照证据。本次把 Q2 预算提为具名常量 `SUB_AGENT_PROBE_TIMEOUT_MS = 15_000`,Q4 也改为具名 `CONTEXT_RATIO_PROBE_TIMEOUT_MS = 10_000`(值未动)。
|
|
11
|
+
- 新增回归断言:**Q2 预算不得低于 Q4 预算**,失败信息点名被改小的常量。负向对照(把 Q2 改回 `5_000`)确实变红,断言不是同义反复。
|
|
12
|
+
- 断言放在新文件 `orchestrator-can-do-probe-budgets.test.ts`:`orchestrator-can-do.test.ts` 在 HEAD 已 564 行、超过 tests 的 500 行上限,staged size ratchet 拒绝增长。
|
|
13
|
+
|
|
14
|
+
### 2. frontend-only 不再等于"没有后端"(`20062aa3`)
|
|
15
|
+
|
|
16
|
+
- `decideFrontendOnly` 此前只有一条判据:`arctype === frontend-monorepo` 或 `!hasBackend && !hasSwaggerOrProto`。一个没有任何前端产物的 TypeScript CLI 因此被报成 `frontend-monorepo` + `frontendOnly: true`,并写进 project-scan 供 PRD/RD 读取。
|
|
17
|
+
- 现在要求**正面证据**(任一):前端框架/运行时依赖;CSS 相关依赖;或 `src|app|pages|components|public` 下存在 `css|scss|sass|less|styl|html|htm|vue|svelte` 文件。目录遍历跳过 `node_modules|dist|build|out|coverage` 与点目录,并且**只认应用根**——本仓库 `examples/**` 与 `skills/**` 里的样式不计入。
|
|
18
|
+
- 新增 `cli` archetype:`bin` 非空 + 无后端 + 无前端证据。本仓库自扫现在是 `cli` / `false` / `archetype=cli`,monorepo 分支不再把它吞掉。
|
|
19
|
+
- 探测放在新模块 `src/services/scan/frontend-evidence.ts`:`archetype-detection.ts` 已 363 行、超过 src 的 300 行上限,闸门拒绝增长。
|
|
20
|
+
- 测试 fixture 里原本断言 `frontendOnly: true` 的用例都补上了真实证据;旧的 `no-backend-no-swagger` 期望被替换,而不是作为期望值保留。
|
|
21
|
+
|
|
22
|
+
### 3. 证据标签与 bin 探针分支(`4c338be4`)
|
|
23
|
+
|
|
24
|
+
- 文件证据的 reason 从 `css-under-<root>` 改为 `asset-under-<root>`:HTML 与 `.vue`/`.svelte` 此前被标成 CSS。
|
|
25
|
+
- 新增 `readRootBin` 的直接单测:manifest 缺失 / 非法 JSON / `bin: {}` → false;字符串 `bin` 与非空对象 → true。
|
|
26
|
+
|
|
27
|
+
### 4. README 的 Node 门槛(`a6233fc4`)
|
|
28
|
+
|
|
29
|
+
- 两个 README 的徽章从 `node ≥20` 改为 `≥24`。真实门槛由 `bin/node-floor.mjs` 的 `MIN_NODE_MAJOR = 24` 决定,`package.json#engines` 也已是 `>=24`;旧徽章会让 Node 20–23 的用户按错误的前提安装。
|
|
30
|
+
|
|
31
|
+
### 5. 证据
|
|
32
|
+
|
|
33
|
+
- 全量 `pnpm test:unit`:**540 files / 5980 passed / 3 skipped**,exit 0(3 个 skip 为既有 `@slow` / `@replay` 标记)。首轮曾因新测试文件未进体积基线而红了两条 standards 测试(census 784 vs `shadow.measuredFiles` 783),重生成基线后转绿;`shadow` 783→784,17 个 ceiling 逐一比对未动。
|
|
34
|
+
- `tsc --noEmit` 0 error;`pnpm build` 成功且 `dist` 携带 4.1.12;`node .husky/peaks-gate.mjs repo` 全部 ceiling 持平;`peaks changeset check` 通过;`no-ai-co-author-trailer` 红线测试通过。
|
|
35
|
+
- 三个代码切片均走 PRD → RD → QA:security / perf 审计由 CLI 出件(全部 `pass`,0 violations),karpathy 复核 4 项全部 pass,`peaks workflow verify-pipeline` 三份均 `gateC=pass / gateH=pass`、0 violations。
|
|
36
|
+
- OCR 1.x 补充评审:直接调用在 60 s 预算处超时;改走无凭据的 delegation 路径(出包 → 宿主模型按包内规则审 → `ocr-delegate-record` 回录),抓到一条 LOW——正是第 3 节修掉的 `css-under-` 标签。ESLint 仍是主闸,全程 0 findings。
|
|
37
|
+
|
|
3
38
|
## 4.1.11 — 2026-10-20(生产依赖升版、OCR 全语言路由,与 delegation 双阶段评审路径)
|
|
4
39
|
|
|
5
40
|
**版本级别**: 未发布区间 `v4.1.10..HEAD` 共 **3 个 commit**(**2 feat / 1 refactor**)。取 **patch**,依维护者 2026-07-22 的常设规则"默认版本新增采用最小的版本位"。`peaks code-review run-ocr-18` 新增 `--languages auto|<csv>` 与 `--delegate` 两条路径、新增 `peaks code-review ocr-delegate-record` 一个动词,均是在既有 service 之上的新入口;既有的 `--language <lang>` 单语言路径与 API 路径行为不变,无破坏性变更。
|
package/README-en.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://github.com/SquabbyZ/peaks-loop/actions/workflows/publish.yml)
|
|
9
9
|
[](https://github.com/SquabbyZ/peaks-loop/actions/workflows/ci.yml)
|
|
10
10
|
[](./LICENSE)
|
|
11
|
-
[](https://www.npmjs.com/package/peaks-loop)
|
|
12
12
|
[](https://github.com/SquabbyZ/peaks-loop/stargazers)
|
|
13
13
|
|
|
14
14
|
**English** · [简体中文](./README.md)
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://github.com/SquabbyZ/peaks-loop/actions/workflows/publish.yml)
|
|
9
9
|
[](https://github.com/SquabbyZ/peaks-loop/actions/workflows/ci.yml)
|
|
10
10
|
[](./LICENSE)
|
|
11
|
-
[](https://www.npmjs.com/package/peaks-loop)
|
|
12
12
|
[](https://github.com/SquabbyZ/peaks-loop/stargazers)
|
|
13
13
|
|
|
14
14
|
[English](./README-en.md) · **简体中文**
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
* tests import them from the same path, so the surface below must stay
|
|
11
11
|
* reachable from there.
|
|
12
12
|
*/
|
|
13
|
+
/**
|
|
14
|
+
* Budget for the Q2 sub-agent probe. macOS CI runs this whole suite in parallel;
|
|
15
|
+
* there the old 5 s budget killed the probe at 5035 ms while the 10 s Q4 probe
|
|
16
|
+
* passed in the same run, so "slow" was reported as "unavailable". A healthy CLI
|
|
17
|
+
* answers in well under a second — this ceiling only bounds a hung one, so it is
|
|
18
|
+
* the worst case, not the expected cost.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SUB_AGENT_PROBE_TIMEOUT_MS = 15000;
|
|
21
|
+
/** Budget for the Q4 context probe. Unchanged; Q2 must stay at least this large. */
|
|
22
|
+
export declare const CONTEXT_RATIO_PROBE_TIMEOUT_MS = 10000;
|
|
13
23
|
export interface ContextProbe {
|
|
14
24
|
/** 0.0–1.0; ≥0.85 = pre-compact; ≥0.95 = red-line. */
|
|
15
25
|
readonly ratio: number;
|
|
@@ -23,6 +23,16 @@ import { cliEntryPath, interpreterArgs } from '../web/daemon-supervisor.js';
|
|
|
23
23
|
const execFileAsync = promisify(execFile);
|
|
24
24
|
/** Sentinel: no explicit binary was injected, so resolve this tree's own CLI. */
|
|
25
25
|
const DEFAULT_PEAKS_BIN = 'peaks';
|
|
26
|
+
/**
|
|
27
|
+
* Budget for the Q2 sub-agent probe. macOS CI runs this whole suite in parallel;
|
|
28
|
+
* there the old 5 s budget killed the probe at 5035 ms while the 10 s Q4 probe
|
|
29
|
+
* passed in the same run, so "slow" was reported as "unavailable". A healthy CLI
|
|
30
|
+
* answers in well under a second — this ceiling only bounds a hung one, so it is
|
|
31
|
+
* the worst case, not the expected cost.
|
|
32
|
+
*/
|
|
33
|
+
export const SUB_AGENT_PROBE_TIMEOUT_MS = 15_000;
|
|
34
|
+
/** Budget for the Q4 context probe. Unchanged; Q2 must stay at least this large. */
|
|
35
|
+
export const CONTEXT_RATIO_PROBE_TIMEOUT_MS = 10_000;
|
|
26
36
|
/**
|
|
27
37
|
* Spawn argv for the peaks CLI. An explicitly injected `peaksBin` (the
|
|
28
38
|
* `--peaks-bin` test seam) is spawned verbatim; the default sentinel resolves
|
|
@@ -44,7 +54,7 @@ export async function probeSubAgentAvailable(projectRoot, peaksBin = DEFAULT_PEA
|
|
|
44
54
|
const { command, args } = peaksSpawn(peaksBin);
|
|
45
55
|
await execFileAsync(command, [...args, 'sub-agent', 'dispatch', '--role', 'rd', '--help'], {
|
|
46
56
|
cwd: projectRoot,
|
|
47
|
-
timeout:
|
|
57
|
+
timeout: SUB_AGENT_PROBE_TIMEOUT_MS,
|
|
48
58
|
windowsHide: true
|
|
49
59
|
});
|
|
50
60
|
return true;
|
|
@@ -63,7 +73,7 @@ export async function probeContextRatio(projectRoot, peaksBin = DEFAULT_PEAKS_BI
|
|
|
63
73
|
const { command, args } = peaksSpawn(peaksBin);
|
|
64
74
|
const { stdout } = await execFileAsync(command, [...args, 'code', 'context-now', '--project', projectRoot, '--json'], {
|
|
65
75
|
cwd: projectRoot,
|
|
66
|
-
timeout:
|
|
76
|
+
timeout: CONTEXT_RATIO_PROBE_TIMEOUT_MS,
|
|
67
77
|
windowsHide: true
|
|
68
78
|
});
|
|
69
79
|
const parsed = JSON.parse(stdout);
|
|
@@ -2,6 +2,7 @@ import { readdir } from 'node:fs/promises';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { isDirectory } from 'peaks-loop-shared/fs';
|
|
4
4
|
import { detectBackendDirs, detectBackendFrameworks, detectMonorepoConfigs, detectNestedServiceEvidence, detectNextApiRoutes, detectNextServerActions, detectSwagger, GREENFIELD_MAX_SRC_FILES, GREENFIELD_MAX_LOCKFILE_DAYS, HIGH_CONFIDENCE_SIGNAL_COUNT, LEGACY_MIN_SRC_FILES, lockfileAgeDays, LOCKFILE_STALE_DAYS, readPackageJsonDeps } from './archetype-detection.js';
|
|
5
|
+
import { detectFrontendEvidence, frontendSignals, readRootBin } from './frontend-evidence.js';
|
|
5
6
|
async function countSrcFiles(projectRoot, max = 500) {
|
|
6
7
|
const srcDir = join(projectRoot, 'src');
|
|
7
8
|
if (!(await isDirectory(srcDir))) {
|
|
@@ -93,9 +94,16 @@ function decideArchetype(detected) {
|
|
|
93
94
|
matched: detected.lockfileAgeDays !== null && detected.lockfileAgeDays > LOCKFILE_STALE_DAYS,
|
|
94
95
|
detail: detected.lockfileAgeDays === null ? 'no lockfile' : `${detected.lockfileAgeDays} days`
|
|
95
96
|
});
|
|
97
|
+
signals.push(...frontendSignals(detected.hasBin, detected.frontendEvidence));
|
|
96
98
|
if (!detected.hasPackageJson) {
|
|
97
99
|
return { archetype: 'unknown', confidence: 'low', signals };
|
|
98
100
|
}
|
|
101
|
+
// A published CLI is not a frontend. `bin` + no backend + no frontend
|
|
102
|
+
// evidence used to fall through to `frontend-monorepo` (monorepo config) or
|
|
103
|
+
// `legacy-frontend`, and `decideFrontendOnly` then called it frontend-only.
|
|
104
|
+
if (detected.hasBin && !hasBackend && detected.frontendEvidence === null) {
|
|
105
|
+
return { archetype: 'cli', confidence: 'high', signals };
|
|
106
|
+
}
|
|
99
107
|
// Monorepo detection runs BEFORE the backend check: a monorepo with
|
|
100
108
|
// a packages/server dir is a fullstack-monorepo, NOT legacy-fullstack.
|
|
101
109
|
// backend sub-package fell through to `legacy-fullstack` because
|
|
@@ -146,17 +154,21 @@ function decideArchetype(detected) {
|
|
|
146
154
|
return { archetype: 'unknown', confidence: 'low', signals };
|
|
147
155
|
}
|
|
148
156
|
function decideFrontendOnly(report) {
|
|
149
|
-
if (report.archetype === '
|
|
150
|
-
return { frontendOnly:
|
|
157
|
+
if (report.archetype === 'cli') {
|
|
158
|
+
return { frontendOnly: false, reason: 'archetype=cli' };
|
|
151
159
|
}
|
|
152
160
|
const noBackend = !hasBackendEvidence(report.detected);
|
|
153
|
-
if (noBackend &&
|
|
154
|
-
return { frontendOnly: true, reason: 'no-backend-no-swagger' };
|
|
155
|
-
}
|
|
156
|
-
if (noBackend) {
|
|
161
|
+
if (noBackend && report.detected.hasSwaggerOrProto) {
|
|
157
162
|
return { frontendOnly: false, reason: 'swagger-or-proto-present' };
|
|
158
163
|
}
|
|
159
|
-
|
|
164
|
+
if (!noBackend) {
|
|
165
|
+
return { frontendOnly: false, reason: 'backend-detected' };
|
|
166
|
+
}
|
|
167
|
+
const evidence = report.detected.frontendEvidence;
|
|
168
|
+
if (evidence === null) {
|
|
169
|
+
return { frontendOnly: false, reason: 'no-frontend-evidence' };
|
|
170
|
+
}
|
|
171
|
+
return { frontendOnly: true, reason: `frontend-evidence=${evidence}` };
|
|
160
172
|
}
|
|
161
173
|
/**
|
|
162
174
|
* Three frontend integration scenarios, from the signals `detected`
|
|
@@ -177,7 +189,9 @@ function decideIntegrationMode(report) {
|
|
|
177
189
|
export async function scanArchetype(options) {
|
|
178
190
|
const { projectRoot } = options;
|
|
179
191
|
const { exists: hasPackageJson, deps } = await readPackageJsonDeps(projectRoot);
|
|
192
|
+
const hasBin = await readRootBin(projectRoot);
|
|
180
193
|
const backendFrameworks = await detectBackendFrameworks(deps);
|
|
194
|
+
const frontendEvidence = await detectFrontendEvidence(projectRoot, deps);
|
|
181
195
|
const hasNext = Object.prototype.hasOwnProperty.call(deps, 'next');
|
|
182
196
|
const hasNextApiRoutes = await detectNextApiRoutes(projectRoot, hasNext);
|
|
183
197
|
const backendDirsPresent = await detectBackendDirs(projectRoot);
|
|
@@ -200,7 +214,9 @@ export async function scanArchetype(options) {
|
|
|
200
214
|
hasNextApiRoutes,
|
|
201
215
|
srcFileCount,
|
|
202
216
|
backendDirsPresent,
|
|
203
|
-
lockfileAgeDays: ageDays
|
|
217
|
+
lockfileAgeDays: ageDays,
|
|
218
|
+
hasBin,
|
|
219
|
+
frontendEvidence
|
|
204
220
|
};
|
|
205
221
|
const { archetype, confidence, signals } = decideArchetype(detected);
|
|
206
222
|
const base = { archetype, confidence, signals, detected };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ArchetypeSignal } from './scan-types.js';
|
|
2
|
+
/** Each list entry is the evidence CLASS returned to the caller, so the report
|
|
3
|
+
* can say what it saw instead of only the verdict. */
|
|
4
|
+
export declare const FRONTEND_FRAMEWORK_DEPS: string[];
|
|
5
|
+
export declare const FRONTEND_STYLE_DEPS: string[];
|
|
6
|
+
export declare const FRONTEND_APPLICATION_ROOTS: string[];
|
|
7
|
+
/** Upper bound on directory entries inspected per scan. An absent signal is the
|
|
8
|
+
* common case (every CLI and library), so the walk must stop even in a huge
|
|
9
|
+
* tree; a miss costs one skipped UI flow, a false positive costs a wrong
|
|
10
|
+
* project classification. */
|
|
11
|
+
export declare const FRONTEND_EVIDENCE_MAX_ENTRIES = 2000;
|
|
12
|
+
export declare function readRootBin(projectRoot: string): Promise<boolean>;
|
|
13
|
+
/** `null` when the repository has no positive frontend signal. Order is
|
|
14
|
+
* deliberate: a framework dep is stronger than a style dep, which is stronger
|
|
15
|
+
* than a file that could be a one-off. */
|
|
16
|
+
export declare function detectFrontendEvidence(projectRoot: string, deps: Record<string, string>): Promise<string | null>;
|
|
17
|
+
/** The two report signals this probe contributes, so the archetype service does
|
|
18
|
+
* not spend its line budget rebuilding them. */
|
|
19
|
+
export declare function frontendSignals(hasBin: boolean, evidence: string | null): ArchetypeSignal[];
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// Positive frontend evidence for `scanArchetype`.
|
|
2
|
+
//
|
|
3
|
+
// "No backend" is not evidence of a frontend: a TypeScript CLI has neither and
|
|
4
|
+
// was reported `frontendOnly: true`. This module answers the opposite question —
|
|
5
|
+
// does the repository declare a frontend framework, a CSS-adjacent dependency,
|
|
6
|
+
// or carry a css/html-family asset under an application root? A `null` answer is
|
|
7
|
+
// the absence of an observation, and the caller reports it as
|
|
8
|
+
// `no-frontend-evidence`.
|
|
9
|
+
//
|
|
10
|
+
// The walk is scoped to application roots on purpose: an unscoped tree walk
|
|
11
|
+
// finds `examples/video-demo/src/styles.css` and the HTML under `skills/`, and
|
|
12
|
+
// calls a CLI a frontend.
|
|
13
|
+
import { readdir } from 'node:fs/promises';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { isDirectory, pathExists, readText } from 'peaks-loop-shared/fs';
|
|
16
|
+
/** Each list entry is the evidence CLASS returned to the caller, so the report
|
|
17
|
+
* can say what it saw instead of only the verdict. */
|
|
18
|
+
export const FRONTEND_FRAMEWORK_DEPS = [
|
|
19
|
+
'react',
|
|
20
|
+
'react-dom',
|
|
21
|
+
'vue',
|
|
22
|
+
'svelte',
|
|
23
|
+
'next',
|
|
24
|
+
'nuxt',
|
|
25
|
+
'@angular/core',
|
|
26
|
+
'solid-js',
|
|
27
|
+
'preact',
|
|
28
|
+
'astro',
|
|
29
|
+
'gatsby',
|
|
30
|
+
'remix'
|
|
31
|
+
];
|
|
32
|
+
export const FRONTEND_STYLE_DEPS = [
|
|
33
|
+
'tailwindcss',
|
|
34
|
+
'sass',
|
|
35
|
+
'less',
|
|
36
|
+
'postcss',
|
|
37
|
+
'styled-components',
|
|
38
|
+
'@emotion/react',
|
|
39
|
+
'bootstrap'
|
|
40
|
+
];
|
|
41
|
+
export const FRONTEND_APPLICATION_ROOTS = ['src', 'app', 'pages', 'components', 'public'];
|
|
42
|
+
/** Upper bound on directory entries inspected per scan. An absent signal is the
|
|
43
|
+
* common case (every CLI and library), so the walk must stop even in a huge
|
|
44
|
+
* tree; a miss costs one skipped UI flow, a false positive costs a wrong
|
|
45
|
+
* project classification. */
|
|
46
|
+
export const FRONTEND_EVIDENCE_MAX_ENTRIES = 2000;
|
|
47
|
+
const ASSET_EXTENSIONS = /\.(css|scss|sass|less|styl|html|htm|vue|svelte)$/;
|
|
48
|
+
/** Generated / installed trees never hold the project's own styles. */
|
|
49
|
+
const WALK_SKIP_DIRS = new Set(['node_modules', 'dist', 'build', 'out', 'coverage']);
|
|
50
|
+
function firstDeclared(deps, names) {
|
|
51
|
+
return names.find((name) => Object.prototype.hasOwnProperty.call(deps, name)) ?? null;
|
|
52
|
+
}
|
|
53
|
+
/** `bin` counts only when it points somewhere: a string or an object of strings. */
|
|
54
|
+
function hasNonEmptyBin(bin) {
|
|
55
|
+
if (typeof bin === 'string')
|
|
56
|
+
return bin.trim().length > 0;
|
|
57
|
+
if (bin === null || typeof bin !== 'object')
|
|
58
|
+
return false;
|
|
59
|
+
return Object.values(bin).some((value) => typeof value === 'string' && value.trim().length > 0);
|
|
60
|
+
}
|
|
61
|
+
export async function readRootBin(projectRoot) {
|
|
62
|
+
const pkgPath = join(projectRoot, 'package.json');
|
|
63
|
+
if (!(await pathExists(pkgPath)))
|
|
64
|
+
return false;
|
|
65
|
+
try {
|
|
66
|
+
const parsed = JSON.parse(await readText(pkgPath));
|
|
67
|
+
return hasNonEmptyBin(parsed.bin);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// An unreadable manifest is not a CLI claim, and not an absence of one
|
|
71
|
+
// either; `false` says only "no bin evidence was observed".
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function isAssetFile(entry) {
|
|
76
|
+
return !entry.isDirectory() && ASSET_EXTENSIONS.test(entry.name);
|
|
77
|
+
}
|
|
78
|
+
function isSkippedDir(name) {
|
|
79
|
+
return name.startsWith('.') || WALK_SKIP_DIRS.has(name);
|
|
80
|
+
}
|
|
81
|
+
async function readDirSafe(dir) {
|
|
82
|
+
return readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
83
|
+
}
|
|
84
|
+
async function assetUnderRoot(rootDir) {
|
|
85
|
+
const queue = [rootDir];
|
|
86
|
+
let inspected = 0;
|
|
87
|
+
while (queue.length > 0 && inspected < FRONTEND_EVIDENCE_MAX_ENTRIES) {
|
|
88
|
+
const current = queue.shift();
|
|
89
|
+
if (current === undefined)
|
|
90
|
+
break;
|
|
91
|
+
const entries = await readDirSafe(current);
|
|
92
|
+
inspected += entries.length;
|
|
93
|
+
if (entries.some(isAssetFile))
|
|
94
|
+
return true;
|
|
95
|
+
for (const entry of entries) {
|
|
96
|
+
if (entry.isDirectory() && !isSkippedDir(entry.name)) {
|
|
97
|
+
queue.push(join(current, entry.name));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
/** The class names the whole asset family, not the extension that matched:
|
|
104
|
+
* a css, html, vue, or svelte file under `<root>` is `asset-under-<root>`. */
|
|
105
|
+
async function assetUnderApplicationRoots(projectRoot) {
|
|
106
|
+
for (const root of FRONTEND_APPLICATION_ROOTS) {
|
|
107
|
+
const rootDir = join(projectRoot, root);
|
|
108
|
+
if (!(await isDirectory(rootDir)))
|
|
109
|
+
continue;
|
|
110
|
+
if (await assetUnderRoot(rootDir))
|
|
111
|
+
return `asset-under-${root}`;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
/** `null` when the repository has no positive frontend signal. Order is
|
|
116
|
+
* deliberate: a framework dep is stronger than a style dep, which is stronger
|
|
117
|
+
* than a file that could be a one-off. */
|
|
118
|
+
export async function detectFrontendEvidence(projectRoot, deps) {
|
|
119
|
+
const framework = firstDeclared(deps, FRONTEND_FRAMEWORK_DEPS);
|
|
120
|
+
if (framework !== null)
|
|
121
|
+
return framework;
|
|
122
|
+
const style = firstDeclared(deps, FRONTEND_STYLE_DEPS);
|
|
123
|
+
if (style !== null)
|
|
124
|
+
return style;
|
|
125
|
+
return assetUnderApplicationRoots(projectRoot);
|
|
126
|
+
}
|
|
127
|
+
/** The two report signals this probe contributes, so the archetype service does
|
|
128
|
+
* not spend its line budget rebuilding them. */
|
|
129
|
+
export function frontendSignals(hasBin, evidence) {
|
|
130
|
+
return [
|
|
131
|
+
{
|
|
132
|
+
name: 'bin',
|
|
133
|
+
matched: hasBin,
|
|
134
|
+
detail: hasBin ? 'package.json declares bin' : 'no bin in package.json'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'frontend-evidence',
|
|
138
|
+
matched: evidence !== null,
|
|
139
|
+
detail: evidence ?? 'no frontend framework, style dependency, or css/html under an application root'
|
|
140
|
+
}
|
|
141
|
+
];
|
|
142
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ProjectArchetype = 'greenfield' | 'legacy-frontend' | 'legacy-fullstack' | 'frontend-monorepo' | 'fullstack-monorepo' | 'unknown';
|
|
1
|
+
export type ProjectArchetype = 'greenfield' | 'legacy-frontend' | 'legacy-fullstack' | 'frontend-monorepo' | 'fullstack-monorepo' | 'cli' | 'unknown';
|
|
2
2
|
export type ArchetypeSignal = {
|
|
3
3
|
name: string;
|
|
4
4
|
matched: boolean;
|
|
@@ -39,6 +39,13 @@ export type ArchetypeReport = {
|
|
|
39
39
|
srcFileCount: number;
|
|
40
40
|
backendDirsPresent: string[];
|
|
41
41
|
lockfileAgeDays: number | null;
|
|
42
|
+
/** The root `package.json` declares a non-empty `bin` entry. */
|
|
43
|
+
hasBin: boolean;
|
|
44
|
+
/** The strongest positive frontend signal observed, or `null` when none
|
|
45
|
+
* was. A frontend framework dep, a CSS-adjacent dep, or a css/html-family
|
|
46
|
+
* asset under an application root. `frontendOnly` is derived from this,
|
|
47
|
+
* never from "the repository is not a backend". */
|
|
48
|
+
frontendEvidence: string | null;
|
|
42
49
|
};
|
|
43
50
|
};
|
|
44
51
|
export type VisualTokenSource = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peaks-loop",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.12",
|
|
4
4
|
"description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
|
|
5
5
|
"author": "SquabbyZ",
|
|
6
6
|
"keywords": [
|
|
@@ -129,10 +129,10 @@
|
|
|
129
129
|
"picomatch": "4.0.7",
|
|
130
130
|
"yaml": "^2.9.1",
|
|
131
131
|
"zod": "^4.6.7",
|
|
132
|
-
"peaks-loop-internal-runtime": "0.0.
|
|
133
|
-
"peaks-loop-
|
|
134
|
-
"peaks-loop-
|
|
135
|
-
"peaks-loop-shared-channel": "0.0.
|
|
132
|
+
"peaks-loop-internal-runtime": "0.0.52",
|
|
133
|
+
"peaks-loop-mut": "0.1.66",
|
|
134
|
+
"peaks-loop-shared": "0.0.101",
|
|
135
|
+
"peaks-loop-shared-channel": "0.0.69"
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
138
|
"@changesets/cli": "2.31.1",
|