arkaos 5.0.0 → 5.1.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 (39) hide show
  1. package/THE-ARKAOS-GUIDE.md +1 -1
  2. package/VERSION +1 -1
  3. package/harness/codex/AGENTS.md +1 -1
  4. package/harness/copilot/copilot-instructions.md +1 -1
  5. package/harness/cursor/rules/arkaos.mdc +2 -2
  6. package/harness/gemini/GEMINI.md +1 -1
  7. package/harness/opencode/AGENTS.md +1 -1
  8. package/harness/opencode/agents/arka-architect-gabriel.md +1 -1
  9. package/harness/opencode/agents/arka-brand-director-valentina.md +1 -1
  10. package/harness/opencode/agents/arka-cfo-helena.md +1 -1
  11. package/harness/opencode/agents/arka-chief-of-staff-afonso.md +1 -1
  12. package/harness/opencode/agents/arka-community-strategist-beatriz.md +1 -1
  13. package/harness/opencode/agents/arka-content-strategist-rafael.md +1 -1
  14. package/harness/opencode/agents/arka-conversion-strategist-ines.md +1 -1
  15. package/harness/opencode/agents/arka-coo-sofia.md +1 -1
  16. package/harness/opencode/agents/arka-copy-director-eduardo.md +1 -1
  17. package/harness/opencode/agents/arka-cqo-marta.md +1 -1
  18. package/harness/opencode/agents/arka-cto-marco.md +1 -1
  19. package/harness/opencode/agents/arka-design-ops-lead-iris.md +1 -1
  20. package/harness/opencode/agents/arka-ecom-director-ricardo.md +1 -1
  21. package/harness/opencode/agents/arka-knowledge-director-clara.md +1 -1
  22. package/harness/opencode/agents/arka-leadership-director-rodrigo.md +1 -1
  23. package/harness/opencode/agents/arka-marketing-director-luna.md +1 -1
  24. package/harness/opencode/agents/arka-ops-lead-daniel.md +1 -1
  25. package/harness/opencode/agents/arka-pm-director-carolina.md +1 -1
  26. package/harness/opencode/agents/arka-revops-lead-vicente.md +1 -1
  27. package/harness/opencode/agents/arka-saas-strategist-tiago.md +1 -1
  28. package/harness/opencode/agents/arka-sales-director-miguel.md +1 -1
  29. package/harness/opencode/agents/arka-strategy-director-tomas.md +1 -1
  30. package/harness/opencode/agents/arka-tech-director-francisca.md +1 -1
  31. package/harness/opencode/agents/arka-tech-lead-paulo.md +1 -1
  32. package/harness/opencode/agents/arka-video-producer-simao.md +1 -1
  33. package/harness/zed/.rules +1 -1
  34. package/installer/claude-md.js +242 -0
  35. package/installer/index.js +10 -8
  36. package/installer/update.js +12 -7
  37. package/knowledge/skills-manifest.json +1 -1
  38. package/package.json +1 -1
  39. package/pyproject.toml +1 -1
@@ -1,6 +1,6 @@
1
1
  # The ArkaOS Guide
2
2
 
3
- > v5.0.0 — 89 agents, 17 departments, 333 skills, 298 commands, 19 ADRs.
3
+ > v5.1.0 — 89 agents, 17 departments, 333 skills, 298 commands, 19 ADRs.
4
4
  > One file, everything you need to start. Generated by `scripts/guide_gen.py` — never hand-edited.
5
5
 
6
6
  ## What it is
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.0
1
+ 5.1.0
@@ -1,6 +1,6 @@
1
1
  # ArkaOS — The Operating System for AI Agent Teams
2
2
 
3
- > v5.0.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
3
+ > v5.1.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
4
4
 
5
5
  You are operating within ArkaOS. Every request routes through the
6
6
  appropriate department squad — never respond as a generic assistant.
@@ -1,6 +1,6 @@
1
1
  # ArkaOS — The Operating System for AI Agent Teams
2
2
 
3
- > v5.0.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
3
+ > v5.1.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
4
4
 
5
5
  You are operating within ArkaOS. Every request routes through the
6
6
  appropriate department squad — never respond as a generic assistant.
@@ -1,11 +1,11 @@
1
1
  ---
