@heretek-ai/epistemic-swarm 0.6.0 → 0.7.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.
Files changed (63) hide show
  1. package/.claude-plugin/marketplace.json +20 -0
  2. package/.claude-plugin/plugin.json +4 -2
  3. package/MARKETPLACE.md +28 -0
  4. package/install.sh +1 -1
  5. package/package.json +1 -1
  6. package/plugins/darkharvest/.claude-plugin/plugin.json +15 -0
  7. package/plugins/darkharvest/agents/harvest-proponent.md +22 -0
  8. package/plugins/darkharvest/agents/harvest-redteam.md +20 -0
  9. package/plugins/darkharvest/evals/teardown-verdict/graders/license-line.md +6 -0
  10. package/plugins/darkharvest/evals/teardown-verdict/graders/skill-fired.md +5 -0
  11. package/plugins/darkharvest/evals/teardown-verdict/prompt.md +6 -0
  12. package/plugins/darkharvest/skills/darkharvest/SKILL.md +70 -0
  13. package/plugins/darkharvest/skills/darkharvest/scripts/harvest.py +252 -0
  14. package/plugins/factory/.claude-plugin/plugin.json +15 -0
  15. package/plugins/factory/agents/factory-manager.md +22 -0
  16. package/plugins/factory/agents/programmer.md +16 -0
  17. package/plugins/factory/agents/qa-adversarial.md +17 -0
  18. package/plugins/factory/agents/qa-functional.md +17 -0
  19. package/plugins/factory/evals/gate-halt/graders/gates-first.md +6 -0
  20. package/plugins/factory/evals/gate-halt/graders/skill-fired.md +5 -0
  21. package/plugins/factory/evals/gate-halt/prompt.md +6 -0
  22. package/plugins/factory/skills/factory/SKILL.md +51 -0
  23. package/plugins/factory/skills/factory/scripts/factory.py +212 -0
  24. package/runner/__pycache__/__init__.cpython-311.pyc +0 -0
  25. package/runner/__pycache__/auctioneer.cpython-311.pyc +0 -0
  26. package/runner/__pycache__/auditor_engine.cpython-311.pyc +0 -0
  27. package/runner/__pycache__/claim_store.cpython-311.pyc +0 -0
  28. package/runner/__pycache__/claim_witness.cpython-311.pyc +0 -0
  29. package/runner/__pycache__/living_dossiers.cpython-311.pyc +0 -0
  30. package/runner/__pycache__/mcp_protocol.cpython-311.pyc +0 -0
  31. package/runner/__pycache__/mcp_server.cpython-311.pyc +0 -0
  32. package/runner/__pycache__/path_safety.cpython-311.pyc +0 -0
  33. package/runner/__pycache__/pcrb.cpython-311.pyc +0 -0
  34. package/runner/__pycache__/pcrb_verify.cpython-311.pyc +0 -0
  35. package/runner/__pycache__/refinement.cpython-311.pyc +0 -0
  36. package/runner/__pycache__/research_swarm.cpython-311.pyc +0 -0
  37. package/runner/__pycache__/state_machine.cpython-311.pyc +0 -0
  38. package/runner/tests/__pycache__/test_auction_order.cpython-311.pyc +0 -0
  39. package/runner/tests/__pycache__/test_bet1_spike.cpython-311.pyc +0 -0
  40. package/runner/tests/__pycache__/test_claim_store.cpython-311.pyc +0 -0
  41. package/runner/tests/__pycache__/test_claim_witness.cpython-311.pyc +0 -0
  42. package/runner/tests/__pycache__/test_claude_plugin.cpython-311.pyc +0 -0
  43. package/runner/tests/__pycache__/test_domain_packs.cpython-311.pyc +0 -0
  44. package/runner/tests/__pycache__/test_factory.cpython-311.pyc +0 -0
  45. package/runner/tests/__pycache__/test_fleet_seam.cpython-311.pyc +0 -0
  46. package/runner/tests/__pycache__/test_living_dossiers.cpython-311.pyc +0 -0
  47. package/runner/tests/__pycache__/test_mcp_server.cpython-311.pyc +0 -0
  48. package/runner/tests/__pycache__/test_opencode_ux.cpython-311.pyc +0 -0
  49. package/runner/tests/__pycache__/test_pcrb.cpython-311.pyc +0 -0
  50. package/runner/tests/__pycache__/test_refinement.cpython-311.pyc +0 -0
  51. package/runner/tests/__pycache__/test_swarm.cpython-311.pyc +0 -0
  52. package/runner/tests/__pycache__/test_sweep_regressions.cpython-311.pyc +0 -0
  53. package/runner/tests/__pycache__/test_webcache.cpython-311.pyc +0 -0
  54. package/runner/tests/test_claude_plugin.py +170 -0
  55. package/scripts/__pycache__/bet1_advisory_spike.cpython-311.pyc +0 -0
  56. package/scripts/__pycache__/build_adapters.cpython-311.pyc +0 -0
  57. package/scripts/__pycache__/divergence_experiment.cpython-311.pyc +0 -0
  58. package/scripts/build_adapters.py +69 -0
  59. package/skills/epistemic_search/scripts/__pycache__/search.cpython-311.pyc +0 -0
  60. package/skills/research_cache/__pycache__/__init__.cpython-311.pyc +0 -0
  61. package/skills/research_cache/__pycache__/hasher.cpython-311.pyc +0 -0
  62. package/skills/swarm_config/__pycache__/__init__.cpython-311.pyc +0 -0
  63. package/skills/swarm_config/__pycache__/configure.cpython-311.pyc +0 -0
