@longzai-intelligence-features/ledger 0.0.2 → 0.0.3
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/dist/index.d.ts +92 -25
- package/dist/index.js +23 -17
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,19 +4,32 @@ import { LziFeaturesConfig } from "@longzai-intelligence-features/config";
|
|
|
4
4
|
/**
|
|
5
5
|
* features 格式口径单一真源
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* 全部格式口径集中于此模块:需求目录命名形态、条目五件套必备件、头部元数据
|
|
8
|
+
* 键与状态五态词表、正文节标题。识别侧与写侧共用同一真源,create 产物在构
|
|
9
|
+
* 造上天然通过 lint。slug 消费 docs 平台共享基础模块的语义域形态,纯字母
|
|
10
|
+
* kebab,禁数字,全族同源
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* 条目结构为五件套:README.md 承载标题与元数据并做目录着陆,spec.md 承载
|
|
14
|
+
* 四节正文与交付记录,tasks.md 与 checklist.md 与 progress.md 分别承载任务
|
|
15
|
+
* 分解、验收清单与进展流水。五件齐备为完整态,缺件计违例
|
|
11
16
|
*/
|
|
12
17
|
/**
|
|
13
18
|
* 需求目录 slug 合法形态,语义域为纯小写字母 kebab,禁数字
|
|
14
19
|
*/
|
|
15
20
|
declare const FEATURE_SLUG_PATTERN: RegExp;
|
|
16
21
|
/**
|
|
17
|
-
*
|
|
22
|
+
* 条目五件套必备件,恰此五件为完整态
|
|
18
23
|
*/
|
|
19
|
-
declare const
|
|
24
|
+
declare const REQUIRED_ENTRY_FILES: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* 元数据载体文件名,标题与加粗键元数据行落于 README.md
|
|
27
|
+
*/
|
|
28
|
+
declare const ENTRY_METADATA_FILENAME = "README.md";
|
|
29
|
+
/**
|
|
30
|
+
* 正文载体文件名,四节正文与交付记录节落于 spec.md
|
|
31
|
+
*/
|
|
32
|
+
declare const ENTRY_SPEC_FILENAME = "spec.md";
|
|
20
33
|
/**
|
|
21
34
|
* 头部元数据行形态,加粗键加全角冒号加值
|
|
22
35
|
*/
|
|
@@ -360,9 +373,9 @@ type ParsedMetadataLine = {
|
|
|
360
373
|
value: string;
|
|
361
374
|
};
|
|
362
375
|
/**
|
|
363
|
-
*
|
|
376
|
+
* README.md 元数据解析结果
|
|
364
377
|
*/
|
|
365
|
-
type
|
|
378
|
+
type ParsedEntryMetadata = {
|
|
366
379
|
/**
|
|
367
380
|
* 标题,首个一级标题行,缺失为 null
|
|
368
381
|
*/
|
|
@@ -399,6 +412,11 @@ type ParsedFeatureRecord = {
|
|
|
399
412
|
* 阻塞引用列表,缺失或空值为空数组
|
|
400
413
|
*/
|
|
401
414
|
blockingRefs: string[];
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* spec.md 正文解析结果
|
|
418
|
+
*/
|
|
419
|
+
type ParsedSpecSections = {
|
|
402
420
|
/**
|
|
403
421
|
* 在位正文节标题全集
|
|
404
422
|
*/
|
|
@@ -409,12 +427,23 @@ type ParsedFeatureRecord = {
|
|
|
409
427
|
deliverySectionBody: string | null;
|
|
410
428
|
};
|
|
411
429
|
/**
|
|
412
|
-
*
|
|
430
|
+
* 条目解析结果,README 元数据与 spec 正文的合成形态
|
|
431
|
+
*/
|
|
432
|
+
type ParsedFeatureRecord = ParsedEntryMetadata & ParsedSpecSections;
|
|
433
|
+
/**
|
|
434
|
+
* 解析 README.md 全文为条目元数据
|
|
413
435
|
*
|
|
414
|
-
* @param content -
|
|
415
|
-
* @returns
|
|
436
|
+
* @param content - README.md 全文
|
|
437
|
+
* @returns 元数据解析结果
|
|
438
|
+
*/
|
|
439
|
+
declare function parseEntryMetadata(content: string): ParsedEntryMetadata;
|
|
440
|
+
/**
|
|
441
|
+
* 解析 spec.md 全文为正文节在位情况
|
|
442
|
+
*
|
|
443
|
+
* @param content - spec.md 全文
|
|
444
|
+
* @returns 正文节解析结果
|
|
416
445
|
*/
|
|
417
|
-
declare function
|
|
446
|
+
declare function parseSpecSections(content: string): ParsedSpecSections;
|
|
418
447
|
//#endregion
|
|
419
448
|
//#region src/recognizer/feature-recognizer.core.d.ts
|
|
420
449
|
/**
|
|
@@ -434,7 +463,7 @@ type RecognizedFeature = {
|
|
|
434
463
|
*/
|
|
435
464
|
namingValid: boolean;
|
|
436
465
|
/**
|
|
437
|
-
*
|
|
466
|
+
* 五件套齐备标记,完整态判定
|
|
438
467
|
*/
|
|
439
468
|
hasEntry: boolean;
|
|
440
469
|
/**
|
|
@@ -442,11 +471,15 @@ type RecognizedFeature = {
|
|
|
442
471
|
*/
|
|
443
472
|
files: string[];
|
|
444
473
|
/**
|
|
445
|
-
*
|
|
474
|
+
* 缺失的必备件清单,完整态为空
|
|
475
|
+
*/
|
|
476
|
+
missing: string[];
|
|
477
|
+
/**
|
|
478
|
+
* 补充材料清单,五件之外的实际文件
|
|
446
479
|
*/
|
|
447
480
|
supplementary: string[];
|
|
448
481
|
/**
|
|
449
|
-
*
|
|
482
|
+
* 解析结果,元数据与正文载体任一缺失为 null
|
|
450
483
|
*/
|
|
451
484
|
record: ParsedFeatureRecord | null;
|
|
452
485
|
};
|
|
@@ -478,15 +511,17 @@ declare function isExcludedPath(itemRelPath: string, exclusions: readonly {
|
|
|
478
511
|
//#endregion
|
|
479
512
|
//#region src/template/feature-template.renderer.d.ts
|
|
480
513
|
/**
|
|
481
|
-
*
|
|
514
|
+
* 条目五件套模板与注册表索引渲染器,唯一真源
|
|
482
515
|
*
|
|
483
516
|
* 标准格式两路共用本渲染器:template 命令的骨架展示与 create 的建档实例。
|
|
484
517
|
* 结构常量与格式单一真源共享,结构漂移在构造上不可能发生。渲染产物被识别器
|
|
485
518
|
* 与 lint 判定为合规态,渲染与识别的回环由测试守卫
|
|
486
519
|
*
|
|
487
520
|
* @remarks
|
|
488
|
-
*
|
|
489
|
-
*
|
|
521
|
+
* 五件套分工:README.md 承载标题、元数据与导览,spec.md 承载四节正文与交付
|
|
522
|
+
* 记录,tasks.md、checklist.md、progress.md 分别承载任务分解、验收清单与
|
|
523
|
+
* 进展流水。注册表 README 为工具 owned 索引档:索引节由本渲染器整体再生,
|
|
524
|
+
* 人工请在索引节之外追加内容并自行维护
|
|
490
525
|
*/
|
|
491
526
|
/**
|
|
492
527
|
* instance 模式渲染入参
|
|
@@ -510,18 +545,50 @@ type FeatureTemplateValues = {
|
|
|
510
545
|
source: string;
|
|
511
546
|
};
|
|
512
547
|
/**
|
|
513
|
-
*
|
|
548
|
+
* 渲染条目 README.md 全文,标题、元数据与五件导览
|
|
514
549
|
*
|
|
515
550
|
* @param values - 实际值入参
|
|
516
|
-
* @returns 可直接落盘的
|
|
551
|
+
* @returns 可直接落盘的 README.md 全文
|
|
517
552
|
*/
|
|
518
|
-
declare function
|
|
553
|
+
declare function renderEntryReadme(values: FeatureTemplateValues): string;
|
|
554
|
+
/**
|
|
555
|
+
* 渲染条目 spec.md 全文,四节正文骨架,建档即骨架内容随工作回填
|
|
556
|
+
*
|
|
557
|
+
* @returns 可直接落盘的 spec.md 全文
|
|
558
|
+
*/
|
|
559
|
+
declare function renderSpecMd(): string;
|
|
560
|
+
/**
|
|
561
|
+
* 渲染条目 tasks.md 全文,阶段到 Task 到 checkbox
|
|
562
|
+
*
|
|
563
|
+
* @returns 可直接落盘的 tasks.md 全文
|
|
564
|
+
*/
|
|
565
|
+
declare function renderTasksMd(): string;
|
|
566
|
+
/**
|
|
567
|
+
* 渲染条目 checklist.md 全文,按阶段分组 checkbox
|
|
568
|
+
*
|
|
569
|
+
* @returns 可直接落盘的 checklist.md 全文
|
|
570
|
+
*/
|
|
571
|
+
declare function renderChecklistMd(): string;
|
|
572
|
+
/**
|
|
573
|
+
* 渲染条目 progress.md 全文,带日期的进展事件流水
|
|
574
|
+
*
|
|
575
|
+
* @param values - 实际值入参
|
|
576
|
+
* @returns 可直接落盘的 progress.md 全文
|
|
577
|
+
*/
|
|
578
|
+
declare function renderProgressMd(values: FeatureTemplateValues): string;
|
|
579
|
+
/**
|
|
580
|
+
* 五件套文件清单,渲染产物落盘顺序,与 REQUIRED_ENTRY_FILES 单一口径对齐
|
|
581
|
+
*/
|
|
582
|
+
declare const TEMPLATE_FILES: readonly {
|
|
583
|
+
name: string;
|
|
584
|
+
render: (values: FeatureTemplateValues) => string;
|
|
585
|
+
}[];
|
|
519
586
|
/**
|
|
520
|
-
*
|
|
587
|
+
* 渲染骨架全集,供 template 命令做 text 输出,占位形态
|
|
521
588
|
*
|
|
522
|
-
* @returns
|
|
589
|
+
* @returns 五件骨架全文,以文件名分隔
|
|
523
590
|
*/
|
|
524
|
-
declare function
|
|
591
|
+
declare function renderSkeletonBundle(): string;
|
|
525
592
|
/**
|
|
526
593
|
* 索引条目,注册表 README 索引行的数据形态
|
|
527
594
|
*/
|
|
@@ -614,4 +681,4 @@ type TemplateFieldDoc = {
|
|
|
614
681
|
*/
|
|
615
682
|
declare const TEMPLATE_FIELDS: readonly TemplateFieldDoc[];
|
|
616
683
|
//#endregion
|
|
617
|
-
export { ADJUDICATION_PHRASE,
|
|
684
|
+
export { ADJUDICATION_PHRASE, ENTRY_METADATA_FILENAME, ENTRY_SPEC_FILENAME, FEATURE_SLUG_PATTERN, FILING_DATE_PATTERN, FeatureStatusKind, FeatureTemplateValues, FeaturesHealthInput, FeaturesHealthResult, FeaturesLintInput, FeaturesLintResult, FeaturesLintViolation, INDEX_SECTION_HEADING, IndexEntry, KEY_ADJUDICATION, KEY_BLOCKING, KEY_CANCEL_REASON, KEY_DOMAIN, KEY_FILING_DATE, KEY_HISTORY, KEY_PROGRESS_NOTE, KEY_SOURCE, KEY_STATUS, METADATA_LINE_PATTERN, OldestPlanning, PROGRESS_NOTE_MIN_LENGTH, ParsedEntryMetadata, ParsedFeatureRecord, ParsedMetadataLine, ParsedSpecSections, REQUIRED_ENTRY_FILES, REQUIRED_SECTION_HEADINGS, RecognizedFeature, SECTION_HEADING_ACCEPTANCE, SECTION_HEADING_CONTEXT, SECTION_HEADING_DELIVERY, SECTION_HEADING_MOTIVATION, SECTION_HEADING_REQUIREMENTS, SECTION_PLACEHOLDER, STATUS_LABELS, STATUS_LABEL_CANCELED, STATUS_LABEL_DELIVERED, STATUS_LABEL_FROZEN, STATUS_LABEL_IMPLEMENTING, STATUS_LABEL_PLANNING, ScopeHealth, ScopeScanStats, TEMPLATE_FIELDS, TEMPLATE_FILES, TemplateFieldDoc, applyFreeze, applyUnfreeze, daysBetween, extractIndexLineSlug, extractIndexSlugs, isExcludedPath, isRealCalendarDate, parseEntryMetadata, parseSpecSections, parseStatusLabel, recognizeFeatureDir, recognizeFeaturesDir, regenerateReadmeIndex, renderChecklistMd, renderEntryReadme, renderIndexLine, renderProgressMd, renderRegistryIndex, renderRegistryReadmeStub, renderSkeletonBundle, renderSpecMd, renderTasksMd, runFeaturesHealth, runFeaturesLint, splitRefList };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{join as e,relative as t}from"node:path";import{SEMANTIC_SLUG_PATTERN as n}from"@longzai-intelligence-docs/core";import{existsSync as r,readFileSync as i,readdirSync as a}from"node:fs";const o=n,s=`
|
|
2
|
-
`)}function
|
|
3
|
-
`),n=t.find(e=>e.startsWith(`# `)&&!e.startsWith(`## `))?.slice(2).trim()??null,r=t.findIndex(e=>e.startsWith(`## `)),i=r===-1?t.length:r,a=[];for(let e of t.slice(0,i)){let t=
|
|
4
|
-
`)
|
|
5
|
-
`);if(
|
|
6
|
-
`)
|
|
7
|
-
`)}
|
|
8
|
-
`)
|
|
9
|
-
`)
|
|
10
|
-
`)
|
|
11
|
-
`)
|
|
12
|
-
`)
|
|
13
|
-
`)}function
|
|
14
|
-
`)}function
|
|
15
|
-
`)
|
|
16
|
-
`)}const
|
|
17
|
-
`)
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{join as e,relative as t}from"node:path";import{SEMANTIC_SLUG_PATTERN as n}from"@longzai-intelligence-docs/core";import{existsSync as r,readFileSync as i,readdirSync as a}from"node:fs";const o=n,s=[`README.md`,`spec.md`,`tasks.md`,`checklist.md`,`progress.md`],c=`README.md`,l=`spec.md`,u=/^\*\*([^*:]+)\*\*:(.*)$/,d=`状态`,f=`立案日期`,ee=`所属域`,te=`来源`,p=`阻塞`,m=`进展注记`,h=`裁定说明`,ne=`取消原因`,g=`沿革`,_=`🔴 规划中`,v=`🟡 实现中`,y=`🟢 已交付`,b=`⚪ 已冻结`,x=`⚫ 已取消`,S=/* @__PURE__ */ new Map([[_,`planning`],[v,`implementing`],[y,`delivered`],[b,`frozen`],[x,`canceled`]]),C=[...S.keys()];function w(e){return S.get(e.trim())??null}const re=/^\d{4}-\d{2}-\d{2}$/,T=`## 一、需求动机`,E=`## 二、现状与背景`,D=`## 三、需求内容`,O=`## 四、验收口径`,k=`## 五、交付记录`,ie=[T,E,D,O],A=`待补充`,j=`用户裁定`,ae=4,oe=/[、,,]\s*/;function M(e){return e.split(oe).map(e=>e.trim()).filter(e=>e.length>0)}function N(e){let[t,n,r]=e.split(`-`).map(e=>Number.parseInt(e,10));if(t===void 0||n===void 0||r===void 0)return!1;let i=new Date(Date.UTC(t,n-1,r));return i.getUTCFullYear()===t&&i.getUTCMonth()===n-1&&i.getUTCDate()===r}function P(e,t){let n=Date.parse(`${e}T00:00:00Z`),r=Date.parse(`${t}T00:00:00Z`);return Math.round((r-n)/864e5)}function se(e,t){let n=e.indexOf(t);if(n===-1)return null;let r=e.length;for(let t=n+1;t<e.length;t+=1)if(e[t]?.startsWith(`## `)){r=t;break}return e.slice(n+1,r).join(`
|
|
2
|
+
`)}function F(e){let t=e.split(`
|
|
3
|
+
`),n=t.find(e=>e.startsWith(`# `)&&!e.startsWith(`## `))?.slice(2).trim()??null,r=t.findIndex(e=>e.startsWith(`## `)),i=r===-1?t.length:r,a=[];for(let e of t.slice(0,i)){let t=u.exec(e.trim());t!==null&&a.push({key:t[1]??``,value:(t[2]??``).trim()})}let o=e=>a.find(t=>t.key===e)?.value??null,s=o(d),c=o(p);return{title:n,metadataLines:a,statusLabel:s,status:s===null?null:w(s),filingDate:o(f),progressNote:o(m),adjudicationNote:o(h),cancelReason:o(ne),blockingRefs:c===null?[]:M(c)}}function I(e){let t=e.split(`
|
|
4
|
+
`);return{sectionsPresent:new Set(t.filter(e=>e.startsWith(`## `))),deliverySectionBody:se(t,k)}}function L(t,n){let r=e(t,n),u=[];try{u=a(r,{withFileTypes:!0}).filter(e=>e.isFile()).map(e=>e.name).sort()}catch{u=[]}let d=s.filter(e=>!u.includes(e)),f=null;if(u.includes(`README.md`)&&u.includes(`spec.md`))try{f={...F(i(e(r,c),`utf8`)),...I(i(e(r,l),`utf8`))}}catch{f=null}return{dirname:n,slug:o.test(n)?n:null,namingValid:o.test(n),hasEntry:d.length===0,files:u,missing:d,supplementary:u.filter(e=>!s.includes(e)),record:f}}function R(e){let t=[];try{t=a(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}return t.sort().map(t=>L(e,t))}function z(e,t){return t.some(t=>e===t.path||e.startsWith(`${t.path}/`))}function ce(t){let n=t.today??new Intl.DateTimeFormat(`en-CA`,{year:`numeric`,month:`2-digit`,day:`2-digit`}).format(/* @__PURE__ */ new Date),r=[];for(let i of t.config.scopes){let a=R(e(t.root,i.registryDir)).filter(n=>!z(e(i.registryDir,n.dirname),t.config.check.exclusions)),o={planning:0,implementing:0,delivered:0,frozen:0,canceled:0};for(let e of a)e.record?.status!==null&&e.record?.status!==void 0&&(o[e.record.status]+=1);let s=a.filter(e=>e.record?.status===`planning`).map(e=>({slug:e.dirname,filingDate:e.record?.filingDate??``,ageDays:P(e.record?.filingDate??n,n)})).sort((e,t)=>t.ageDays-e.ageDays)[0];r.push({scopeKey:i.key,registryDir:i.registryDir,total:a.length,byStatus:o,oldestPlanning:s===void 0||s.filingDate===``?null:s})}return{today:n,scopes:r}}function B(e){let t=e.findIndex(e=>e.startsWith(`## `));return t===-1?e.length:t}function V(e,t,n){let r=B(e),i=[...e];for(let e=0;e<r;e+=1){let r=u.exec((i[e]??``).trim());if(r!==null&&r[1]===t){i[e]=`**${t}**:${n}`;break}}return i.join(`
|
|
5
|
+
`)}function H(e,t){let n=B(e);return e.filter((e,r)=>{if(r>=n)return!0;let i=u.exec(e.trim());return i===null||i[1]!==t})}function le(e,t,n){let r=B(e),i=r;for(let n=0;n<r;n+=1){let r=u.exec((e[n]??``).trim());if(r!==null&&r[1]===t){i=n+1;break}}return[...e.slice(0,i),n,...e.slice(i)]}function U(e,t){let n=B(e);for(let r=0;r<n;r+=1){let n=u.exec((e[r]??``).trim());if(n!==null&&n[1]===t)return(n[2]??``).trim()}return null}function ue(e,t){let n=e.split(`
|
|
6
|
+
`);if(U(n,`状态`)===null)throw Error(`LifecycleError: status-line-missing`);return le(H(V(n,d,b).split(`
|
|
7
|
+
`),h),d,`**${h}**:${t}`).join(`
|
|
8
|
+
`)}function de(e,t,n){let r=e.split(`
|
|
9
|
+
`);if(U(r,`状态`)===null)throw Error(`LifecycleError: status-line-missing`);let i=H(V(r,d,_).split(`
|
|
10
|
+
`),h),a=U(i,g);return a===null?le(i,d,`**${g}**:${n} ${t}`).join(`
|
|
11
|
+
`):V(i,g,`${a},${n} ${t}`)}function W(e){return[`# ${e.title}`,``,`**${d}**:🔴 规划中`,`**${f}**:${e.filingDate}`,`**${ee}**:${e.domain}`,`**${te}**:${e.source}`,``,`## 导览`,``,`- [需求规格](spec.md)——动机、现状、需求内容与验收口径`,`- [任务分解](tasks.md)——阶段与任务 checkbox`,`- [验收清单](checklist.md)——按阶段分组验收项`,`- [进展流水](progress.md)——带日期的进展事件`,``].join(`
|
|
12
|
+
`)}function G(){return[T,``,`${A}:为什么做,动机与问题背景`,``,E,``,`${A}:现状描述与证据`,``,D,``,`${A}:需求条目,EARS 风格 Scenario 列表`,``,O,``,"```criteria",`${A}:一行一判据`,"```",``].join(`
|
|
13
|
+
`)}function K(){return[`# 任务分解`,``,`## 阶段一`,``,`- [ ] Task 1:<任务>`,` - [ ] <子任务>`,``].join(`
|
|
14
|
+
`)}function q(){return[`# 验收清单`,``,`## 阶段一`,``,`- [ ] <验收项>`,``].join(`
|
|
15
|
+
`)}function J(e){return[`# 进展流水`,``,`- ${e.filingDate} 立项`,``].join(`
|
|
16
|
+
`)}const Y=[{name:`README.md`,render:W},{name:`spec.md`,render:()=>G()},{name:`tasks.md`,render:()=>K()},{name:`checklist.md`,render:()=>q()},{name:`progress.md`,render:J}];function fe(){return Y.map(e=>`===== ${e.name} =====\n${e.render({title:`<一句话标题>`,filingDate:`<YYYY-MM-DD>`,domain:`<所属域人类可读名>`,source:`<需求来源>`})}`).join(`
|
|
17
|
+
`)}const X=`## 需求索引`,Z=`暂无条目`;function Q(e){return`- [${e.title}](${e.slug}/README.md) | ${e.statusLabel} | 立案 ${e.filingDate}`}const pe=/\]\(([^()/\s]+)\/README\.md\)/;function $(e){let t=pe.exec(e);return t===null?null:t[1]??null}function me(e){return e.split(`
|
|
18
|
+
`).map(e=>$(e)).filter(e=>e!==null)}const he=["本目录是 lzi-features 注册表,每个需求一个 `<slug>/` 目录,条目为五件套:`README.md`、`spec.md`、`tasks.md`、`checklist.md`、`progress.md`。",``,`## 使用口径`,``,"- 立项:`lzi-features create --title <标题>`,slug 围绕单一需求拟定,中文标题须显式 `--slug`","- 审计:`lzi-features lint` 只读判定,豁免走配置基线棘轮,只许缩短",`- 索引:本 README 的「${X.slice(3)}」节由工具再生,人工内容请写在本节之外`];function ge(e){return[`# ${e} features 注册表`,``,...he,``,X,``,Z,``].join(`
|
|
19
|
+
`)}function _e(e,t){let n=t.length===0?[Z]:[...t].sort((e,t)=>e.slug.localeCompare(t.slug)).map(Q);return[`# ${e} features 注册表`,``,...he,``,X,``,...n,``].join(`
|
|
20
|
+
`)}function ve(e,t,n){if(e===null)return _e(t,n);let r=n.length===0?[Z]:[...n].sort((e,t)=>e.slug.localeCompare(t.slug)).map(Q),i=e.split(`
|
|
21
|
+
`),a=i.indexOf(X),o=a===-1?[...i]:i.slice(0,a);for(;o.length>0&&(o[o.length-1]?.trim()??`x`)===``;)o.pop();return[...o,``,X,``,...r,``].join(`
|
|
22
|
+
`)}const ye=[{name:`dirname`,required:!0,description:`语义 slug,纯小写字母 kebab,禁数字,围绕单一需求拟定,禁止手工改目录名`},{name:`README.md`,required:!0,description:`条目着陆页:标题、加粗键元数据行与五件导览`},{name:`spec.md`,required:!0,description:`需求规格四节:需求动机、现状与背景、需求内容、验收口径,交付记录为第五节`},{name:`tasks.md`,required:!0,description:`阶段到 Task 到 checkbox 任务分解`},{name:`checklist.md`,required:!0,description:`按阶段分组 checkbox 验收清单`},{name:`progress.md`,required:!0,description:`带日期的进展事件流水`},{name:`状态`,required:!0,description:`五态词表之一:${C.join(`、`)}`},{name:`立案日期`,required:!0,description:`YYYY-MM-DD,真实日历日,README 头部加粗键行`},{name:`所属域`,required:!0,description:`scope 人类可读名,README 头部加粗键行`},{name:`来源`,required:!0,description:`需求来源,用户指令出处或渠道名,README 头部加粗键行`},{name:`进展注记`,required:!1,description:`实现中黄灯强制,不少于 4 字,README 头部加粗键行`},{name:`裁定说明`,required:!1,description:`冻结态强制,须含用户裁定字样,README 头部加粗键行`},{name:`取消原因`,required:!1,description:`取消态强制,README 头部加粗键行`},{name:`阻塞`,required:!1,description:`同注册表 slug 引用列表,顿号分隔,引用未知目录计违规`},{name:`交付记录`,required:!1,description:`spec.md 第五节「${k.slice(3)}」,已交付态强制且不得为占位内容`},{name:`补充材料`,required:!1,description:`需求目录内五件之外的文件,仅观测不判违规`}];function be(e){return!e.split(`
|
|
23
|
+
`).some(e=>e.trim().length>0&&!e.trim().startsWith(`待补充`))}function xe(e,t,n){let r=[],i=`${n}/${c}`,a=`${n}/${l}`,o=e.record;if(o===null)return r;if(o.statusLabel===null?r.push({rule:`status-line-missing`,file:i,message:`README 头部缺「**状态**:标签」元数据行`}):o.status===null&&r.push({rule:`status-label-unknown`,file:i,message:`状态标签「${o.statusLabel}」不在五态词表`}),o.filingDate===null||!re.test(o.filingDate)?r.push({rule:`filing-date-invalid`,file:i,message:`立案日期须为 YYYY-MM-DD 形态元数据行`}):N(o.filingDate)||r.push({rule:`filing-date-invalid`,file:i,message:`立案日期「${o.filingDate}」非真实日历日`}),o.status===`implementing`){let e=o.progressNote?.replaceAll(/\s/g,``).length??0;(o.progressNote===null||e<4)&&r.push({rule:`active-no-progress-note`,file:i,message:`实现中状态须附进展注记且不少于 4 字`})}o.status===`delivered`&&(o.sectionsPresent.has(`## 五、交付记录`)?(o.deliverySectionBody===null||be(o.deliverySectionBody))&&r.push({rule:`delivered-placeholder`,file:a,message:`交付记录节不得为空或占位内容`}):r.push({rule:`delivered-no-section`,file:a,message:`已交付状态须有 spec.md 第五节交付记录`})),o.status===`frozen`&&(o.adjudicationNote===null||!o.adjudicationNote.includes(`用户裁定`))&&r.push({rule:`frozen-no-adjudication`,file:i,message:`冻结状态须附裁定说明且含「${j}」字样`}),o.status===`canceled`&&o.cancelReason===null&&r.push({rule:`canceled-no-reason`,file:i,message:`取消状态须附取消原因`});let s=/* @__PURE__ */ new Map;for(let e of o.metadataLines)s.set(e.key,(s.get(e.key)??0)+1);for(let[e,t]of s)t>1&&r.push({rule:`duplicate-metadata-key`,file:i,message:`元数据键「${e}」出现 ${t} 次,须唯一`});for(let e of o.blockingRefs)t.has(e)||r.push({rule:`blocking-ref-unknown`,file:i,message:`阻塞引用「${e}」不在本注册表合法 slug 集内`});return r}function Se(t,n,a,o){let s=[],c=R(e(t,n)).filter(t=>!z(e(n,t.dirname),a)),l=new Set(c.filter(e=>e.namingValid).map(e=>e.dirname)),u=new Set(c.filter(e=>e.namingValid&&e.hasEntry).map(e=>e.dirname));for(let t of c){let r=e(n,t.dirname);t.namingValid?t.hasEntry?s.push(...xe(t,l,r)):s.push({rule:`entry-files-missing`,file:r,message:`五件套缺件:${t.missing.join(`、`)}`}):s.push({rule:`slug-policy-violation`,file:r,message:`目录名须为语义 slug 形态,纯小写字母 kebab,禁数字,围绕单一需求拟定`})}let d=e(t,n,`README.md`);if(!r(d))s.push({rule:`index-out-of-sync`,file:e(n,`README.md`),message:`注册表缺 README 索引档,可执行 lzi-features index 再生`});else{let t=me(i(d,`utf8`));for(let r of u)t.includes(r)||s.push({rule:`index-out-of-sync`,file:e(n,`README.md`),message:`索引缺条目「${r}」,可执行 lzi-features index 再生`});for(let r of t)u.has(r)||s.push({rule:`index-out-of-sync`,file:e(n,`README.md`),message:`索引含失效条目「${r}」,可执行 lzi-features index 再生`})}return o.push({scopeKey:n,registryDir:n,featureCount:c.length}),s}function Ce(n){let r=[],i=[];for(let e of n.config.scopes)r.push(...Se(n.root,e.registryDir,n.config.check.exclusions,i));for(let a of n.extraDirs??[]){let o=e(n.root,a);r.push(...Se(o,t(n.root,o),[],i))}let a=new Set(n.config.check.baseline.map(e=>`${e.file}|${e.rule}`)),o=0;return{violations:r.filter(e=>{let t=a.has(`${e.file}|${e.rule}`);return t&&(o+=1),!t}),rawCount:r.length,exemptedCount:o,stats:i}}export{j as ADJUDICATION_PHRASE,c as ENTRY_METADATA_FILENAME,l as ENTRY_SPEC_FILENAME,o as FEATURE_SLUG_PATTERN,re as FILING_DATE_PATTERN,X as INDEX_SECTION_HEADING,h as KEY_ADJUDICATION,p as KEY_BLOCKING,ne as KEY_CANCEL_REASON,ee as KEY_DOMAIN,f as KEY_FILING_DATE,g as KEY_HISTORY,m as KEY_PROGRESS_NOTE,te as KEY_SOURCE,d as KEY_STATUS,u as METADATA_LINE_PATTERN,ae as PROGRESS_NOTE_MIN_LENGTH,s as REQUIRED_ENTRY_FILES,ie as REQUIRED_SECTION_HEADINGS,O as SECTION_HEADING_ACCEPTANCE,E as SECTION_HEADING_CONTEXT,k as SECTION_HEADING_DELIVERY,T as SECTION_HEADING_MOTIVATION,D as SECTION_HEADING_REQUIREMENTS,A as SECTION_PLACEHOLDER,C as STATUS_LABELS,x as STATUS_LABEL_CANCELED,y as STATUS_LABEL_DELIVERED,b as STATUS_LABEL_FROZEN,v as STATUS_LABEL_IMPLEMENTING,_ as STATUS_LABEL_PLANNING,ye as TEMPLATE_FIELDS,Y as TEMPLATE_FILES,ue as applyFreeze,de as applyUnfreeze,P as daysBetween,$ as extractIndexLineSlug,me as extractIndexSlugs,z as isExcludedPath,N as isRealCalendarDate,F as parseEntryMetadata,I as parseSpecSections,w as parseStatusLabel,L as recognizeFeatureDir,R as recognizeFeaturesDir,ve as regenerateReadmeIndex,q as renderChecklistMd,W as renderEntryReadme,Q as renderIndexLine,J as renderProgressMd,_e as renderRegistryIndex,ge as renderRegistryReadmeStub,fe as renderSkeletonBundle,G as renderSpecMd,K as renderTasksMd,ce as runFeaturesHealth,Ce as runFeaturesLint,M as splitRefList};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-features/ledger",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@longzai-intelligence-docs/core": "0.0.12",
|
|
33
|
-
"@longzai-intelligence-features/config": "0.0.
|
|
33
|
+
"@longzai-intelligence-features/config": "0.0.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/bun": "latest"
|