2
- description: ArkaOS v5.0.0 agent-team contract
2
+ description: ArkaOS v5.1.0 agent-team contract
3
3
  alwaysApply: true
4
4
  ---
5
5
 
6
6
  # ArkaOS — The Operating System for AI Agent Teams
7
7
 
8
- > v5.0.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
8
+ > v5.1.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
9
9
 
10
10
  You are operating within ArkaOS. Every request routes through the
11
11
  appropriate department squad — never respond as a generic assistant.
@@ -1,6 +1,6 @@
1
1
  # ArkaOS — The Operating System for AI Agent Teams
2
2
 
3
- > v5.0.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
3
+ > v5.1.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
4
4
 
5
5
  You are operating within ArkaOS. Every request routes through the
6
6
  appropriate department squad — never respond as a generic assistant.
@@ -1,6 +1,6 @@
1
1
  # ArkaOS — The Operating System for AI Agent Teams
2
2
 
3
- > v5.0.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
3
+ > v5.1.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
4
4
 
5
5
  You are operating within ArkaOS. Every request routes through the
6
6
  appropriate department squad — never respond as a generic assistant.
@@ -3,7 +3,7 @@ description: "Software Architect — ArkaOS /dev department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Gabriel, Software Architect of the ArkaOS /dev department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Gabriel, Software Architect of the ArkaOS /dev department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: system design, system visualization via dev/diagram (architecture + dataflow diagrams delivered as browser artifacts), domain modeling (event storming, bounded contexts), design patterns (GoF, PoEAA), business / domain analysis, API design.
9
9
 
@@ -3,7 +3,7 @@ description: "Creative Director — ArkaOS /brand department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Valentina, Creative Director of the ArkaOS /brand department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Valentina, Creative Director of the ArkaOS /brand department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: brand identity creation, reference-video visual analysis via dev/watch (complete frames + transcript — motion and art direction judged on evidence, never on screenshots), visual design direction, UX/UI strategy, design systems, brand voice & tone.
9
9
 
@@ -3,7 +3,7 @@ description: "Chief Financial Officer — ArkaOS /fin department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Helena, Chief Financial Officer of the ArkaOS /fin department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Helena, Chief Financial Officer of the ArkaOS /fin department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: financial planning & analysis, valuation & investment, unit economics & SaaS metrics, risk management & ERM, fundraising & cap tables, cash flow management.
9
9
 
@@ -3,7 +3,7 @@ description: "Chief of Staff & Governance Lead — ArkaOS /org department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Afonso, Chief of Staff & Governance Lead of the ArkaOS /org department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Afonso, Chief of Staff & Governance Lead of the ArkaOS /org department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: meeting cadence (daily/weekly/quarterly/annual), OKR & CFR orchestration cross-department, decision records & RACI, premortem / blameless postmortem rituals, governance, board & founder-CEO succession, strategic alignment & single-threaded leadership.
9
9
 
@@ -3,7 +3,7 @@ description: "Community Strategist — ArkaOS /community department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Beatriz, Community Strategist of the ArkaOS /community department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Beatriz, Community Strategist of the ArkaOS /community department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: community strategy & design, platform selection (Discord, Telegram, Skool, Circle), member onboarding & retention, monetization (membership, courses, coaching), gamification & engagement, niche communities (betting, AI, vertical).
9
9
 
@@ -3,7 +3,7 @@ description: "Content Strategist — ArkaOS /content department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Rafael, Content Strategist of the ArkaOS /content department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Rafael, Content Strategist of the ArkaOS /content department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: viral content design, reference-video analysis via dev/watch (frames + timestamped transcript before judging any video), hook writing & packaging, script structure, content operating systems, platform-specific optimization.
9
9
 
@@ -3,7 +3,7 @@ description: "Conversion Strategist — ArkaOS /landing department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Ines, Conversion Strategist of the ArkaOS /landing department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Ines, Conversion Strategist of the ArkaOS /landing department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: sales funnels, landing page optimization, offer creation, copywriting (direct response), launch sequences, affiliate marketing.
9
9
 
@@ -3,7 +3,7 @@ description: "Chief Operations Officer — ArkaOS /org department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Sofia, Chief Operations Officer of the ArkaOS /org department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Sofia, Chief Operations Officer of the ArkaOS /org department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: organizational design, process optimization, cross-department coordination, culture & team health, scaling operations, workflow automation.
9
9
 
