Schema for the `InstructionSource` type.
| 10923 | # Experimental: this type is part of an experimental API and may change or be removed. |
| 10924 | @dataclass |
| 10925 | class InstructionSource: |
| 10926 | """Schema for the `InstructionSource` type.""" |
| 10927 | |
| 10928 | content: str |
| 10929 | """Raw content of the instruction file""" |
| 10930 | |
| 10931 | id: str |
| 10932 | """Unique identifier for this source (used for toggling)""" |
| 10933 | |
| 10934 | label: str |
| 10935 | """Human-readable label""" |
| 10936 | |
| 10937 | location: InstructionLocation |
| 10938 | """Where this source lives — used for UI grouping""" |
| 10939 | |
| 10940 | source_path: str |
| 10941 | """File path relative to repo or absolute for home""" |
| 10942 | |
| 10943 | type: InstructionSourceType |
| 10944 | """Category of instruction source — used for merge logic""" |
| 10945 | |
| 10946 | apply_to: list[str] | None = None |
| 10947 | """Glob pattern(s) from frontmatter — when set, this instruction applies only to matching |
| 10948 | files |
| 10949 | """ |
| 10950 | default_disabled: bool | None = None |
| 10951 | """When true, this source starts disabled and must be toggled on by the user""" |
| 10952 | |
| 10953 | description: str | None = None |
| 10954 | """Short description (body after frontmatter) for use in instruction tables""" |
| 10955 | |
| 10956 | project_path: str | None = None |
| 10957 | """The project path this source was discovered from. Only set by sessionless discovery for |
| 10958 | repository/working-directory sources, where it disambiguates same-named files (e.g. |
| 10959 | .github/copilot-instructions.md) across multiple workspace roots. The session-scoped |
| 10960 | getSources leaves it unset. |
| 10961 | """ |
| 10962 | |
| 10963 | @staticmethod |
| 10964 | def from_dict(obj: Any) -> 'InstructionSource': |
| 10965 | assert isinstance(obj, dict) |
| 10966 | content = from_str(obj.get("content")) |
| 10967 | id = from_str(obj.get("id")) |
| 10968 | label = from_str(obj.get("label")) |
| 10969 | location = InstructionLocation(obj.get("location")) |
| 10970 | source_path = from_str(obj.get("sourcePath")) |
| 10971 | type = InstructionSourceType(obj.get("type")) |
| 10972 | apply_to = from_union([lambda x: from_list(from_str, x), from_none], obj.get("applyTo")) |
| 10973 | default_disabled = from_union([from_bool, from_none], obj.get("defaultDisabled")) |
| 10974 | description = from_union([from_str, from_none], obj.get("description")) |
| 10975 | project_path = from_union([from_str, from_none], obj.get("projectPath")) |
| 10976 | return InstructionSource(content, id, label, location, source_path, type, apply_to, default_disabled, description, project_path) |
| 10977 | |
| 10978 | def to_dict(self) -> dict: |
| 10979 | result: dict = {} |
| 10980 | result["content"] = from_str(self.content) |
| 10981 | result["id"] = from_str(self.id) |
| 10982 | result["label"] = from_str(self.label) |
no outgoing calls
no test coverage detected
searching dependent graphs…