Logo Provision Network Stack

Provision Network Stack

Tổ chức
duplocloud
provision-network-stack

Provisions and operates a Network Stack (AWS VPC + subnets + security group) with a LONG-RUNNING background terraform the agent launches detached and watches with a sleep loop. Dispatches on spec.lastRequestedAction for on-demand plan/apply runs after provisioning, writes per-run logs the Logs tab reads, and handles deprovision as terraform destroy.

Tổng quan

Nhà phát hànhduplocloud
Kho mãdevkit
Tên kỹ năngprovision-network-stack
Sao
51
Bản fork
18
Tệp đi kèm
5
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 5 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được duplocloud công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Provision Network Stack trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/duplocloud/devkit/tree/main/samples/network-stack/skills/provision-network-stack
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/duplocloud/devkit.git /tmp/devkit
mkdir -p .claude/skills
cp -r /tmp/devkit/samples/network-stack/skills/provision-network-stack .claude/skills/provision-network-stack
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Provision Network Stack trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Provision Network Stack ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Provision Network Stack không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

provision-network-stack — long-running terraform + on-demand actions

You are the provisioning agent for a NetworkStack resource (origin NetworkStack, subType network-stack). This skill is the dev-kit's reference for three patterns beyond hello-world:

  1. Long-running provisioning — terraform runs for minutes: launch it DETACHED in the background and watch it with a sleep loop, posting progressive Result.modules[] + subStatus heartbeats.
  2. On-demand actions — after provisioning, the user presses Plan/Apply on the detail view; the backend stamps spec.lastRequestedAction and the platform messages THIS SAME ticket. You dispatch on the verb. There is never a second ticket.
  3. Run logs — every run writes canvas-documents/{plans,applies}/<runId>.{log,meta.json} in the ticket workdir; the extension's backend serves them to the Logs tab via ITicketService (see reference/05 §7).

Inputs the platform gives you

  • $DUPLO_HOST + $DUPLO_TOKEN — resource-scoped write-back credentials (never overwrite either; $DUPLO_BASE exists only when a developer exports it locally — scripts read ${DUPLO_BASE:-$DUPLO_HOST}).
  • shared/network-stack.json — the expanded spec: spec.region, spec.vpcCidr, spec.subnets[], spec.tags, spec.lastRequestedAction, plus id / ownerWorkspaceId / name.
  • An AWS scope — its credentials land at .aws/credentials (+ AWS_SHARED_CREDENTIALS_FILE / AWS_CONFIG_FILE env), which the terraform AWS provider picks up automatically (reference/07-scope-credentials.md).

Write-back base: RES=${DUPLO_BASE:-$DUPLO_HOST}/v1/aiservicedesk/user/data/workspaces/<ownerWorkspaceId>/environment/extensions/network-stacks/<id>

Dispatch — what run is this?

spec.lastRequestedAction PERSISTS on the spec forever, but every "spec updated" reconcile message re-delivers the whole spec — so a request must be acted on once. tf-run.sh stamps the requestedAt it consumed to shared/.last-action-processed after every run; compare before acting:

bash
REQ_AT=$(jq -r '.spec.lastRequestedAction.requestedAt // empty' shared/network-stack.json)
DONE_AT=$(cat shared/.last-action-processed 2>/dev/null || true)
SituationMeaningRun
lastRequestedAction absent AND no prior provision runinitial provisioning (first message)bash .claude/skills/provision-network-stack/scripts/tf-run.sh apply provision
$REQ_AT non-empty and ≠ $DONE_ATa NEW user request (Plan or Apply button)tf-run.sh plan or tf-run.sh apply per .action
$REQ_AT empty or == $DONE_AT (and already provisioned)a plain reconcile — e.g. the user edited the specdo NOT re-run the stale action. First check the run-lock: shared/.run-lock is a HEARTBEAT file — a run is in flight iff it exists AND its mtime is younger than 90 s ([ -f shared/.run-lock ] && [ $(( $(date +%s) - $(stat -c %Y shared/.run-lock) )) -lt 90 ]; PID probes are meaningless across bash calls). In flight → post {"status":"Processing","subStatus":"a run is in flight — the edit is recorded"} (never flip a mid-run resource to Complete). Otherwise post {"status":"Complete","subStatus":"Spec updated — run a Plan to preview the change"}. Then stop.

The message the platform sends for an on-demand action re-states the requested verb — but the spec file + stamp are the source of truth. Never run destroy in response to these messages (see Deprovision below). A duplicate plan/apply while the lock is live exits 3 without posting any status (report "a run is already in progress" in chat and stop; do not re-run); a deprovision waits for the lock (up to 20 min) instead of being dropped.

Runtime facts worth knowing

  • This skill lands in the ticket at .claude/skills/<sanitized skill Name>/ (lowercased, [^a-zA-Z0-9_-] → -) — the bash .claude/skills/provision-network-stack/… paths hold because the registered skill name is exactly provision-network-stack. Skills are frozen after the ticket's first message — editing the bundle mid-ticket does not update the copy on disk.
  • Files this script writes under canvas-documents/ do not auto-open the chat canvas panel (only Write/Edit-tool writes do) — that's fine: the extension's Logs tab reads them through the backend API.
  • Cross-call scratch belongs in $TMPDIR (the ticket's tmp/), never /tmp — /tmp is a private tmpfs per bash invocation.

Turn lifetime — the rules this design lives under (verified against the agent runtime)

  • The whole run happens inside ONE bash invocation. Launch tf-run.sh and stay attached until it exits. Nothing resumes a run later: there are no cross-turn wakeups, and the ticket's credential files (.aws/…) are wiped at the end of every agent turn — a terraform that outlives its invocation loses its credentials mid-run and nobody finalizes it. The next dispatch heals such orphaned runs to Failed.
  • Always pass an explicit Bash timeout when invoking tf-run.sh for provision/apply/destroy — e.g. timeout: 3600000 (60 min; ceiling 90 min). The DEFAULT bash budget is 30 minutes, which is exactly the manifest's timeout.provision — a slow apply on the default budget is killed mid-watch.
  • The run-lock exists because force-sent messages (deprovision, forced spec updates) kill the in-flight turn: the next invocation must not race a half-finished terraform over the same state. It is a heartbeat file, stale after 90 s.

What tf-run.sh does (the long-running pattern — read it, it is the lesson)

take shared/.run-lock — duplicate plan/apply: exit 3, NO status post; deprovision: wait for the lock
  (heartbeat file — the watch loop re-touches it every tick; stale after 90 s)
heal orphaned runs: any meta still running:true with a stale lock -> running:false, success:false
write canvas-documents/<plans|applies>/<runId>.meta.json  (running:true)
copy _terraform -> .tf-work/   (skill mount is read-only; local tfstate persists here across runs)
spec -> stack.tfvars.json
POST status Processing "terraform <verb> started"
terraform init && terraform <verb> ... in the background # the long-running part — watched below,
                                                         # finished INSIDE this same invocation
while the rc file has not appeared:                     # the watch loop
    sleep 10; touch the run-lock (heartbeat)
    grep the log for aws_vpc/aws_subnet/aws_security_group transitions
      -> POST results { modules:[ {key,label,status} … ] }   # progressive, only on change
    POST status Processing "terraform <verb>: <last log line>"
classify rc (plan: 0 clean / 2 has-diff / else failed) -> finalize <runId>.meta.json
apply: terraform output -json -> POST results { vpcId, subnetIds, securityGroupId } + modules Created
append the run to results.actions[] (copying spec.lastRequestedAction.requestedBy — the run's only
  notion of WHO) and POST the merged result store
stamp spec.lastRequestedAction.requestedAt -> shared/.last-action-processed  # consumed, even on failure
POST terminal status:  apply -> Complete|Failed;  plan -> ALWAYS Complete (a failed plan mutates
  nothing — it reports "Plan FAILED — see the Logs tab" in subStatus instead of failing the resource)

Stay attached until the script exits and report its terminal status in your reply. If the script itself cannot start (missing spec, no AWS scope), POST $RES/status {"status":"Failed","faults":["<why>"]}.

Deprovision

When the platform sends the generic teardown message ("Deprovision this resource. Tear down all infrastructure managed by this resource.") — and ONLY then:

bash
DEPROVISION=1 bash .claude/skills/provision-network-stack/scripts/tf-run.sh destroy deprovision

DEPROVISION=1 makes the script post DeProvisioning heartbeats and a terminal DeProvisioned (success) or Failed (see reference/11-deprovisioning.md). Terraform destroy is idempotent — a re-run after a partial teardown destroys the remainder.

Notes

  • Status and results are separate APIs — never fold one into the other.
  • The result accumulator shared/.result.json is merged and re-POSTed whole after every run so earlier outputs and the actions[] history survive later runs.
  • Terraform state is LOCAL to the ticket workdir (.tf-work/terraform.tfstate) — fine for a sample whose ticket owns the stack's whole life. A production extension uses a remote backend (S3 + locking).

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Provision Network Stack làm được gì?

Provisions and operates a Network Stack (AWS VPC + subnets + security group) with a LONG-RUNNING background terraform the agent launches detached and watches with a sleep loop. Dispatches on spec.lastRequestedAction for on-demand plan/apply runs after provisioning, writes per-run logs the Logs tab reads, and handles deprovision as terraform destroy.

Vì sao nên dùng Provision Network Stack trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Provision Network Stack là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Provision Network Stack trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/duplocloud/devkit/tree/main/samples/network-stack/skills/provision-network-stack. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Provision Network Stack?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Provision Network Stack với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Provision Network Stack với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Provision Network Stack có miễn phí không?

Có. Kỹ năng này được duplocloud phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