aegisai-harness 0.78.0 → 0.80.0

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/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to AegisAi Harness are documented here.
4
4
 
5
- ## [0.78.0] - 2026-11-25
5
+ ## [0.80.0] - 2026-11-25
6
6
 
7
7
  ### Fixed
8
8
  - Installation: Windows installer now preflights Node.js 22.13+ with actionable messages; launcher no longer hides npm failures, uses `--omit=dev`, and records a dependency marker. Inno uninstall removes stale `node_modules`/lockfiles; `install.ps1` preserves `data/` and handles GitHub source zips.
package/README.md CHANGED
@@ -10,7 +10,7 @@ A **feature-rich, local-only AI agent harness** — OpenCode-class runtime, but
10
10
  offline-first: no cloud dependencies, no telemetry. 66 milestones, ~200 modules,
11
11
  257 tests, CI green.
12
12
 
13
- > Status: v0.78.0 (see [ROADMAP.md](./ROADMAP.md)).
13
+ > Status: v0.80.0 (see [ROADMAP.md](./ROADMAP.md)).
14
14
  > **Successor to [aegisai-next](https://github.com/user6811992/aegisai-next)** — that project is deprecated; all features have been ported here.
15
15
  > **Live docs:** https://user6811992.github.io/aegisai-harness/
16
16
 
package/ROADMAP.md CHANGED
@@ -497,9 +497,43 @@ Feasibility: **H** = fits current JS architecture, **M** = needs external servic
497
497
  - [ ] Synthetic security log corpus (talos/EvidenceForge) — generated hunt datasets for testing `security_kb` and detection rules. — **H**
498
498
  - [ ] IoC feed import (talos/IOCs) — load indicators into `security_kb` with hashes/domains/IPs for offline matching. — **H**
499
499
 
500
- ## Batch plan (updated)
500
+ ## v0.79 — From anthropics, openai, usestrix, projectdiscovery, microsoft, qybaihe
501
+ (`aquaticsecurity` returned 404 — org not found/renamed; nothing to mine.)
501
502
 
502
- ### Batch 3 — next
503
+ ### Agent skills & plugins (anthropics/skills, claude-plugins-official)
504
+ - [ ] Align `SKILL.md` with the canonical Agent Skills schema (name, description, license, allowed-tools) and validate on import. — **H**
505
+ - [ ] Adopt the official plugin manifest shape for `plugin_marketplace` so third-party directories can be consumed. — **M**
506
+ - [ ] Domain plugin packs (legal/knowledge-work style bundles) as a first-class packaging unit. — **M**
507
+
508
+ ### Multi-agent handoffs (openai/openai-agents-python)
509
+ - [ ] Handoff primitive — transfer the conversation (with context) from one agent to another, distinct from agents-as-tools. — **H**
510
+
511
+ ### Pentest → remediation loop (usestrix/strix, usestrix/benchmarks)
512
+ - [ ] Remediation stage — after a finding, propose a patch, apply it in a worktree, re-run the probe to prove the fix, and record evidence. — **H**
513
+ - [ ] Pentest eval harness — deterministic target fixtures + expected findings, scored like `yasscore`. — **H**
514
+ - [ ] Package-install guard (supply-chain firewall) — policy check before `npm install`-style actions. — **M**
515
+
516
+ ### Template-driven scanning & web recon (projectdiscovery)
517
+ - [ ] YAML template scanner (nuclei-style subset) — request templates with matchers/extractors, run against a target, emit SARIF. — **H**
518
+ - [ ] Endpoint crawler (katana-style) — crawl links + extract from JS, feed the pentest pipeline and `re_index`. — **H**
519
+ - [ ] HTTP probe tool (httpx-style) — status, title, headers, tech fingerprint for a list of URLs. — **H**
520
+ - [ ] OOB interaction channel (interactsh-style) for blind SSRF/XXE — needs an external collaborator or self-hosted listener. — **M**
521
+ - [ ] DNS/port enumeration adapters (subfinder/dnsx/naabu) behind the pentest profile. — **M**
522
+
523
+ ### Document ingestion (microsoft/markitdown)
524
+ - [ ] Document → Markdown converter — PDF text, DOCX/XLSX/PPTX (OOXML zip+XML, zero deps), HTML, CSV; wire into attachments and `/api/file`. — **H**
525
+ - [ ] Playwright driver as an alternative browser backend to raw CDP. — **M**
526
+
527
+ ### Cheap decision routing & generation skills (qybaihe/mu, codex-ppt)
528
+ - [ ] Tiny-model boolean router — route binary decisions (yes/no gates) to a small local model, with fallback to heuristics. — **H**
529
+ - [ ] Slide/deck skill — generate 16:9 PDF decks using the existing `pdf_writer`. — **H**
530
+ - [ ] Deterministic design-direction picker (hash-design pattern) — seeded choice among style presets for generated artifacts. — **L**
531
+
532
+ ### Runtime defense for generated apps (qybaihe/bla)
533
+ - [ ] Opt-in guard injection for generated JS/TS/Electron apps (defensive scaffolding), reported as a build-time artefact. — **M**
534
+
535
+
536
+ ### Batch 3 — next (v0.79)
503
537
  | Item | Source | Feasibility |
504
538
  |---|---|---|
505
539
  | Model behaviour probe suite | nvidia/garak | H |
@@ -508,12 +542,22 @@ Feasibility: **H** = fits current JS architecture, **M** = needs external servic
508
542
  | Multi-phase audit with independent verification | cloudflare/security-audit-skill | H |
509
543
  | `mcp-inspect` deterministic MCP tests | modelcontextprotocol/inspector | H |
510
544
  | Screenshot → vision → click | bytedance/UI-TARS-desktop | H |
545
+ | YAML template scanner (nuclei subset) | projectdiscovery/nuclei | H |
546
+ | Endpoint crawler | projectdiscovery/katana | H |
547
+ | Remediation loop (find → fix → re-verify) | usestrix/strix | H |
548
+ | Document → Markdown converter | microsoft/markitdown | H |
549
+ | Handoff primitive | openai/openai-agents-python | H |
511
550
  | Conversation templates | prior backlog | H |
512
- | Multi-model A/B testing across runs | prior backlog | H |
551
+ | Multi-model A/B across runs | prior backlog | H |
513
552
 
514
553
  ### Batch 4 — after
515
554
  | Item | Source | Feasibility |
516
555
  |---|---|---|
556
+ | HTTP probe tool (httpx-style) | projectdiscovery/httpx | H |
557
+ | Pentest eval harness | usestrix/benchmarks | H |
558
+ | Tiny-model boolean router | qybaihe/mu | H |
559
+ | Slide/deck skill (PDF) | qybaihe/codex-ppt | H |
560
+ | Canonical Agent Skills schema | anthropics/skills | H |
517
561
  | Interactive architecture map page | haydenschmitty/floorplan | H |
518
562
  | Guardrail routing API surface | sandbox-quantum/switch-trust | H |
519
563
  | IoC feed import | cisco-talos/IOCs | H |
@@ -527,12 +571,20 @@ Feasibility: **H** = fits current JS architecture, **M** = needs external servic
527
571
  | Binary function similarity | cisco-talos/binary_function_similarity | M |
528
572
  | RAGFlow-style private retrieval | bytedance/deer-flow | M |
529
573
  | Codex-style MCP config presets | openai/codex | H |
574
+ | Package-install guard | usestrix/firewall | M |
575
+ | OOB interaction channel | projectdiscovery/interactsh | M |
576
+ | DNS/port enumeration | projectdiscovery/subfinder+dnsx+naabu | M |
577
+ | Playwright browser driver | microsoft/playwright | M |
578
+ | Official plugin manifest | anthropics/claude-plugins-official | M |
579
+ | Domain plugin packs | anthropics/knowledge-work-plugins | M |
580
+ | Runtime defense scaffolding | qybaihe/bla | M |
530
581
  | Plugin marketplace maturity | prior backlog | M |
531
582
  | Mobile PWA polish | prior backlog | H |
532
583
 
533
584
  ### Batch 5 — polish / ecosystem
534
585
  | Item | Source | Feasibility |
535
586
  |---|---|---|
587
+ | Deterministic design-direction picker | qybaihe/hash-design | L |
536
588
  | Community plugin ecosystem | prior backlog | ecosystem |
537
589
  | Docs & tutorials | prior backlog | H |
538
590
  | Performance optimization (large context) | prior backlog | H |
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # AegisAi Harness — agent-readable catalog
2
2
 
3
- A feature-rich, local-only AI agent harness. CLI-first, offline-first. v0.78.0.
3
+ A feature-rich, local-only AI agent harness. CLI-first, offline-first. v0.80.0.
4
4
 
5
5
  ## Capabilities
6
6
  - Multi-backend LLM adapter (Ollama + OpenAI-compatible + 18 providers)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aegisai-harness",
3
- "version": "0.78.0",
3
+ "version": "0.80.0",
4
4
  "description": "AegisAi Harness — feature-rich, local-only AI agent harness",
5
5
  "type": "commonjs",
6
6
  "main": "src/index.js",
@@ -4,13 +4,13 @@
4
4
  [Setup]
5
5
  AppId={{8F3D1B2A-6C4E-4B9A-9D21-AE615A010001}}
6
6
  AppName=AegisAi Harness
7
- AppVersion=0.78.0
7
+ AppVersion=0.80.0
8
8
  AppPublisher=AegisAi
9
9
  AppPublisherURL=https://github.com/user6811992/aegisai-harness
10
10
  DefaultDirName={autopf}\AegisAiHarness
11
11
  DefaultGroupName=AegisAi Harness
12
12
  OutputDir=..\..\dist
13
- OutputBaseFilename=AegisAi-Harness-0.78.0-Setup
13
+ OutputBaseFilename=AegisAi-Harness-0.80.0-Setup
14
14
  Compression=lzma2
15
15
  SolidCompression=yes
16
16
  PrivilegesRequired=lowest
@@ -0,0 +1,42 @@
1
+ // /authtoken.js — shared auth shim for secondary pages (plugins, dag, trajectory).
2
+ // Reads the token from sessionStorage (set by the main UI) or ?token= in the URL,
3
+ // then attaches it to fetch() and EventSource() calls.
4
+ (function () {
5
+ function readToken() {
6
+ try {
7
+ const q = new URL(location.href).searchParams.get('token');
8
+ if (q) { try { sessionStorage.setItem('aegisai_token', q); } catch (e) {} return q; }
9
+ return sessionStorage.getItem('aegisai_token') || localStorage.getItem('aegisai_token') || '';
10
+ } catch (e) { return ''; }
11
+ }
12
+ const token = readToken();
13
+
14
+ function withToken(url) {
15
+ if (!token) return url;
16
+ try {
17
+ const u = new URL(url, location.origin);
18
+ if (!u.searchParams.has('token')) u.searchParams.set('token', token);
19
+ return u.pathname + u.search + u.hash;
20
+ } catch (e) { return url; }
21
+ }
22
+
23
+ if (token) {
24
+ const origFetch = window.fetch.bind(window);
25
+ window.fetch = function (input, init) {
26
+ const opts = Object.assign({}, init || {});
27
+ const headers = new Headers(opts.headers || {});
28
+ if (!headers.has('Authorization')) headers.set('Authorization', 'Bearer ' + token);
29
+ opts.headers = headers;
30
+ const url = typeof input === 'string' ? withToken(input) : input;
31
+ return origFetch(url, opts);
32
+ };
33
+
34
+ const OrigEventSource = window.EventSource;
35
+ if (OrigEventSource) {
36
+ window.EventSource = function (url, cfg) { return new OrigEventSource(withToken(url), cfg); };
37
+ window.EventSource.prototype = OrigEventSource.prototype;
38
+ }
39
+ }
40
+
41
+ window.AEGISAI_AUTH = { token, withToken, hasToken: Boolean(token) };
42
+ })();
package/public/dag.html CHANGED
@@ -15,6 +15,7 @@
15
15
  <h3>Recent runs</h3>
16
16
  <div id="runs" class="graph"></div>
17
17
  </div>
18
+ <script src="/authtoken.js"></script>
18
19
  <script>
19
20
  async function load() {
20
21
  const r = await fetch('/api/dag-runs'); const data = await r.json();
@@ -9,6 +9,7 @@
9
9
  <h3>Live events</h3>
10
10
  <pre id="events" style="max-height:400px;overflow:auto"></pre>
11
11
  </div>
12
+ <script src="/authtoken.js"></script>
12
13
  <script>
13
14
  async function load() {
14
15
  const r = await fetch('/api/plugins'); const data = await r.json();
package/public/sw.js CHANGED
@@ -1,4 +1,4 @@
1
- const CACHE = 'aegisai-harness-v2';
1
+ const CACHE = 'aegisai-harness-v3';
2
2
  const PRECACHE = ['/', '/style.css', '/app.js', '/manifest.json', '/vendor/preact.mjs', '/vendor/hooks.mjs', '/vendor/htm.mjs', '/vendor/tailwind.js'];
3
3
 
4
4
  self.addEventListener('install', (e) => {
@@ -21,6 +21,24 @@ self.addEventListener('fetch', (e) => {
21
21
  if (url.origin !== self.location.origin) return;
22
22
  // Never intercept API / protocol calls: always network, never cached.
23
23
  if (url.pathname.startsWith('/api/') || url.pathname === '/mcp' || url.pathname.startsWith('/mcp/')) return;
24
+
25
+ const isNavigation = req.mode === 'navigate' || (req.headers.get('accept') || '').includes('text/html');
26
+ if (isNavigation) {
27
+ // Network-first for pages so a new build is picked up immediately; fall back
28
+ // to cache only when offline.
29
+ e.respondWith(
30
+ fetch(req).then((res) => {
31
+ if (res && res.ok && res.type === 'basic') {
32
+ const copy = res.clone();
33
+ caches.open(CACHE).then((c) => c.put(req, copy)).catch(() => {});
34
+ }
35
+ return res;
36
+ }).catch(() => caches.match(req).then((hit) => hit || caches.match('/')))
37
+ );
38
+ return;
39
+ }
40
+
41
+ // Static assets: cache-first is fine (they are versioned by CACHE).
24
42
  e.respondWith(
25
43
  caches.match(req).then((hit) => hit || fetch(req).then((res) => {
26
44
  if (res && res.ok && res.type === 'basic') {
@@ -28,6 +46,6 @@ self.addEventListener('fetch', (e) => {
28
46
  caches.open(CACHE).then((c) => c.put(req, copy)).catch(() => {});
29
47
  }
30
48
  return res;
31
- }).catch(() => hit))
49
+ }))
32
50
  );
33
51
  });
@@ -6,6 +6,7 @@
6
6
  <header><h2>Live Trajectory</h2><button onclick="location.href='/'">Back</button></header>
7
7
  <pre id="feed" style="max-height:70vh;overflow:auto"></pre>
8
8
  </div>
9
+ <script src="/authtoken.js"></script>
9
10
  <script>
10
11
  const es = new EventSource('/api/events');
11
12
  es.onmessage = (e) => {
@@ -0,0 +1,27 @@
1
+ // scripts/repo-scan.js — list a GitHub org/user's top repos (public API).
2
+ const https = require('https');
3
+ function get(url) {
4
+ return new Promise((resolve, reject) => {
5
+ https.get(url, { headers: { 'User-Agent': 'aegisai-repo-scan', Accept: 'application/vnd.github+json' } }, (res) => {
6
+ let d = '';
7
+ res.on('data', (c) => { d += c; });
8
+ res.on('end', () => {
9
+ if (res.statusCode >= 400) return reject(new Error('HTTP ' + res.statusCode));
10
+ try { resolve(JSON.parse(d)); } catch (e) { reject(e); }
11
+ });
12
+ }).on('error', reject);
13
+ });
14
+ }
15
+ (async () => {
16
+ for (const u of process.argv.slice(2)) {
17
+ console.log('\n=== ' + u + ' ===');
18
+ try {
19
+ const repos = await get('https://api.github.com/users/' + u + '/repos?per_page=40&sort=updated');
20
+ const sorted = repos.slice().sort((a, b) => (b.stargazers_count || 0) - (a.stargazers_count || 0));
21
+ for (const r of sorted.slice(0, 10)) {
22
+ console.log(' ' + r.name + ' [*' + (r.stargazers_count || 0) + '] ' + (r.language || '-') + ' :: ' + (r.description || '').slice(0, 110));
23
+ }
24
+ } catch (e) { console.log(' error: ' + e.message); }
25
+ await new Promise((r) => setTimeout(r, 400));
26
+ }
27
+ })();
@@ -0,0 +1,138 @@
1
+ // src/audit_pipeline.js
2
+ // Multi-phase security audit: recon → candidate findings → INDEPENDENT verification → report.
3
+ // The verification pass re-derives each finding from scratch and drops anything it cannot
4
+ // reproduce, so single-pass false positives do not reach the report.
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ const PHASES = ['recon', 'candidates', 'verify', 'report'];
9
+
10
+ function walk(dir, files, depth) {
11
+ if ((depth || 0) > 8) return files;
12
+ let entries = [];
13
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) { return files; }
14
+ for (const e of entries) {
15
+ if (['node_modules', '.git', 'dist', 'build', 'coverage'].includes(e.name)) continue;
16
+ const p = path.join(dir, e.name);
17
+ if (e.isDirectory()) walk(p, files, (depth || 0) + 1);
18
+ else if (/\.(js|mjs|cjs|ts|tsx|jsx|py|go|rs|java|rb|php)$/i.test(e.name)) files.push(p);
19
+ }
20
+ return files;
21
+ }
22
+
23
+ async function recon(root) {
24
+ const files = walk(root, [], 0);
25
+ const byExt = {};
26
+ for (const f of files) { const e = path.extname(f) || 'none'; byExt[e] = (byExt[e] || 0) + 1; }
27
+ return { root, files: files.length, byExt, languages: Object.keys(byExt) };
28
+ }
29
+
30
+ async function candidates(root) {
31
+ const out = [];
32
+ const secrets = require('./secret_verify');
33
+ const vuln = require('./vuln_scan');
34
+ const files = walk(root, [], 0);
35
+ for (const f of files.slice(0, 400)) {
36
+ let text = '';
37
+ try { text = fs.readFileSync(f, 'utf8'); } catch (e) { continue; }
38
+ if (text.length > 400000) continue;
39
+ // Candidate secrets (detection only; verification happens in the verify phase).
40
+ const s = await secrets.scan(text, { source: f, verify: false });
41
+ for (const x of s) out.push({ kind: 'secret', file: f, line: x.line, ruleId: x.ruleId, excerpt: x.redacted, raw: x.raw || null });
42
+ }
43
+ // Candidate code patterns via the existing scanner (it walks the tree itself).
44
+ try {
45
+ const v = vuln.scan(root);
46
+ for (const x of (v.findings || [])) {
47
+ out.push({ kind: 'code', file: path.resolve(root, x.file), line: x.line || 0, ruleId: 'vuln/' + String(x.label || 'pattern').toLowerCase().replace(/[^a-z0-9]+/g, '-'), excerpt: (x.code || '').slice(0, 160), raw: null, label: x.label });
48
+ }
49
+ } catch (e) {}
50
+ return out;
51
+ }
52
+
53
+ // Independent verification: re-read the file and confirm the pattern still matches at
54
+ // the reported line. Anything that cannot be reproduced is dropped.
55
+ function verify(cands) {
56
+ const confirmed = [];
57
+ const dropped = [];
58
+ for (const c of cands) {
59
+ let text = '';
60
+ try { text = fs.readFileSync(c.file, 'utf8'); } catch (e) { dropped.push(Object.assign({ reason: 'file_unreadable' }, c)); continue; }
61
+ const lines = text.split(/\r?\n/);
62
+ const lineText = lines[(c.line || 1) - 1] || '';
63
+ const hay = c.kind === 'secret' ? c.excerpt : lineText;
64
+ let rule = null;
65
+ try {
66
+ if (c.kind === 'secret') {
67
+ const { PATTERNS } = require('./secret_verify');
68
+ rule = PATTERNS.find((p) => 'secret/' + p.id === c.ruleId);
69
+ } else {
70
+ const { RULES } = require('./skill_scan');
71
+ rule = RULES.find((r) => r.id === c.ruleId);
72
+ }
73
+ } catch (e) { rule = null; }
74
+ if (!rule && c.kind === 'code') {
75
+ // Unknown rule id: accept only if the recorded excerpt is still on the same line.
76
+ if (c.excerpt && lineText.includes(c.excerpt.slice(0, 40))) confirmed.push(Object.assign({ verified: true }, c));
77
+ else dropped.push(Object.assign({ reason: 'not_reproducible' }, c));
78
+ continue;
79
+ }
80
+ if (!rule) { dropped.push(Object.assign({ reason: 'rule_not_found' }, c)); continue; }
81
+ const re = new RegExp(rule.re.source, rule.re.flags.includes('g') ? rule.re.flags : rule.re.flags + 'g');
82
+ const target = c.kind === 'secret' ? text : lineText;
83
+ if (re.test(target)) confirmed.push(Object.assign({ verified: true }, c));
84
+ else dropped.push(Object.assign({ reason: 'not_reproducible' }, c));
85
+ }
86
+ return { confirmed, dropped };
87
+ }
88
+
89
+ async function run(root, opts) {
90
+ opts = opts || {};
91
+ const started = Date.now();
92
+ const r = await recon(root);
93
+ const cands = await candidates(root);
94
+ const v = verify(cands);
95
+ const bySeverity = { critical: 0, high: 0, medium: 0, low: 0 };
96
+ for (const c of v.confirmed) {
97
+ const sev = /secret/.test(c.ruleId) ? 'high' : 'medium';
98
+ bySeverity[sev] += 1;
99
+ }
100
+ // Never leak raw secret material in reports.
101
+ const scrub = (c) => { const o = Object.assign({}, c); delete o.raw; return o; };
102
+ return {
103
+ root,
104
+ phases: PHASES,
105
+ recon: r,
106
+ candidates: cands.length,
107
+ confirmed: v.confirmed.map(scrub),
108
+ dropped: v.dropped.map(scrub),
109
+ summary: {
110
+ candidates: cands.length,
111
+ confirmed: v.confirmed.length,
112
+ dropped: v.dropped.length,
113
+ falsePositiveRate: cands.length ? +(v.dropped.length / cands.length).toFixed(3) : 0,
114
+ bySeverity,
115
+ verdict: bySeverity.critical || bySeverity.high ? 'fail' : v.confirmed.length ? 'warn' : 'pass',
116
+ },
117
+ duration: Date.now() - started,
118
+ };
119
+ }
120
+
121
+ function toSarif(report) {
122
+ return {
123
+ version: '2.1.0',
124
+ $schema: 'https://json.schemastore.org/sarif-2.1.0.json',
125
+ runs: [{
126
+ tool: { driver: { name: 'aegisai-audit' } },
127
+ results: report.confirmed.map((c) => ({
128
+ ruleId: c.ruleId,
129
+ level: /secret/.test(c.ruleId) ? 'error' : 'warning',
130
+ message: { text: (c.kind === 'secret' ? 'Confirmed secret: ' + c.excerpt : 'Confirmed pattern: ' + c.ruleId) },
131
+ locations: [{ physicalLocation: { artifactLocation: { uri: String(c.file).replace(/\\/g, '/') }, region: { startLine: c.line || 1 } } }],
132
+ properties: { verified: true },
133
+ })),
134
+ }],
135
+ };
136
+ }
137
+
138
+ module.exports = { PHASES, run, recon, candidates, verify, toSarif };
@@ -0,0 +1,108 @@
1
+ // src/conversation_templates.js
2
+ // Reusable prompt/workflow templates for the chat UI and REPL.
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { DATA_DIR } = require('./core/config');
6
+
7
+ const BUILTIN = [
8
+ {
9
+ id: 'code-review',
10
+ name: 'Code review',
11
+ category: 'code',
12
+ description: 'Review the current diff for correctness, security, and style.',
13
+ body: 'Review the current changes.\n\nFocus on:\n1. Correctness and edge cases\n2. Security (injection, secrets, unsafe paths)\n3. Consistency with the surrounding code\n4. Tests that should exist\n\nReport findings as a short list with file:line references, then a verdict.',
14
+ },
15
+ {
16
+ id: 'bug-triage',
17
+ name: 'Bug triage',
18
+ category: 'debug',
19
+ description: 'Reproduce, isolate, and propose a minimal fix.',
20
+ body: 'Help me triage this bug:\n\n{{symptom}}\n\n1. Restate the expected vs actual behaviour.\n2. List the most likely causes, cheapest to test first.\n3. Propose the smallest experiment that distinguishes them.\n4. Once confirmed, propose a minimal fix and a regression test.',
21
+ },
22
+ {
23
+ id: 'refactor',
24
+ name: 'Refactor safely',
25
+ category: 'code',
26
+ description: 'Refactor with a verification step after each change.',
27
+ body: 'Refactor {{target}} without changing behaviour.\n\nRules:\n- One logical change at a time.\n- Run the relevant tests after each step.\n- Stop and report if a step cannot be verified.\n\nFinish with a summary of what moved and why.',
28
+ },
29
+ {
30
+ id: 'test-plan',
31
+ name: 'Test plan',
32
+ category: 'quality',
33
+ description: 'Derive a test plan from a feature description.',
34
+ body: 'Produce a test plan for: {{feature}}\n\nInclude happy paths, boundary cases, failure modes, and the cheapest way to cover each. Mark which are unit vs integration.',
35
+ },
36
+ {
37
+ id: 'security-audit',
38
+ name: 'Security audit',
39
+ category: 'security',
40
+ description: 'Structured audit with verification of each finding.',
41
+ body: 'Audit {{target}} for security issues.\n\nPhases:\n1. Recon — map the entry points.\n2. Candidates — list suspected issues with evidence.\n3. Verify — re-check each candidate independently; drop anything you cannot reproduce.\n4. Report — only confirmed issues, each with file:line, impact, and a fix.',
42
+ },
43
+ {
44
+ id: 'docs',
45
+ name: 'Write docs',
46
+ category: 'docs',
47
+ description: 'Generate reference docs for a module.',
48
+ body: 'Write reference documentation for {{module}}.\n\nCover purpose, public API with signatures, configuration, failure modes, and one runnable example. Keep it terse.',
49
+ },
50
+ {
51
+ id: 'release-notes',
52
+ name: 'Release notes',
53
+ category: 'docs',
54
+ description: 'Summarise changes since a tag.',
55
+ body: 'Write release notes since {{tag}}.\n\nGroup into Added / Changed / Fixed / Security. One line per user-visible change. Call out breaking changes first.',
56
+ },
57
+ {
58
+ id: 'debug-runtime',
59
+ name: 'Runtime debugging',
60
+ category: 'debug',
61
+ description: 'Instrument, reproduce, then fix.',
62
+ body: 'Debug this runtime failure: {{error}}\n\n1. Reproduce it deterministically.\n2. Add the minimum instrumentation needed to see the state.\n3. Identify the first point where reality diverges from expectation.\n4. Fix that point only, then re-run.',
63
+ },
64
+ ];
65
+
66
+ function dir() { return path.join(DATA_DIR, 'templates'); }
67
+
68
+ function list() {
69
+ const out = BUILTIN.map((t) => Object.assign({ builtin: true }, t));
70
+ try {
71
+ for (const f of fs.readdirSync(dir())) {
72
+ if (!f.endsWith('.json')) continue;
73
+ try {
74
+ const t = JSON.parse(fs.readFileSync(path.join(dir(), f), 'utf8'));
75
+ if (t && t.id) out.push(Object.assign({ builtin: false }, t));
76
+ } catch (e) {}
77
+ }
78
+ } catch (e) {}
79
+ return out;
80
+ }
81
+
82
+ function get(id) {
83
+ const found = list().find((t) => t.id === id);
84
+ return found || null;
85
+ }
86
+
87
+ function save(tpl) {
88
+ const id = String((tpl && (tpl.id || tpl.name)) || '').trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
89
+ if (!id) throw Object.assign(new Error('template id required'), { status: 400 });
90
+ const record = { id, name: tpl.name || id, category: tpl.category || 'custom', description: tpl.description || '', body: tpl.body || '' };
91
+ fs.mkdirSync(dir(), { recursive: true });
92
+ fs.writeFileSync(path.join(dir(), id + '.json'), JSON.stringify(record, null, 2));
93
+ return record;
94
+ }
95
+
96
+ function remove(id) {
97
+ try { fs.unlinkSync(path.join(dir(), id + '.json')); return { ok: true, id }; }
98
+ catch (e) { return { ok: false, id, error: String(e.message || e) }; }
99
+ }
100
+
101
+ function render(id, vars) {
102
+ const t = get(id);
103
+ if (!t) return null;
104
+ const body = String(t.body || '').replace(/\{\{\s*(\w+)\s*\}\}/g, (m, k) => (vars && vars[k] != null ? vars[k] : m));
105
+ return Object.assign({}, t, { rendered: body });
106
+ }
107
+
108
+ module.exports = { BUILTIN, list, get, save, remove, render };
package/src/crawler.js ADDED
@@ -0,0 +1,70 @@
1
+ // src/crawler.js
2
+ // Endpoint crawler (katana-style, bounded): follows links and extracts URLs/paths
3
+ // from HTML and JavaScript. Same-origin by default; no auth bypass, no fuzzing.
4
+ const MAX_PAGES_DEFAULT = 30;
5
+
6
+ function extractLinks(html, baseUrl) {
7
+ const out = new Set();
8
+ const push = (raw) => {
9
+ if (!raw) return;
10
+ let u;
11
+ try { u = new URL(raw, baseUrl); } catch (e) { return; }
12
+ if (u.protocol !== 'http:' && u.protocol !== 'https:') return;
13
+ out.add(u.origin + u.pathname + (u.search || ''));
14
+ };
15
+ const hrefRe = /(?:href|src|action)\s*=\s*["']([^"'#]+)["']/gi;
16
+ let m;
17
+ while ((m = hrefRe.exec(html)) !== null) push(m[1]);
18
+ // Absolute URLs anywhere in the document (catches JS fetch/axios targets).
19
+ const urlRe = /https?:\/\/[^\s"'`<>()\\]+/g;
20
+ while ((m = urlRe.exec(html)) !== null) push(m[0]);
21
+ // Relative API paths in JS strings.
22
+ const apiRe = /["'`](\/[A-Za-z0-9_\-./]{2,120})["'`]/g;
23
+ while ((m = apiRe.exec(html)) !== null) push(m[1]);
24
+ return Array.from(out);
25
+ }
26
+
27
+ function sameOrigin(u, base) {
28
+ try { return new URL(u).origin === new URL(base).origin; } catch (e) { return false; }
29
+ }
30
+
31
+ async function crawl(startUrl, opts) {
32
+ opts = opts || {};
33
+ const maxPages = opts.maxPages || MAX_PAGES_DEFAULT;
34
+ const sameSiteOnly = opts.sameOrigin !== false;
35
+ const seen = new Set();
36
+ const queue = [startUrl];
37
+ const pages = [];
38
+ const endpoints = new Set();
39
+ while (queue.length && pages.length < maxPages) {
40
+ const url = queue.shift();
41
+ if (!url || seen.has(url)) continue;
42
+ if (sameSiteOnly && !sameOrigin(url, startUrl)) continue;
43
+ seen.add(url);
44
+ let res;
45
+ try {
46
+ res = await fetch(url, { signal: AbortSignal.timeout(opts.timeoutMs || 10000), redirect: 'follow', headers: { 'User-Agent': 'aegisai-crawler' } });
47
+ } catch (e) {
48
+ pages.push({ url, error: String((e && e.message) || e) });
49
+ continue;
50
+ }
51
+ const type = res.headers.get('content-type') || '';
52
+ let body = '';
53
+ try { body = await res.text(); } catch (e) { body = ''; }
54
+ const found = /text\/html|javascript|application\/json/i.test(type) ? extractLinks(body, url) : [];
55
+ for (const f of found) {
56
+ if (sameSiteOnly && !sameOrigin(f, startUrl)) continue;
57
+ if (new URL(f).pathname !== new URL(url).pathname) endpoints.add(f);
58
+ if (!seen.has(f) && queue.length + pages.length < maxPages * 3) queue.push(f);
59
+ }
60
+ pages.push({ url, status: res.status, contentType: type, bytes: body.length, links: found.length });
61
+ }
62
+ return {
63
+ startUrl,
64
+ pages,
65
+ endpoints: Array.from(endpoints).sort(),
66
+ summary: { pages: pages.length, endpoints: endpoints.size, errors: pages.filter((p) => p.error).length },
67
+ };
68
+ }
69
+
70
+ module.exports = { crawl, extractLinks, sameOrigin };