Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build/
.env.local
.DS_Store
.context/
MEMORY/
Binary file added Evaluating AGENTS.md.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion cli/reins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reins-cli",
"version": "0.1.2",
"version": "0.1.3",
"description": "Scaffold, audit, and evolve projects using the Harness Engineering methodology",
"type": "module",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions cli/reins/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe("reins audit", () => {

const result = JSON.parse(stdout);
expect(result.total_score).toBe(0);
expect(result.max_score).toBe(18);
expect(result.max_score).toBe(21);
expect(result.maturity_level).toBe("L0: Manual");
expect(result.scores.repository_knowledge.score).toBe(0);
expect(result.scores.architecture_enforcement.score).toBe(0);
Expand Down Expand Up @@ -268,7 +268,7 @@ describe("reins audit", () => {
expect(result).toHaveProperty("max_score");
expect(result).toHaveProperty("maturity_level");
expect(result).toHaveProperty("recommendations");
expect(result.max_score).toBe(18);
expect(result.max_score).toBe(21);
});

test("fails on nonexistent directory", async () => {
Expand Down Expand Up @@ -331,7 +331,7 @@ describe("reins evolve", () => {
const result = JSON.parse(stdout);
expect(result.command).toBe("evolve");
expect(result.current_level).toBe("L0: Manual");
expect(result.next_level).toBe("L1: Assisted");
expect(result.next_level).toBe("L1: Inloop");
expect(result.steps.length).toBe(5);
expect(result.success_criteria).toBeTruthy();
expect(result.weakest_dimensions).toBeDefined();
Expand All @@ -347,7 +347,7 @@ describe("reins evolve", () => {
// After init, should be at least L1
expect(result.current_level).toMatch(/L1|L2/);
if (result.current_level.startsWith("L1")) {
expect(result.next_level).toBe("L2: Steered");
expect(result.next_level).toBe("L2: Guided Outloop");
}
});

Expand Down
10 changes: 5 additions & 5 deletions cli/reins/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ EXAMPLES:
reins doctor . # Get prescriptive fixes

MATURITY LEVELS:
L0: Manual (0-4) Traditional engineering
L1: Assisted (5-8) Agents help, humans still code
L2: Steered (9-13) Humans steer, agents execute
L3: Autonomous (14-16) Agents handle full lifecycle
L4: Self-Correcting (17-18) System maintains itself
L0: Manual (0-5) Traditional engineering
L1: Inloop (6-10) Agents in the loop, humans code
L2: Guided Outloop (11-15) Humans steer, agents execute
L3: Full Outloop (16-18) Agents handle full lifecycle
L4: Zero Touch (19-21) System maintains itself
`;
console.log(help);
}
Expand Down
59 changes: 54 additions & 5 deletions cli/reins/src/lib/audit/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, readFileSync } from "node:fs";
import { existsSync, readFileSync, readdirSync } from "node:fs";
import { join } from "node:path";
import { detectCliProject, detectMonorepoWorkspaces, scanWorkflowsForEnforcement } from "../detection";
import { findFiles } from "../filesystem";
Expand All @@ -22,22 +22,29 @@ export interface AuditRuntimeContext {
isCliRepo: boolean;
verifiedDocs: string[];
hasCleanupDocs: boolean;
hasAgentCommands: boolean;
hasSessionOrchestrator: boolean;
hasMcpConfig: boolean;
hasGlobBasedRules: boolean;
hierarchicalAgentContextCount: number;
hasSkillsManifest: boolean;
}

export function createAuditResult(projectName: string): AuditResult {
return {
project: projectName,
schema_version: "2.0",
timestamp: new Date().toISOString(),
scores: {
repository_knowledge: { score: 0, max: 3, findings: [] },
repository_knowledge: { score: 0, max: 4, findings: [] },
architecture_enforcement: { score: 0, max: 3, findings: [] },
agent_legibility: { score: 0, max: 3, findings: [] },
agent_legibility: { score: 0, max: 4, findings: [] },
golden_principles: { score: 0, max: 3, findings: [] },
agent_workflow: { score: 0, max: 3, findings: [] },
agent_workflow: { score: 0, max: 4, findings: [] },
garbage_collection: { score: 0, max: 3, findings: [] },
},
total_score: 0,
max_score: 18,
max_score: 21,
maturity_level: "L0",
recommendations: [],
};
Expand Down Expand Up @@ -79,6 +86,42 @@ export function buildAuditRuntimeContext(targetDir: string): AuditRuntimeContext
const verifiedDocs = readVerifiedDocs(targetDir);
const hasCleanupDocs = existsSync(join(targetDir, "docs", "exec-plans", "tech-debt-tracker.md"));

const commandsDir = join(targetDir, ".claude", "commands");
let hasAgentCommands = false;
if (existsSync(commandsDir)) {
try {
hasAgentCommands = readdirSync(commandsDir).length > 0;
} catch {
// ignore read errors
}
}

const hasSessionOrchestrator =
existsSync(join(targetDir, ".flow")) ||
existsSync(join(targetDir, "gsd")) ||
existsSync(join(targetDir, "conductor.json")) ||
existsSync(join(targetDir, ".claude", "settings.json"));

const hasMcpConfig =
existsSync(join(targetDir, ".claude", "mcp.json")) ||
existsSync(join(targetDir, ".cursor", "mcp.json")) ||
existsSync(join(targetDir, "mcp.json"));

const hasGlobBasedRules =
existsSync(join(targetDir, ".cursor", "rules")) ||
existsSync(join(targetDir, ".claude", "rules"));

const agentContextFiles = [
...findFiles(targetDir, /^AGENTS\.md$/, 3),
...findFiles(targetDir, /^CLAUDE\.md$/, 3),
];
const hierarchicalAgentContextCount = agentContextFiles.length;

const hasSkillsManifest =
existsSync(join(targetDir, "skills.json")) ||
existsSync(join(targetDir, ".claude", "skills")) ||
existsSync(join(targetDir, ".cursor", "extensions"));

return {
targetDir,
pkgJsonPath,
Expand All @@ -97,5 +140,11 @@ export function buildAuditRuntimeContext(targetDir: string): AuditRuntimeContext
isCliRepo,
verifiedDocs,
hasCleanupDocs,
hasAgentCommands,
hasSessionOrchestrator,
hasMcpConfig,
hasGlobBasedRules,
hierarchicalAgentContextCount,
hasSkillsManifest,
};
}
83 changes: 77 additions & 6 deletions cli/reins/src/lib/audit/scoring.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, readFileSync } from "node:fs";
import { existsSync, readFileSync, readdirSync } from "node:fs";
import { join } from "node:path";
import { detectCliDiagnosabilitySignals } from "../detection";
import { findFiles, safeReadDir } from "../filesystem";
Expand Down Expand Up @@ -71,10 +71,25 @@ function scoreRepositoryExecutionPlans(result: AuditResult, ctx: AuditRuntimeCon
}
}

function scoreConditionalContext(result: AuditResult, ctx: AuditRuntimeContext): void {
if (ctx.hasGlobBasedRules) {
result.scores.repository_knowledge.score++;
result.scores.repository_knowledge.findings.push("Glob-based rule files detected");
return;
}
if (ctx.hierarchicalAgentContextCount >= 3) {
result.scores.repository_knowledge.score++;
result.scores.repository_knowledge.findings.push(
`Conditional context engineering detected (${ctx.hierarchicalAgentContextCount} hierarchical files)`,
);
}
}

function scoreRepositoryKnowledge(result: AuditResult, ctx: AuditRuntimeContext): void {
scoreRepositoryAgents(result, ctx);
scoreRepositoryDocs(result, ctx);
scoreRepositoryExecutionPlans(result, ctx);
scoreConditionalContext(result, ctx);
}

function hasDeepLinterEnforcement(ctx: AuditRuntimeContext): boolean {
Expand Down Expand Up @@ -288,6 +303,16 @@ function scoreDependencyFootprint(result: AuditResult, ctx: AuditRuntimeContext)
}
}

function scoreToolRegistry(result: AuditResult, ctx: AuditRuntimeContext): void {
if (ctx.hasMcpConfig || ctx.hasSkillsManifest) {
result.scores.agent_legibility.score++;
const signals: string[] = [];
if (ctx.hasMcpConfig) signals.push("MCP config");
if (ctx.hasSkillsManifest) signals.push("skills manifest");
result.scores.agent_legibility.findings.push(`Declared tool registry: ${signals.join("|")}`);
}
}

function scoreAgentLegibility(result: AuditResult, ctx: AuditRuntimeContext): void {
if (existsSync(ctx.pkgJsonPath)) {
try {
Expand All @@ -308,6 +333,7 @@ function scoreAgentLegibility(result: AuditResult, ctx: AuditRuntimeContext): vo

scoreObservability(result, ctx);
scoreDependencyFootprint(result, ctx);
scoreToolRegistry(result, ctx);
}

function scoreGoldenPrinciples(result: AuditResult, ctx: AuditRuntimeContext): void {
Expand Down Expand Up @@ -395,10 +421,55 @@ function scoreAgentWorkflowCi(result: AuditResult, ctx: AuditRuntimeContext): vo
}
}

function scoreAgentWorkflowBlueprints(result: AuditResult, ctx: AuditRuntimeContext): void {
if (ctx.hasAgentCommands || ctx.hasSessionOrchestrator) {
result.scores.agent_workflow.score++;
const signals: string[] = [];
if (ctx.hasAgentCommands) signals.push("commands");
if (ctx.hasSessionOrchestrator) signals.push("orchestrator");
result.scores.agent_workflow.findings.push(`Agent blueprint signals: ${signals.join("|")}`);
}
}

function detectZteSignals(result: AuditResult, ctx: AuditRuntimeContext): void {
if (!existsSync(ctx.workflowDir)) return;

let hasAutoMerge = false;
let hasDeployOnMerge = false;

try {
const files = readdirSync(ctx.workflowDir).filter((f) => f.endsWith(".yml") || f.endsWith(".yaml"));
for (const file of files) {
const content = readFileSync(join(ctx.workflowDir, file), "utf-8");
if (/auto-merge|mergify|kodiak/i.test(content)) {
hasAutoMerge = true;
}
const hasPushToMain =
/push:[\s\S]*?branches:[\s\S]*?(?:-\s*["']?main["']?|\[\s*["']?main["']?\s*\])/i.test(content);
const hasDeploySignal = /\bdeploy(?:ment)?\b/i.test(content);
const hasMergeDeploySignal = /merge[\s\S]*deploy|deploy[\s\S]*merge/i.test(content);
if ((hasPushToMain && hasDeploySignal) || hasMergeDeploySignal) {
hasDeployOnMerge = true;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
}
} catch {
// ignore read errors
}

if (hasAutoMerge) {
result.scores.agent_workflow.findings.push("ZTE signal: auto-merge configuration detected");
}
if (hasDeployOnMerge) {
result.scores.agent_workflow.findings.push("ZTE signal: deploy-on-merge pattern detected");
}
}

function scoreAgentWorkflow(result: AuditResult, ctx: AuditRuntimeContext): void {
scoreAgentWorkflowConfig(result, ctx);
scoreAgentWorkflowGovernance(result, ctx);
scoreAgentWorkflowCi(result, ctx);
scoreAgentWorkflowBlueprints(result, ctx);
detectZteSignals(result, ctx);
}

function hasActiveDocGardening(ctx: AuditRuntimeContext): boolean {
Expand Down Expand Up @@ -476,9 +547,9 @@ export function applyAuditScoring(result: AuditResult, ctx: AuditRuntimeContext)
}

export function resolveMaturityLevel(totalScore: number): string {
if (totalScore <= 4) return "L0: Manual";
if (totalScore <= 8) return "L1: Assisted";
if (totalScore <= 13) return "L2: Steered";
if (totalScore <= 16) return "L3: Autonomous";
return "L4: Self-Correcting";
if (totalScore <= 5) return "L0: Manual";
if (totalScore <= 10) return "L1: Inloop";
if (totalScore <= 15) return "L2: Guided Outloop";
if (totalScore <= 18) return "L3: Full Outloop";
return "L4: Zero Touch";
}
15 changes: 8 additions & 7 deletions cli/reins/src/lib/commands/evolve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ describe("runEvolve unit behavior", () => {

const mockAuditResult: AuditResult = {
project: "sample",
schema_version: "2.0",
timestamp: new Date().toISOString(),
scores: {
repository_knowledge: { score: 3, max: 3, findings: [] },
repository_knowledge: { score: 3, max: 4, findings: [] },
architecture_enforcement: { score: 3, max: 3, findings: [] },
agent_legibility: { score: 3, max: 3, findings: [] },
agent_legibility: { score: 3, max: 4, findings: [] },
golden_principles: { score: 3, max: 3, findings: [] },
agent_workflow: { score: 1, max: 3, findings: [] },
garbage_collection: { score: 1, max: 3, findings: [] },
agent_workflow: { score: 3, max: 4, findings: [] },
garbage_collection: { score: 2, max: 3, findings: [] },
},
total_score: 14,
max_score: 18,
maturity_level: "L3: Autonomous",
total_score: 17,
max_score: 21,
maturity_level: "L3: Full Outloop",
recommendations: [],
};

Expand Down
Loading
Loading