@@ -36,6 +36,26 @@
36
36
  "category": "research",
37
37
  "source": "./plugins/research-cache",
38
38
  "homepage": "https://github.com/Heretek-AI/IUMBTEMS"
39
+ },
40
+ {
41
+ "name": "darkharvest",
42
+ "description": "Product-level competitor teardown and clean-room harvest engine.",
43
+ "author": {
44
+ "name": "Heretek AI"
45
+ },
46
+ "category": "research",
47
+ "source": "./plugins/darkharvest",
48
+ "homepage": "https://github.com/Heretek-AI/IUMBTEMS"
49
+ },
50
+ {
51
+ "name": "factory",
52
+ "description": "Coding-factory Manager loop with grill-gated phased builds and dual QA.",
53
+ "author": {
54
+ "name": "Heretek AI"
55
+ },
56
+ "category": "agents",
57
+ "source": "./plugins/factory",
58
+ "homepage": "https://github.com/Heretek-AI/IUMBTEMS"
39
59
  }
40
60
  ]
41
61
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epistemic-swarm",
3
- "version": "0.4.8",
3
+ "version": "0.7.0",
4
4
  "description": "High-Integrity Dialectic Research Agent Harness for Claude Code enforcing empirical evidence over parametric hallucination.",
5
5
  "author": {
6
6
  "name": "Heretek AI",
@@ -69,6 +69,8 @@
69
69
  "./skills/swarm_config",
70
70
  "./skills/code_audit",
71
71
  "./skills/oss_scout",
72
- "./skills/brainstorming"
72
+ "./skills/brainstorming",
73
+ "./skills/darkharvest",
74
+ "./skills/factory"
73
75
  ]
74
76
  }
package/MARKETPLACE.md CHANGED
@@ -30,6 +30,8 @@ claude plugin marketplace list
30
30
  | **`epistemic-swarm`** | `research` | **Flagship Swarm Harness**: Multi-agent dialectic research harness pairing Agent Alpha (Thesis) against Agent Beta (Red Team), audited by an Epistemic Auditor with verbatim empirical quote validation. | `claude plugin install epistemic-swarm@heretek-official` |
31
31
  | **`socratic-grilling`** | `agents` | **Socratic Ideation**: Matt Pocock-style Socratic interrogation, premise inversion, and lateral exploration skill. | `claude plugin install socratic-grilling@heretek-official` |
32
32
  | **`research-cache`** | `research` | **Source Hasher**: Content-addressed SHA256 Markdown source hashing and verbatim quote verification engine. | `claude plugin install research-cache@heretek-official` |
33
+ | **`darkharvest`** | `research` | **Competitor Teardown**: Product-level teardown with per-feature `depend\|vendor\|clean-room\|skip` verdicts and SPDX attribution. | `claude plugin install darkharvest@heretek-official` |
34
+ | **`factory`** | `agents` | **Coding Factory**: Manager loop with grill-gated phases, programmer spawns, and dual QA. | `claude plugin install factory@heretek-official` |
33
35
 
34
36
  ---
35
37
 
@@ -72,6 +74,32 @@ claude plugin marketplace list
72
74
  claude plugin install research-cache@heretek-official
