@prefix : <#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<> a schema:CreativeWork ;
    schema:name "preferences.ttl"@en ;
    schema:description "Configuration for agent RDF memory management and semantic memory skill usage." ;
    schema:dateModified "2026-05-29T21:22:00Z"^^xsd:dateTime ;
    schema:dateCreated "2026-05-29T17:22:00Z"^^xsd:dateTime ;
    schema:author <https://linkedin.com/in/kidehen#this> ;
    schema:about :agentBehaviorGuide .

:agentBehaviorGuide a schema:HowTo ;
    schema:name "Agent Standing Instructions"@en ;
    schema:description "Procedural rules the agent must follow in every session. Encoded as structured RDF so rules are queryable, resolvable, and harder to overlook than flat prose alone."@en ;
    schema:about :topicApprovalWorkflow, :topicArtifactRouting,
        :topicSkillComposition, :topicEntityResolution,
        :topicMemoryManagement, :topicVersionControl,
        :topicAttributionStyling, :topicPackaging,
        :topicThemeImplementation, :topicGraphVisualization,
        :topicContractValidation ;
    schema:step :step-approval, :step-outputDirs, :step-gpt5ChatCodexOutputDirs, :step-skillChain,
        :step-entityDenotation, :step-memoryProtocol,
        :step-gitWorkflow, :step-attribution, :step-zipRepackage,
        :step-darkModeCSS, :step-kgExplorerReuse,
        :step-harnessIds, :step-footerLabels, :step-sparqlFormat,
        :step-complianceBug, :step-simulationLifecycle,
        :step-clickGuard, :step-kgDataRegex,
        :step-documentEntity .

# ── Step 1: Seek Approval ────────────────────────────────────────────────────

:step-approval a schema:HowToStep ;
    schema:position 1 ;
    schema:name "Seek approval before acting unless told otherwise"@en ;
    schema:text "Present plans for user approval before implementing. Never proactively fix or modify documents without explicit request and approval. If unsure, ask. Once approval is granted for a scope, operate autonomously within that scope."@en .

# ── Step 2: Output Directory Routing ─────────────────────────────────────────

:step-outputDirs a schema:HowToStep ;
    schema:position 2 ;
    schema:name "Route artifacts to model-specific output directories"@en ;
    schema:text "DeepSeek V4 Pro → /Users/kidehen/Documents/LLMs/DeepSeek/{rdf,md,webpages}/. Claude Sonnet/Opus → /Users/kidehen/Documents/LLMs/Claude Generated/{RDF,md,webpages}/. MiniMax → /Users/kidehen/Documents/LLMs/MiniMax Generated/{rdf,md,webpages}/. GPT-5 Chat in Codex Desktop → /Users/kidehen/Documents/LLMs/GPT5-Chat-Generated/{rdf,md,webpages}/. Determine the output root from the active LLM model ID before writing any file. Do not use kg-output/, the repo root, or a generator work folder as the final artifact destination."@en .

:step-gpt5ChatCodexOutputDirs a schema:HowToStep ;
    schema:position 2.1 ;
    schema:name "GPT-5 Chat Codex writes generated collections to GPT5-Chat-Generated root folders"@en ;
    schema:text "For GPT-5 Chat running in Codex Desktop, write generated RDF, Markdown, and HTML document collections to /Users/kidehen/Documents/LLMs/GPT5-Chat-Generated/rdf/, /Users/kidehen/Documents/LLMs/GPT5-Chat-Generated/md/, and /Users/kidehen/Documents/LLMs/GPT5-Chat-Generated/webpages/. Keep generator scripts in their project/work folders under showcases when appropriate, but never treat showcases/{rdf,md,webpages}/ as the canonical collection destination."@en .

# ── Step 3: Skill Chain ──────────────────────────────────────────────────────

:step-skillChain a schema:HowToStep ;
    schema:position 3 ;
    schema:name "Use kg-generator → rdf-infographic-skill chain for RDF/MD/HTML collections"@en ;
    schema:text "When generating a Knowledge Graph collection (RDF + MD + HTML), invoke kg-generator first to produce RDF-Turtle, then hand off to rdf-infographic-skill for HTML and MD companions. Never hand-build HTML infographics when the skill exists. Let each skill's contract gates drive quality — do not bypass them."@en .

# ── Step 4: Entity Denotation ────────────────────────────────────────────────

