v1.2
This commit is contained in:
parent
f500279abd
commit
cefa2ace5a
27 changed files with 1275 additions and 314 deletions
104
scripts/ai_inventory.ps1
Normal file
104
scripts/ai_inventory.ps1
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
param(
|
||||
[string]$Query = "",
|
||||
[switch]$All,
|
||||
[switch]$Json
|
||||
)
|
||||
|
||||
$Root = Resolve-Path (Join-Path $PSScriptRoot "..")
|
||||
$RoutingPath = Join-Path $Root "FILES.json"
|
||||
$Routing = Get-Content -Raw -LiteralPath $RoutingPath | ConvertFrom-Json
|
||||
|
||||
$Exact = @{
|
||||
".gitignore" = "ignore rules for local/generated artifacts"
|
||||
".htaccess" = "Apache/static-host cache, MIME, and service-worker behavior"
|
||||
"app_manifest.json" = "canonical version plus CSS/JS/static asset manifest"
|
||||
"favicon.ico" = "legacy favicon"
|
||||
"index.html" = "app DOM shell, canvas, panels, dialogs, and ordered script tags"
|
||||
"README.md" = "small AI entrypoint and read strategy"
|
||||
"AI_MAP.md" = "subsystem map and task-oriented read sets"
|
||||
"FILES.json" = "machine-readable file routing and glob semantics"
|
||||
"service-worker.js" = "generated offline/cache service worker"
|
||||
}
|
||||
|
||||
$JsExact = @{
|
||||
"ants.js" = "ant actor and ant nest worker behavior"
|
||||
"assets.js" = "image loading, image metrics, and render caches"
|
||||
"audio.js" = "sample playback and audio controls"
|
||||
"command_dispatcher.js" = "central command routing for UI/tools/pointers/save"
|
||||
"data.js" = "sprite/decor definitions, needs, config, field tuning"
|
||||
"debug_tools.js" = "browser debug overlay and diagnostics"
|
||||
"family_graph.js" = "lineage graph helpers"
|
||||
"ground_types.js" = "ground definitions, multipliers, limits, labels"
|
||||
"health.js" = "health, stress, need, damage, and death helpers"
|
||||
"history_system.js" = "rolling world statistics/history"
|
||||
"input_mode_manager.js" = "pointer/touch/mobile input classification"
|
||||
"items.js" = "item constructors, food/grass helpers, item preview drawing"
|
||||
"main.js" = "startup, restore, UI binding, update/render loop"
|
||||
"render.js" = "main canvas renderer"
|
||||
"system_order.js" = "named update phase order"
|
||||
"text_catalog.js" = "Japanese UI/state/behavior labels"
|
||||
"version.js" = "app version/cache/static query config"
|
||||
"weather_system.js" = "weather selection and application"
|
||||
}
|
||||
|
||||
function Get-GroupId($Path) {
|
||||
foreach ($Group in $Routing.groups) {
|
||||
foreach ($Pattern in $Group.patterns) {
|
||||
if ($Path -like $Pattern) { return $Group.id }
|
||||
}
|
||||
}
|
||||
return ($Path -split "/")[0]
|
||||
}
|
||||
|
||||
function Get-Meaning($Path) {
|
||||
if ($Exact.ContainsKey($Path)) { return $Exact[$Path] }
|
||||
if ($Path.StartsWith("js/")) {
|
||||
$Name = Split-Path -Leaf $Path
|
||||
if ($JsExact.ContainsKey($Name)) { return $JsExact[$Name] }
|
||||
if ($Name.StartsWith("world_")) { return "world state/view/update/tool/environment/combat/social subsystem" }
|
||||
if ($Name.StartsWith("tarinai_")) { return "creature action/needs/social/item/update subsystem" }
|
||||
if ($Name.StartsWith("item_lifecycle_step_")) { return "item lifecycle pipeline stage" }
|
||||
if ($Name.StartsWith("item_lifecycle_")) { return "item lifecycle subsystem" }
|
||||
if ($Name.StartsWith("item_dynamic_")) { return "dynamic item behavior subsystem" }
|
||||
if ($Name.StartsWith("item_")) { return "item registry/runtime/update/render subsystem" }
|
||||
if ($Name.StartsWith("simulation_")) { return "simulation phase subsystem" }
|
||||
if ($Name.StartsWith("ui_family_")) { return "family tree UI subsystem" }
|
||||
if ($Name.StartsWith("ui_input_")) { return "input handling subsystem" }
|
||||
if ($Name.StartsWith("ui_")) { return "DOM/panel UI subsystem" }
|
||||
if ($Name.StartsWith("save_")) { return "save/load persistence subsystem" }
|
||||
if ($Name.StartsWith("physics_")) { return "physics helper/world subsystem" }
|
||||
return "runtime JavaScript module"
|
||||
}
|
||||
if ($Path.StartsWith("scripts/")) { return "repo script/tooling" }
|
||||
if ($Path.StartsWith("css/")) { return "stylesheet layer" }
|
||||
if ($Path.StartsWith("assets/sprites/")) { return "creature state sprite" }
|
||||
if ($Path.StartsWith("assets/ui/")) { return "UI/app/tool image asset" }
|
||||
if ($Path.StartsWith("assets/objects/")) { return "field object image asset" }
|
||||
if ($Path.StartsWith("assets/sounds/")) { return "voice or sound-effect sample" }
|
||||
return "project file"
|
||||
}
|
||||
|
||||
$Files = Get-ChildItem -LiteralPath $Root -Recurse -File -Force |
|
||||
Where-Object { $_.FullName -notmatch "\\.git\\" -and $_.FullName -notmatch "\\__pycache__\\" } |
|
||||
ForEach-Object { $_.FullName.Substring($Root.Path.Length + 1).Replace("\", "/") } |
|
||||
Sort-Object
|
||||
|
||||
$Records = foreach ($Path in $Files) {
|
||||
$Group = Get-GroupId $Path
|
||||
$Meaning = Get-Meaning $Path
|
||||
if ($Query -and ($Path.ToLowerInvariant() -notlike "*$($Query.ToLowerInvariant())*" -and $Group.ToLowerInvariant() -notlike "*$($Query.ToLowerInvariant())*" -and $Meaning.ToLowerInvariant() -notlike "*$($Query.ToLowerInvariant())*")) {
|
||||
continue
|
||||
}
|
||||
[pscustomobject]@{ path = $Path; group = $Group; meaning = $Meaning }
|
||||
}
|
||||
|
||||
if ($Json) {
|
||||
$Records | ConvertTo-Json -Depth 4
|
||||
} elseif ($All) {
|
||||
$Records | ForEach-Object { "$($_.path): $($_.meaning)" }
|
||||
} else {
|
||||
$Records | Group-Object group | Sort-Object Name | ForEach-Object {
|
||||
"$($_.Name): $($_.Count) files"
|
||||
$_.Group | Select-Object -ExpandProperty meaning -Unique | Sort-Object | Select-Object -First 8 | ForEach-Object { " - $_" }
|
||||
}
|
||||
}
|
||||
207
scripts/ai_inventory.py
Normal file
207
scripts/ai_inventory.py
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import fnmatch
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ROUTING_FILE = ROOT / "FILES.json"
|
||||
|
||||
|
||||
EXCLUDE_DIRS = {".git", "__pycache__"}
|
||||
|
||||
|
||||
EXACT_DESCRIPTIONS = {
|
||||
".gitignore": "ignore rules for local/generated artifacts",
|
||||
".htaccess": "Apache/static-host cache, MIME, and service-worker behavior",
|
||||
"app_manifest.json": "canonical version plus CSS/JS/static asset manifest",
|
||||
"favicon.ico": "legacy favicon",
|
||||
"index.html": "app DOM shell, canvas, panels, dialogs, and ordered script tags",
|
||||
"README.md": "small AI entrypoint and read strategy",
|
||||
"AI_MAP.md": "subsystem map and task-oriented read sets",
|
||||
"FILES.json": "machine-readable file routing and glob semantics",
|
||||
"service-worker.js": "generated offline/cache service worker",
|
||||
}
|
||||
|
||||
|
||||
GROUP_DESCRIPTIONS = {
|
||||
"css": "stylesheet layer",
|
||||
"scripts": "repo tooling",
|
||||
"js": "runtime JavaScript",
|
||||
"assets/sprites": "creature state sprite",
|
||||
"assets/ui": "UI/app/tool image asset",
|
||||
"assets/objects": "field object image asset",
|
||||
"assets/sounds": "voice or sound-effect sample",
|
||||
}
|
||||
|
||||
|
||||
JS_PREFIX_DESCRIPTIONS = [
|
||||
("world_", "world state/view/update/tool/environment/combat/social subsystem"),
|
||||
("tarinai_", "creature action/needs/social/item/update subsystem"),
|
||||
("item_lifecycle_step_", "item lifecycle pipeline stage"),
|
||||
("item_lifecycle_", "item lifecycle subsystem"),
|
||||
("item_dynamic_", "dynamic item behavior subsystem"),
|
||||
("item_", "item registry/runtime/update/render subsystem"),
|
||||
("simulation_", "simulation phase subsystem"),
|
||||
("ui_family_", "family tree UI subsystem"),
|
||||
("ui_input_", "input handling subsystem"),
|
||||
("ui_", "DOM/panel UI subsystem"),
|
||||
("save_", "save/load persistence subsystem"),
|
||||
("physics_", "physics helper/world subsystem"),
|
||||
]
|
||||
|
||||
|
||||
JS_EXACT_DESCRIPTIONS = {
|
||||
"ants.js": "ant actor and ant nest worker behavior",
|
||||
"assets.js": "image loading, image metrics, and render caches",
|
||||
"audio.js": "sample playback and audio controls",
|
||||
"collision_footprint_system.js": "collision footprint shapes and overlap tests",
|
||||
"command_dispatcher.js": "central command routing for UI/tools/pointers/save",
|
||||
"constraint_system.js": "attachments, ropes, push/pull, and collision constraints",
|
||||
"data.js": "sprite/decor definitions, needs, config, field tuning",
|
||||
"debug_tools.js": "browser debug overlay and diagnostics",
|
||||
"disease_registry.js": "disease definitions and lookup",
|
||||
"event_bus.js": "global event bus singleton",
|
||||
"family_graph.js": "lineage graph helpers",
|
||||
"ground_types.js": "ground definitions, multipliers, limits, labels",
|
||||
"health.js": "health, stress, need, damage, and death helpers",
|
||||
"history_system.js": "rolling world statistics/history",
|
||||
"input_mode_manager.js": "pointer/touch/mobile input classification",
|
||||
"items.js": "item constructors, food/grass helpers, item preview drawing",
|
||||
"main.js": "startup, restore, UI binding, update/render loop",
|
||||
"math.js": "shared numeric helpers",
|
||||
"mechanical_system.js": "mechanical item forces, rails, ropes, pins, fences",
|
||||
"patch_helpers.js": "compatibility patch helpers",
|
||||
"perf_profiler.js": "performance profiler and quality adaptation",
|
||||
"registry_base.js": "registry normalization helper base",
|
||||
"render.js": "main canvas renderer",
|
||||
"restore_coordinator.js": "post-load restore ordering/fixups",
|
||||
"sim_core.js": "simulation primitives and shared helpers",
|
||||
"sound_pack.js": "logical sound ID to asset mapping",
|
||||
"snapshot_system.js": "world snapshot capture/restore",
|
||||
"structures.js": "structure definitions and placement/runtime helpers",
|
||||
"structure_lifecycle.js": "structure update lifecycle",
|
||||
"system_order.js": "named update phase order",
|
||||
"text_catalog.js": "Japanese UI/state/behavior labels",
|
||||
"version.js": "app version/cache/static query config",
|
||||
"weather_system.js": "weather selection and application",
|
||||
}
|
||||
|
||||
|
||||
def rel(path: Path) -> str:
|
||||
return path.relative_to(ROOT).as_posix()
|
||||
|
||||
|
||||
def iter_files() -> list[str]:
|
||||
files: list[str] = []
|
||||
for path in ROOT.rglob("*"):
|
||||
if not path.is_file():
|
||||
continue
|
||||
if any(part in EXCLUDE_DIRS for part in path.relative_to(ROOT).parts):
|
||||
continue
|
||||
files.append(rel(path))
|
||||
return sorted(files)
|
||||
|
||||
|
||||
def load_routing() -> dict:
|
||||
return json.loads(ROUTING_FILE.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def group_for(path: str, routing: dict) -> str:
|
||||
for group in routing.get("groups", []):
|
||||
for pattern in group.get("patterns", []):
|
||||
if fnmatch.fnmatch(path, pattern):
|
||||
return group["id"]
|
||||
return path.split("/", 1)[0]
|
||||
|
||||
|
||||
def describe(path: str, routing: dict) -> str:
|
||||
if path in EXACT_DESCRIPTIONS:
|
||||
return EXACT_DESCRIPTIONS[path]
|
||||
if path.startswith("js/"):
|
||||
name = path.rsplit("/", 1)[-1]
|
||||
if name in JS_EXACT_DESCRIPTIONS:
|
||||
return JS_EXACT_DESCRIPTIONS[name]
|
||||
for prefix, desc in JS_PREFIX_DESCRIPTIONS:
|
||||
if name.startswith(prefix):
|
||||
return desc
|
||||
return "runtime JavaScript module"
|
||||
if path.startswith("scripts/"):
|
||||
return "repo script/tooling"
|
||||
if path.startswith("css/"):
|
||||
return "stylesheet layer"
|
||||
if path.startswith("assets/"):
|
||||
for prefix, desc in GROUP_DESCRIPTIONS.items():
|
||||
if path.startswith(prefix + "/"):
|
||||
return desc
|
||||
return "static asset"
|
||||
group_id = group_for(path, routing)
|
||||
for group in routing.get("groups", []):
|
||||
if group.get("id") == group_id:
|
||||
return group.get("meaning", "project file")
|
||||
return "project file"
|
||||
|
||||
|
||||
def matches_query(path: str, query: str, routing: dict) -> bool:
|
||||
if not query:
|
||||
return True
|
||||
q = query.lower()
|
||||
if q in path.lower():
|
||||
return True
|
||||
group_id = group_for(path, routing).lower()
|
||||
if q == group_id or q in group_id:
|
||||
return True
|
||||
return q in describe(path, routing).lower()
|
||||
|
||||
|
||||
def build_records(query: str = "") -> list[dict]:
|
||||
routing = load_routing()
|
||||
records = []
|
||||
for path in iter_files():
|
||||
if not matches_query(path, query, routing):
|
||||
continue
|
||||
records.append({
|
||||
"path": path,
|
||||
"group": group_for(path, routing),
|
||||
"meaning": describe(path, routing),
|
||||
})
|
||||
return records
|
||||
|
||||
|
||||
def print_compact(records: list[dict]) -> None:
|
||||
groups: dict[str, list[dict]] = {}
|
||||
for record in records:
|
||||
groups.setdefault(record["group"], []).append(record)
|
||||
for group_id in sorted(groups):
|
||||
print(f"{group_id}: {len(groups[group_id])} files")
|
||||
meanings = sorted({record["meaning"] for record in groups[group_id]})
|
||||
for meaning in meanings[:8]:
|
||||
print(f" - {meaning}")
|
||||
|
||||
|
||||
def print_all(records: list[dict]) -> None:
|
||||
for record in records:
|
||||
print(f"{record['path']}: {record['meaning']}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Print token-aware AI file inventory.")
|
||||
parser.add_argument("query", nargs="?", default="", help="Optional group/path/meaning filter, e.g. ui, world, assets.")
|
||||
parser.add_argument("--all", action="store_true", help="Print every matching file instead of grouped summary.")
|
||||
parser.add_argument("--json", action="store_true", help="Print JSON records.")
|
||||
args = parser.parse_args()
|
||||
|
||||
records = build_records(args.query)
|
||||
if args.json:
|
||||
print(json.dumps(records, ensure_ascii=False, indent=2))
|
||||
elif args.all:
|
||||
print_all(records)
|
||||
else:
|
||||
print_compact(records)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue