Skip to content

forcedotcom/sf-skills / plugins/builder/agentforce-adlc/skills/agentforce-architecture-analyze

agentforce-architecture-analyze

Verified

Declared architecture snapshot for one Agentforce agent: planner, topics, actions, flows, Apex, prompt templates, and NGA plugins. Renders a human-readable architecture document and Mermaid invocation graph from design-time metadata (not runtime audit rows). TRIGGER when user asks to describe, diagram, inventory, audit, document, or diff (e.g. v3 vs v5) the architecture / action tree / topic structure / tool inventory of a specific agent by agent API name in a specific org. DO NOT TRIGGER for runtime session traces, conversation transcripts, generation timings, or gateway audit chains — this skill reads design-time metadata only (use agentforce-d360-analyze for session traces).

FileKindSize
README.mdmarkdown8.5 KB
SKILL.mdskill md17.5 KB
assets/cli/describe_sobject.yamlconfig317 B
assets/cli/describe_tooling_sobject.yamlconfig347 B
assets/cli/list_metadata_genaiprompttemplate.yamlconfig342 B
assets/cli/org_display.yamlconfig280 B
assets/cli/retrieve_genai_plugin.yamlconfig391 B
assets/cli/show_access_token.yamlconfig700 B
assets/mermaid/action_tree.mmdother986 B
assets/mermaid/data_flow.mmdother893 B
assets/mermaid/dependency_graph.mmdother810 B
assets/mermaid/invocation_sequence.mmdother1004 B
assets/mermaid/planner_state.mmdother813 B
assets/soql/apex_class_bodies_by_ids.soqlother103 B
assets/soql/apex_class_bodies_by_names.soqlother102 B
assets/soql/bot_definition_details.soqlother152 B
assets/soql/bot_version_lookup.soqlother186 B
assets/soql/flow_definition_by_ids.soqlother115 B
assets/soql/flow_definition_ids_by_names.soqlother146 B
assets/soql/flow_definition_view_by_durable_ids.soqlother180 B
assets/soql/flow_metadata_by_id.soqlother73 B
assets/soql/functions_by_plugins.soqlother317 B
assets/soql/planner_attrs_by_parent_ids.soqlother156 B
assets/soql/planner_bundle_functions.soqlother93 B
assets/soql/planner_definition_by_agent_chain.soqlother174 B
assets/soql/plugin_functions_by_plugin_ids.soqlother93 B
assets/soql/plugin_instructions_by_plugin_ids.soqlother168 B
assets/soql/plugins_by_planner.soqlother199 B
references/architecture_sections.mdmarkdown8.3 KB
references/contract.jsonconfig11.7 KB
references/soql_fields.mdmarkdown24.6 KB
scripts/_shared/__init__.pyscript82 B
scripts/_shared/fs_guard.pyexecutablescript12.8 KB
scripts/_shared/paths.pyscript3.9 KB
scripts/_shared/runtime.pyscript2.0 KB
scripts/_shared/sql.pyscript355 B
scripts/cache_check.pyexecutablescript8.9 KB
scripts/config.pyscript5.9 KB
scripts/emit_env.pyexecutablescript5.1 KB
scripts/emit_result.pyexecutablescript10.7 KB
scripts/fetch_soql.pyscript26.1 KB
scripts/finalize.pyexecutablescript11.8 KB
scripts/main.pyscript113.9 KB
scripts/metadata_listing.pyscript9.5 KB
scripts/parallel_retrieve.pyscript3.3 KB
scripts/parse_bundle.pyexecutablescript7.9 KB
scripts/parse_wave.pyexecutablescript36.1 KB
scripts/probe_channels.pyscript11.1 KB
scripts/render_architecture.pyscript40.0 KB
scripts/resolve_bot.pyexecutablescript9.4 KB
scripts/resolve_invocation_target.pyscript4.8 KB
scripts/rest_client.pyscript33.7 KB
scripts/retrieve_planner.pyscript464 B
scripts/sanitize.pyexecutablescript1013 B
scripts/sf_cli.pyscript12.3 KB
scripts/soql_loader.pyscript11.1 KB
scripts/summarize_tree.pyexecutablescript4.6 KB
scripts/tests/__init__.pyscript0 B
scripts/tests/_bootstrap.pyscript843 B
scripts/tests/fixtures/__init__.pyscript0 B
scripts/tests/fixtures/genai_payloads.pyscript12.5 KB
scripts/tests/test_cache_check.pyscript12.6 KB
scripts/tests/test_cache_check_main.pyscript10.4 KB
scripts/tests/test_config.pyscript3.8 KB
scripts/tests/test_end_to_end_fixture.pyscript26.2 KB
scripts/tests/test_finalize.pyscript11.2 KB
scripts/tests/test_flow_children_inflation.pyscript25.6 KB
scripts/tests/test_fs_guard.pyscript4.3 KB
scripts/tests/test_iterative_wave_b.pyscript19.0 KB
scripts/tests/test_main_pipeline.pyscript145.1 KB
scripts/tests/test_parallel_retrieve.pyscript4.8 KB
scripts/tests/test_parse_bundle.pyscript15.6 KB
scripts/tests/test_parse_wave.pyscript26.9 KB
scripts/tests/test_parse_wave_classifiers.pyscript8.6 KB
scripts/tests/test_parse_wave_helpers.pyscript14.3 KB
scripts/tests/test_parse_wave_main.pyscript16.4 KB
scripts/tests/test_per_branch_visited.pyscript9.5 KB
scripts/tests/test_probe_channels.pyscript13.3 KB
scripts/tests/test_probe_cli_recipes.pyscript8.2 KB
scripts/tests/test_render_architecture.pyscript32.7 KB
scripts/tests/test_resolve_bot.pyscript7.5 KB
scripts/tests/test_resolve_creds.pyscript12.0 KB
scripts/tests/test_resolve_invocation_target.pyscript5.2 KB
scripts/tests/test_rest_client.pyscript49.8 KB
scripts/tests/test_runtime_override.pyscript3.9 KB
scripts/tests/test_sf_cli.pyscript17.3 KB
scripts/tests/test_signature_stamping.pyscript18.0 KB
scripts/tests/test_skill_md_pipeline_block.pyscript12.7 KB
scripts/tests/test_soql_loader.pyscript21.3 KB
scripts/tests/test_summarize_tree.pyscript8.9 KB
scripts/tests/test_write_emit_ctx.pyscript19.2 KB
scripts/write_emit_ctx.pyexecutablescript14.1 KB

scripts/emit_env.py

View on GitHub
#!/usr/bin/env python3
"""Generic JSON-in → shell-export-out extractor.

Reads a JSON document (from stdin or a file), traverses it by dot-path specs,
and emits `export KEY=shlex.quote(VALUE)` lines on stdout. Callers consume via
`eval "$(python3 emit_env.py ...)"`.

Replaces four single-purpose parsers that previously existed as inline Python
heredocs in the agent:
  * sf org display result parser
  * Q1 row-count + SESSION_ACTIVE derivation
  * _cache_meta.json reader (CACHED_AT_UTC, SESSION_ACTIVE_AT_CACHE)
  * individual field extractors

Field-spec DSL:
    EXPORT_KEY:path           — plain dot-path traversal
    EXPORT_KEY:path[:N]       — string slice after traversal (first N chars)
    EXPORT_KEY:path.length    — length of array / string at path
    EXPORT_KEY:path.empty     — "true" if missing or empty string, else "false"

The DSL is deliberately small: three operators, no dot-inside-key escaping.
Any path component is a dictionary key OR an integer array index
(`data[0].ssot__Foo` works). If the path doesn't resolve, the emitted value
is the empty string — caller decides whether that's OK.

Usage:
    # Parse `sf org display --json` output via stdin (org metadata only —
    # access tokens come only from `sf org auth show-access-token --json --no-prompt`)
    eval "$(printf '%s' "$_SF_JSON" | python3 emit_env.py stdin \\
            'INSTANCE_URL:result.instanceUrl' \\
            'ORG_ID_18:result.id' \\
            'ORG_ID_15:result.id[:15]')"

    # Q1 post-wave: derive SESSION_ACTIVE from row 0's end timestamp
    eval "$(python3 emit_env.py "$WORK_DIR/_q1_body.json" \\
            'SESSION_ACTIVE:data[0].ssot__EndTimestamp__c.empty')"

    # Cache-hit meta read
    eval "$(python3 emit_env.py "$WORK_DIR/$SID.dc.json" \\
            'CACHED_AT_UTC:_cache_meta.cached_at_utc' \\
            'SESSION_ACTIVE:_cache_meta.session_active_at_cache')"

Inputs:
    argv[1]     'stdin' or an absolute file path
    argv[2+]    field specs (at least one)

Outputs:
    stdout      zero or more `export K=V` lines
    exit 0      always (missing keys just produce empty values)
    exit 1      bad argv, unparseable JSON, or I/O error
"""
import json
import pathlib
import re
import shlex
import sys

SLICE_RE = re.compile(r"^(.*?)\[:(\d+)\]$")


def traverse(data, path: str):
    # Path components are dot-separated. Numeric components index into arrays;
    # everything else is a dict key. Missing/invalid → None (emitted as empty).
    node = data
    for part in path.split("."):
        if node is None:
            return None
        if part.isdigit():
            try:
                node = node[int(part)]
            except (IndexError, KeyError, TypeError):
                return None
        elif isinstance(node, dict):
            node = node.get(part)
        else:
            return None
    return node


def apply_spec(data, spec: str) -> tuple[str, str]:
    # spec: "EXPORT_KEY:path<operator>"
    if ":" not in spec:
        raise ValueError(f"spec missing colon: {spec}")
    key, rhs = spec.split(":", 1)
    if not key:
        raise ValueError(f"spec has empty key: {spec}")

    # Resolve the operator suffix on rhs. Check slice LAST because it's the
    # only one that doesn't alter the traversed value's type.
    if rhs.endswith(".length"):
        value = traverse(data, rhs[:-7])
        if value is None:
            return key, "0"
        if isinstance(value, (list, str)):
            return key, str(len(value))
        return key, "0"

    if rhs.endswith(".empty"):
        value = traverse(data, rhs[:-6])
        is_empty = value is None or value == ""
        return key, "true" if is_empty else "false"

    m = SLICE_RE.match(rhs)
    if m:
        path, n = m.group(1), int(m.group(2))
        value = traverse(data, path)
        if value is None:
            return key, ""
        return key, str(value)[:n]

    # Plain traversal.
    value = traverse(data, rhs)
    if value is None:
        return key, ""
    if isinstance(value, bool):
        # Python `True` / `False` → `true` / `false` so bash string compares
        # work without an extra lowercase step.
        return key, "true" if value else "false"
    return key, str(value)


def main() -> int:
    if len(sys.argv) < 3:
        sys.stderr.write("emit_env.py: need source ('stdin' or path) and at least one field spec\n")
        return 1

    source = sys.argv[1]
    specs = sys.argv[2:]

    try:
        if source == "stdin":
            raw = sys.stdin.read()
        else:
            raw = pathlib.Path(source).read_text()
    except OSError as e:
        sys.stderr.write(f"emit_env.py: cannot read {source}: {e}\n")
        return 1

    try:
        data = json.loads(raw)
    except json.JSONDecodeError as e:
        sys.stderr.write(f"emit_env.py: JSON parse error: {e}\n")
        return 1

    for spec in specs:
        try:
            key, value = apply_spec(data, spec)
        except ValueError as e:
            sys.stderr.write(f"emit_env.py: {e}\n")
            return 1
        sys.stdout.write(f"export {key}={shlex.quote(value)}\n")

    return 0


if __name__ == "__main__":
    sys.exit(main())
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall