feat: Update command validation tools and improve README documentation

This commit is contained in:
catlog22
2026-01-24 08:41:32 +08:00
parent 24a28f289d
commit fd50adf581
5 changed files with 31 additions and 14 deletions

View File

@@ -40,6 +40,6 @@
| phases/orchestrator.md | 编排逻辑 |
| phases/state-schema.md | 状态定义 |
| phases/actions/*.md | 动作实现 |
| specs/chain-registry.json | 命令元数据 |
| specs/chain-validation-rules.md | 验证规则 |
| tools/chain-validate.js | 验证工具 |
| specs/specs.md | 命令库、验证规则、注册表 |
| tools/chain-validate.cjs | 验证工具 |
| tools/command-registry.cjs | 命令注册表工具 |

View File

@@ -224,10 +224,9 @@ Bash(`mkdir -p "${workDir}/logs"`);
| [phases/actions/action-command-execute.md](phases/actions/action-command-execute.md) | 命令执行动作 |
| [phases/actions/action-complete.md](phases/actions/action-complete.md) | 完成动作 |
| [phases/actions/action-abort.md](phases/actions/action-abort.md) | 中止动作 |
| [specs/command-library.md](specs/command-library.md) | 命令库 |
| [specs/chain-registry.json](specs/chain-registry.json) | 命令元数据 |
| [specs/chain-validation-rules.md](specs/chain-validation-rules.md) | 验证规则 |
| [tools/chain-validate.js](tools/chain-validate.js) | 验证工具 |
| [specs/specs.md](specs/specs.md) | 命令库、验证规则、注册表 |
| [tools/chain-validate.cjs](tools/chain-validate.cjs) | 验证工具 |
| [tools/command-registry.cjs](tools/command-registry.cjs) | 命令注册表工具 |
---

View File

@@ -12,6 +12,7 @@ const state = {
session_id: `coord-${timestamp}`,
status: 'running',
started_at: new Date().toISOString(),
task_description: '',
command_chain: [],
current_command_index: 0,
execution_results: [],

View File

@@ -276,14 +276,14 @@ tdd-plan → lite-execute
## 验证工具
### chain-validate.js
### chain-validate.cjs
位置: `tools/chain-validate.js`
位置: `tools/chain-validate.cjs`
验证命令链合法性:
```bash
node tools/chain-validate.js plan execute test-cycle-execute
node tools/chain-validate.cjs plan execute test-cycle-execute
```
输出:

View File

@@ -14,9 +14,16 @@
const fs = require('fs');
const path = require('path');
// Load registry
const registryPath = path.join(__dirname, '..', 'specs', 'chain-registry.json');
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
// Optional registry loading - gracefully degrade if not found
let registry = null;
try {
const registryPath = path.join(__dirname, '..', 'specs', 'chain-registry.json');
if (fs.existsSync(registryPath)) {
registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
}
} catch (error) {
// Registry not available - dependency validation will be skipped
}
class ChainValidator {
constructor(registry) {
@@ -161,10 +168,15 @@ class ChainValidator {
}
validateDependencies(chain) {
// Skip if registry not available
if (!this.registry || !this.registry.commands) {
return;
}
for (let i = 0; i < chain.length; i++) {
const cmd = chain[i];
const cmdMeta = this.registry.commands[cmd];
if (!cmdMeta) continue;
const deps = cmdMeta.dependencies || [];
@@ -208,6 +220,11 @@ class ChainValidator {
}
validateCommandExistence(chain) {
// Skip if registry not available
if (!this.registry || !this.registry.commands) {
return;
}
for (const cmd of chain) {
if (!this.registry.commands[cmd]) {
this.errors.push({