afyx-engineering-kit 0.0.0-stage → 0.1.0-alpha.4
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/.afyx-source-revision +1 -0
- package/LICENSE +21 -0
- package/README.md +377 -2
- package/SECURITY.md +74 -0
- package/afyx-context/LICENSE +21 -0
- package/afyx-context/README.md +155 -0
- package/afyx-context/afyx-context.json +30 -0
- package/afyx-context/contracts/integration-v1.schema.json +34 -0
- package/afyx-context/package-lock.json +53 -0
- package/afyx-context/package.json +34 -0
- package/afyx-context/scripts/benchmark.mjs +39 -0
- package/afyx-context/scripts/build.mjs +15 -0
- package/afyx-context/scripts/comparative-benchmark.mjs +342 -0
- package/afyx-context/scripts/comparative-worker.mjs +74 -0
- package/afyx-context/scripts/graph-integration-e2e.mjs +188 -0
- package/afyx-context/scripts/integrated-dogfood.mjs +309 -0
- package/afyx-context/src/budget.js +166 -0
- package/afyx-context/src/cli.js +110 -0
- package/afyx-context/src/coordination.js +343 -0
- package/afyx-context/src/engine.js +198 -0
- package/afyx-context/src/errors.js +14 -0
- package/afyx-context/src/graph-integration-worker.js +70 -0
- package/afyx-context/src/graph-integration.js +373 -0
- package/afyx-context/src/graph-mcp-bridge.js +103 -0
- package/afyx-context/src/index.js +25 -0
- package/afyx-context/src/integrations.js +87 -0
- package/afyx-context/src/memory.js +255 -0
- package/afyx-context/src/storage.js +364 -0
- package/afyx-context/test-fixtures/coordination-worker.mjs +52 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__init__.py +1 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/__manifest__.py +4 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/__init__.py +1 -0
- package/afyx-context/test-fixtures/graph-consumer-repo/addons/sale_extension/models/sale_order.py +5 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__init__.py +1 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/__manifest__.py +10 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/__init__.py +2 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order.py +20 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/models/sale_order_audit.py +11 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/security/ir.model.access.csv +2 -0
- package/afyx-context/test-fixtures/integrated-dogfood-repo/addons/integrated_sales/views/sale_order_views.xml +14 -0
- package/afyx-forge/LICENSE +55 -0
- package/afyx-forge/README.md +126 -0
- package/afyx-forge/afyx-forge.json +28 -0
- package/afyx-forge/bin/afyx-forge +4 -0
- package/afyx-forge/bin/afyx-forge.cmd +3 -0
- package/afyx-forge/bin/afyx-forge.js +16 -0
- package/afyx-forge/contracts/forge-plan-v1.schema.json +172 -0
- package/afyx-forge/package.json +26 -0
- package/afyx-forge/src/classifier.js +190 -0
- package/afyx-forge/src/cli.js +111 -0
- package/afyx-forge/src/doctor.js +105 -0
- package/afyx-forge/src/guidance.js +120 -0
- package/afyx-forge/src/index.js +273 -0
- package/afyx-forge/src/planning.js +107 -0
- package/afyx-forge/src/policy.js +109 -0
- package/afyx-forge/src/workflow-refiner.js +151 -0
- package/afyx-graph/afyx-graph.json +20 -0
- package/afyx-graph/engine/LICENSE +21 -0
- package/afyx-graph/engine/README.md +104 -0
- package/afyx-graph/engine/release/RELEASE-MANIFEST.json +21 -0
- package/afyx-graph/engine/release/SHA256SUMS +2 -0
- package/afyx-graph/engine/release/afyx-graph-linux-x64.tar.gz +0 -0
- package/afyx-graph/engine/release/afyx-graph-win32-x64.zip +0 -0
- package/afyx-graph/engine/scripts/distribution-contract.mjs +212 -0
- package/afyx-graph/engine/scripts/distribution-product.json +33 -0
- package/bin/afyx-engineering-kit.mjs +61 -0
- package/install.ps1 +1053 -0
- package/install.sh +617 -0
- package/package.json +66 -4
- package/scripts/afyx-capability-orchestrator.mjs +752 -0
- package/scripts/afyx-claude-integration.mjs +547 -0
- package/scripts/afyx-context-artifact.mjs +105 -0
- package/scripts/afyx-credential-broker.mjs +75 -0
- package/scripts/afyx-doctor.ps1 +152 -0
- package/scripts/afyx-doctor.sh +146 -0
- package/scripts/afyx-forge-artifact.mjs +183 -0
- package/scripts/afyx-global-routing-policy.md +12 -0
- package/scripts/afyx-global-routing.mjs +168 -0
- package/scripts/afyx-graph-artifact.mjs +178 -0
- package/scripts/afyx-host-adapters.mjs +543 -0
- package/scripts/afyx-host-bridge-lifecycle.mjs +174 -0
- package/scripts/afyx-host-bridge.mjs +288 -0
- package/scripts/afyx-integration-contracts.mjs +825 -0
- package/scripts/afyx-mcp-integration.mjs +528 -0
- package/scripts/afyx-modular-integration.mjs +361 -0
- package/scripts/afyx-modular-runtime.mjs +451 -0
- package/scripts/afyx-native-skill-host.mjs +124 -0
- package/scripts/afyx-npm-installer.mjs +486 -0
- package/scripts/afyx-project.ps1 +205 -0
- package/scripts/afyx-project.sh +207 -0
- package/scripts/afyx-provider-backup.mjs +1206 -0
- package/scripts/afyx-provider-integration.mjs +724 -0
- package/scripts/afyx-provider-inventory.mjs +147 -0
- package/scripts/afyx-security-auditor.mjs +224 -0
- package/scripts/afyx-skill-engineering.mjs +354 -0
- package/scripts/afyx-tool-family-routing.mjs +64 -0
- package/scripts/afyx-universal-runtime.mjs +530 -0
- package/scripts/alpha_acceptance_preflight.py +240 -0
- package/scripts/benchmark-graph-memory.mjs +96 -0
- package/scripts/benchmark_capability_orchestrator.mjs +64 -0
- package/scripts/build-windows-installer.ps1 +259 -0
- package/scripts/build_forge_synthetic_image.py +328 -0
- package/scripts/check-reference-staleness.py +71 -0
- package/scripts/components.json +254 -0
- package/scripts/contracts/afyx-capability-request-v1.schema.json +189 -0
- package/scripts/contracts/afyx-capability-result-v1.schema.json +32 -0
- package/scripts/dogfood_engineering_comparison.mjs +303 -0
- package/scripts/engineering-assurance.json +28 -0
- package/scripts/install-afyx-context.ps1 +142 -0
- package/scripts/install-afyx-context.sh +126 -0
- package/scripts/install-afyx-forge.ps1 +265 -0
- package/scripts/install-afyx-forge.sh +273 -0
- package/scripts/install-afyx-graph.ps1 +571 -0
- package/scripts/install-afyx-graph.sh +438 -0
- package/scripts/install-codex-usage-tracker.ps1 +172 -0
- package/scripts/lib/AfyxComponents.psm1 +399 -0
- package/scripts/lib/AfyxSkillLifecycle.psm1 +289 -0
- package/scripts/lib/AfyxTerminal.psm1 +838 -0
- package/scripts/lib/afyx-components.sh +256 -0
- package/scripts/lib/afyx-skill-lifecycle.sh +271 -0
- package/scripts/link-global-dev.ps1 +193 -0
- package/scripts/link-global-dev.sh +130 -0
- package/scripts/phase8-paired-evidence.mjs +195 -0
- package/scripts/phase8-representative-workload.mjs +771 -0
- package/scripts/phase8-session-recorder.mjs +157 -0
- package/scripts/phase8_event_ledger.py +248 -0
- package/scripts/phase8_evidence_discovery.py +189 -0
- package/scripts/prepare-g6-package.mjs +349 -0
- package/scripts/resolve-git-release-artifacts.mjs +321 -0
- package/scripts/stage-npm-release.mjs +94 -0
- package/scripts/validate-afyx-graph.py +203 -0
- package/scripts/validate-components.py +194 -0
- package/scripts/validate-engineering-assurance.py +281 -0
- package/scripts/verify-graph-archive.mjs +64 -0
- package/skills/afyx-context/SKILL.md +26 -0
- package/skills/afyx-engineering-expert/README.md +42 -0
- package/skills/afyx-engineering-expert/SKILL.md +70 -0
- package/skills/afyx-engineering-expert/assets/result-template.md +15 -0
- package/skills/afyx-engineering-expert/references/ai-ml-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/business-analyst.md +17 -0
- package/skills/afyx-engineering-expert/references/clean-code-engineer.md +26 -0
- package/skills/afyx-engineering-expert/references/code-reviewer.md +24 -0
- package/skills/afyx-engineering-expert/references/cybersecurity-devsecops.md +17 -0
- package/skills/afyx-engineering-expert/references/data-analyst-bi.md +24 -0
- package/skills/afyx-engineering-expert/references/data-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/database-administrator.md +17 -0
- package/skills/afyx-engineering-expert/references/debugging-specialist.md +24 -0
- package/skills/afyx-engineering-expert/references/embedded-iot-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/erp-technical-specialist.md +17 -0
- package/skills/afyx-engineering-expert/references/hardware-diagnostics-auditor.md +24 -0
- package/skills/afyx-engineering-expert/references/hardware-electronics-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/integration-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/legacy-modernization-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/llmops-prompt-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/network-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/performance-benchmark-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/platform-engineer.md +24 -0
- package/skills/afyx-engineering-expert/references/product-manager.md +17 -0
- package/skills/afyx-engineering-expert/references/qa-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/site-reliability-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/software-engineer.md +17 -0
- package/skills/afyx-engineering-expert/references/solutions-architect.md +17 -0
- package/skills/afyx-engineering-expert/references/specialists-index.md +33 -0
- package/skills/afyx-engineering-expert/references/subject-matter-expert.md +17 -0
- package/skills/afyx-engineering-expert/references/system-analyst.md +17 -0
- package/skills/afyx-engineering-expert/references/technical-project-manager.md +24 -0
- package/skills/afyx-engineering-expert/references/technical-writer.md +24 -0
- package/skills/afyx-engineering-expert/references/ui-ux-designer.md +17 -0
- package/skills/afyx-engineering-expert/workflows/ai-data-erp.md +20 -0
- package/skills/afyx-engineering-expert/workflows/debugging.md +10 -0
- package/skills/afyx-engineering-expert/workflows/discovery-design.md +11 -0
- package/skills/afyx-engineering-expert/workflows/implementation.md +12 -0
- package/skills/afyx-engineering-expert/workflows/incident-reliability.md +12 -0
- package/skills/afyx-engineering-expert/workflows/review-audit.md +13 -0
- package/skills/afyx-forge/SKILL.md +43 -0
- package/skills/afyx-forge/references/adaptive-policy.md +19 -0
- package/skills/efficient-coding/SKILL.md +33 -0
- package/skills/efficient-coding/references/investigation.md +27 -0
- package/skills/efficient-coding/references/token-efficiency.md +25 -0
- package/skills/efficient-coding/references/tool-routing.md +13 -0
- package/skills/odoo-engineering/SKILL.md +33 -0
- package/skills/odoo-engineering/references/common.md +9 -0
- package/skills/odoo-engineering/references/odoo-10.md +32 -0
- package/skills/odoo-engineering/references/odoo-11.md +26 -0
- package/skills/odoo-engineering/references/odoo-12.md +31 -0
- package/skills/odoo-engineering/references/odoo-13.md +27 -0
- package/skills/odoo-engineering/references/odoo-14.md +31 -0
- package/skills/odoo-engineering/references/odoo-15.md +34 -0
- package/skills/odoo-engineering/references/odoo-16.md +37 -0
- package/skills/odoo-engineering/references/odoo-17.md +37 -0
- package/skills/odoo-engineering/references/odoo-18.md +48 -0
- package/skills/odoo-engineering/references/odoo-19.md +43 -0
- package/skills/odoo-engineering/references/odoo-20.md +39 -0
- package/skills/odoo-engineering/references/reference-schema.md +16 -0
- package/skills/odoo-engineering/references/version-detection.md +13 -0
- package/tools/codex-usage/CodexUsage.psm1 +496 -0
- package/tools/codex-usage/codex-usage-doctor.ps1 +150 -0
- package/tools/codex-usage/codex-usage-pricing.json +25 -0
- package/tools/codex-usage/codex-usage-stop.ps1 +167 -0
- package/tools/codex-usage/codex-usage-watch.ps1 +250 -0
- package/tools/codex-usage/vscode-user-task.json +31 -0
- package/tools/windows-setup/SetupBootstrapper.cs +258 -0
- package/uninstall.ps1 +189 -0
- package/uninstall.sh +167 -0
- package/update.ps1 +95 -0
- package/update.sh +67 -0
- package/verify.ps1 +411 -0
- package/verify.sh +265 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Afyx Forge Core — Observable Task Classifier
|
|
3
|
+
* Analyzes task input (text or task file) and classifies it into
|
|
4
|
+
* the 6 standard Forge A0-A3 categories, assessing risk, framework, and safety boundaries.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const TASK_CATEGORIES = Object.freeze({
|
|
8
|
+
KNOWN_FILE_BUG: 'KNOWN_FILE_BUG',
|
|
9
|
+
UNKNOWN_DEFECT_DIAGNOSIS: 'UNKNOWN_DEFECT_DIAGNOSIS',
|
|
10
|
+
CROSS_MODULE_CHANGE: 'CROSS_MODULE_CHANGE',
|
|
11
|
+
SECURITY_SENSITIVE: 'SECURITY_SENSITIVE',
|
|
12
|
+
DATA_RELIABILITY: 'DATA_RELIABILITY',
|
|
13
|
+
NEGATIVE_SIMPLE: 'NEGATIVE_SIMPLE',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const RISK_LEVELS = Object.freeze({
|
|
17
|
+
LOW: 'LOW',
|
|
18
|
+
MEDIUM: 'MEDIUM',
|
|
19
|
+
HIGH: 'HIGH',
|
|
20
|
+
CRITICAL: 'CRITICAL',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const UNSAFE_DEFINITIONS = [
|
|
24
|
+
{
|
|
25
|
+
regex: /\b(?:force[\s_-]?push|push\s+(?:--force|-f))\b/i,
|
|
26
|
+
description: 'Unauthorized autonomous push or force-push directive detected',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
regex: /\b(?:bypass[\s_-]?(?:security|guard|gate|review)|ignore\s+permissions?)\b/i,
|
|
30
|
+
description: 'Bypassing security checks, review gates, or permission controls is prohibited',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
regex: /\b(?:expose|leak|dump)\s+(?:secret|token|api_key|password|credential|private_key)\b/i,
|
|
34
|
+
description: 'Directives to dump or expose secrets or private credentials are prohibited',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
regex: /\b(?:rm\s+-rf\s+[\/\*]|format\s+[c-z]:|drop\s+database\s+prod)\b/i,
|
|
38
|
+
description: 'Destructive filesystem or database deletion directives are prohibited',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const ODOO_PATTERNS = [
|
|
43
|
+
/\bodoo\b/i,
|
|
44
|
+
/\b__manifest__\.py\b/,
|
|
45
|
+
/\bir\.model\.access\.csv\b/,
|
|
46
|
+
/\b(?:_inherit|_name)\s*=\s*['"][a-zA-Z0-9_\.]+['"]/,
|
|
47
|
+
/\baddons\b[\/\\][a-zA-Z0-9_]+/,
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const SECURITY_PATTERNS = [
|
|
51
|
+
/\b(?:vulnerab|exploit|cve|xss|sql[\s_-]?injection|csrf|timing[\s_-]?attack)\b/i,
|
|
52
|
+
/\b(?:auth(?:entication|orization)?|oauth|jwt|session|crypto|cipher|secret|credential|acl|rbac)\s+(?:fix|bug|leak|audit|token|login|logout|grant|permission)\b/i,
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const DATA_PATTERNS = [
|
|
56
|
+
/\b(?:migration|schema|alembic|transaction|rollback|integrity|foreign\s+key|table\s+drop|data\s+loss)\b/i,
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const CROSS_MODULE_PATTERNS = [
|
|
60
|
+
/\b(?:cross[\s_-]?(?:module|service|package|component)|across\s+(?:modules|services|packages|components)|inter[\s_-]service|multi[\s_-]component|interface\s+contract|dependency\s+graph)\b/i,
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const UNKNOWN_DEFECT_PATTERNS = [
|
|
64
|
+
/\b(?:diagnos\w*|investigat\w*|unknown\s+(?:cause|defect|bug)|reproduc\w*|intermittent|root[\s_-]cause|flaky|traceback|stacktrace)\b/i,
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const SIMPLE_PATTERNS = [
|
|
68
|
+
/\b(?:typo|format(?:ting)?|comment|docstring|readme|lint\s+fix|simple\s+rename|whitespace)\b/i,
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Checks if task content contains unsafe requests forbidden by Bounded Execution.
|
|
73
|
+
* @param {string} text
|
|
74
|
+
* @returns {{ isUnsafe: boolean, reason?: string }}
|
|
75
|
+
*/
|
|
76
|
+
export function checkUnsafeRequest(text) {
|
|
77
|
+
for (const def of UNSAFE_DEFINITIONS) {
|
|
78
|
+
if (def.regex.test(text)) {
|
|
79
|
+
return {
|
|
80
|
+
isUnsafe: true,
|
|
81
|
+
reason: `${def.description} (pattern: ${def.regex.source})`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { isUnsafe: false };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Extracts referenced file paths from task text.
|
|
90
|
+
* @param {string} text
|
|
91
|
+
* @returns {string[]}
|
|
92
|
+
*/
|
|
93
|
+
export function extractReferencedFiles(text) {
|
|
94
|
+
const matches = new Set();
|
|
95
|
+
const fileRegex = /(?:[a-zA-Z0-9_\-\.\/\\]+\.(?:py|js|ts|mjs|cjs|json|xml|csv|md|ya?ml|html|css|sh|ps1|toml))/gi;
|
|
96
|
+
let match;
|
|
97
|
+
while ((match = fileRegex.exec(text)) !== null) {
|
|
98
|
+
const candidate = match[0].trim();
|
|
99
|
+
if (!candidate.startsWith('http://') && !candidate.startsWith('https://')) {
|
|
100
|
+
matches.add(candidate.replace(/\\/g, '/'));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return Array.from(matches);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Classifies an incoming task based on text content and optional explicit attributes.
|
|
108
|
+
* @param {string} taskText
|
|
109
|
+
* @param {object} [metadata={}]
|
|
110
|
+
* @returns {object} Classification result
|
|
111
|
+
*/
|
|
112
|
+
export function classifyTask(taskText, metadata = {}) {
|
|
113
|
+
const rawText = (taskText || '').trim();
|
|
114
|
+
const referencedFiles = extractReferencedFiles(rawText);
|
|
115
|
+
|
|
116
|
+
// Check safety first
|
|
117
|
+
const safetyCheck = checkUnsafeRequest(rawText);
|
|
118
|
+
if (safetyCheck.isUnsafe) {
|
|
119
|
+
return {
|
|
120
|
+
status: 'REFUSED_UNSAFE',
|
|
121
|
+
refusalReason: safetyCheck.reason,
|
|
122
|
+
primaryCategory: TASK_CATEGORIES.SECURITY_SENSITIVE,
|
|
123
|
+
riskLevel: RISK_LEVELS.CRITICAL,
|
|
124
|
+
confidence: 1.0,
|
|
125
|
+
referencedFiles,
|
|
126
|
+
frameworks: [],
|
|
127
|
+
observedComplexity: 'CRITICAL',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Detect frameworks
|
|
132
|
+
const frameworks = [];
|
|
133
|
+
if (ODOO_PATTERNS.some((re) => re.test(rawText)) || referencedFiles.some((f) => f.includes('__manifest__.py') || f.endsWith('ir.model.access.csv'))) {
|
|
134
|
+
frameworks.push('Odoo');
|
|
135
|
+
}
|
|
136
|
+
if (/\b(?:typescript|ts-node|tsconfig\.json)\b/i.test(rawText) || referencedFiles.some((f) => f.endsWith('.ts') || f.endsWith('.tsx'))) {
|
|
137
|
+
frameworks.push('TypeScript');
|
|
138
|
+
}
|
|
139
|
+
if (/\b(?:python|pytest|pip|requirements\.txt)\b/i.test(rawText) || referencedFiles.some((f) => f.endsWith('.py'))) {
|
|
140
|
+
frameworks.push('Python');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Determine category & risk
|
|
144
|
+
let category = TASK_CATEGORIES.UNKNOWN_DEFECT_DIAGNOSIS;
|
|
145
|
+
let risk = RISK_LEVELS.MEDIUM;
|
|
146
|
+
let complexity = 'MEDIUM';
|
|
147
|
+
let confidence = 0.85;
|
|
148
|
+
|
|
149
|
+
if (SECURITY_PATTERNS.some((re) => re.test(rawText))) {
|
|
150
|
+
category = TASK_CATEGORIES.SECURITY_SENSITIVE;
|
|
151
|
+
risk = RISK_LEVELS.HIGH;
|
|
152
|
+
complexity = 'HIGH';
|
|
153
|
+
confidence = 0.95;
|
|
154
|
+
} else if (DATA_PATTERNS.some((re) => re.test(rawText))) {
|
|
155
|
+
category = TASK_CATEGORIES.DATA_RELIABILITY;
|
|
156
|
+
risk = RISK_LEVELS.HIGH;
|
|
157
|
+
complexity = 'HIGH';
|
|
158
|
+
confidence = 0.90;
|
|
159
|
+
} else if (CROSS_MODULE_PATTERNS.some((re) => re.test(rawText)) || referencedFiles.length > 3) {
|
|
160
|
+
category = TASK_CATEGORIES.CROSS_MODULE_CHANGE;
|
|
161
|
+
risk = RISK_LEVELS.MEDIUM;
|
|
162
|
+
complexity = 'HIGH';
|
|
163
|
+
confidence = 0.88;
|
|
164
|
+
} else if (SIMPLE_PATTERNS.some((re) => re.test(rawText)) && referencedFiles.length <= 1) {
|
|
165
|
+
category = TASK_CATEGORIES.NEGATIVE_SIMPLE;
|
|
166
|
+
risk = RISK_LEVELS.LOW;
|
|
167
|
+
complexity = 'LOW';
|
|
168
|
+
confidence = 0.95;
|
|
169
|
+
} else if (referencedFiles.length === 1 && !UNKNOWN_DEFECT_PATTERNS.some((re) => re.test(rawText))) {
|
|
170
|
+
category = TASK_CATEGORIES.KNOWN_FILE_BUG;
|
|
171
|
+
risk = RISK_LEVELS.LOW;
|
|
172
|
+
complexity = 'LOW';
|
|
173
|
+
confidence = 0.92;
|
|
174
|
+
} else if (UNKNOWN_DEFECT_PATTERNS.some((re) => re.test(rawText))) {
|
|
175
|
+
category = TASK_CATEGORIES.UNKNOWN_DEFECT_DIAGNOSIS;
|
|
176
|
+
risk = RISK_LEVELS.MEDIUM;
|
|
177
|
+
complexity = 'MEDIUM';
|
|
178
|
+
confidence = 0.85;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
status: 'PLANNED',
|
|
183
|
+
primaryCategory: category,
|
|
184
|
+
riskLevel: risk,
|
|
185
|
+
observedComplexity: complexity,
|
|
186
|
+
confidence,
|
|
187
|
+
frameworks,
|
|
188
|
+
referencedFiles,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Afyx Forge Core — CLI Interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { createForgePlan, runDoctor, FORGE_CORE_VERSION } from './index.js';
|
|
8
|
+
|
|
9
|
+
function printHelp() {
|
|
10
|
+
console.log(`
|
|
11
|
+
Afyx Forge Core v${FORGE_CORE_VERSION} — Standalone Adaptive Engineering Guidance Runtime
|
|
12
|
+
|
|
13
|
+
USAGE:
|
|
14
|
+
afyx-forge <command> [options]
|
|
15
|
+
|
|
16
|
+
COMMANDS:
|
|
17
|
+
plan Formulate an actionable engineering plan and adaptive routing policy
|
|
18
|
+
doctor Diagnose agent surfaces, runtime components, and governance gates
|
|
19
|
+
version Display version and build metadata
|
|
20
|
+
help Display help information
|
|
21
|
+
|
|
22
|
+
OPTIONS for 'plan':
|
|
23
|
+
--task <string> Direct task description string
|
|
24
|
+
--task-file <path> Path to task markdown/text file
|
|
25
|
+
--format <type> Output format: 'json' (default) or 'markdown'
|
|
26
|
+
--output <path> Save result to specified file path instead of stdout
|
|
27
|
+
|
|
28
|
+
GLOBAL OPTIONS:
|
|
29
|
+
-v, --version Show version
|
|
30
|
+
-h, --help Show help
|
|
31
|
+
|
|
32
|
+
EXAMPLES:
|
|
33
|
+
afyx-forge doctor
|
|
34
|
+
afyx-forge plan --task "Fix NullPointerException in checkout payment settlement"
|
|
35
|
+
afyx-forge plan --task-file ./task-description.md --format markdown
|
|
36
|
+
afyx-forge plan --task-file ./task.md --output ./plan.json
|
|
37
|
+
`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function runCli(args = process.argv.slice(2)) {
|
|
41
|
+
if (args.length === 0 || args.includes('-h') || args.includes('--help') || args[0] === 'help') {
|
|
42
|
+
printHelp();
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (args.includes('-v') || args.includes('--version') || args[0] === 'version') {
|
|
47
|
+
console.log(`afyx-forge ${FORGE_CORE_VERSION} (Afyx Forge Core Alpha - Bounded Engineering Guidance)`);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const command = args[0];
|
|
52
|
+
|
|
53
|
+
if (command === 'doctor') {
|
|
54
|
+
const diagnostic = runDoctor();
|
|
55
|
+
console.log(JSON.stringify(diagnostic, null, 2));
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (command === 'plan') {
|
|
60
|
+
let taskText = '';
|
|
61
|
+
let taskFile = '';
|
|
62
|
+
let format = 'json';
|
|
63
|
+
let outputPath = '';
|
|
64
|
+
|
|
65
|
+
for (let i = 1; i < args.length; i++) {
|
|
66
|
+
if (args[i] === '--task' && args[i + 1]) {
|
|
67
|
+
taskText = args[++i];
|
|
68
|
+
} else if (args[i] === '--task-file' && args[i + 1]) {
|
|
69
|
+
taskFile = args[++i];
|
|
70
|
+
} else if (args[i] === '--format' && args[i + 1]) {
|
|
71
|
+
format = args[++i].toLowerCase();
|
|
72
|
+
} else if (args[i] === '--output' && args[i + 1]) {
|
|
73
|
+
outputPath = args[++i];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!taskText && !taskFile) {
|
|
78
|
+
console.error('Error: Either --task or --task-file must be provided for "plan".');
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
const plan = createForgePlan({ taskText, taskFile, format });
|
|
84
|
+
const rendered = typeof plan === 'string' ? plan : JSON.stringify(plan, null, 2);
|
|
85
|
+
|
|
86
|
+
if (outputPath) {
|
|
87
|
+
const resolvedOut = path.resolve(outputPath);
|
|
88
|
+
fs.mkdirSync(path.dirname(resolvedOut), { recursive: true });
|
|
89
|
+
fs.writeFileSync(resolvedOut, rendered + '\n', 'utf8');
|
|
90
|
+
console.log(`Plan written to: ${resolvedOut}`);
|
|
91
|
+
} else {
|
|
92
|
+
console.log(rendered);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// If refused unsafe, exit with status 2 to indicate safety refusal
|
|
96
|
+
if (typeof plan === 'object' && plan.status === 'REFUSED_UNSAFE') {
|
|
97
|
+
return 2;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return 0;
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.error(`Error: ${err.message}`);
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.error(`Unknown command: ${command}`);
|
|
108
|
+
printHelp();
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Afyx Forge Core — Doctor & Environment Diagnostic
|
|
3
|
+
* Inspects host surfaces, runtime components, and governance boundaries.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
|
|
11
|
+
function checkCommand(cmd) {
|
|
12
|
+
try {
|
|
13
|
+
const isWin = process.platform === 'win32';
|
|
14
|
+
const checkCmd = isWin ? `where ${cmd}` : `which ${cmd}`;
|
|
15
|
+
execSync(checkCmd, { stdio: 'pipe', encoding: 'utf8' });
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function checkPathExists(targetPath) {
|
|
23
|
+
try {
|
|
24
|
+
return fs.existsSync(targetPath);
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Runs a comprehensive health diagnostic of the Forge Core runtime and its integration environment.
|
|
32
|
+
* @returns {object} Diagnostic report
|
|
33
|
+
*/
|
|
34
|
+
export function runDoctor() {
|
|
35
|
+
const homeDir = os.homedir();
|
|
36
|
+
const nodeVersion = process.version;
|
|
37
|
+
const platform = `${process.platform} (${os.arch()})`;
|
|
38
|
+
|
|
39
|
+
// 1. Host Agent Surfaces
|
|
40
|
+
const hasCodex = checkCommand('codex');
|
|
41
|
+
const hasAgy = checkCommand('agy') || checkCommand('antigravity');
|
|
42
|
+
const hasClaude = checkCommand('claude');
|
|
43
|
+
|
|
44
|
+
// 2. Afyx Runtime Components
|
|
45
|
+
const hasGraphCli = checkCommand('afyx-graph');
|
|
46
|
+
const hasContextCli = checkCommand('afyx-context');
|
|
47
|
+
|
|
48
|
+
const graphRuntimeDir = process.env.AFYX_GRAPH_RUNTIME_ROOT || path.join(homeDir, '.afyx', 'graph');
|
|
49
|
+
const contextRuntimeDir = process.env.AFYX_CONTEXT_RUNTIME_ROOT || path.join(homeDir, '.afyx', 'context');
|
|
50
|
+
const forgeRuntimeDir = process.env.AFYX_FORGE_RUNTIME_ROOT || path.join(homeDir, '.afyx', 'forge');
|
|
51
|
+
|
|
52
|
+
const isGraphInstalled = hasGraphCli || checkPathExists(path.join(graphRuntimeDir, 'metadata.json'));
|
|
53
|
+
const isContextInstalled = hasContextCli || checkPathExists(path.join(contextRuntimeDir, 'metadata.json'));
|
|
54
|
+
const isForgeInstalled = checkPathExists(path.join(forgeRuntimeDir, 'metadata.json'));
|
|
55
|
+
|
|
56
|
+
// 3. Skills Presence
|
|
57
|
+
const agentsSkillsDir = path.join(homeDir, '.agents', 'skills');
|
|
58
|
+
const geminiSkillsDir = path.join(homeDir, '.gemini', 'config', 'skills');
|
|
59
|
+
|
|
60
|
+
const hasEfficientCoding =
|
|
61
|
+
checkPathExists(path.join(agentsSkillsDir, 'efficient-coding')) ||
|
|
62
|
+
checkPathExists(path.join(geminiSkillsDir, 'efficient-coding'));
|
|
63
|
+
const hasOdooEngineering =
|
|
64
|
+
checkPathExists(path.join(agentsSkillsDir, 'odoo-engineering')) ||
|
|
65
|
+
checkPathExists(path.join(geminiSkillsDir, 'odoo-engineering'));
|
|
66
|
+
const hasEngineeringExpert =
|
|
67
|
+
checkPathExists(path.join(agentsSkillsDir, 'afyx-engineering-expert')) ||
|
|
68
|
+
checkPathExists(path.join(geminiSkillsDir, 'afyx-engineering-expert'));
|
|
69
|
+
|
|
70
|
+
// 4. Governance & Evaluation Gate
|
|
71
|
+
const evaluationGate = {
|
|
72
|
+
gate: 'A8_FORMAL_CAMPAIGN',
|
|
73
|
+
status: 'EVALUATION_GATED (0/36 NOT_RUN)',
|
|
74
|
+
localDecision: 'GO_OWNER_APPROVED_LOCAL_SCOPE',
|
|
75
|
+
formalCampaign: 'WAIVED_BY_OWNER_NOT_RUN',
|
|
76
|
+
autonomousExecutionAllowed: false,
|
|
77
|
+
uncontrolledModelCost: false,
|
|
78
|
+
runtimeMode: 'ASSISTIVE_GUIDANCE_ONLY',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
forgeCoreVersion: '0.1.0',
|
|
83
|
+
runtime: {
|
|
84
|
+
nodeVersion,
|
|
85
|
+
platform,
|
|
86
|
+
},
|
|
87
|
+
agentSurfaces: {
|
|
88
|
+
codex: hasCodex ? 'DETECTED' : 'UNAVAILABLE',
|
|
89
|
+
antigravity: hasAgy ? 'DETECTED' : 'UNAVAILABLE',
|
|
90
|
+
claude: hasClaude ? 'DETECTED' : 'UNAVAILABLE',
|
|
91
|
+
},
|
|
92
|
+
afyxComponents: {
|
|
93
|
+
afyxGraph: isGraphInstalled ? 'HEALTHY' : 'NOT_INSTALLED',
|
|
94
|
+
afyxContext: isContextInstalled ? 'HEALTHY (DEFAULT OFF)' : 'NOT_INSTALLED',
|
|
95
|
+
afyxForgeCore: isForgeInstalled ? 'INSTALLED' : 'DEVELOPMENT_SOURCE',
|
|
96
|
+
},
|
|
97
|
+
skills: {
|
|
98
|
+
efficientCoding: hasEfficientCoding ? 'INSTALLED' : 'NOT_FOUND',
|
|
99
|
+
odooEngineering: hasOdooEngineering ? 'INSTALLED' : 'NOT_FOUND',
|
|
100
|
+
engineeringExpert: hasEngineeringExpert ? 'INSTALLED' : 'NOT_FOUND',
|
|
101
|
+
},
|
|
102
|
+
governance: evaluationGate,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Afyx Forge Core — Actionable Engineering Guidance Generator
|
|
3
|
+
* Formulates investigation priorities, preferred/avoided tools,
|
|
4
|
+
* validation scope, and explicit completion criteria for software engineers and AI agents.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { EXECUTION_MODES } from './policy.js';
|
|
8
|
+
import { TASK_CATEGORIES } from './classifier.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generates actionable engineering guidance based on classification and adaptive policy.
|
|
12
|
+
*
|
|
13
|
+
* @param {object} classification
|
|
14
|
+
* @param {object} policy
|
|
15
|
+
* @param {string} taskText
|
|
16
|
+
* @returns {object} Structured guidance
|
|
17
|
+
*/
|
|
18
|
+
export function generateGuidance(classification, policy, taskText) {
|
|
19
|
+
const { primaryCategory, frameworks = [], referencedFiles = [] } = classification;
|
|
20
|
+
const { executionMode, graphRouting } = policy;
|
|
21
|
+
|
|
22
|
+
const investigationPriorities = [];
|
|
23
|
+
const preferredTools = [];
|
|
24
|
+
const avoidedTools = [];
|
|
25
|
+
const validationScope = [];
|
|
26
|
+
const completionCriteria = [];
|
|
27
|
+
|
|
28
|
+
// 1. Investigation Priorities
|
|
29
|
+
if (executionMode === EXECUTION_MODES.DIRECT_MINIMAL) {
|
|
30
|
+
investigationPriorities.push('1. Direct Inspection: Read the target file directly at the exact symbol location.');
|
|
31
|
+
investigationPriorities.push('2. Focused Edit: Apply the minimal necessary change while preserving surrounding comments and structure.');
|
|
32
|
+
investigationPriorities.push('3. Unit Verification: Execute the single affected unit test.');
|
|
33
|
+
} else if (executionMode === EXECUTION_MODES.FOCUSED_INVESTIGATION) {
|
|
34
|
+
investigationPriorities.push('1. Symptom Reproduction: Reproduce the observed defect or error trace before modifying code.');
|
|
35
|
+
investigationPriorities.push('2. Root-Cause Isolation: Trace variable states and caller paths using focused search.');
|
|
36
|
+
investigationPriorities.push('3. Hypothesize & Verify: Formulate the minimal correction and prove it resolves the symptom.');
|
|
37
|
+
} else if (executionMode === EXECUTION_MODES.STRUCTURAL_GRAPH_AWARE) {
|
|
38
|
+
investigationPriorities.push('1. Dependency Mapping: Inspect cross-module interfaces and call hierarchies.');
|
|
39
|
+
if (graphRouting === 'RECOMMENDED') {
|
|
40
|
+
investigationPriorities.push('2. Graph Impact Analysis: Query callers, callees, and affected test suites via Afyx Graph.');
|
|
41
|
+
} else {
|
|
42
|
+
investigationPriorities.push('2. Source Trace: Trace imports and usages across modules using ripgrep.');
|
|
43
|
+
}
|
|
44
|
+
investigationPriorities.push('3. Contract Preservation: Verify that existing API signatures remain backwards-compatible.');
|
|
45
|
+
investigationPriorities.push('4. Integrated Validation: Run multi-component test suite.');
|
|
46
|
+
} else if (executionMode === EXECUTION_MODES.SECURITY_DEFENSE_IN_DEPTH) {
|
|
47
|
+
investigationPriorities.push('1. Security Boundary Audit: Identify trust boundaries, untrusted input paths, and privilege levels.');
|
|
48
|
+
investigationPriorities.push('2. Defense-in-Depth Verification: Ensure strict validation, authorization checks, and fail-closed defaults.');
|
|
49
|
+
investigationPriorities.push('3. Exploit/Regression Test: Write a negative test proving unauthorized requests are rejected.');
|
|
50
|
+
} else if (executionMode === EXECUTION_MODES.DOMAIN_SPECIALIST) {
|
|
51
|
+
if (frameworks.includes('Odoo')) {
|
|
52
|
+
investigationPriorities.push('1. Odoo Release Schema: Determine target Odoo release (10-20) from evidence and follow ORM conventions.');
|
|
53
|
+
investigationPriorities.push('2. Model & View Inheritance: Track `_inherit` hierarchy and XML view xpath selectors.');
|
|
54
|
+
investigationPriorities.push('3. Security & ACL: Ensure ir.model.access.csv and record rules match model definitions.');
|
|
55
|
+
} else {
|
|
56
|
+
investigationPriorities.push('1. Domain Architecture Review: Consult domain-specific standards and data models.');
|
|
57
|
+
investigationPriorities.push('2. Transactional Safety: Verify atomicity, rollback safety, and migration reversibility.');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 2. Tool Recommendations
|
|
62
|
+
if (executionMode === EXECUTION_MODES.DIRECT_MINIMAL) {
|
|
63
|
+
preferredTools.push('Direct source reading (read_file)');
|
|
64
|
+
preferredTools.push('Focused search (rg / ripgrep)');
|
|
65
|
+
preferredTools.push('Single test runner');
|
|
66
|
+
avoidedTools.push('Afyx Graph indexing (unnecessary overhead for known file)');
|
|
67
|
+
avoidedTools.push('Afyx Context Engine (keep default OFF)');
|
|
68
|
+
avoidedTools.push('Speculative prompt rewriting or agent swarms');
|
|
69
|
+
} else if (executionMode === EXECUTION_MODES.STRUCTURAL_GRAPH_AWARE) {
|
|
70
|
+
if (graphRouting === 'RECOMMENDED') {
|
|
71
|
+
preferredTools.push('Afyx Graph CLI/MCP (afyx_graph_explore, callers, impact)');
|
|
72
|
+
}
|
|
73
|
+
preferredTools.push('ripgrep (cross-file symbol search)');
|
|
74
|
+
preferredTools.push('git diff (verifying boundary changes)');
|
|
75
|
+
avoidedTools.push('Blind whole-repository search');
|
|
76
|
+
avoidedTools.push('Afyx Context Engine (keep default OFF unless explicitly requested)');
|
|
77
|
+
} else if (executionMode === EXECUTION_MODES.SECURITY_DEFENSE_IN_DEPTH) {
|
|
78
|
+
preferredTools.push('Source code inspection and dataflow tracing');
|
|
79
|
+
preferredTools.push('Negative unit/integration security tests');
|
|
80
|
+
avoidedTools.push('Disabling security checks or mock-only bypasses');
|
|
81
|
+
avoidedTools.push('Uncontrolled external package installations');
|
|
82
|
+
} else {
|
|
83
|
+
preferredTools.push('Direct source tools (read_file, edit_file)');
|
|
84
|
+
preferredTools.push('Focused test execution');
|
|
85
|
+
avoidedTools.push('Heavyweight indexing when localized tools suffice');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 3. Validation Scope
|
|
89
|
+
if (referencedFiles.length > 0) {
|
|
90
|
+
for (const f of referencedFiles.slice(0, 3)) {
|
|
91
|
+
validationScope.push(`Verify syntax and structure of ${f}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
validationScope.push('Run targeted unit and regression tests associated with the change.');
|
|
95
|
+
if (frameworks.includes('Odoo')) {
|
|
96
|
+
validationScope.push('Validate Odoo manifest syntax and dependency consistency.');
|
|
97
|
+
}
|
|
98
|
+
if (primaryCategory === TASK_CATEGORIES.SECURITY_SENSITIVE) {
|
|
99
|
+
validationScope.push('Prove unauthorized access fails closed with proper rejection.');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 4. Completion Criteria
|
|
103
|
+
completionCriteria.push('All targeted unit and regression tests pass with exit code 0.');
|
|
104
|
+
completionCriteria.push('Working tree is clean with no temporary files, debug logs, or unwanted artifacts committed.');
|
|
105
|
+
completionCriteria.push('No regressions introduced into existing public contracts or interfaces.');
|
|
106
|
+
if (primaryCategory === TASK_CATEGORIES.SECURITY_SENSITIVE) {
|
|
107
|
+
completionCriteria.push('Security audit verified: no credentials exposed, no permissions bypassed.');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
investigationPriorities,
|
|
112
|
+
toolRecommendations: {
|
|
113
|
+
preferred: preferredTools,
|
|
114
|
+
avoided: avoidedTools,
|
|
115
|
+
},
|
|
116
|
+
validationScope,
|
|
117
|
+
completionCriteria,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|