:step-entityDenotation a schema:HowToStep ;
    schema:position 4 ;
    schema:name "Apply entity IRI denotation priority rules"@en ;
    schema:text "Person IRI: LinkedIn profile URL with #this appended → X/Twitter → Substack → other platform → document-local hash fallback. Remove document-local IRI when a platform profile IRI is available. Organization IRI: DBpedia → Wikidata → LinkedIn company → X org → homepage #this → hash fallback. SoftwareApplication IRI: DBpedia → Wikidata → homepage #this. Country IRI: DBpedia → Wikidata → document-local. Link all discovered platform identities via owl:sameAs. Never fabricate IRIs. LinkedIn www/non-www reconciliation: when a LinkedIn IRI uses 'linkedin.com' (no www), add owl:sameAs to the 'www.linkedin.com' form and vice versa — both forms refer to the same profile and must be linked."@en .

# ── Step 5: Memory Protocol ──────────────────────────────────────────────────

:step-memoryProtocol a schema:HowToStep ;
    schema:position 5 ;
    schema:name "Read agent-rdf-memory/ before tasks, write after"@en ;
    schema:text "Before any task needing context: list agent-rdf-memory/, read core.ttl, preferences.ttl, and index.ttl, then follow index.ttl to relevant session/project files. After completing any meaningful task: generate valid RDF-Turtle and write to sessions/YYYY-MM-DD-{llm-id}-{agent-env}.ttl. Never skip this — the RDF memory is the source of truth, not the Claude auto-memory."@en .

# ── Step 6: Git Workflow ─────────────────────────────────────────────────────

:step-gitWorkflow a schema:HowToStep ;
    schema:position 6 ;
    schema:name "Commit and push only when explicitly asked"@en ;
    schema:text "Never commit or push as a side effect of other tasks. Edit skill files → repackage ZIP → commit only when asked → sync registries after commit, not before. Never amend published commits or skip hooks (--no-verify)."@en .

# ── Step 7: Footer Attribution ───────────────────────────────────────────────

:step-attribution a schema:HowToStep ;
    schema:position 7 ;
    schema:name "Use <p> prose format for footer attribution, never chip <div>"@en ;
    schema:text "Every HTML infographic footer MUST use a <p> element with inline prose for skills attribution — never <div class='skills-attribution'> with chip/button styling. All tool/product names MUST hyperlink to their canonical homepages (not resolver URLs): kg-generator and rdf-infographic-skill → GitHub repo, URIBurner → https://linkeddata.uriburner.com/, Virtuoso → https://virtuoso.openlinksw.com/. The resolver is for semantic KG entities only, not product credits."@en .

# ── Step 8: ZIP Repackage ────────────────────────────────────────────────────

:step-zipRepackage a schema:HowToStep ;
    schema:position 8 ;
    schema:name "Delete ZIP before recreating — zip -r on existing archive does not remove deleted files"@en ;
    schema:text "After editing any skill, always: rm <skill-name>.zip && zip -r <skill-name>.zip <skill-name>/ -x '*.DS_Store'. Always exclude .DS_Store. The RSS feed generator bundle is named rss-feed-generator-skill.zip (not rss-feed-generator.zip)."@en .

# ── Step 9: Dark Mode CSS ────────────────────────────────────────────────────

:step-darkModeCSS a schema:HowToStep ;
    schema:position 9 ;
    schema:name "Dark mode must use two separate CSS blocks, never comma-combined"@en ;
    schema:text "Dark mode CSS MUST appear as two entirely separate blocks: (1) html[data-theme='dark'] { ... } for the explicit toggle, (2) @media (prefers-color-scheme: dark) { :root { ... } } for system preference. Never comma-combine these selectors — a trailing comma before @media silently fails in most browsers. All colors must use CSS variables; never hardcode hex values."@en .

# ── Step 10: KG Explorer Template Reuse ──────────────────────────────────────

:step-kgExplorerReuse a schema:HowToStep ;
    schema:position 10 ;
    schema:name "Reuse the last validated KG Explorer HTML as a template — never regenerate from scratch"@en ;
    schema:text "When generating a new HTML infographic with a KG Explorer, copy the most recent validated artifact as a structural template and adapt content. Never write the KG Explorer JS/CSS/HTML from scratch. Proven patterns that must carry forward: (a) zoom isolation with {capture:true} on .kg-stage, (b) SVG <a> wrappers for node labels and edge labels with resolver href, (c) #kg-explorer:fullscreen CSS for legend repositioning, (d) D3 mutation-safe getKGData() with sid()/tid()/cloneLink() helpers, (e) per-group node filtering via kgActiveGroups, (f) predicate checkboxes from allLinks not getKGData(), (g) #kg-settings[hidden]{display:none} CSS rule. Regenerating from scratch reintroduces bugs already fixed in the template."@en .

