@polymorphism-tech/morph-spec 4.21.0 → 5.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/CLAUDE.md +57 -71
- package/README.md +2 -2
- package/bin/morph-spec.js +224 -491
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +55 -38
- package/framework/MORPH.md +244 -0
- package/framework/agents.json +127 -1183
- package/framework/commands/morph-apply.md +56 -240
- package/framework/commands/morph-archive.md +48 -85
- package/framework/commands/morph-preflight.md +7 -7
- package/framework/commands/morph-proposal.md +35 -191
- package/framework/commands/morph-status.md +19 -50
- package/framework/commands/morph-troubleshoot.md +2 -2
- package/framework/evals/rubrics/README.md +44 -0
- package/framework/evals/rubrics/architecture.md +46 -0
- package/framework/evals/rubrics/code-quality.md +50 -0
- package/framework/evals/rubrics/contracts.md +47 -0
- package/framework/evals/rubrics/test-coverage.md +50 -0
- package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
- package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
- package/framework/evals/suites/standard.yaml +5 -0
- package/framework/evals/trace-schema.md +67 -0
- package/framework/hooks/claude-code/core/README.md +3 -0
- package/framework/hooks/claude-code/core/denylist.json +14 -0
- package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
- package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
- package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
- package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
- package/framework/hooks/shared/phase-utils.js +20 -28
- package/framework/hooks/shared/state-reader.js +4 -5
- package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -210
- package/framework/phases.json +40 -114
- package/framework/rubrics/eval-rubric.json +66 -0
- package/framework/skills/README.md +39 -64
- package/framework/skills/core/README.md +3 -0
- package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
- package/framework/skills/core/morph-eval/SKILL.md +57 -0
- package/framework/skills/core/morph-implement/SKILL.md +83 -0
- package/framework/skills/core/morph-plan/SKILL.md +64 -0
- package/framework/skills/core/morph-review/SKILL.md +62 -0
- package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
- package/framework/skills/core/morph-standards/SKILL.md +49 -0
- package/framework/standards/STANDARDS.json +32 -0
- package/framework/standards/frontend/design-system/ai-image-generation.md +244 -0
- package/framework/standards/integration/mcp/mcp-tools.md +48 -0
- package/framework/templates/CLAUDE.md.core.guide.md +29 -0
- package/framework/templates/CLAUDE.md.core.template +22 -0
- package/framework/templates/REGISTRY.json +4 -4
- package/framework/workflows/configs/fast-track.json +5 -10
- package/framework/workflows/configs/full.json +4 -8
- package/framework/workflows/configs/quick.json +32 -0
- package/framework/workflows/configs/standard.json +57 -64
- package/package.json +7 -6
- package/src/commands/mcp/mcp-setup.js +58 -31
- package/src/commands/project/doctor.js +69 -70
- package/src/commands/project/init.js +26 -5
- package/src/commands/project/status.js +18 -19
- package/src/commands/state/approve.js +1 -1
- package/src/commands/validation/validate-feature.js +18 -112
- package/src/core/paths/output-schema.js +133 -151
- package/src/core/state/phase-state-machine.js +10 -24
- package/src/core/state/state-manager.js +17 -17
- package/src/core/workflows/workflow-detector.js +214 -31
- package/src/core/workflows/workflow-router.js +204 -0
- package/src/dashboard/app/pages/AgentMap.jsx +32 -33
- package/src/dashboard/app/pages/LiveState.jsx +1 -1
- package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
- package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
- package/src/dashboard/app/pages/Workflows.jsx +2 -2
- package/src/dashboard/scanner/agents-scanner.js +30 -35
- package/src/lib/agents/metrics-aggregator.js +1 -1
- package/src/lib/agents/output-collector.js +7 -8
- package/src/lib/context/context-builder.js +289 -0
- package/src/lib/detectors/claude-config-detector.js +19 -3
- package/src/lib/generators/context-generator.js +20 -42
- package/src/lib/generators/index.js +1 -0
- package/src/lib/generators/mandate-generator.js +512 -0
- package/src/lib/generators/metadata-extractor.js +1 -1
- package/src/lib/generators/recap-generator.js +3 -4
- package/src/lib/installers/mcp-installer.js +300 -92
- package/src/lib/phase-chain/phase-validator.js +36 -40
- package/src/lib/stack/stack-profile.js +74 -91
- package/src/lib/tasks/task-parser.js +1 -1
- package/src/lib/tasks/wave-resolver.js +353 -0
- package/src/lib/validators/checkpoint-persistence.js +2 -2
- package/src/lib/validators/content/cross-phase-validator.js +281 -0
- package/src/lib/validators/content/index.js +1 -0
- package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
- package/src/scripts/global-install.js +2 -27
- package/src/utils/agents-installer.js +224 -447
- package/src/utils/claude-settings-manager.js +57 -15
- package/src/utils/file-copier.js +1 -0
- package/src/utils/hooks-installer.js +15 -117
- package/src/utils/skills-installer.js +12 -18
- package/bin/detect-agents.js +0 -226
- package/bin/task-manager.js +0 -1036
- package/framework/agents/README.md +0 -13
- package/framework/agents/ai-agents/ai-system-architect.md +0 -194
- package/framework/agents/ai-agents/vector-search-expert.md +0 -247
- package/framework/agents/architecture/architecture-expert.md +0 -98
- package/framework/agents/architecture/morph-spec-architect.md +0 -66
- package/framework/agents/architecture/packages-validator.md +0 -89
- package/framework/agents/architecture/security-expert.md +0 -79
- package/framework/agents/architecture/seo-growth-hacker.md +0 -168
- package/framework/agents/architecture/standards-architect.md +0 -153
- package/framework/agents/backend/dotnet-senior.md +0 -163
- package/framework/agents/backend/ef-modeler.md +0 -119
- package/framework/agents/backend/hangfire-orchestrator.md +0 -133
- package/framework/agents/backend/ms-agent-expert.md +0 -55
- package/framework/agents/backend/neon-expert.md +0 -379
- package/framework/agents/frontend/css-specialist.md +0 -89
- package/framework/agents/frontend/design-system-validator.md +0 -100
- package/framework/agents/frontend/gsap-animator.md +0 -131
- package/framework/agents/frontend/nextjs-component-validator.md +0 -97
- package/framework/agents/frontend/nextjs-expert.md +0 -201
- package/framework/agents/frontend/ui-designer.md +0 -259
- package/framework/agents/infrastructure/infra-architect.md +0 -215
- package/framework/agents/integrations/asaas-financial.md +0 -138
- package/framework/agents/integrations/neon-auth.md +0 -151
- package/framework/agents/integrations/resend-email.md +0 -127
- package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
- package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
- package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
- package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
- package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
- package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
- package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
- package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
- package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
- package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
- package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
- package/framework/hooks/shared/compact-restore.js +0 -123
- package/framework/hooks/shared/dispatch-helpers.js +0 -147
- package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
- package/framework/hooks/shared/stale-task-reset.js +0 -57
- package/framework/hooks/shared/worktree-helpers.js +0 -75
- package/framework/skills/level-0-meta/README.md +0 -7
- package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
- package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
- package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
- package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
- package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
- package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
- package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
- package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
- package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
- package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
- package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
- package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
- package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
- package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
- package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
- package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -382
- package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
- package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
- package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
- package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
- package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
- package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
- package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
- package/framework/skills/level-1-workflows/README.md +0 -7
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
- package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
- package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
- package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
- package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -493
- package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
- package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -46
- package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
- package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
- package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
- package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
- package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
- package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
- package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -788
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
- package/framework/squad-templates/backend-only.json +0 -47
- package/framework/squad-templates/frontend-only.json +0 -56
- package/framework/squad-templates/full-stack.json +0 -74
- package/src/commands/agents/agent-metrics.js +0 -174
- package/src/commands/agents/audit-dispatch.js +0 -82
- package/src/commands/agents/detect-agents.js +0 -275
- package/src/commands/agents/dispatch-agents.js +0 -461
- package/src/commands/agents/index.js +0 -13
- package/src/commands/agents/manage-agents.js +0 -352
- package/src/commands/agents/project-metrics.js +0 -74
- package/src/commands/phase/phase-reset.js +0 -74
- package/src/commands/scope/escalate.js +0 -217
- package/src/commands/state/advance-phase.js +0 -600
- package/src/commands/state/phase-runner.js +0 -215
- package/src/commands/state/state.js +0 -444
- package/src/commands/task/expand.js +0 -100
- package/src/commands/tasks/index.js +0 -4
- package/src/commands/tasks/task.js +0 -105
- package/src/commands/templates/index.js +0 -5
- package/src/commands/templates/template-render.js +0 -93
- package/src/commands/trust/trust.js +0 -118
- package/src/lib/agents/agents-manager.js +0 -349
- package/src/lib/build/build-runner.js +0 -99
- package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
- package/src/lib/contracts/sprint-contract-generator.js +0 -137
- package/src/lib/scope/impact-analyzer.js +0 -106
- package/src/lib/trust/trust-manager.js +0 -157
- package/src/utils/tier-helpers.js +0 -24
- /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Impact Analyzer for Scope Escalation
|
|
3
|
-
*
|
|
4
|
-
* Analyzes tasks.md + spec.md to determine the impact of a discovered
|
|
5
|
-
* complexity and recommend an escalation action.
|
|
6
|
-
*
|
|
7
|
-
* Pure functions — no I/O, no state mutations.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Classify impact based on affected task count and spec status.
|
|
12
|
-
*
|
|
13
|
-
* @param {{ affectedTasks: string[], specNeedsUpdate: boolean }} input
|
|
14
|
-
* @returns {{ impact: 'low'|'medium'|'high', recommendation: string, targetPhase?: string }}
|
|
15
|
-
*/
|
|
16
|
-
export function classifyImpact({ affectedTasks, specNeedsUpdate }) {
|
|
17
|
-
if (specNeedsUpdate) {
|
|
18
|
-
return { impact: 'high', recommendation: 'regress-design', targetPhase: 'design' };
|
|
19
|
-
}
|
|
20
|
-
if (affectedTasks.length <= 3) {
|
|
21
|
-
return { impact: 'low', recommendation: 'expand' };
|
|
22
|
-
}
|
|
23
|
-
return { impact: 'medium', recommendation: 'regress-tasks', targetPhase: 'tasks' };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Parse task IDs from tasks.md content.
|
|
28
|
-
* @param {string} tasksMd
|
|
29
|
-
* @returns {string[]} Ordered task IDs
|
|
30
|
-
*/
|
|
31
|
-
function parseTaskIds(tasksMd) {
|
|
32
|
-
const ids = [];
|
|
33
|
-
const re = /^###\s+(T\d+)\s*[—–:\-]/gm;
|
|
34
|
-
let match;
|
|
35
|
-
while ((match = re.exec(tasksMd)) !== null) {
|
|
36
|
-
ids.push(match[1]);
|
|
37
|
-
}
|
|
38
|
-
return ids;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Find consecutive task IDs starting from a trigger task.
|
|
43
|
-
* Tasks are "consecutive" if their numeric IDs have no gaps.
|
|
44
|
-
*
|
|
45
|
-
* @param {string[]} allIds - All task IDs in order
|
|
46
|
-
* @param {string} triggerId - The trigger task ID
|
|
47
|
-
* @returns {string[]} Consecutive group including trigger
|
|
48
|
-
*/
|
|
49
|
-
function findConsecutiveGroup(allIds, triggerId) {
|
|
50
|
-
const triggerIdx = allIds.indexOf(triggerId);
|
|
51
|
-
if (triggerIdx === -1) return [triggerId];
|
|
52
|
-
|
|
53
|
-
const numOf = id => parseInt(id.replace(/\D/g, ''), 10);
|
|
54
|
-
|
|
55
|
-
const group = [triggerId];
|
|
56
|
-
|
|
57
|
-
// Look forward
|
|
58
|
-
for (let i = triggerIdx + 1; i < allIds.length; i++) {
|
|
59
|
-
const prevNum = numOf(allIds[i - 1]);
|
|
60
|
-
const currNum = numOf(allIds[i]);
|
|
61
|
-
if (currNum - prevNum <= 1) {
|
|
62
|
-
group.push(allIds[i]);
|
|
63
|
-
} else {
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Look backward
|
|
69
|
-
for (let i = triggerIdx - 1; i >= 0; i--) {
|
|
70
|
-
const nextNum = numOf(allIds[i + 1]);
|
|
71
|
-
const currNum = numOf(allIds[i]);
|
|
72
|
-
if (nextNum - currNum <= 1) {
|
|
73
|
-
group.unshift(allIds[i]);
|
|
74
|
-
} else {
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return group;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Analyze the impact of a scope escalation.
|
|
84
|
-
*
|
|
85
|
-
* @param {{ triggerTaskId: string, tasksMd: string, specMd: string, reason: string }} input
|
|
86
|
-
* @returns {{ triggerTask: string, affectedTasks: string[], impact: string, recommendation: string, targetPhase?: string, reason: string }}
|
|
87
|
-
*/
|
|
88
|
-
export function analyzeImpact({ triggerTaskId, tasksMd, specMd, reason }) {
|
|
89
|
-
const allIds = parseTaskIds(tasksMd);
|
|
90
|
-
const affectedTasks = findConsecutiveGroup(allIds, triggerTaskId);
|
|
91
|
-
|
|
92
|
-
// Heuristic: detect phrases that indicate the spec itself is wrong, not just casual mentions.
|
|
93
|
-
// Requires phrases like "spec is wrong", "architecture needs", "contract mismatch", etc.
|
|
94
|
-
// Avoids false positives on casual uses like "the design of the component" or "schema file".
|
|
95
|
-
const specPhrases = /\b(spec\s+(is|was|needs|incorrect|wrong|outdated|assumed|missed)|architecture\s+(needs|is wrong|incorrect|mismatch)|contract\s+(mismatch|wrong|incorrect|needs|outdated)|schema\s+(needs|incorrect|wrong|mismatch|change))\b/i;
|
|
96
|
-
const specNeedsUpdate = specPhrases.test(reason);
|
|
97
|
-
|
|
98
|
-
const classification = classifyImpact({ affectedTasks, specNeedsUpdate });
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
triggerTask: triggerTaskId,
|
|
102
|
-
affectedTasks,
|
|
103
|
-
...classification,
|
|
104
|
-
reason
|
|
105
|
-
};
|
|
106
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trust Manager — Simplified 3-level trust model
|
|
3
|
-
*
|
|
4
|
-
* Trust levels:
|
|
5
|
-
* manual — nothing auto-approved (default)
|
|
6
|
-
* high — auto-approve low-risk gates (design, tasks)
|
|
7
|
-
* auto — auto-approve all gates
|
|
8
|
-
*
|
|
9
|
-
* Set with: morph-spec trust set <feature> <level>
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { readFileSync, existsSync } from 'fs';
|
|
13
|
-
import { join } from 'path';
|
|
14
|
-
import { saveState } from '../../core/state/state-manager.js';
|
|
15
|
-
|
|
16
|
-
const VALID_LEVELS = ['manual', 'high', 'auto'];
|
|
17
|
-
|
|
18
|
-
// Gates that can be auto-approved at each trust level
|
|
19
|
-
export const AUTO_APPROVE_GATES = {
|
|
20
|
-
manual: [],
|
|
21
|
-
high: ['design', 'tasks'],
|
|
22
|
-
auto: ['design', 'tasks', 'proposal', 'uiux']
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Load state.json
|
|
27
|
-
* @returns {Object} State
|
|
28
|
-
*/
|
|
29
|
-
function loadState() {
|
|
30
|
-
const statePath = join(process.cwd(), '.morph/state.json');
|
|
31
|
-
if (!existsSync(statePath)) return { features: {} };
|
|
32
|
-
try {
|
|
33
|
-
return JSON.parse(readFileSync(statePath, 'utf8'));
|
|
34
|
-
} catch {
|
|
35
|
-
return { features: {} };
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get current trust config for a feature
|
|
41
|
-
* @param {string} featureName
|
|
42
|
-
* @returns {{ level: string, autoApprove: string[], source: string, overrideReason?: string }}
|
|
43
|
-
*/
|
|
44
|
-
export function getTrust(featureName) {
|
|
45
|
-
const state = loadState();
|
|
46
|
-
const feature = state.features?.[featureName];
|
|
47
|
-
|
|
48
|
-
if (!feature) {
|
|
49
|
-
return { level: 'manual', autoApprove: [], source: 'default' };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const override = feature.trustConfig?.override;
|
|
53
|
-
const level = VALID_LEVELS.includes(override?.level) ? override.level : 'manual';
|
|
54
|
-
const source = override ? 'manual' : 'default';
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
level,
|
|
58
|
-
autoApprove: AUTO_APPROVE_GATES[level] || [],
|
|
59
|
-
source,
|
|
60
|
-
overrideReason: override?.reason,
|
|
61
|
-
overrideAt: override?.setAt
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Manually set trust level with reason
|
|
67
|
-
* @param {string} featureName
|
|
68
|
-
* @param {string} level - 'manual' | 'high' | 'auto'
|
|
69
|
-
* @param {string} [reason]
|
|
70
|
-
*/
|
|
71
|
-
export function setTrust(featureName, level, reason) {
|
|
72
|
-
if (!VALID_LEVELS.includes(level)) {
|
|
73
|
-
throw new Error(`Invalid trust level: ${level}. Valid: ${VALID_LEVELS.join(', ')}`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const state = loadState();
|
|
77
|
-
if (!state.features[featureName]) {
|
|
78
|
-
throw new Error(`Feature not found: ${featureName}`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!state.features[featureName].trustConfig) {
|
|
82
|
-
state.features[featureName].trustConfig = {};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
state.features[featureName].trustConfig.override = {
|
|
86
|
-
level,
|
|
87
|
-
reason: reason || `Manual override to ${level}`,
|
|
88
|
-
setAt: new Date().toISOString(),
|
|
89
|
-
setBy: 'manual'
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
saveState(state);
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
feature: featureName,
|
|
96
|
-
level,
|
|
97
|
-
autoApprove: AUTO_APPROVE_GATES[level] || [],
|
|
98
|
-
reason: state.features[featureName].trustConfig.override.reason
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Clear manual trust override (reverts to default: manual)
|
|
104
|
-
* @param {string} featureName
|
|
105
|
-
*/
|
|
106
|
-
export function clearTrustOverride(featureName) {
|
|
107
|
-
const state = loadState();
|
|
108
|
-
if (state.features[featureName]?.trustConfig?.override) {
|
|
109
|
-
delete state.features[featureName].trustConfig.override;
|
|
110
|
-
saveState(state);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Check if a gate should be auto-approved based on trust level
|
|
116
|
-
* @param {string} featureName
|
|
117
|
-
* @param {string} gate - 'design' | 'tasks' | 'proposal' | 'uiux'
|
|
118
|
-
* @returns {{ autoApprove: boolean, level: string, reason: string }}
|
|
119
|
-
*/
|
|
120
|
-
export function shouldAutoApprove(featureName, gate) {
|
|
121
|
-
const trust = getTrust(featureName);
|
|
122
|
-
|
|
123
|
-
if (!trust.autoApprove.includes(gate)) {
|
|
124
|
-
return {
|
|
125
|
-
autoApprove: false,
|
|
126
|
-
level: trust.level,
|
|
127
|
-
reason: `Trust level "${trust.level}" does not auto-approve "${gate}" gate`
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
autoApprove: true,
|
|
133
|
-
level: trust.level,
|
|
134
|
-
reason: `Auto-approved: trust level "${trust.level}" includes gate "${gate}"`
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Get trust info for all features
|
|
140
|
-
* @returns {Array} Feature trust summaries
|
|
141
|
-
*/
|
|
142
|
-
export function getTrustHistory() {
|
|
143
|
-
const state = loadState();
|
|
144
|
-
const features = state.features || {};
|
|
145
|
-
|
|
146
|
-
return Object.entries(features).map(([name, feature]) => {
|
|
147
|
-
const trust = getTrust(name);
|
|
148
|
-
return {
|
|
149
|
-
feature: name,
|
|
150
|
-
level: trust.level,
|
|
151
|
-
autoApprove: trust.autoApprove,
|
|
152
|
-
source: trust.source,
|
|
153
|
-
phase: feature.phase,
|
|
154
|
-
status: feature.status
|
|
155
|
-
};
|
|
156
|
-
});
|
|
157
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tier-to-role helpers for agents.json v4.0
|
|
3
|
-
*
|
|
4
|
-
* Derives role strings from tier numbers, eliminating the need
|
|
5
|
-
* for an explicit `role` field on each agent.
|
|
6
|
-
*
|
|
7
|
-
* @module tier-helpers
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const TIER_ROLES = {
|
|
11
|
-
1: 'orchestrator',
|
|
12
|
-
2: 'leader',
|
|
13
|
-
3: 'specialist',
|
|
14
|
-
4: 'validator',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Derive role string from agent tier number.
|
|
19
|
-
* @param {number} tier - Agent tier (1-4)
|
|
20
|
-
* @returns {string} Role name
|
|
21
|
-
*/
|
|
22
|
-
export function tierToRole(tier) {
|
|
23
|
-
return TIER_ROLES[tier] || 'specialist';
|
|
24
|
-
}
|
|
File without changes
|