@@ -3,7 +3,7 @@ description: "Copy & Language Director — ArkaOS /quality department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Eduardo, Copy & Language Director of the ArkaOS /quality department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Eduardo, Copy & Language Director of the ArkaOS /quality department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: spelling and grammar (EN, PT-PT, PT-BR, ES, FR), tone and voice consistency, AI pattern detection and removal, accentuation and orthography, copywriting quality, factual accuracy in text.
9
9
 
@@ -3,7 +3,7 @@ description: "Chief Quality Officer — ArkaOS /quality department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Marta, Chief Quality Officer of the ArkaOS /quality department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Marta, Chief Quality Officer of the ArkaOS /quality department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: quality assurance orchestration, cross-department quality standards, text quality (spelling, grammar, tone), technical quality (code, UX, data), compliance and audit.
9
9
 
@@ -3,7 +3,7 @@ description: "Chief Technology Officer — ArkaOS /dev department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Marco, Chief Technology Officer of the ArkaOS /dev department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Marco, Chief Technology Officer of the ArkaOS /dev department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: software architecture, system design, tech strategy, cloud infrastructure, ai/ml systems.
9
9
 
@@ -3,7 +3,7 @@ description: "Design Ops Lead — ArkaOS /brand department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Iris, Design Ops Lead of the ArkaOS /brand department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Iris, Design Ops Lead of the ArkaOS /brand department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: design tokens (JSON + CSS variables), component libraries (shadcn/ui, Radix, Headless UI), design system governance, figma → code pipelines, accessibility compliance (WCAG 2.2 AA/AAA), cross-platform tokenisation (Style Dictionary, Tailwind).
9
9
 
@@ -3,7 +3,7 @@ description: "E-Commerce Director — ArkaOS /ecom department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Ricardo, E-Commerce Director of the ArkaOS /ecom department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Ricardo, E-Commerce Director of the ArkaOS /ecom department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: e-commerce strategy, conversion optimization, marketplace operations, pricing strategy, fulfillment & logistics, email & retention.
9
9
 
@@ -3,7 +3,7 @@ description: "Knowledge Director — ArkaOS /kb department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Clara, Knowledge Director of the ArkaOS /kb department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Clara, Knowledge Director of the ArkaOS /kb department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: knowledge management, research methodology, persona building, content curation, taxonomy & ontology, Obsidian vault management.
9
9
 
@@ -3,7 +3,7 @@ description: "Leadership & People Director — ArkaOS /lead department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Rodrigo, Leadership & People Director of the ArkaOS /lead department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Rodrigo, Leadership & People Director of the ArkaOS /lead department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: team assessment & health, leadership development, hiring & onboarding, performance management, feedback & 1-on-1s, culture building.
9
9
 
@@ -3,7 +3,7 @@ description: "Marketing Director — ArkaOS /mkt department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Luna, Marketing Director of the ArkaOS /mkt department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Luna, Marketing Director of the ArkaOS /mkt department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: growth strategy, video-ad teardown via dev/watch (hook, pacing and spoken-copy evidence from frames + transcript), content marketing, SEO, paid acquisition, social media.
9
9
 
@@ -3,7 +3,7 @@ description: "Operations Lead — ArkaOS /ops department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Daniel, Operations Lead of the ArkaOS /ops department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Daniel, Operations Lead of the ArkaOS /ops department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: workflow automation (Zapier, Make, n8n), SOP/process visualization via dev/diagram (workflow + lifecycle diagrams for automations and runbooks), process mapping & optimization, SOP creation & management, bottleneck analysis, integration design.
9
9
 
@@ -3,7 +3,7 @@ description: "Product Manager — ArkaOS /pm department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Carolina, Product Manager of the ArkaOS /pm department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Carolina, Product Manager of the ArkaOS /pm department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: continuous product discovery (daily habit), deliverable visualization via dev/diagram (workflow diagrams so stakeholders see scope before build), weekly customer interviewing, dual-track agile (discovery + delivery), product risk assessment (value/usability/feasibility/viability), framing problems for empowered teams (not features).
9
9
 
@@ -3,7 +3,7 @@ description: "RevOps Lead — ArkaOS /saas department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Vicente, RevOps Lead of the ArkaOS /saas department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Vicente, RevOps Lead of the ArkaOS /saas department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: revenue operations (cross mkt + sales + CS), unified funnel & CRM hygiene, SLA MQL→SQL between marketing and sales, revenue metrics (LTV/CAC, NRR, payback), lead scoring & routing, commission & forecast modeling.
9
9
 
@@ -3,7 +3,7 @@ description: "SaaS Strategist — ArkaOS /saas department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Tiago, SaaS Strategist of the ArkaOS /saas department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Tiago, SaaS Strategist of the ArkaOS /saas department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: SaaS metrics & benchmarking, product-led growth, pricing strategy, customer success, micro-SaaS validation, go-to-market for SaaS.
9
9
 
@@ -3,7 +3,7 @@ description: "Sales Director — ArkaOS /sales department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Miguel, Sales Director of the ArkaOS /sales department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Miguel, Sales Director of the ArkaOS /sales department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: consultative selling, pipeline management, proposal writing, negotiation, discovery calls, deal qualification.
9
9
 
@@ -3,7 +3,7 @@ description: "Chief Strategist — ArkaOS /strat department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Tomas, Chief Strategist of the ArkaOS /strat department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Tomas, Chief Strategist of the ArkaOS /strat department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: competitive strategy, business-flow visualization via dev/diagram (architecture + dataflow diagrams of business models and value chains), market analysis, business model design, positioning, innovation strategy.
9
9
 
@@ -3,7 +3,7 @@ description: "Technical & UX Quality Director — ArkaOS /quality department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Francisca, Technical & UX Quality Director of the ArkaOS /quality department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Francisca, Technical & UX Quality Director of the ArkaOS /quality department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: code quality (SOLID, Clean Code, DRY), test coverage and quality, UX/UI review (heuristics, accessibility), security review (OWASP), performance review (CWV, API latency), data integrity and API contracts.
9
9
 
@@ -3,7 +3,7 @@ description: "Tech Lead — ArkaOS /dev department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Paulo, Tech Lead of the ArkaOS /dev department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Paulo, Tech Lead of the ArkaOS /dev department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: workflow orchestration, visual spec/plan companions via dev/diagram (typed IR -> interactive HTML the user opens before build), code quality enforcement, sprint/cycle management, technical decision-making, developer experience.
9
9
 
@@ -3,7 +3,7 @@ description: "Video Producer & Production Lead — ArkaOS /content department"
3
3
  mode: subagent
4
4
  ---
5
5
 
6
- You are Simão, Video Producer & Production Lead of the ArkaOS /content department (v5.0.0; generated by scripts/harness_gen.py — do not edit).
6
+ You are Simão, Video Producer & Production Lead of the ArkaOS /content department (v5.1.0; generated by scripts/harness_gen.py — do not edit).
7
7
 
8
8
  Expertise: video production pipelines (script → storyboard → assets → edit → render), cut review via dev/watch (frame + transcript evidence on own renders before the Quality Gate), Hyperframes video-as-code editing (HTML/CSS/JS + GSAP → MP4), Higgsfield generation orchestration (image, video, audio, motion control, upscale, reframe), shot lists and EDLs (scene/shot/VO/on-screen-text columns), transcription-synced cuts and word-level captions.
9
9
 
@@ -1,6 +1,6 @@
1
1
  # ArkaOS — The Operating System for AI Agent Teams
2
2
 
3
- > v5.0.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
3
+ > v5.1.0 — 89 agents, 17 departments, 333 skills. Generated by `scripts/harness_gen.py`; do not edit.
4
4
 
5
5
  You are operating within ArkaOS. Every request routes through the
6
6
  appropriate department squad — never respond as a generic assistant.
@@ -0,0 +1,242 @@
1
+ // Managed-block writer for ~/.claude/CLAUDE.md (PR-C5).
2
+ //
3
+ // installer/update.js used to copy the packaged template straight over
4
+ // the live file. On 2026-08-03 the launchd autoupdater did exactly that
5
+ // and destroyed the operator's own instructions (spec
6
+ // .arkaos/specs/installer-claude-md-managed-block.yaml, incident on
7
+ // record). The contract now: shipped instructions live inside an
8
+ // explicitly marked region; once the block exists only that region is
9
+ // rewritten, an unmarked file is adopted (wrapped or prepended to), and
10
+ // no operator byte is ever lost.
11
+ //
12
+ // An unmarked existing file is ambiguous between "pre-C5 install we
13
+ // should adopt" and "the operator deleted our markers on purpose".
14
+ // Those demand OPPOSITE actions (adopt vs leave alone), so adoption is
15
+ // recorded in ~/.arkaos/claude-md-state.json; a missing or unreadable
16
+ // state degrades to adoption, which loses no operator byte.
17
+
18
+ import { createHash } from "node:crypto";
19
+ import {
20
+ copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync,
21
+ renameSync, writeFileSync,
22
+ } from "node:fs";
23
+ import { join, dirname } from "node:path";
24
+
25
+ export const MARKER_START = "<!-- arka:user-instructions:start -->";
26
+ export const MARKER_END = "<!-- arka:user-instructions:end -->";
27
+
28
+ // Every revision of config/user-claude.md ever shipped, by sha256 of its
29
+ // exact bytes. An unmarked file matching one of these is ours to wrap;
30
+ // anything else carries operator edits and is preserved — a file that
31
+ // starts with the shipped template keeps only its remainder below the
32
+ // block; every other file is prepended to.
33
+ // tests/installer/claude-md.test.js fails when the tracked template
34
+ // changes without this list growing.
35
+ export const KNOWN_TEMPLATE_HASHES = Object.freeze([
36
+ // config/user-claude.md @ 05ce86e2 (2026-04-08), sole revision to date
37
+ "cf7c007c9568fe3edc40877e9ce526fc4edaf7c458c0ae6e0e92354b229709a0",
38
+ ]);
39
+
40
+ export function sha256(text) {
41
+ return createHash("sha256").update(text, "utf-8").digest("hex");
42
+ }
43
+
44
+ export function renderManagedBlock(template) {
45
+ const body = template.endsWith("\n") ? template : `${template}\n`;
46
+ return `${MARKER_START}\n${body}${MARKER_END}\n`;
47
+ }
48
+
49
+ // Marker states: "none" (no marker at all), "ok" (exactly one
50
+ // well-ordered pair), "malformed" (anything else, with a reason).
51
+ // Malformed is always a refusal upstream — a wrong guess about which
52
+ // bytes are ours is how content gets destroyed.
53
+ export function analyzeMarkers(content) {
54
+ const starts = indexesOf(content, MARKER_START);
55
+ const ends = indexesOf(content, MARKER_END);
56
+ if (starts.length === 0 && ends.length === 0) return { state: "none" };
57
+ if (starts.length === 0) return malformed("end marker without a start marker");
58
+ if (ends.length === 0) return malformed("start marker without an end marker");
59
+ if (starts.length > 1 || ends.length > 1) {
60
+ return malformed("more than one managed block marker pair");
61
+ }
62
+ if (ends[0] < starts[0]) return malformed("end marker appears before the start marker");
63
+ return { state: "ok", start: starts[0], end: ends[0] + MARKER_END.length };
64
+ }
65
+
66
+ function malformed(reason) {
67
+ return { state: "malformed", reason };
68
+ }
69
+
70
+ function indexesOf(content, needle) {
71
+ const found = [];
72
+ let at = content.indexOf(needle);
73
+ while (at !== -1) {
74
+ found.push(at);
75
+ at = content.indexOf(needle, at + needle.length);
76
+ }
77
+ return found;
78
+ }
79
+
80
+ // Pure decision. `existing` is the current file content (null when the
81
+ // file does not exist); `wasManaged` is the recorded adoption state.
82
+ // `knownHashes` is injectable because the shipped list's discriminating
83
+ // entries are OLD template revisions — files exactly equal to one must
84
+ // wrap, not prepend, even though they no longer prefix-match the
85
+ // current template. With a single shipped revision that case cannot be
86
+ // built from the real list, so the tests pin it with a synthetic one.
87
+ export function planUpdate({ existing, template, wasManaged, knownHashes = KNOWN_TEMPLATE_HASHES }) {
88
+ if (existing === null) return { action: "created", content: renderManagedBlock(template) };
89
+ const markers = analyzeMarkers(existing);
90
+ if (markers.state === "malformed") return { action: "refuse", reason: markers.reason };
91
+ if (markers.state === "ok") return planBlockReplace(existing, template, markers);
92
+ if (wasManaged) return { action: "markers-removed" };
93
+ if (knownHashes.includes(sha256(existing))) {
94
+ return { action: "adopt-wrap", content: renderManagedBlock(template) };
95
+ }
96
+ // "Shipped template + operator additions" is the MODAL pre-C5 shape —
97
+ // every existing install was blind-copied from this same template and
98
+ // then edited below it. Prepending here would duplicate the entire
99
+ // instruction set (QG C5 r1, Francisca B2 — reproduced on the
100
+ // operator's live file), so the template prefix is absorbed into the
101
+ // block and only the operator's remainder is preserved below it.
102
+ if (existing.startsWith(template)) {
103
+ return {
104
+ action: "adopt-wrap",
105
+ content: renderManagedBlock(template) + existing.slice(template.length),
106
+ preservedRemainder: existing.length > template.length,
107
+ };
108
+ }
109
+ return { action: "adopt-prepend", content: `${renderManagedBlock(template)}\n${existing}` };
110
+ }
111
+
112
+ function planBlockReplace(existing, template, markers) {
113
+ const block = renderManagedBlock(template);
114
+ // The rendered block ends with "\n"; when the marker pair is mid-file
115
+ // the original suffix already carries whatever followed the end
116
+ // marker, so the block is spliced in without its trailing newline.
117
+ const spliced = block.slice(0, -1);
118
+ const content =
119
+ existing.slice(0, markers.start) + spliced + existing.slice(markers.end);
120
+ if (content === existing) return { action: "unchanged" };
121
+ return { action: "replace-block", content };
122
+ }
123
+
124
+ // A crash mid-write must never leave a truncated CLAUDE.md, and a
125
+ // symlinked file must keep pointing at its target — renaming onto the
126
+ // LINK would replace the link itself (the C3 remediation lesson), so
127
+ // the write lands on the resolved path. Known trade-off of temp+rename:
128
+ // a HARD-linked twin keeps the old inode's content.
129
+ function writeAtomic(target, content) {
130
+ const real = existsSync(target) ? realpathSync(target) : target;
131
+ const tmp = `${real}.arkaos-tmp-${process.pid}`;
132
+ writeFileSync(tmp, content);
133
+ renameSync(tmp, real);
134
+ }
135
+
136
+ export function backupFile(target) {
137
+ const stamp = new Date().toISOString().replace(/[-:.]/g, "");
138
+ let dest = `${target}.arkaos-backup-${stamp}`;
139
+ let n = 1;
140
+ while (existsSync(dest)) dest = `${target}.arkaos-backup-${stamp}-${n++}`;
141
+ copyFileSync(target, dest);
142
+ return dest;
143
+ }
144
+
145
+ function statePath(home) {
146
+ return join(home, ".arkaos", "claude-md-state.json");
147
+ }
148
+
149
+ function readManagedState(home) {
150
+ try {
151
+ return JSON.parse(readFileSync(statePath(home), "utf-8")).managed === true;
152
+ } catch {
153
+ return false;
154
+ }
155
+ }
156
+
157
+ function writeManagedState(home, lastAction) {
158
+ const path = statePath(home);
159
+ mkdirSync(dirname(path), { recursive: true });
160
+ writeFileSync(path, `${JSON.stringify({ managed: true, lastAction }, null, 2)}\n`);
161
+ }
162
+
163
+ // Update path (installer/update.js). Reads, decides, backs up before
164
+ // any mutation of an existing file, writes, records adoption. CLAUDE.md
165
+ // itself is never touched on refuse/markers-removed/unchanged (the
166
+ // unchanged path still records the adoption state).
167
+ export function syncUserClaudeMd({ home, templatePath }) {
168
+ if (!existsSync(templatePath)) return { action: "no-template" };
169
+ const template = readFileSync(templatePath, "utf-8");
170
+ const target = join(home, ".claude", "CLAUDE.md");
171
+ const raw = existsSync(target) ? readFileSync(target) : null;
172
+ // Decoding a non-UTF-8 file replaces bytes with U+FFFD and writing
173
+ // the decode back corrupts content OUTSIDE the block (QG C5 r1,
174
+ // Francisca B1 — reproduced on latin-1). Refuse unless it round-trips.
175
+ if (raw !== null && !Buffer.from(raw.toString("utf-8"), "utf-8").equals(raw)) {
176
+ return { action: "refuse", reason: "file is not valid UTF-8 — a rewrite would corrupt it" };
177
+ }
178
+ const existing = raw === null ? null : raw.toString("utf-8");
179
+ const plan = planUpdate({ existing, template, wasManaged: readManagedState(home) });
180
+
181
+ if (plan.action === "refuse" || plan.action === "markers-removed") return plan;
182
+ if (plan.action === "unchanged") {
183
+ writeManagedState(home, plan.action);
184
+ return plan;
185
+ }
186
+ const backupPath = existing === null ? null : backupFile(target);
187
+ mkdirSync(dirname(target), { recursive: true });
188
+ writeAtomic(target, plan.content);
189
+ writeManagedState(home, plan.action);
190
+ const result = { action: plan.action, backupPath, path: target };
191
+ if (plan.preservedRemainder) result.preservedRemainder = true;
192
+ return result;
193
+ }
194
+
195
+ // Fresh-install path (installer/index.js). Only ever writes when the
196
+ // file does not exist — the historical "already exists (preserved)"
197
+ // behaviour is unchanged; adoption belongs to the update path.
198
+ export function installUserClaudeMd({ home, templatePath }) {
199
+ if (!existsSync(templatePath)) return { action: "no-template" };
200
+ const target = join(home, ".claude", "CLAUDE.md");
201
+ if (existsSync(target)) return { action: "preserved" };
202
+ mkdirSync(dirname(target), { recursive: true });
203
+ writeAtomic(target, renderManagedBlock(readFileSync(templatePath, "utf-8")));
204
+ writeManagedState(home, "created");
205
+ return { action: "created", path: target };
206
+ }
207
+
208
+ // One printable line per outcome so update.js and index.js report the
209
+ // same result the same way.
210
+ export function describeSyncResult(result) {
211
+ const messages = {
212
+ "no-template": { level: "warn", message: "CLAUDE.md template missing from package — skipped" },
213
+ refuse: { level: "warn", message: `~/.claude/CLAUDE.md NOT updated: ${result.reason}` },
214
+ "markers-removed": {
215
+ level: "warn",
216
+ message: "~/.claude/CLAUDE.md managed markers were removed — treated as deliberate; file left untouched",
217
+ },
218
+ unchanged: { level: "ok", message: "~/.claude/CLAUDE.md already up to date" },
219
+ preserved: { level: "ok", message: "~/.claude/CLAUDE.md already exists (preserved)" },
220
+ created: { level: "ok", message: "~/.claude/CLAUDE.md created (ArkaOS user instructions)" },
221
+ "replace-block": {
222
+ level: "ok",
223
+ message: "~/.claude/CLAUDE.md updated inside the arka:user-instructions markers only",
224
+ },
225
+ "adopt-wrap": {
226
+ level: "ok",
227
+ message: result.preservedRemainder
228
+ ? "~/.claude/CLAUDE.md adopted into managed markers — your content preserved below the block"
229
+ : "~/.claude/CLAUDE.md adopted into managed markers",
230
+ },
231
+ "adopt-prepend": {
232
+ level: "ok",
233
+ message: "~/.claude/CLAUDE.md updated — your content preserved below the managed block",
234
+ },
235
+ };
236
+ const described = messages[result.action]
237
+ ?? { level: "warn", message: `~/.claude/CLAUDE.md: unexpected sync result (${result.action})` };
238
+ if (result.backupPath) {
239
+ return { ...described, detail: `backup: ${result.backupPath}` };
240
+ }
241
+ return described;
242
+ }
@@ -13,6 +13,7 @@ import { deployCoreSnapshot } from "./core-snapshot.js";
13
13
  import { getUi } from "./ui.js";