# ── Step 11: Harness Validator ID Conventions ────────────────────────────────

:step-harnessIds a schema:HowToStep ;
    schema:position 11 ;
    schema:name "Match exact HTML IDs and attributes expected by the harness validator"@en ;
    schema:text "The harness contract validator (validate-harness-contract.py) searches for exact id attributes: sparqlGraph (not sparql-graph), sparqlRecipe (not sparql-recipe), sparqlText (not sparql-query), sparqlFormat (not sparql-format), settingsPanel (not kgSettingsPanel), kgControlsToggle, data-mode='Basic' (not 'basic'), data-mode='Advanced', data-density='Core', data-density='Full'. The D3 script src must contain 'd3@7'. Using different IDs or casing causes FAIL even when the UI is functionally identical. Verify every id before delivery."@en .

# ── Step 12: Footer Attribution Label Casing ─────────────────────────────────

:step-footerLabels a schema:HowToStep ;
    schema:position 12 ;
    schema:name "Use exact lowercase label strings in footer attribution cards"@en ;
    schema:text "The harness validator checks for exact strings in attribution cards: 'Source material', 'Companion files', 'Skills used', 'Generation environment', 'Linked Data runtime', 'Named graphs', 'Resolver pattern', 'Extraction provenance'. Title case ('Source Material') or any variation will FAIL. Match case exactly. Do not rephrase."@en .

# ── Step 13: SPARQL Format Guidance Text ─────────────────────────────────────

:step-sparqlFormat a schema:HowToStep ;
    schema:position 13 ;
    schema:name "Include visible SPARQL result format guidance prose in HTML"@en ;
    schema:text "The harness validator requires the literal strings 'text/x-html+tr' and 'text/x-html-nice-turtle' to appear somewhere in the HTML body, not just in select option values or JS strings. Add a visible prose note near the SPARQL workbench: 'SELECT queries use text/x-html+tr. DESCRIBE and CONSTRUCT use text/x-html-nice-turtle.'"@en .

# ── Step 14: KG Compliance Script ERE Regex Bug ────────────────────────────

:step-complianceBug a schema:HowToStep ;
    schema:position 14 ;
    schema:name "Work around macOS ERE regex bug in validate-kg-compliance.sh"@en ;
    schema:text "validate-kg-compliance.sh line 86 uses a grep -qE pattern intended to match colon followed by whitespace, comma, semicolon, or close parenthesis. In ERE on macOS, the whitespace escape in that pattern is not portable, causing a false 'Ontology not linked via schema:hasPart' failure even when :ontology is correctly listed in schema:hasPart. Workaround: add a standalone comment line '# schema:hasPart : ' in the Turtle file so the -A2 grep context picks up a match. Do not alter the script."@en .

# ── Step 15: KG Explorer Simulation Lifecycle ────────────────────────────────

:step-simulationLifecycle a schema:HowToStep ;
    schema:position 15 ;
    schema:name "Create D3 forceSimulation once and reuse it across renders"@en ;
    schema:text "CRITICAL: Create d3.forceSimulation() ONCE outside the render function, without initial node/link data. In render(): filter nodes/links, then call simulation.nodes(filteredNodes) and simulation.force('link').links(filteredLinks). NEVER recreate the simulation in render() — this destroys all node positions and breaks the graph. Handle D3 source/target object mutation by checking typeof === 'object' when filtering links."@en .

# ── Step 16: Click-Distance Guard ────────────────────────────────────────────

:step-clickGuard a schema:HowToStep ;
    schema:position 16 ;
    schema:name "Use a click-distance guard to distinguish drag from click"@en ;
    schema:text "In D3 drag.on('start'), store dragStartX and dragStartY. In drag.on('end'), compute Math.hypot(event.x - dragStartX, event.y - dragStartY). If distance < 6px, treat as click and open the resolver link via window.open(). If distance >= 6px, treat as drag and keep the node pinned (d.fx/fy remain set). A 6px threshold balances precision and usability."@en .

# ── Step 17: kgData to IIFE Regex Constraint ─────────────────────────────────