73
75
  ```
74
76
 
77
+ ### 4. `darkharvest` (Modular Tool)
78
+ - **Manifest**: [`plugins/darkharvest/.claude-plugin/plugin.json`](file:///plugins/darkharvest/.claude-plugin/plugin.json)
79
+ - **Components**:
80
+ - **Skill**: `skills/darkharvest` (competitor Ɨ capability teardown).
81
+ - **Agents**: `harvest-proponent` (per-feature verdicts), `harvest-redteam` (license/Bloat/CVE vetting).
82
+ - **Evals**: `plugins/darkharvest/evals/teardown-verdict` (skill fires + license-line rubric).
83
+ - **Install**:
84
+ ```bash
85
+ claude plugin install darkharvest@heretek-official
86
+ ```
87
+
88
+ ### 5. `factory` (Modular Agent Pack)
89
+ - **Manifest**: [`plugins/factory/.claude-plugin/plugin.json`](file:///plugins/factory/.claude-plugin/plugin.json)
90
+ - **Components**:
91
+ - **Skill**: `skills/factory` (Manager loop, gates, QA bounds).
92
+ - **Agents**: `factory-manager`, `programmer`, `qa-functional`, `qa-adversarial`.
93
+ - **Evals**: `plugins/factory/evals/gate-halt` (skill fires + gates-first rubric).
94
+ - **Install**:
95
+ ```bash
96
+ claude plugin install factory@heretek-official
97
+ ```
98
+
99
+ ### Flagship agents & evals
100
+ - **Agents** (repo-root `agents/`): `alpha-thesis`, `beta-antithesis`, `epistemic-auditor` — condensed from `prompts/agent_alpha_thesis.md`, `prompts/agent_beta_antithesis.md`, `prompts/epistemic_auditor.md`.
101
+ - **Evals** (repo-root `evals/`): `grill-fires`, `darkharvest-fires`, `factory-gate` — each `prompt.md` plus `tool_used: Skill` and `llm` graders. Run `claude plugin eval .` (billable model calls); CI gates via `.github/workflows/plugin-evals.yml` on release/dispatch.
102
+
75
103
  ---
76
104
 
77
105
  ## šŸ’” Lateral Brainstorming (`/brainstorming`)
package/install.sh CHANGED
@@ -21,7 +21,7 @@ echo "āœ… Core prerequisites detected (Python $(python3 --version | cut -d' ' -f
21
21
  mkdir -p "$CLAUDE_DIR/skills"
22
22
 
23
23
  echo "šŸ”— Linking skills into $CLAUDE_DIR/skills/..."
24
- for skill in grilling research_cache epistemic_search swarm_config code_audit oss_scout brainstorming; do
24
+ for skill in grilling research_cache epistemic_search swarm_config code_audit oss_scout brainstorming darkharvest factory; do
25
25
  # legacy research-cache dir name kept as alias for older configs
26
26
  ln -sfn "$REPO_DIR/skills/$skill" "$CLAUDE_DIR/skills/$skill"
27
27
  echo " - $CLAUDE_DIR/skills/$skill -> $REPO_DIR/skills/$skill"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heretek-ai/epistemic-swarm",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "IUMBTEMS: I Use My Brain To Express My Self — High-Integrity Dialectic Research Agent Harness for Claude Code, OpenCode V2, Pi, OMP (oh-my-pi), Gemini CLI, Codex CLI, and AntiGravity",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "darkharvest",
3
+ "version": "0.1.0",
4
+ "description": "Product-level competitor teardown and clean-room harvest engine for Claude Code.",
5
+ "author": {
6
+ "name": "Heretek AI",
7
+ "email": "dev@heretek.ai"
8
+ },
9
+ "license": "Apache-2.0",
10
+ "repository": "https://github.com/Heretek-AI/IUMBTEMS",
11
+ "homepage": "https://github.com/Heretek-AI/IUMBTEMS#readme",
12
+ "skills": [
13
+ "./skills/darkharvest"
14
+ ]
15
+ }
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: harvest-proponent
3
+ description: Competitor-teardown proponent. Inventories what a competitor does well and proposes per-feature harvest verdicts. Use per competitor scope in darkharvest runs.
4
+ model: sonnet
5
+ ---
6
+
7
+ You are the Harvest Proponent in the darkharvest plugin.
8
+
9
+ Per assigned competitor: build the capability inventory (present / missing /
10
+ partial per capability with `[VERIFIED: <hash>]` evidence from
11
+ `.research/sources/<sha256>.md`), then propose per-feature verdicts:
12
+ `depend | vendor | clean-room-rebuild | skip(reason)`, ranked by
13
+ Impact x Effort x Differentiation.
14
+
15
+ Legal guardrails (final): permissive licenses only (MIT, Apache-2.0, BSD, ISC)
16
+ may be `depend`/`vendor`. GPL / AGPL / UNKNOWN license means
17
+ `clean-room-rebuild` spec only — never copy code. Workflows clonable;
18
+ copy-text, UI assets, and brand are never copied. Every `vendor` item emits an
19
+ SPDX attribution block (license + upstream URL + files). Closed targets get
20
+ metadata-only rows plus `[NEGATIVE_KNOWLEDGE: <query>]`, never a failed run.
21
+
22
+ Full specification: `skills/darkharvest/SKILL.md` in the plugin root.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: harvest-redteam
3
+ description: Competitor-teardown red team. Vets license contamination, bloat, CVEs, and staleness; maps white-space gaps both ways. Use per competitor scope alongside the proponent.
4
+ model: sonnet
5
+ ---
6
+
7
+ You are the Harvest Red Team in the darkharvest plugin.
8
+
9
+ Per assigned competitor: determine SPDX from LICENSE file plus package
10
+ metadata; flag transitive bloat, CVE/takeover surface, and staleness
11
+ (`STALE` when inactive over 12 months or solo-maintained). Gates are
12
+ warn-only — badge inline per matrix cell plus a risks section, never
13
+ auto-skip. Map white-space gaps in BOTH directions: what the competitor lacks
14
+ that we own or could own, and what we lack.
15
+
16
+ Challenge every proponent harvest proposal: any `vendor` verdict on
17
+ copyleft or unknown-licensed code must be rewritten as `clean-room-rebuild`
18
+ with reasoning. Benchmarks are optional but, when present, must be VERIFIED.
19
+
20
+ Full specification: `skills/darkharvest/SKILL.md` in the plugin root.
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: llm
3
+ ---
4
+
5
+ PASS if the reply distinguishes what may be borrowed directly (permissive licenses) from what must be re-implemented clean-room (copyleft or unknown licenses), or asks which seed competitors to tear down before verdicts.
6
+ FAIL if the reply recommends vendoring GPL/AGPL-licensed code, copying UI assets, or gives harvest verdicts with no license reasoning at all.
@@ -0,0 +1,5 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?darkharvest"'
5
+ ---
@@ -0,0 +1,6 @@
1
+ ---
2
+ max_turns: 10
3
+ allowed_tools: [Read, Glob, Grep, Skill]
4
+ ---
5
+
6
+ I'm building a competitor to a desktop app that orchestrates multiple coding agents. What do similar open-source projects do well, and what could I borrow clean-room?
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: darkharvest
3
+ description: Product-level competitor teardown and clean-room harvest engine. Use when user wants to compete with or learn from existing products (e.g. Paseo, OpenChambers). Seed with inspiration URLs plus prompt, auto-expand to adjacents, clone-scan competitors, compare product plus code, and emit per-feature depend/vendor/clean-room/skip verdicts with SPDX attribution. Never copies GPL/AGPL code or UI assets.
4
+ ---
5
+
6
+ # Darkharvest — Competitor Teardown & Clean-Room Harvest
7
+
8
+ Product-level teardown, not library scouting. `oss_scout` answers "which Raft lib do I depend on"; `darkharvest` answers "I'm building a Paseo competitor — what do Paseo-likes do well, what white space exists, and what may I harvest clean-room?"
9
+
10
+ ## 1. Invocation
11
+
12
+ ```bash
13
+ # Full dialectic teardown swarm (mock = zero token cost)
14
+ python3 runner/research_swarm.py --mode darkharvest --objective "Paseo-class agent harness competitor" --mock-claude
15
+
16
+ # Competitor fetch helper (read-only scan, allowlisted, capped)
17
+ python3 skills/darkharvest/scripts/harvest.py --repo https://github.com/owner/repo --show-context
18
+
19
+ # Via CLI
20
+ iumbtems darkharvest "Paseo-class agent harness competitor" --seeds https://github.com/a/b,https://github.com/c/d --max-repos 6 --mock-claude
21
+ ```
22
+
23
+ In OpenCode V2: `iumbtems_darkharvest` tool. Slash: `/darkharvest <objective>`.
24
+ In Pi / OMP: `/darkharvest <objective>`. In Gemini: skill auto-activates on competitor-teardown intent.
25
+
26
+ ## 2. Input contract (hybrid, merged)
27
+
28
+ 1. Seeds: GitHub/GitLab URLs plus free-text prompt guidance. Unlimited seeds accepted; runner caps at `--max-repos` (default 10, recommended 6 for live runs).
29
+ 2. Local baseline: full `brainstorm.py` domain model (tree + README + stack + TODOs + git log/status). Manual prompt ADDS to auto facts; conflicts record both, manual tagged `[HYPOTHESIS: <how to check>]`.
30
+ 3. Gaps: open-loops + user wishlist combined.
31
+
32
+ ## 3. Discovery (seed + expand)
33
+
34
+ - Seeds + 5–8 auto adjacents; direct competitors and adjacent inspirations SPLIT in the report.
35
+ - Similarity: hybrid pre-filter (README topics + feature keywords + dep overlap) then LLM rerank. Never LLM-vibe alone.
36
+ - Rank relevance first, stars second. Any stack allowed with porting-effort note. Stale (>12mo or solo-maintainer) flagged with `āš ļø STALE`, never auto-skipped.
37
+
38
+ ## 4. Fetch & scan budgets (defaults, all flag-overridable)
39
+
40
+ - Defaults: `--max-repos 10 --depth 3 --per-repo-mb 100 --per-repo-timeout 300s`. Prefer `--max-repos 6 --depth 2` for live runs.
41
+ - `harvest.py` clones to temp then drops; allowlist scan only: tree + README + LICENSE + manifests + key source headers. Skips `.git, node_modules, dist, build, target, .next, .venv, .research`. Caps file count and bytes — full dump without caps will OOM and is banned.
42
+ - Closed or non-cloneable targets: try Firecrawl/docs fetch; when unavailable emit metadata-only row + `[NEGATIVE_KNOWLEDGE: <query>]`, never fail the run.
43
+ - Evidence: every matrix cell needs a SHA-256 cached source (`.research/sources/<sha256>.md`) with verbatim quote, or a `file://<path>#L<start>-L<end>` pointer. Unverified cells are purged to NEGATIVE_KNOWLEDGE.
44
+
45
+ ## 5. Dialectic roles (one scope per competitor)
46
+
47
+ - Orchestrator decomposes the candidate list into one scope per competitor (DAG default, auction optional).
48
+ - Alpha (harvest proponent): what competitor does well + per-feature harvest proposals.
49
+ - Beta (red-team): license contamination, transitive bloat, CVE/takeover surface, staleness, both-ways missing (white space).
50
+ - Auditor: enforces strict-cells bar, warn-only gates surface as inline `āš ļø LICENSE/CVE/STALE` badges plus a risks section.
51
+
52
+ ## 6. Legal guardrails (final)
53
+
54
+ - Permissive only (MIT / Apache-2.0 / BSD / ISC) may be `depend` or `vendor`.
55
+ - GPL / AGPL / unknown license → `clean-room-rebuild` spec only, never copy.
56
+ - Workflows clonable; copy-text, UI assets, brand never copied.
57
+ - Every vendored item emits an SPDX attribution block (license + upstream URL + files).
58
+
59
+ ## 7. Output
60
+
61
+ - `.research/darkharvest_report.md`: competitor Ɨ capability matrix (present / missing / partial + evidence) + white-space gaps both directions + harvest backlog (per-feature `depend|vendor|clean-room-rebuild|skip(reason)`, ImpactƗEffortƗDifferentiation ranked, top 5) + risks + epistemic audit totals.
62
+ - Machine dossier: `.research/darkharvest_dossier.json` for rerun diffs (changed cells + new/removed candidates).
63
+ - Errors: structured log + NEGATIVE_KNOWLEDGE, never silent. Writes only under `.research/`.
64
+
65
+ ## 8. Anti-patterns (hard bans)
66
+
67
+ - No auto-install of dependencies, no writes outside `.research/`.
68
+ - No pixel-level UX cloning, no GPL/AGPL vendoring.
69
+ - No parametric repo claims as `[VERIFIED]` — metadata suffices only for rank hints, never for harvest verdicts.
70
+ - No unbounded expansion: seeds + expansion must respect `--max-repos` and per-repo caps.
@@ -0,0 +1,252 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Darkharvest fetch helper: clone-to-temp + allowlisted scan + SHA-256 cache.
4
+
5
+ Read-only. Never installs dependencies. Never writes outside .research/
6
+ (except the temp clone, which is dropped). Enforces per-repo caps so
7
+ `--max-repos 10 --depth 3` style defaults cannot OOM the host.
8
+
9
+ Usage:
10
+ python3 skills/darkharvest/scripts/harvest.py --repo <url> [--show-context]
11
+ python3 skills/darkharvest/scripts/harvest.py --repo <url> --export <path>
12
+
13
+ Closed / non-cloneable targets: prints a metadata-only stub with a
14
+ [NEGATIVE_KNOWLEDGE] gap note instead of failing.
15
+ """
16
+
17
+ import argparse
18
+ import json
19
+ import os
20
+ import re
21
+ import shutil
22
+ import subprocess
23
+ import sys
24
+ import tempfile
25
+ from datetime import datetime, timezone
26
+ from pathlib import Path
27
+
28
+ PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent.parent
29
+ if str(PROJECT_ROOT) not in sys.path:
30
+ sys.path.insert(0, str(PROJECT_ROOT))
31
+
32
+ from skills.research_cache.hasher import SourceHasher # noqa: E402
33
+
34
+ SKIP_DIRS = {
35
+ ".git",
36
+ "node_modules",
37
+ "__pycache__",
38
+ ".venv",
39
+ "venv",
40
+ "dist",
41
+ "build",
42
+ "target",
43
+ ".next",
44
+ ".research",
45
+ "coverage",
46
+ }
47
+ MANIFEST_FILES = [
48
+ "package.json",
49
+ "pyproject.toml",
50
+ "Cargo.toml",
51
+ "go.mod",
52
+ "requirements.txt",
53
+ "LICENSE",
54
+ "LICENSE.md",
55
+ "README.md",
56
+ ]
57
+ TEXT_EXTS = {".md", ".json", ".toml", ".yaml", ".yml", ".txt", ".py", ".js", ".ts"}
58
+
59
+ DEFAULT_MAX_FILES = 120
60
+ DEFAULT_MAX_BYTES = 400_000
61
+ DEFAULT_TIMEOUT = 120
62
+
63
+ SPDX_MAP = {
64
+ "mit": "MIT",
65
+ "apache-2.0": "Apache-2.0",
66
+ "apache 2.0": "Apache-2.0",
67
+ "bsd-3-clause": "BSD-3-Clause",
68
+ "bsd 3-clause": "BSD-3-Clause",
69
+ "isc": "ISC",
70
+ "gpl": "GPL",
71
+ "agpl": "AGPL",
72
+ "mpl": "MPL",
73
+ "lgpl": "LGPL",
74
+ }
75
+
76
+
77
+ def sh(cmd, cwd=None, timeout=DEFAULT_TIMEOUT):
78
+ try:
79
+ r = subprocess.run(
80
+ cmd,
81
+ capture_output=True,
82
+ text=True,
83
+ cwd=str(cwd or PROJECT_ROOT),
84
+ timeout=timeout,
85
+ )
86
+ return r.returncode, (r.stdout or "").strip()
87
+ except Exception as exc: # noqa: BLE001
88
+ return 1, f"error: {exc}"
89
+
90
+
91
+ def detect_license(text):
92
+ low = (text or "").lower()
93
+ for key, spdx in SPDX_MAP.items():
94
+ if key in low:
95
+ return spdx
96
+ return "UNKNOWN"
97
+
98
+
99
+ def scan_tree(root, max_files=DEFAULT_MAX_FILES, max_bytes=DEFAULT_MAX_BYTES):
100
+ entries = []
101
+ total_bytes = 0
102
+ manifests = {}
103
+ license_text = ""
104
+ readme_head = ""
105
+ for dirpath, dirnames, filenames in os.walk(root):
106
+ dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS]
107
+ rel = Path(dirpath).relative_to(root)
108
+ depth = len(rel.parts) if str(rel) != "." else 0
109
+ if depth > 3:
110
+ dirnames[:] = []
111
+ continue
112
+ for f in sorted(filenames):
113
+ if len(entries) >= max_files or total_bytes >= max_bytes:
114
+ return entries, manifests, license_text, readme_head, True
115
+ fp = Path(dirpath) / f
116
+ try:
117
+ size = fp.stat().st_size
118
+ except OSError:
119
+ continue
120
+ if size > 100_000:
121
+ continue
122
+ rel_p = str(rel / f) if str(rel) != "." else f
123
+ entries.append(rel_p)
124
+ if f in MANIFEST_FILES or Path(f).suffix in TEXT_EXTS:
125
+ try:
126
+ content = fp.read_text(encoding="utf-8", errors="replace")
127
+ except OSError:
128
+ continue
129
+ total_bytes += len(content.encode("utf-8", errors="replace"))
130
+ if f in MANIFEST_FILES and f not in manifests:
131
+ manifests[f] = content[:4000]
132
+ if f.lower().startswith("license") and not license_text:
133
+ license_text = content[:4000]
134
+ if f.lower() == "readme.md" and not readme_head:
135
+ readme_head = content[:4000]
136
+ return entries, manifests, license_text, readme_head, False
137
+
138
+
139
+ def harvest_repo(
140
+ url,
141
+ max_files=DEFAULT_MAX_FILES,
142
+ max_bytes=DEFAULT_MAX_BYTES,
143
+ timeout=DEFAULT_TIMEOUT,
144
+ base_dir=".research",
145
+ ):
146
+ started = datetime.now(timezone.utc).isoformat()
147
+ tmp = tempfile.mkdtemp(prefix="darkharvest-")
148
+ try:
149
+ code, out = sh(["git", "clone", "--depth", "1", url, tmp], timeout=timeout)
150
+ if code != 0:
151
+ return {
152
+ "url": url,
153
+ "status": "metadata-only",
154
+ "generated_at": started,
155
+ "negative_knowledge": (
156
+ f"[NEGATIVE_KNOWLEDGE: clone failed for {url}; "
157
+ f"used metadata-only row. Detail: {out[:200]}]"
158
+ ),
159
+ }
160
+ entries, manifests, license_text, readme_head, truncated = scan_tree(
161
+ Path(tmp), max_files=max_files, max_bytes=max_bytes
162
+ )
163
+ spdx = detect_license(license_text + manifests.get("package.json", ""))
164
+ harvestable = (
165
+ "depend-or-vendor"
166
+ if spdx in ("MIT", "Apache-2.0", "BSD-3-Clause", "ISC")
167
+ else "clean-room-rebuild-only"
168
+ )
169
+ hasher = SourceHasher(Path(base_dir))
170
+ cache_blob = (
171
+ f"# {url}\n\nSPDX: {spdx}\n\n"
172
+ f"## README head\n{readme_head[:2000]}\n\n"
173
+ f"## Tree sample ({len(entries)} entries)\n" + "\n".join(entries[:60])
174
+ )
175
+ source_hash = hasher.store_source(url, cache_blob, f"Darkharvest {url}")
176
+ warnings = []
177
+ if spdx in ("GPL", "AGPL"):
178
+ warnings.append(
179
+ "āš ļø LICENSE: strong copyleft — spec rebuild only, never vendor"
180
+ )
181
+ elif spdx == "UNKNOWN":
182
+ warnings.append("āš ļø LICENSE: unknown — treat as clean-room-rebuild-only")
183
+ if truncated:
184
+ warnings.append(
185
+ "āš ļø SCAN: truncated by file/byte caps; treat as partial evidence"
186
+ )
187
+ return {
188
+ "url": url,
189
+ "status": "scanned",
190
+ "generated_at": started,
191
+ "spdx": spdx,
192
+ "harvest_policy": harvestable,
193
+ "tree_entries": len(entries),
194
+ "truncated": truncated,
195
+ "source_hash": source_hash,
196
+ "readme_head": readme_head[:1500],
197
+ "manifests_seen": sorted(manifests.keys()),
198
+ "warnings": warnings,
199
+ }
200
+ finally:
201
+ shutil.rmtree(tmp, ignore_errors=True)
202
+
203
+
204
+ def main():
205
+ ap = argparse.ArgumentParser(description="Darkharvest competitor fetch helper")
206
+ ap.add_argument("--repo", required=True, help="Competitor repo URL to scan")
207
+ ap.add_argument("--show-context", action="store_true")
208
+ ap.add_argument("--export", default="")
209
+ ap.add_argument("--max-files", type=int, default=DEFAULT_MAX_FILES)
210
+ ap.add_argument("--max-bytes", type=int, default=DEFAULT_MAX_BYTES)
211
+ ap.add_argument("--timeout", type=int, default=DEFAULT_TIMEOUT)
212
+ ap.add_argument("--dir", default=".research")
213
+ args = ap.parse_args()
214
+
215
+ if not re.match(r"^https?://", args.repo):
216
+ print(f"WARN: {args.repo} is not an http(s) URL; metadata-only stub emitted.")
217
+ result = {
218
+ "url": args.repo,
219
+ "status": "metadata-only",
220
+ "generated_at": datetime.now(timezone.utc).isoformat(),
221
+ "negative_knowledge": (
222
+ f"[NEGATIVE_KNOWLEDGE: non-cloneable target {args.repo}]"
223
+ ),
224
+ }
225
+ else:
226
+ result = harvest_repo(
227
+ args.repo,
228
+ max_files=args.max_files,
229
+ max_bytes=args.max_bytes,
230
+ timeout=args.timeout,
231
+ base_dir=args.dir,
232
+ )
233
+
234
+ if args.show_context or not args.export:
235
+ print(f"\nšŸŒ‘ [Darkharvest] {result['url']} → {result['status']}")
236
+ for key in ("spdx", "harvest_policy", "tree_entries", "source_hash"):
237
+ if key in result:
238
+ print(f" {key}: {result[key]}")
239
+ for w in result.get("warnings", []):
240
+ print(f" {w}")
241
+ if result.get("negative_knowledge"):
242
+ print(f" {result['negative_knowledge'][:200]}")
243
+
244
+ if args.export:
245
+ out = Path(os.path.realpath(args.export))
246
+ out.parent.mkdir(parents=True, exist_ok=True)
247
+ out.write_text(json.dumps(result, indent=2), encoding="utf-8")
248
+ print(f"āœ… Harvest scan exported to {out}")
249
+
250
+
251
+ if __name__ == "__main__":
252
+ main()
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "factory",
3
+ "version": "0.1.0",
4
+ "description": "Coding-factory Manager loop with grill-gated phased builds and dual QA for Claude Code.",
5
+ "author": {
6
+ "name": "Heretek AI",
7
+ "email": "dev@heretek.ai"
8
+ },
9
+ "license": "Apache-2.0",
10
+ "repository": "https://github.com/Heretek-AI/IUMBTEMS",
11
+ "homepage": "https://github.com/Heretek-AI/IUMBTEMS#readme",
12
+ "skills": [
13
+ "./skills/factory"
14
+ ]
15
+ }
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: factory-manager
3
+ description: Coding-factory Manager. Owns grill gates, swarm dispatch, roadmap synthesis, and QA tiebreaks. Never writes code. Use to drive /factory runs.
4
+ model: sonnet
5
+ ---
6
+
7
+ You are the Factory Manager in the factory plugin.
8
+
9
+ Loop: grill the user until `.factory/frontier.json` is settled (max 5
10
+ brainstorm+darkharvest swarm cycles per gate); explicit user approve advances
11
+ each gate. Per gate, dispatch both swarms (mock-first on fixtures), then
12
+ synthesize `.roadmap/<phase>/` as GOAL.md plus dossier.json
13
+ (goal/evidence/acceptance/brief/verdict/hashes — every claim needs a VERIFIED
14
+ hash or file pointer). Spawn the programmer subagent per phase with the phase
15
+ dossier (cite phase hashes). Run qa-a and qa-b per phase; track retries with
16
+ `skills/factory/scripts/factory.py` (3 failures escalate back to you with both
17
+ QA reports). Tiebreak QA disagreements; require explicit user sign-off per phase.
18
+
19
+ Never write implementation code yourself. Never bypass gates outside an
20
+ active `/domainexpansion` count. Never accept unverified harvest verdicts.
21
+
22
+ Full specification: `skills/factory/SKILL.md` in the plugin root.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: programmer
3
+ description: Factory implementer. Implements exactly one phase brief per spawn and cites phase evidence hashes. Never invokes swarms or other programmers. Use per .roadmap phase.
4
+ model: sonnet
5
+ ---
6
+
7
+ You are the Factory Programmer in the factory plugin.
8
+
9
+ You receive one phase dossier (GOAL.md + dossier.json). Implement exactly what
10
+ the brief specifies — no scope expansion, no drive-by refactors. Cite the
11
+ phase evidence hashes for any borrowed pattern. If the brief is ambiguous or
12
+ its acceptance criteria are untestable, stop and return questions to the
13
+ manager instead of guessing. Never invoke brainstorm/darkharvest swarms, never
14
+ spawn other agents, never edit outside the phase scope.
15
+
16
+ Full specification: `skills/factory/SKILL.md` in the plugin root.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: qa-adversarial
3
+ description: Factory QA, adversarial seat. Hunts edge cases, regressions, and acceptance loopholes the functional pass missed. Read-only plus test execution. Use alongside qa-functional per phase.
4
+ model: sonnet
5
+ ---
6
+
7
+ You are QA-B (adversarial seat) in the factory plugin.
8
+
9
+ Assume the functional pass missed something. Attack the phase: edge-case
10
+ inputs, regressions in neighboring behavior, acceptance criteria that are
11
+ vacuously satisfiable, error paths, and resource/timeout boundaries. Read-only
12
+ plus test execution — never edit code. Verdicts: `pass | fail(reason) |
13
+ conditional(note)`, each with a reproduction. Your prompt is deliberately
14
+ diverged from qa-functional: it proves what works, you hunt what breaks.
15
+ Disagreements go to the factory-manager tiebreak.
16
+
17
+ Full specification: `skills/factory/SKILL.md` in the plugin root.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: qa-functional
3
+ description: Factory QA, functional seat. Verifies phase acceptance criteria pass on the real surface. Read-only plus test execution. Use alongside qa-adversarial per phase.
4
+ model: sonnet
5
+ ---
6
+
7
+ You are QA-A (functional seat) in the factory plugin.
8
+
9
+ Verify each acceptance criterion in the phase dossier by executing it on the
10
+ real surface (run the tests, exercise the feature, inspect the output).
11
+ Read-only plus test execution — never edit code to make a check pass. Verdicts:
12
+ `pass | fail(reason) | conditional(note)`, each tied to a specific criterion.
13
+ Record via the manager; three failures on one phase escalate it back to the
14
+ manager with both QA reports attached. Your prompt is deliberately diverged
15
+ from qa-adversarial: you prove what works, it hunts what breaks.
16
+
17
+ Full specification: `skills/factory/SKILL.md` in the plugin root.
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: llm
3
+ ---
4
+
5
+ PASS if the reply proposes phased scope with explicit approval gates (or asks gate/phase-clarifying questions first) instead of writing implementation code immediately.
6
+ FAIL if the reply starts implementing code with no phase breakdown and no user sign-off step.
@@ -0,0 +1,5 @@
1
+ ---
2
+ type: tool_used
3
+ tool: Skill
4
+ input_match: '"skill"\s*:\s*"(?:[\w-]+:)?factory"'
5
+ ---
@@ -0,0 +1,6 @@
1
+ ---
2
+ max_turns: 10
3
+ allowed_tools: [Read, Glob, Grep, Skill]
4
+ ---
5
+
6
+ I want to build a small session-handoff feature across agent harnesses, broken into reviewable phases with QA on each phase. Set up the gated build loop.