14
14
  import { buildProfileRecord } from "./profile.js";
15
15
  import { readProductStats, productStatsLines } from "./product-stats.js";
16
+ import { installUserClaudeMd, describeSyncResult } from "./claude-md.js";
16
17
 
17
18
  const __filename = fileURLToPath(import.meta.url);
18
19
  const __dirname = dirname(__filename);
@@ -217,14 +218,15 @@ export async function install({ runtime, path, force, skipSystem, withOllama, pr
217
218
  ok("arka-py interpreter shim installed");
218
219
  }
219
220
  }
220
- const claudeMdSrc = join(ARKAOS_ROOT, "config", "user-claude.md");
221
- const userClaudeMd = join(homedir(), ".claude", "CLAUDE.md");
222
- if (existsSync(claudeMdSrc) && !existsSync(userClaudeMd)) {
223
- copyFileSync(claudeMdSrc, userClaudeMd);
224
- ok("~/.claude/CLAUDE.md created (ArkaOS user instructions)");
225
- } else if (existsSync(userClaudeMd)) {
226
- ok("~/.claude/CLAUDE.md already exists (preserved)");
227
- }
221
+ // Fresh install writes the template inside managed markers (PR-C5) so
222
+ // later updates can manage the file via its markers, no hash path
223
+ // needed; an existing file keeps the historical preserve semantics.
224
+ const claudeMdResult = installUserClaudeMd({
225
+ home: homedir(),
226
+ templatePath: join(ARKAOS_ROOT, "config", "user-claude.md"),
227
+ });
228
+ const claudeMdReport = describeSyncResult(claudeMdResult);
229
+ (claudeMdReport.level === "warn" ? warn : ok)(claudeMdReport.message);
228
230
 