:step-kgDataRegex a schema:HowToStep ;
    schema:position 17 ;
    schema:name "Place kgData immediately adjacent to the IIFE opening"@en ;
    schema:text "The harness validator expects the JavaScript kgData declaration to be immediately followed by the IIFE opening. The IIFE (()=>{ must start immediately after the semicolon with only whitespace between. No comment lines, no blank lines with content, no section dividers. Any text between the kgData semicolon and the IIFE breaks validation."@en .

# ── Step 18: Document Entity Declaration ─────────────────────────────────────

:step-documentEntity a schema:HowToStep ;
    schema:position 18 ;
    schema:name "Declare the document entity in every TTL file"@en ;
    schema:text "Every Turtle document MUST declare its own container entity using the empty-prefix relative IRI (:). The pattern is: ': a schema:CreativeWork ; schema:name {title} ; schema:description {summary} ; schema:dateModified {now()} ; schema:author {authorIRI} ; schema:about {primaryTopic}.' Timestamps MUST use the current time (now()) in ISO 8601 UTC format (e.g., \"2026-05-29T21:22:00Z\"^^xsd:dateTime). For new sessions, set both schema:dateCreated and schema:dateModified to now(). For updates to existing files, update only schema:dateModified. The schema:about MUST point to the primary entity described in the document (e.g., :agentBehaviorGuide for preferences.ttl). This makes the document self-describing and queryable as a first-class CreativeWork."@en .

# ── Step 19: Document Entity Property ────────────────────────────────────────

:step-documentAbout a schema:HowToStep ;
    schema:position 19 ;
    schema:name "Use schema:about for the document entity"@en ;
    schema:text "The document-level CreativeWork MUST use schema:about to link to its primary topic, NOT schema:mainEntity. schema:about is the correct predicate for describing what a CreativeWork is about. schema:mainEntity is reserved for specific use cases such as schema:FAQPage mainEntity linking. When in doubt, use schema:about for the document container entity."@en .

# ── Topic Entities (schema:about targets for the container document) ─────────

:topicApprovalWorkflow a schema:Thing ;
    schema:name "Approval Workflow"@en ;
    schema:description "Process of seeking user approval before acting or modifying documents."@en .

:topicArtifactRouting a schema:Thing ;
    schema:name "Artifact Output Routing"@en ;
    schema:description "Rules for directing generated RDF, HTML, and Markdown artifacts to model-specific output directories."@en .

:topicSkillComposition a schema:Thing ;
    schema:name "Skill Chain Composition"@en ;
    schema:description "Patterns for invoking kg-generator, rdf-infographic-skill, and other skills in sequence with proper hand-off and gate compliance."@en .

:topicEntityResolution a schema:Thing ;
    schema:name "Entity IRI Resolution"@en ;
    schema:description "Priority rules for assigning IRIs to people, organizations, software, and countries using LinkedIn, DBpedia, Wikidata, and hash-based fallbacks."@en .

:topicMemoryManagement a schema:Thing ;
    schema:name "RDF Memory Management"@en ;
    schema:description "Protocol for reading and writing agent-rdf-memory files before and after tasks, including retrieval and storage rules."@en .

:topicVersionControl a schema:Thing ;
    schema:name "Git Workflow"@en ;
    schema:description "Rules for committing, pushing, amending, and repackaging skill ZIP bundles without side effects."@en .

:topicAttributionStyling a schema:Thing ;
    schema:name "Footer Attribution Styling"@en ;
    schema:description "HTML footer formatting rules, including <p> prose attribution, canonical homepage links, and exact label casing for validator compliance."@en .

:topicPackaging a schema:Thing ;
    schema:name "Skill Packaging"@en ;
    schema:description "ZIP bundle creation and repackaging rules, including deletion before recreation and .DS_Store exclusion."@en .

:topicThemeImplementation a schema:Thing ;
    schema:name "Theme Implementation"@en ;
    schema:description "Dark mode CSS requirements, including separate blocks for explicit toggle and system preference without comma-combined selectors."@en .

:topicGraphVisualization a schema:Thing ;
    schema:name "Knowledge Graph Visualization"@en ;
    schema:description "KG Explorer patterns, including D3 simulation lifecycle, click-distance guard, zoom isolation, SVG resolver links, and template reuse."@en .

:topicContractValidation a schema:Thing ;
    schema:name "Harness Contract Validation"@en ;
    schema:description "Validator-specific requirements, including exact HTML IDs, footer label casing, SPARQL format guidance text, and macOS ERE regex workarounds."@en .
