@longzai-intelligence-records/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 +47 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
//#region src/plugins/records.plugin.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* records 内置插件(契约适配层)
|
|
5
|
+
*
|
|
6
|
+
* 引擎核不搬家——本文件仅将门禁与读取命令包装为 docs 平台插件契约形态,
|
|
7
|
+
* 供 lzi-docs 宿主经 plugins.records 声明装载。CLI 侧直接消费引擎核不变。
|
|
8
|
+
*/
|
|
9
|
+
declare const recordsPlugin: import("@longzai-intelligence-docs/core").DocsPlugin;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { recordsPlugin };
|
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,renderRecordTemplate as o,renderRecordTemplateSkeleton as s,renderRegistryReadmeStub as c,runIndexCheck as l,runRecordsLint as u}from"@longzai-intelligence-records/ledger";import{join as d,relative as f,resolve as p}from"node:path";import*as m from"zod";import{loadLziRecordsConfig as h,renderConfigScaffold as g}from"@longzai-intelligence-records/config";import{parseNumberingPluginConfig as _,runNumberingNext as v}from"@longzai-intelligence-docs/numbering-plugin";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 p(process.cwd())}async function T(e){let t=await h(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(e){t(e,{name:`lint`,description:`注册表 lint(文件名 / H1 / 头部元数据 + 棘轮基线豁免)`,options:[{flags:`--config <path>`,description:`显式配置路径`}],schema:m.looseObject({config:m.string().optional()}),action:async e=>{let t=w(),{config:n}=await T(e.config),r=u({root:t,config:n});for(let e of r.violations)O(`${e.file}:${e.line} [${e.rule}] ${e.message}`);E(`扫描 ${r.fileCount} 文件|豁免 ${r.exemptedCount} 项(基线 ${n.lint.baseline.length} 条)`),r.violations.length>0&&k(`lint 违例 ${r.violations.length} 项`),D(`lint 通过(零违例)`)}});let n=e.command(`index`).description(`README 索引新鲜度检查(只读——索引表人工维护,工具只检查不写入)`),r=m.looseObject({scope:m.string().optional(),config:m.string().optional()});t(n,{name:`check`,description:`索引新鲜度判定(缺行/多行/slug 漂移;报文附期望行供人工粘贴)`,options:[{flags:`--scope <scope>`,description:`限定 scope key`},{flags:`--config <path>`,description:`显式配置路径`}],schema:r,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=0;for(let e of r){let n=l({registryDirAbs:d(t,e.registryDir)});for(let t of n.findings)O(`[index:${t.kind}] [${e.key}] ${t.file} ${t.message}`);if(n.findings.length>0){E(`期望行(${e.key},人工粘贴进 README):`);for(let e of n.expectedLines)E(` ${e}`)}i+=n.findings.length}i>0&&k(`index:check ${i} 项差异——索引表人工维护,请按期望行修正 README`),D(`index:check 通过(${r.length} scope 索引新鲜)`)}})}function N(e){t(e,{name:`create`,description:`建档(取号经 numbering 插件,标准模板落盘)`,options:[{flags:`--title <title>`,description:`一句话标题(必填)`},{flags:`--slug <slug>`,description:`slug(缺省由标题派生)`},{flags:`--source <source>`,description:`来源说明(必填——头部元数据强制项)`},{flags:`--ref <ref>`,description:`关联条目(可选,头部元数据行)`},{flags:`--scope <scope>`,description:`scope key(缺省按 cwd 解析)`},{flags:`--dry-run`,description:`只呈现不落盘`},{flags:`--config <path>`,description:`显式配置路径`}],schema:m.looseObject({title:m.string(),slug:m.string().optional(),source:m.string(),ref:m.string().optional(),scope:m.string().optional(),dryRun:m.boolean().optional(),config:m.string().optional()}),action:async e=>{let t=w(),{config:n}=await T(e.config),r=f(t,process.cwd()),a=e.scope??A(n,r)??k(`cwd「${r}」未命中任何 scope 覆盖面——候选:${n.scopes.map(e=>e.key).join(`、`)}(或显式 --scope)`),s=n.scopes.find(e=>e.key===a)??k(`scope「${a}」未登记`),c=_({scopes:n.scopes.map(e=>({key:e.key,title:e.title,paths:e.paths,registryDir:e.registryDir}))}),l=v({root:t,config:c,scopeKey:a});l.ok||k(l.error);let u=e.slug??e.title.toLowerCase().replace(/[\s_]+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``),p=i.test(u)?u:k(`slug 须为纯 ASCII kebab,中文标题请显式提供 --slug <slug>`),m=o({number:l.number,slug:p,title:e.title,date:j(),source:e.source,ref:e.ref}),h=d(t,s.registryDir,`${l.number}-${p}.md`);if(y(h)&&k(`目标已存在:${h}(编号或 slug 撞车——重跑取号或换 slug)`),e.dryRun){E(`[dry-run] 将落盘 ${h}:\n${m}`);return}b(d(t,s.registryDir),{recursive:!0}),x(h,m),D(`已建档:${f(t,h)}(scope ${a},编号 ${l.number})`),E(`索引行人工登记:lzi-records index check 报差量并附期望行`)}})}function P(e){t(e,{name:`init`,description:`生成 lzi-records.config.ts + 注册表 README 存根(幂等不覆盖)`,options:[{flags:`--scope <scope>`,description:`scope key(缺省 root)`},{flags:`--title <title>`,description:`scope 人类可读名(缺省 全局)`},{flags:`--registry-dir <dir>`,description:`注册表目录(缺省 docs/records)`},{flags:`--dry-run`,description:`只呈现不落盘`}],schema:m.looseObject({scope:m.string().optional(),title:m.string().optional(),registryDir:m.string().optional(),dryRun:m.boolean().optional()}),action:async e=>{let t=w(),n=e.scope??`root`,r=e.title??`全局`,i=e.registryDir??`docs/records`,a=d(t,`lzi-records.config.ts`),o=d(t,i,`README.md`),s=g({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(d(t,i),{recursive:!0}),x(o,c(r)),D(`已生成注册表 README 存根:${o}`))}}),t(e,{name:`template`,description:`标准模板骨架与字段契约`,options:[{flags:`--format <format>`,description:`text | json(json = 字段契约,供 agent 机读)`}],schema:m.looseObject({format:m.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(s())}})}function F(e){P(e),N(e),M(e)}const I=S({name:`records`,version:`0.1.0`,commands:[()=>R(),()=>z(),()=>B()]}),L={scopes:[{key:`root`,title:`全局`,paths:[`.`],registryDir:`docs/records`}],lint:{baseline:[]}};function R(){return C({name:`records-lint`,description:`records 注册表 lint(文件名 / H1 / 头部元数据 + 棘轮基线)`,schema:m.object({}),action:async()=>{let e=u({root:process.cwd(),config:L});for(let t of e.violations)process.stderr.write(`[${t.rule}] ${t.file}:${t.line} ${t.message}\n`);e.violations.length>0&&process.exit(1)}})}function z(){return C({name:`records-index-check`,description:`records README 索引差量(只读——索引行人工登记)`,schema:m.object({}),action:async()=>{let e=l({registryDirAbs:`${process.cwd()}/docs/records`});for(let t of e.findings)process.stderr.write(`[index:${t.kind}] ${t.file} ${t.message}\n`);e.findings.length>0&&process.exit(1)}})}function B(){return C({name:`records-template`,description:`records 标准模板字段契约(agent 机读)`,schema:m.object({}),action:async()=>{process.stdout.write(`${JSON.stringify(a,null,2)}\n`)}})}async function V(){let t=e({name:`lzi-records`,description:`Longzai Intelligence Records CLI(文件化注册表 · 广义降级 fallback 通道)`,interaction:n,color:r});F(t),await t.parseAsync(process.argv)}await V();export{I as recordsPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:module";export{};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-records/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Longzai Intelligence records CLI 工具(文件化注册表 · 广义降级 fallback 通道)",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"bin": {
|
|
7
|
+
"lzi-records": "./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-docs/numbering-plugin": "0.0.9",
|
|
40
|
+
"@longzai-intelligence-records/config": "0.0.1",
|
|
41
|
+
"@longzai-intelligence-records/ledger": "0.0.1",
|
|
42
|
+
"zod": "^4.4.3"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/bun": "latest"
|
|
46
|
+
}
|
|
47
|
+
}
|