packet-tracer-skill 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/LICENSE.Twofish-BSD-3-Clause.txt +29 -0
  3. package/README.md +687 -0
  4. package/SKILL.md +221 -0
  5. package/bin/packet-tracer-skill.js +635 -0
  6. package/examples/blueprint_minimal.json +46 -0
  7. package/package.json +42 -0
  8. package/references/packettracer-sample-catalog.json +21410 -0
  9. package/references/packettracer-sample-catalog.md +1124 -0
  10. package/references/pkt-format.md +57 -0
  11. package/references/xml-skeleton-notes.md +44 -0
  12. package/requirements-dev.txt +1 -0
  13. package/requirements.txt +6 -0
  14. package/scripts/build_sample_catalog.py +65 -0
  15. package/scripts/donor_diagnostics.py +35 -0
  16. package/scripts/generate_pkt.py +1264 -0
  17. package/scripts/install_skill.py +71 -0
  18. package/scripts/intent_parser.py +712 -0
  19. package/scripts/packet_tracer_env.py +278 -0
  20. package/scripts/pkt_builder.py +15 -0
  21. package/scripts/pkt_codec.py +181 -0
  22. package/scripts/pkt_editor.py +752 -0
  23. package/scripts/pkt_transformer.py +541 -0
  24. package/scripts/sample_catalog.py +385 -0
  25. package/scripts/sample_selector.py +156 -0
  26. package/scripts/setup.ps1 +26 -0
  27. package/scripts/twofish_diagnostics.py +91 -0
  28. package/scripts/vendor/README.md +46 -0
  29. package/scripts/vendor/twofish.py +81 -0
  30. package/scripts/workspace_repair.py +441 -0
  31. package/templates/pt900/base_empty.xml +21 -0
  32. package/templates/pt900/device_library/pc.xml +20 -0
  33. package/templates/pt900/device_library/printer.xml +432 -0
  34. package/templates/pt900/device_library/router.xml +16 -0
  35. package/templates/pt900/device_library/switch.xml +38 -0
package/SKILL.md ADDED
@@ -0,0 +1,221 @@
1
+ ---
2
+ name: pkt
3
+ description: >
4
+ Create and edit Cisco Packet Tracer 9.0 `.pkt` files from hybrid natural-language
5
+ requests and explicit commands. Use this skill for topology generation, VLAN/router-on-a-stick,
6
+ DHCP, management VLAN, Telnet, wireless/AP-client setup, server services, and existing `.pkt` edits.
7
+ ---
8
+
9
+ # Cisco Packet Tracer 9.0 `.pkt` Hybrid Generator/Editor
10
+
11
+ This skill targets Packet Tracer `9.0.0.0810` and treats a `.pkt` file as a single
12
+ binary blob, not a zip container or folder tree.
13
+
14
+ The current builder/editor is Cisco-sample-centric:
15
+
16
+ - installed Packet Tracer sample saves are the primary prototype source
17
+ - bundled device templates are the secondary fallback for gaps such as missing
18
+ device families in Cisco's own saves
19
+ - imported external labs are reference-only by default and are not used as the
20
+ default donor/prototype source
21
+
22
+ That is intentional: it avoids the invalid synthetic XML approach that Packet
23
+ Tracer rejects while still keeping the skill usable when Cisco's own sample set
24
+ does not cover a device family directly.
25
+
26
+ The prompt-first architecture now follows a planner/validator/autofix split:
27
+
28
+ 1. intent extraction
29
+ 2. topology/config planning
30
+ 3. donor ranking
31
+ 4. donor-prune mutation
32
+ 5. compatibility validation
33
+
34
+ Useful ideas from `MCP-Packet-Tracer` were adopted only at the architecture
35
+ level. PTBuilder live deploy and external donor usage were intentionally not
36
+ adopted.
37
+
38
+ ## How `.pkt` Files Work
39
+
40
+ For the modern format targeted by this skill, the pipeline is:
41
+
42
+ 1. Build a Packet Tracer XML document rooted at `<PACKETTRACER5>`
43
+ 2. qCompress the UTF-8 XML bytes using:
44
+ - 4-byte big-endian uncompressed length
45
+ - raw zlib payload
46
+ 3. Apply Stage-2 XOR obfuscation
47
+ 4. Encrypt with Twofish in EAX mode and append the 16-byte authentication tag
48
+ 5. Apply Stage-1 reverse/XOR obfuscation
49
+
50
+ The XML includes a `<VERSION>` value. Compatibility is not guaranteed across Packet
51
+ Tracer releases, so this skill intentionally targets the 9.0 line.
52
+
53
+ ## Workflow
54
+
55
+ 1. Parse the request into a hybrid intent plan:
56
+ - topology, device models, links, cable types, ports
57
+ - natural Azerbaijani or mixed-language counts such as `3 dene switch ve 6 komputer`
58
+ - department/campus prompts such as `6 sobeli kampus sebekesi`
59
+ - VLAN/trunk/access/router-on-a-stick intent
60
+ - router DHCP or server DHCP/DNS intent
61
+ - management VLAN / Telnet intent
62
+ - AP SSID/security and wireless client association intent
63
+ - existing `.pkt` edit operations when a source file is provided
64
+ 2. Build an intent-first topology/config plan:
65
+ - topology archetype
66
+ - device list
67
+ - port map
68
+ - VLAN/service/config plan
69
+ - assumptions and blocking gaps
70
+ 3. Rank Cisco local donor candidates with capability and topology scoring
71
+ 4. Optionally rank external imported labs as reference patterns only
72
+ 5. Apply donor-prune mutations on a working Cisco 9.0 donor lab
73
+ 6. Validate workspace/runtime/scenario compatibility
74
+ 7. Encode XML into a `.pkt` blob with `scripts/pkt_codec.py`
75
+ 8. Save generated or edited output locally
76
+
77
+ ## Files
78
+
79
+ - `scripts/pkt_builder.py`
80
+ Builds Packet Tracer XML from a blueprint
81
+ - `scripts/pkt_codec.py`
82
+ Encodes and decodes the modern `.pkt` format
83
+ - `scripts/generate_pkt.py`
84
+ CLI entrypoint for generate/edit/decode/inventory/explain-plan
85
+ - `scripts/intent_parser.py`
86
+ Hybrid natural-language and mini-DSL parser
87
+ - `scripts/pkt_editor.py`
88
+ Existing `.pkt` inventory and mutation engine
89
+ - `scripts/sample_catalog.py`
90
+ Capability-tagged sample index and reference-pattern loader
91
+ - `scripts/sample_selector.py`
92
+ Sample ranking by capability, topology, trust level, and prototype eligibility
93
+ - `scripts/packet_tracer_env.py`
94
+ Resolves Packet Tracer install, saves root, and executable paths
95
+ - `templates/pt900/base_empty.xml`
96
+ Base Packet Tracer 9.0 skeleton
97
+ - `templates/pt900/device_library/*.xml`
98
+ Secondary fallback device XML templates for the first supported device set
99
+
100
+ The runtime builder currently prefers the installed FTP sample from the local
101
+ Packet Tracer `saves/` directory. The exact path is resolved at runtime from
102
+ the local Packet Tracer installation or the `PACKET_TRACER_*` environment
103
+ variables.
104
+
105
+ Prompt-driven donor-prune generation prefers an explicit
106
+ `PACKET_TRACER_COMPAT_DONOR`, but it can also auto-detect a working local
107
+ Packet Tracer 9.0 donor from common local locations when the environment
108
+ override is absent.
109
+
110
+ Strict compatibility rules:
111
+
112
+ - keep `PACKET_TRACER_TARGET_VERSION` on `9.0.0.0810`
113
+ - do not downgrade prompt generation to `5.3.0.0011`
114
+ - do not use a legacy `5.3` donor/template fallback to bypass strict 9.0 mode
115
+ - if the donor is missing, undecodable, or version-mismatched, stop with a
116
+ blocking error instead of switching versions
117
+ - if `PACKET_TRACER_COMPAT_DONOR` is explicitly set and wrong, do not silently
118
+ fall back to another donor
119
+ - every host process must inherit the same `PACKET_TRACER_*` and
120
+ `PKT_TWOFISH_LIBRARY` environment variables; this is not host-specific
121
+
122
+ ## Supported First Iteration
123
+
124
+ - `Router`, `Switch`, `PC`, `Server`
125
+ - `LightWeightAccessPoint` / `WirelessRouter` where sample prototypes exist
126
+ - natural prompt planning for device counts, VLAN IDs, `gig` uplinks, `fa` host links,
127
+ department/campus prompts, and default `chain` / `core switch` topologies
128
+ - structured `blocking_gaps`, `assumptions_used`, and `confidence_score` reporting
129
+ - transparent `explain-plan` output with:
130
+ - `intent_plan`
131
+ - `topology_plan`
132
+ - `config_plan`
133
+ - `estimate_plan`
134
+ - `preflight_validation`
135
+ - `autofix_summary`
136
+ - `cisco_sample_candidates`
137
+ - `external_reference_patterns`
138
+ - `validation_report`
139
+ - explicit port-to-port and cable/media mapping
140
+ - VLAN create, access port, trunk port, native VLAN
141
+ - router subinterfaces and router-on-a-stick
142
+ - named ACL create, permit/deny rule injection, and `ip access-group` interface binding
143
+ - router DHCP pool
144
+ - server DHCP pool, DNS enablement, and DNS records
145
+ - HTTP / HTTPS / FTP / TFTP / NTP service enable state
146
+ - end-device DNS client settings
147
+ - management VLAN SVI + default gateway
148
+ - Telnet enablement on switches/routers via config mutations
149
+ - wireless SSID/security/channel mutations
150
+ - wireless client association and DHCP/static mode where compatible prototypes exist
151
+ - existing `.pkt` inventory and edit flow
152
+
153
+ ## Defaults
154
+
155
+ If the user does not specify details:
156
+
157
+ - Packet Tracer version: `9.0.0.0810`
158
+ - Subnet: `192.168.1.0/24`
159
+ - Default gateway: `192.168.1.1`
160
+ - PC addresses: `.10`, `.11`, `.12`, ...
161
+ - Layout:
162
+ - router around `(400, 140)`
163
+ - switch around `(400, 280)`
164
+ - PCs along the bottom row
165
+
166
+ ## Constraints
167
+
168
+ - This skill currently plans for Packet Tracer 9.0 only
169
+ - The builder currently depends on a local Packet Tracer installation with the bundled
170
+ sample saves present
171
+ - The bundled template library is intentionally minimal in v1
172
+ - Imported external sample roots are reference-only unless you explicitly promote them
173
+ - Prompt generation in the default path is donor-prune based, not full synthetic rebuild
174
+ - If VLANs are requested for end hosts but host-to-VLAN distribution is not provided,
175
+ the skill returns `blocking_gaps` instead of guessing and generating an unsafe `.pkt`
176
+ - Manual validation in Packet Tracer is still required before claiming a topology
177
+ is fully compatible with the Cisco application
178
+
179
+ ## CLI Examples
180
+
181
+ Generate from a blueprint file:
182
+
183
+ ```powershell
184
+ python scripts/generate_pkt.py --blueprint examples/blueprint_minimal.json --output output\minimal.pkt
185
+ ```
186
+
187
+ Generate from a hybrid prompt:
188
+
189
+ ```powershell
190
+ python scripts/generate_pkt.py --prompt "6 şöbəli şəbəkə qur, VLAN 10 20 30 40 50 60 və management VLAN 99 yarat" --output output\campus.pkt
191
+ ```
192
+
193
+ Explain the parsed plan before generation:
194
+
195
+ ```powershell
196
+ python scripts/generate_pkt.py --explain-plan "set SW1 vlan 10 name Finance; enable telnet on SW1 username admin password 1234"
197
+ ```
198
+
199
+ Explain a natural Azerbaijani prompt before generation:
200
+
201
+ ```powershell
202
+ python scripts/generate_pkt.py --explain-plan "3 dene switch ve 6 komputer ve 1 router vlanlarda 10,20,30 switchlerin oz aralarinda ve routerle aralarinda gig portuna qosulsun komputerler ise fa portlarla qosulsun"
203
+ ```
204
+
205
+ Inspect an existing `.pkt` inventory:
206
+
207
+ ```powershell
208
+ python scripts/generate_pkt.py --inventory input\lab.pkt
209
+ ```
210
+
211
+ Decode a `.pkt` back to XML for inspection:
212
+
213
+ ```powershell
214
+ python scripts/generate_pkt.py --decode output\minimal.pkt --xml-out output\minimal.xml
215
+ ```
216
+
217
+ Launch Packet Tracer for a smoke open test:
218
+
219
+ ```powershell
220
+ python scripts/generate_pkt.py --validate-open output\minimal.pkt
221
+ ```