@longzai-intelligence-specs/cli 0.0.1
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 +11 -0
- package/dist/index.js +1 -0
- package/dist/rolldown-runtime-BqT_7tdF.js +1 -0
- package/package.json +46 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
//#region src/plugins/specs.plugin.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* specs 内置插件(契约适配层)
|
|
5
|
+
*
|
|
6
|
+
* 引擎核不搬家——本文件仅将门禁与读取命令包装为 docs 平台插件契约形态,
|
|
7
|
+
* 供 lzi-docs 宿主经 plugins.specs 声明装载。CLI 侧直接消费引擎核不变。
|
|
8
|
+
*/
|
|
9
|
+
declare const specsPlugin: import("@longzai-intelligence-docs/core").DocsPlugin;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { specsPlugin };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{createCli as e,defineCommand as t}from"@longzai-intelligence-cli/core";import{clackInteraction as n,picocolorsColor as r}from"@longzai-intelligence-cli/standard";import{ASCII_KEBAB_SLUG_PATTERN as i,TEMPLATE_FIELDS as a,TEMPLATE_FILES as o,compactToHyphenDate as s,hyphenToCompactDate as c,isRealCompactDate as l,renderRegistryReadmeStub as u,renderSkeletonBundle as d,runSpecsCheck as f}from"@longzai-intelligence-specs/ledger";import{join as p,relative as m,resolve as h}from"node:path";import*as g from"zod";import{loadLziSpecsConfig as _,renderConfigScaffold as v}from"@longzai-intelligence-specs/config";import{existsSync as y,mkdirSync as b,writeFileSync as x}from"node:fs";import{definePlugin as S,pluginCommand as C}from"@longzai-intelligence-docs/core";function w(){return h(process.cwd())}async function T(e){let t=await _(e===void 0?{}:{configPath:e});return t.ok||(process.stderr.write(`错误: ${t.reason}\n`),process.exit(1)),{config:t.config,configFilePath:t.configFilePath}}function E(e){process.stdout.write(`[INFO] ${e}\n`)}function D(e){process.stdout.write(`[SUCCESS] ${e}\n`)}function O(e){process.stdout.write(`${e}\n`)}function k(e){process.stderr.write(`错误: ${e}\n`),process.exit(1)}function A(e,t){let n=null,r=-1;for(let i of e.scopes)for(let e of i.paths)(e===`.`||e===``||t===e||t.startsWith(`${e}/`))&&e.length>r&&(n=i.key,r=e.length);return n}function j(){return new Intl.DateTimeFormat(`en-CA`,{year:`numeric`,month:`2-digit`,day:`2-digit`}).format(/* @__PURE__ */ new Date)}function M(){return c(j())}function N(e){t(e,{name:`check`,description:`命名审计 + 格式三态识别(只读——变体容忍,缺件拦截,零注入)`,options:[{flags:`--scope <scope>`,description:`限定 scope key`},{flags:`--config <path>`,description:`显式配置路径`}],schema:g.looseObject({scope:g.string().optional(),config:g.string().optional()}),action:async e=>{let t=w(),{config:n}=await T(e.config),r=e.scope===void 0?n.scopes:n.scopes.filter(t=>t.key===e.scope);r.length===0&&k(`scope「${e.scope}」未登记`);let i={...n,scopes:r},a=f({root:t,config:i});for(let e of a.violations)O(`${e.file} [${e.rule}] ${e.message}`);for(let e of a.variants)E(`[variant] ${e.dirname} 额外件:${e.extra.join(`、`)}(容忍不改写——存量不追溯)`);let o={standard:0,variant:0,incomplete:0};for(let e of a.recognized)o[e.state]+=1;E(`识别 ${a.recognized.length} 目录|标准 ${o.standard}|变体 ${o.variant}|缺件 ${o.incomplete}|豁免 ${a.exemptedCount} 项(基线 ${n.check.baseline.length} 条)`),a.violations.length>0&&k(`check 违例 ${a.violations.length} 项`),D(`check 通过(registryDir: ${r.map(e=>p(e.registryDir)).join(`、`)})`)}})}function P(e){t(e,{name:`init`,description:`生成 lzi-specs.config.ts + 注册表 README 存根(幂等不覆盖)`,options:[{flags:`--scope <scope>`,description:`scope key(缺省 root)`},{flags:`--title <title>`,description:`scope 人类可读名(缺省 全局)`},{flags:`--registry-dir <dir>`,description:`注册表目录(缺省 docs/specs)`},{flags:`--dry-run`,description:`只呈现不落盘`}],schema:g.looseObject({scope:g.string().optional(),title:g.string().optional(),registryDir:g.string().optional(),dryRun:g.boolean().optional()}),action:async e=>{let t=w(),n=e.scope??`root`,r=e.title??`全局`,i=e.registryDir??`docs/specs`,a=p(t,`lzi-specs.config.ts`),o=p(t,i,`README.md`),s=v({scopeKey:n,scopeTitle:r,registryDir:i});if(e.dryRun){E(`[dry-run] 将落盘 ${a}:\n${s}`),E(`[dry-run] 将落盘 ${o}(README 存根)`);return}y(a)?E(`配置已存在,跳过:${a}`):(x(a,s),D(`已生成配置:${a}`)),y(o)?E(`README 已存在,跳过:${o}`):(b(p(t,i),{recursive:!0}),x(o,u(r)),D(`已生成注册表 README 存根:${o}`))}}),t(e,{name:`template`,description:`标准三件套骨架与字段契约(Trae spec 格式)`,options:[{flags:`--format <format>`,description:`text | json(json = 字段契约,供 agent 机读)`}],schema:g.looseObject({format:g.enum([`text`,`json`]).optional()}),action:async e=>{if(e.format===`json`){process.stdout.write(`${JSON.stringify(a,null,2)}\n`);return}e.format!==void 0&&k(`不支持的 format:${e.format}`),process.stdout.write(d())}})}function F(e){t(e,{name:`create`,description:`立项(标准三件套脚手架——目录 spec-YYYYMMDD-<slug>,日期缺省今日)`,options:[{flags:`--title <title>`,description:`一句话标题(必填)`},{flags:`--slug <slug>`,description:`slug(缺省由标题派生)`},{flags:`--date <date>`,description:`立项日期 YYYYMMDD(缺省今日)`},{flags:`--scope <scope>`,description:`scope key(缺省按 cwd 解析)`},{flags:`--dry-run`,description:`只呈现不落盘`},{flags:`--config <path>`,description:`显式配置路径`}],schema:g.looseObject({title:g.string(),slug:g.string().optional(),date:g.string().optional(),scope:g.string().optional(),dryRun:g.boolean().optional(),config:g.string().optional()}),action:async e=>{let t=w(),{config:n}=await T(e.config),r=m(t,process.cwd()),a=e.scope??A(n,r)??k(`cwd「${r}」未命中任何 scope 覆盖面——候选:${n.scopes.map(e=>e.key).join(`、`)}(或显式 --scope)`),c=n.scopes.find(e=>e.key===a)??k(`scope「${a}」未登记`),u=e.date??M();(!/^\d{8}$/.test(u)||!l(u))&&k(`立项日期「${u}」须为真实日历日的 YYYYMMDD 形态`);let d=e.slug??e.title.toLowerCase().replace(/[\s_]+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),f=`spec-${u}-${i.test(d)?d:k(`slug 须为纯 ASCII kebab,中文标题请显式提供 --slug <slug>`)}`,h=p(t,c.registryDir,f);if(y(h)&&k(`目标已存在:${h}(同日同 slug 撞车——换 slug 或显式 --date)`),e.dryRun){E(`[dry-run] 将落盘目录 ${h}(标准三件套)`);return}b(h,{recursive:!0});let g={title:e.title,date:s(u)};for(let e of o)x(p(h,e.name),e.render(g));D(`已立项:${m(t,h)}/(scope ${a},三件套:spec/tasks/checklist)`),E(`识别只读:lzi-specs check 三态判定(标准 / 变体容忍 / 缺件拦截)`)}})}function I(e){P(e),F(e),N(e)}const L=S({name:`specs`,version:`0.1.0`,commands:[()=>z(),()=>B()]}),R={scopes:[{key:`root`,title:`全局`,paths:[`.`],registryDir:`docs/specs`}],check:{baseline:[]}};function z(){return C({name:`specs-check`,description:`specs 目录命名审计 + 格式三态识别(只读零注入)`,schema:g.object({}),action:async()=>{let e=f({root:process.cwd(),config:R});for(let t of e.violations)process.stderr.write(`[${t.rule}] ${t.file} ${t.message}\n`);e.violations.length>0&&process.exit(1)}})}function B(){return C({name:`specs-template`,description:`specs 标准三件套字段契约(agent 机读)`,schema:g.object({}),action:async()=>{process.stdout.write(`${JSON.stringify(a,null,2)}\n`)}})}async function V(){let t=e({name:`lzi-specs`,description:`Longzai Intelligence Specs CLI(脚手架 + 只读识别审计 · Trae 三件套标准)`,interaction:n,color:r});I(t),await t.parseAsync(process.argv)}await V();export{L as specsPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:module";export{};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-specs/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Longzai Intelligence specs CLI 工具(脚手架 + 只读识别审计 · Trae 三件套标准)",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"bin": {
|
|
7
|
+
"lzi-specs": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "lzi-builder",
|
|
23
|
+
"build:prod": "NODE_ENV=production bun run build",
|
|
24
|
+
"prepublishOnly": "bun run build:prod",
|
|
25
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
26
|
+
"typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
|
|
27
|
+
"typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
|
|
28
|
+
"typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
|
|
29
|
+
"lint": "oxlint && oxfmt --check",
|
|
30
|
+
"lint:fix": "oxlint --fix && oxfmt",
|
|
31
|
+
"test": "bun test",
|
|
32
|
+
"test:watch": "bun test --watch",
|
|
33
|
+
"test:coverage": "bun test --coverage"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@longzai-intelligence-cli/core": "^0.0.10",
|
|
37
|
+
"@longzai-intelligence-cli/standard": "^0.0.10",
|
|
38
|
+
"@longzai-intelligence-docs/core": "0.0.8",
|
|
39
|
+
"@longzai-intelligence-specs/config": "0.0.1",
|
|
40
|
+
"@longzai-intelligence-specs/ledger": "0.0.1",
|
|
41
|
+
"zod": "^4.4.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/bun": "latest"
|
|
45
|
+
}
|
|
46
|
+
}
|