import { HardeningScanner, AgentRuntimeProtection, AttackScanner } from 'hackmyagent';
import {
SemanticCompiler,
analyzeCapabilities,
analyzeCredentials,
analyzeGovernance,
analyzeScope,
analyzePrompt,
analyzeCode,
getTMEClassifier,
} from 'hackmyagent/nanomind-core';
const compiler = new SemanticCompiler();
const { ast } = await compiler.compile(skillContent, 'my-skill.skill.md');
// ast.intentClassification: 'benign' | 'suspicious' | 'malicious'
// ast.inferredCapabilities, ast.declaredConstraints, ast.inferredRiskSurface
const findings = analyzeCapabilities(ast);parseHmaIgnore, matchHmaIgnore and isScopeChannel are exported from the
package root, so a tool that honours the same .hmaignore file reads it with
the parser and tier order secure and check use.
import { readFileSync } from 'node:fs';
import { parseHmaIgnore, matchHmaIgnore, isScopeChannel } from 'hackmyagent';
import type { ParsedHmaIgnore } from 'hackmyagent';
const today = new Date().toISOString().slice(0, 10); // UTC, YYYY-MM-DD
const parsed: ParsedHmaIgnore = {
present: true,
file: '.hmaignore',
...parseHmaIgnore(readFileSync('.hmaignore', 'utf-8'), today),
};
for (const e of parsed.errors) console.error(`.hmaignore:${e.line}: ${e.error}`);
const finding = { checkId: 'NEMO-009', file: 'danger.py' };
const match = matchHmaIgnore(structuredClone(finding), parsed);
if (match === null) {
// No rule matches: the finding stays in the report.
} else if (isScopeChannel(match.channel)) {
// `<path>` or `<path>:<CHECK-ID>`: the finding leaves the score and the exit code.
} else {
// `!<CHECK-ID>`: listed as suppressed, still scored and still in the exit code.
}todayis the UTC calendar date asYYYY-MM-DD, the datesecureandcheckuse. A rule withexpires:<YYYY-MM-DD>is active whiletodayis on or before that date; from the next day it is anerrorsentry, not a rule. A local date can apply a rule one day longer or shorter than the CLI does.parseHmaIgnorereturns{ rules, errors }.matchHmaIgnoretakes aParsedHmaIgnore, which also holdspresent(whether the file exists) andfile('.hmaignore', relative to the scanned directory), so add both to the parser's result as above. The loader that builds this object for the CLI is not exported from the package root. For a directory without the file, pass{ present: false, file: '.hmaignore', rules: [], errors: [] }.matchHmaIgnorecan change the finding it is given. When<path>rules cover some but not all of the paths a finding names (fileanddetails.files), the finding is kept and those two fields are rewritten to the paths that are not covered. Pass a deep copy, asstructuredClonedoes above, when the original has to stay as it was.- The third argument of
matchHmaIgnoreis a list of further paths treated as<path>rules, such as paths a caller excludes on its command line. A match through one of them haslineundefined; any other match carries the 1-based line of the rule. - The tiers are applied in order:
<path>, then<path>:<CHECK-ID>, then!<CHECK-ID>. Check ids and patterns compare case-insensitively, and*in a pattern matches any run of characters.
Plugin authoring: docs/PLUGIN_API.md.