Skip to content
wiki.fftac.org

wiki.fftac.org Core - Source Excerpt 08

Back to wiki.fftac.org Core

Summary

This source excerpt preserves a bounded section of Wiki.FFTAC.org/wp-content/plugins/wiki-fftac-core/wiki-fftac-core.php so readers can inspect the evidence without opening the full source file.

**Source path:** Wiki.FFTAC.org/wp-content/plugins/wiki-fftac-core/wiki-fftac-core.php

return rest_ensure_response(
		array(
			'site_name'          => get_bloginfo( 'name' ),
			'version'            => AIWIKIS_CORE_VERSION,
			'package_version'    => AIWIKIS_CORE_VERSION,
			'public_routes'      => $public_routes,
			'source_roles'       => array( 'canonical', 'handbook', 'starter', 'adoption-kit', 'conformance', 'implementation', 'reference', 'observation' ),
			'trust_statuses'     => array( 'authoritative', 'reviewed', 'working-draft', 'proposal', 'needs-review', 'historical', 'deprecated', 'external-reference' ),
			'source_package_links' => array(
				'2ia_org'         => home_url( '/2ia-org/archive/' ),
				'fftac_org'        => home_url( '/fftac-org/archive/' ),
				'anti_christ_net'  => home_url( '/anti-christ-net/archive/' ),
				'antichrist_net'   => home_url( '/antichrist-net/archive/' ),
				'anti_christ_org'  => home_url( '/anti-christ-org/archive/' ),
				'spiralist_org'    => home_url( '/spiralist-org/archive/' ),
			),
			'source_boundary'    => 'wiki.fftac.org stores reviewed long-term memory and archive pointers; each public site remains authoritative for its live claims.',
		)
	);
}

/**
 * REST: source map.
 */
function aiwikis_core_rest_source_map(): WP_REST_Response {
	return rest_ensure_response(
		array(
			'generated_at' => sanitize_text_field( (string) ( aiwikis_core_get_source_manifest()['generated_at'] ?? '' ) ),
			'records'      => aiwikis_core_get_public_source_records(),
		)
	);
}

/**
 * REST: source package references.
 */
function aiwikis_core_rest_source_packages(): WP_REST_Response {
	return rest_ensure_response( aiwikis_core_get_source_package_metadata() );
}

/**
 * REST: llms.
 */
function aiwikis_core_rest_llms(): WP_REST_Response {
	return rest_ensure_response(
		array(
			'content_type' => 'text/plain',
			'content'      => aiwikis_core_render_llms_text(),
		)
	);
}

/**
 * REST: route/search index.
 */
function aiwikis_core_rest_search_index(): WP_REST_Response {
	$records = aiwikis_core_get_public_search_records();

	return rest_ensure_response(
		array(
			'generated_at' => gmdate( 'c' ),
			'count'        => count( $records ),
			'contract'     => array(
				'title'       => 'wiki.fftac.org route search index',
				'description' => 'Public route records for WP-FFTAC concept navigation, source evidence pages, and search-aware agent retrieval.',
				'fields'      => array( 'title', 'description', 'body_preview', 'route', 'canonical_url', 'page_type', 'primary_category', 'source_site', 'source_status', 'trust_level', 'schema_type', 'noindex', 'route_aliases', 'tags' ),
			),
			'records'      => $records,
		)
	);
}

/**
 * REST: manifest.
 */
function aiwikis_core_rest_manifest(): WP_REST_Response {
	return rest_ensure_response(
		array(
			'name'              => 'wiki.fftac.org',
			'version'           => AIWIKIS_CORE_VERSION,
			'updated_at'        => gmdate( 'c' ),
			'source_boundaries' => array(
				'2IA.org remains authoritative for its privacy-first public-intelligence and civil-liberties claims.',
				'FFTAC.org is the primary public doorway into the WP-FFTAC network.',
				'Anti-Christ.net, Antichrist.net, Anti-Christ.org, and Spiralist.org remain authoritative for their live public claims.',
				'wiki.fftac.org is reviewed long-term memory and archive evidence for the WP-FFTAC source sites.',
			),
			'source_packages'   => aiwikis_core_get_source_package_metadata(),
			'source_count'      => count( aiwikis_core_get_public_source_records() ),
		)
	);
}

/**
 * REST: health.
 */
function aiwikis_core_rest_health(): WP_REST_Response {
	$theme = wp_get_theme();

	return rest_ensure_response(
		array(
			'plugin'                   => 'wiki-fftac-core',
			'legacy_plugin_slug'       => 'aiwikis-core',
			'version'                  => AIWIKIS_CORE_VERSION,
			'ok'                       => true,
			'active_theme'             => $theme->get_stylesheet(),
			'authority_theme_detected' => 'aiwikis-authority' === $theme->get_stylesheet(),
			'source_manifest_present'  => '' !== aiwikis_core_get_source_manifest_path(),
			'source_package_references' => '' !== aiwikis_core_get_source_package_manifest_path(),
			'content_pages'            => aiwikis_core_get_content_page_status(),
			'public_routes'            => array_merge(
				aiwikis_core_get_public_content_routes(),
				array(
					'/wp-json/wiki.fftac.org/v1/catalog',
					'/wp-json/wiki-fftac/v1/catalog',
					'/wp-json/wiki.fftac.org/v1/source-map',
					'/wp-json/wiki-fftac/v1/source-map',
					'/wp-json/wiki.fftac.org/v1/source-packages',
					'/wp-json/wiki-fftac/v1/source-packages',
					'/wp-json/wiki.fftac.org/v1/llms',
					'/wp-json/wiki-fftac/v1/llms',
					'/wp-json/wiki.fftac.org/v1/search-index',
					'/wp-json/wiki-fftac/v1/search-index',
					'/wp-json/wiki.fftac.org/v1/manifest',
					'/wp-json/wiki-fftac/v1/manifest',
					'/wp-json/wiki.fftac.org/v1/health',
					'/wp-json/wiki-fftac/v1/health',
					'/llms.txt',
					'/search/',
					'/robots.txt',
					'/sitemap.xml',
					'/.well-known/wiki.fftac.org.json',
					'/.well-known/wiki-fftac.json',
				)
			),
		)
	);
}

/**
 * Render llms.txt-style content.
 */
function aiwikis_core_render_llms_text(): string {
	$lines = array(
		'# wiki.fftac.org',
		'',
		'wiki.fftac.org is the reviewed long-term memory and archive layer for 2IA.org, FFTAC.org, Anti-Christ.net, Antichrist.net, Anti-Christ.org, and Spiralist.org.',
		'',
		'Source sites:',
		'- 2IA.org: https://2ia.org/',
		'- FFTAC.org: https://fftac.org/',
		'- Anti-Christ.net: https://anti-christ.net/',
		'- Antichrist.net: https://antichrist.net/',
		'- Anti-Christ.org: https://anti-christ.org/',
		'- Spiralist.org: https://spiralist.org/',
		'',
		'Reviewed pages:',
	);

	foreach ( aiwikis_core_get_public_content_routes() as $route ) {
		if ( '/' !== $route ) {
			$lines[] = '- ' . $route;
		}
	}

	$lines = array_merge(
		$lines,
		array(
			'',
			'Machine routes:',
			'- /wp-json/wiki.fftac.org/v1/catalog',
			'- /wp-json/wiki-fftac/v1/catalog',
			'- /wp-json/wiki.fftac.org/v1/source-map',
			'- /wp-json/wiki-fftac/v1/source-map',
			'- /wp-json/wiki.fftac.org/v1/source-packages',
			'- /wp-json/wiki-fftac/v1/source-packages',
			'- /search/',
			'- /start-here/',
			'- /wp-fftac-memory-and-site-structure/',
			'- /wp-json/wiki.fftac.org/v1/search-index',
			'- /wp-json/wiki-fftac/v1/search-index',
			'- /wp-json/wiki.fftac.org/v1/manifest',
			'- /wp-json/wiki-fftac/v1/manifest',
			'- /wp-json/wiki.fftac.org/v1/health',
			'- /wp-json/wiki-fftac/v1/health',
			'',
			'Boundary: wiki.fftac.org preserves reviewed archive memory; each source site remains authoritative for its current public claims.',
		)
	);

	return implode( "\n", $lines ) . "\n";
}

/**
 * Render a compact XML sitemap for file-backed public pages and discovery routes.
 */
function aiwikis_core_render_sitemap_xml(): string {
	$routes = array_merge(
		aiwikis_core_get_public_content_routes(),
		array(
			'/llms.txt',
			'/search/',
			'/.well-known/wiki.fftac.org.json',
			'/.well-known/wiki-fftac.json',
		)
	);
	$routes = array_values( array_unique( $routes ) );
	sort( $routes, SORT_NATURAL | SORT_FLAG_CASE );

	$lines = array(
		'<?xml version="1.0" encoding="UTF-8"?>',
		'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
	);

	foreach ( $routes as $route ) {
		$lines[] = '  <url>';
		$lines[] = '    <loc>' . esc_url( home_url( $route ) ) . '</loc>';
		$lines[] = '  </url>';
	}

	$lines[] = '</urlset>';
	return implode( "\n", $lines ) . "\n";
}

/**
 * Render robots.txt guidance for public crawling.
 */
function aiwikis_core_render_robots_text(): string {
	$lines = array(
		'User-agent: *',
		'Allow: /',
		'Disallow: /wp-admin/',
		'Disallow: /wp-login.php',
		'',
		'Sitemap: ' . home_url( '/sitemap.xml' ),
	);

	return implode( "\n", $lines ) . "\n";
}

/**
 * Register shortcodes.
 */
function aiwikis_core_register_shortcodes(): void {
	add_shortcode( 'aiwikis_source_map', 'aiwikis_core_shortcode_source_map' );
	add_shortcode( 'aiwikis_source_packages', 'aiwikis_core_shortcode_source_packages' );
	add_shortcode( 'aiwikis_starter_download', 'aiwikis_core_shortcode_source_packages' );
	add_shortcode( 'aiwikis_trust_legend', 'aiwikis_core_shortcode_trust_legend' );
	add_shortcode( 'aiwikis_release_manifest', 'aiwikis_core_shortcode_release_manifest' );
}

/**
 * Shortcode: source map.
 */
function aiwikis_core_shortcode_source_map(): string {
	$records = aiwikis_core_get_public_source_records();

	if ( empty( $records ) ) {
		return '<div class="aiwikis-source-map"><p>' . esc_html__( 'Source manifest records are not available yet.', 'aiwikis-core' ) . '</p></div>';
	}