229
231
  // ═══ Step 10: Deploy Cognitive Scheduler ═══
230
232
  step(10, 14, "Deploying cognitive scheduler...");
@@ -10,6 +10,7 @@ import { deployCoreSnapshot } from "./core-snapshot.js";
10
10
  import { getRuntimeConfig } from "./detect-runtime.js";
11
11
  import { loadAdapter } from "./index.js";
12
12
  import { migrateUserData, printMigrationReport } from "./migrate-user-data.js";
13
+ import { syncUserClaudeMd, describeSyncResult } from "./claude-md.js";
13
14
  import { resolveFile } from "./path-resolver.js";
14
15
  import { IS_WINDOWS, HOOK_EXT } from "./platform.js";
15
16
  import { getUi } from "./ui.js";
@@ -368,13 +369,17 @@ export async function update({ skillsFlag = "" } = {}) {
368
369
  ok("arka-py interpreter shim updated");
369
370
  }
370
371
  }
371
- const userClaudeMd = join(homedir(), ".claude", "CLAUDE.md");
372
- const claudeMdSrc = join(ARKAOS_ROOT, "config", "user-claude.md");
373
- if (existsSync(claudeMdSrc)) {
374
- mkdirSync(join(homedir(), ".claude"), { recursive: true });
375
- copyFileSync(claudeMdSrc, userClaudeMd);
376
- ok("~/.claude/CLAUDE.md updated");
377
- }
372
+ // Managed-block sync: once the block exists only the marked region is
373
+ // rewritten; an unmarked file is adopted (wrapped or prepended to) and
374
+ // no operator byte is lost (PR-C5 — the blind copy here destroyed the
375
+ // operator's CLAUDE.md via the autoupdater on 2026-08-03).
376
+ const claudeMdResult = syncUserClaudeMd({
377
+ home: homedir(),
378
+ templatePath: join(ARKAOS_ROOT, "config", "user-claude.md"),
379
+ });
380
+ const claudeMdReport = describeSyncResult(claudeMdResult);
381
+ (claudeMdReport.level === "warn" ? warn : ok)(claudeMdReport.message);
382
+ if (claudeMdReport.detail) detail(` ${claudeMdReport.detail}`);
378
383
 
379
384
  // ── 5. Update Cognitive Scheduler ──
380
385
  section(5, 9, "Updating cognitive scheduler...");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "_meta": {
3
3
  "generator": "scripts/marketplace_gen.py",
4
- "version": "5.0.0",
4
+ "version": "5.1.0",
5
5
  "marketplace": "arkaos"
6
6
  },
7
7
  "structural": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkaos",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "The Operating System for AI Agent Teams",
5
5
  "type": "module",
6
6
  "bin": {
package/pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "arkaos-core"
3
- version = "5.0.0"
3
+ version = "5.1.0"
4
4
  description = "Core engine for ArkaOS — The Operating System for AI Agent Teams"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}