इसे छोड़कर कंटेंट पर जाएं
AggregaAggregaAggregaAggrega
भाषा चुने: हिन्दी
इस पेज का मशीन अनुवाद किया गया है। मूल अंग्रेज़ी पढ़ें।

aggrega edit-document

किसी दस्तावेज़ पर एक सीमित संरचित संपादन लागू करें, और हर उस बाइट को बनाए रखें जिसे वह नहीं छूता

सारांश

aggrega edit-document <edit> <file> [flags]

विवरण

Apply one bounded structured edit to a document in the workspace.
The edit is named first and the document second. One call adds one entry under one container, or sets one scalar, and it can do nothing else:
add-component add a component instance under a components container
attach-feature attach a Feature to the node you name
wire-edge wire a connection inside one of that node's sockets
set-value set one value on that node
There is no edit that deletes, replaces a block you already wrote, reorders anything, or writes bytes you supply verbatim. The edits this command applies are add-component, attach-feature, wire-edge, set-value, and a name outside that set is refused rather than interpreted.
Name the node with --node, once per path segment, from the document root. It is a segment at a time rather than one dotted string because a dot is a legal character in a name you type, so a joined path could address a key nobody wrote and the entry would be created there rather than refused:
aggrega edit-document add-component app.yaml \
--node spec --node components --name web --value example/service
aggrega edit-document wire-edge app.yaml \
--node spec --node components --node web \
--socket database --name db --value spec.components.store
For add-component the path names the components container itself, because the entry being added is the node. For the other three it names the node the edit is about, and the container follows from the edit.
--name is the key the entry is written under: the instance name, the attachment's name, the connection's alias, or the value's key. --value is what that entry carries, and what it means follows from the edit — the entity the entry requests, the node a connection points at, or the scalar a value is set to. It is read as a YAML scalar, so --value 3 sets a number, --value true a boolean, and --value '"3"' the string; omitting it sets nothing at all.
Every byte the edit does not touch survives. The document is parsed only to locate the container and the line its block ends at, so comments, blank lines, quoting style, folded and literal scalars and the trailing-newline shape all carry through, and the nesting step is measured from the document's own indentation rather than imposed. The same request against the same document produces the same bytes.
The result has to be a document you could have typed, and that is what the write is gated on: the composed document is checked against its own kind's schema and reaches disk only if that passes. A request that would produce something the schema refuses is refused, naming the property the schema would not admit and where, and the file is left byte-for-byte as it was — so a refused edit is indistinguishable from one never attempted and you can retry a corrected request against the document you started with.
An entry that is already there, carrying what you asked for, is a no-op. An entry of that name carrying something else is refused rather than replaced.
--dry-run does everything the plain command does except write: the edited document goes to standard output as content, naming the file it is for, and nothing is created — for a caller that puts the result in front of someone before it is saved. Every other behaviour is the write's, the schema gate included, so a request the write would refuse is refused under --dry-run too and its exit code predicts the write's. Without it the document is written.
Whether what you wire is semantically admissible is not decided here. Whether a socket is one the producer declares, or whether a Feature's applicability is satisfied, is what aggrega validate answers.

फ़्लैग

फ़्लैगडिफ़ॉल्टविवरण
--dry-runfalseलिखने के अलावा सब कुछ करें: संपादित दस्तावेज़ को सामग्री के रूप में वापस दें, उस फ़ाइल का नाम बताते हुए जिसके लिए वह है, और कुछ भी न बनाएं न बदलें। बाकी हर व्यवहार लेखन वाला ही है, स्कीमा गेट सहित। इसके बिना दस्तावेज़ लिखा जाता है
--name—वह कुंजी जिसके अंतर्गत नई प्रविष्टि लिखी जाती है: component इंस्टेंस का नाम, अटैचमेंट का नाम, कनेक्शन का एलियास, या मान की कुंजी
--node[]दस्तावेज़ रूट से उस नोड तक के संरचनात्मक पाथ का एक सेगमेंट जिसके बारे में संपादन है। इसे हर सेगमेंट के लिए एक बार दोहराएं, सबसे बाहरी पहले। यह एक बिंदु-युक्त पाथ के बजाय एक बार में एक सेगमेंट लेता है, क्योंकि आपके द्वारा टाइप किए गए नाम में बिंदु एक वैध अक्षर है, इसलिए जोड़ा गया पाथ ऐसी कुंजी को संबोधित कर सकता है जिसे किसी ने नहीं लिखा
--socket—वह डिपेंडेंसी सॉकेट जिसके भीतर कनेक्शन वायर किया जाता है। wire-edge के लिए पढ़ा जाता है और अन्यथा अनदेखा किया जाता है
--value—प्रविष्टि क्या रखती है, जिसे YAML स्केलर के रूप में पढ़ा जाता है। इसका अर्थ संपादन से निकलता है: वह एंटिटी जिसे प्रविष्टि माँगती है, वह नोड जिसकी ओर कनेक्शन इंगित करता है, या वह स्केलर जिस पर कोई मान सेट किया जाता है

यह क्या करता है

aggrega edit-document <edit> <file> आपके वर्कस्पेस के किसी दस्तावेज़ पर एक संरचित संपादन लागू करता है और जिन बाइट्स को उसने नहीं छुआ, उन्हें ठीक वैसा ही छोड़ देता है जैसा आपने लिखा था। संपादन का नाम पहले दिया जाता है और दस्तावेज़ का बाद में:

Terminal window
aggrega edit-document add-component storefront.aggregate.yaml \
--node spec --node components \
--name checkout --value core/api-server:1.0.0

यह उस स्थिति के लिए है जहाँ आप चाहेंगे कि फ़ाइल संपादित हो जाए, न कि आपको यह बताया जाए कि उसे कहाँ संपादित करना है। यदि आप अपना बफ़र और अपना undo इतिहास स्वयं रखते हैं, तो aggrega serve एक पोज़ीशन बताता है और टेक्स्ट को आपको स्वयं रखने देता है; यह कमांड प्रविष्टि रचता है और उसे लिखता है।

दस्तावेज़ वह है जिसे आपका वर्कस्पेस रखता है। इसका नाम वर्कस्पेस रूट के सापेक्ष या इसके निरपेक्ष पाथ से दें; वर्कस्पेस से बाहर का दस्तावेज़ कुछ भी पढ़े या लिखे बिना अस्वीकार किया जाता है, चाहे वह ऐसा लिखा गया हो या वर्कस्पेस से बाहर ले जाने वाले किसी लिंक के ज़रिए पहुँचा गया हो — फ़ाइल का कोई लिंक, या रास्ते की कोई डायरेक्टरी जो लिंक है। संपादन दस्तावेज़ को वापस लिखने से पहले उसे पढ़ता है, इसलिए ऐसे लिंक के पीछे का दस्तावेज़ एक ऐसी फ़ाइल है जिसे वर्कस्पेस नहीं रखता, और अस्वीकृति यही बताती है:

the document named leads outside the workspace through a link, and an edit is only applied to a document the workspace carries: "shared/storefront.aggregate.yaml"

कहीं और रखे दस्तावेज़ को संपादित करने के लिए, कमांड उस वर्कस्पेस में चलाएं जो उसे रखता है। लैंग्वेज सर्वर और असिस्टेंट टूल के संपादन भी यही नियम लागू करते हैं, क्योंकि तीनों एक ही संपादन लागू करते हैं। इसका दस्तावेज़ वह एकमात्र पाथ है जिसे आप टाइप करते हैं और जो वर्कस्पेस तक सीमित रखा जाता है, जैसा वर्कस्पेस बाउंड्री बताती है।

एक कॉल, एक प्रविष्टि, और समुच्चय बंद है

चार संपादन हैं और कोई अन्य नहीं:

संपादनयह क्या जोड़ता है
add-componentकिसी components कंटेनर के अंतर्गत एक component इंस्टेंस
attach-featureआपके द्वारा नामित नोड पर एक Feature अटैचमेंट
wire-edgeउस नोड के डिपेंडेंसी सॉकेट में से किसी एक के भीतर एक कनेक्शन
set-valueआपके द्वारा नामित नोड पर एक मान

ऐसा कोई संपादन नहीं है जो हटाए, आपके पहले से लिखे किसी ब्लॉक को बदले, किसी चीज़ का क्रम बदले, या आपके द्वारा दिए गए बाइट्स ज्यों-का-त्यों लिखे। यह इस पर कोई प्रतिबंध नहीं, बल्कि पूरी डिज़ाइन यही है: चारों से बाहर के किसी नाम का कमांड से होकर कोई रास्ता ही नहीं है, इसलिए यह कोई संकरा नाम ओढ़े हुए फ़ाइल लेखक नहीं है। समुच्चय से बाहर का नाम व्याख्यायित नहीं, बल्कि अस्वीकार किया जाता है।

जो प्रविष्टि पहले से मौजूद है और वही रखती है जो आपने माँगा, वह no-op है — कमांड यह बताता है और कुछ नहीं लिखता:

storefront.aggregate.yaml already carries that entry; nothing was written

उस नाम की प्रविष्टि जो कुछ और रखती है, बदली नहीं, बल्कि अस्वीकार की जाती है, क्योंकि आपके लिखे को बदलना चारों में से एक नहीं है।

आप नोड का नाम एक पाथ के रूप में, एक बार में एक सेगमेंट देते हैं

--node दस्तावेज़ रूट से पाथ के हर सेगमेंट के लिए एक बार दोहराया जाता है, सबसे बाहरी पहले:

Terminal window
aggrega edit-document wire-edge storefront.aggregate.yaml \
--node spec --node components --node web \
--socket database --name replica --value store

यह एक बिंदु-युक्त पाथ के बजाय जान-बूझकर एक बार में एक सेगमेंट लेता है, और इसका कारण शुद्धता से जुड़ा है। आपके द्वारा टाइप किए गए नाम में बिंदु एक वैध अक्षर है, इसलिए दस्तावेज़ के बाहर की कोई भी चीज़ संरचनात्मक बिंदु और नाम के भीतर के बिंदु में अंतर नहीं कर सकती। जोड़ा गया पाथ सही पढ़ा जाता और ऐसी कुंजी को संबोधित करता जिसे किसी ने नहीं लिखा — और क्योंकि add-component ऐसा कंटेनर बना सकता है जो दस्तावेज़ में नहीं है, प्रविष्टि अस्वीकार होने के बजाय उस गढ़ी गई कुंजी के अंतर्गत पहुँच जाती। सेगमेंट अस्पष्टता को कहीं और ले जाने के बजाय उसे हटा देते हैं।

add-component के लिए पाथ स्वयं components कंटेनर का नाम देता है, क्योंकि जोड़ी जा रही प्रविष्टि ही नोड है। बाकी तीन के लिए यह उस नोड का नाम देता है जिसके बारे में संपादन है, और कंटेनर संपादन से निकलता है: अटैचमेंट उस नोड के features के अंतर्गत जाता है, कनेक्शन उसके uses और आपके द्वारा नामित सॉकेट के अंतर्गत, और मान उसके values के अंतर्गत।

--name वह कुंजी है जिसके अंतर्गत प्रविष्टि लिखी जाती है — इंस्टेंस का नाम, अटैचमेंट का नाम, कनेक्शन का एलियास, या मान की कुंजी। --socket wire-edge के लिए पढ़ा जाता है और अन्यथा अनदेखा किया जाता है।

मान वही type रखता है जो उसके अक्षर दर्शाते हैं

--value को YAML स्केलर के रूप में पढ़ा जाता है, ठीक उसी तरह जैसे वे अक्षर पढ़े जाते यदि आपने उन्हें दस्तावेज़ में टाइप किया होता:

Terminal window
aggrega edit-document set-value storefront.aggregate.yaml \
--node spec --node components --node web --name workers --value 4
values:
replicas: 3
workers: 4

इसलिए --value 4 एक संख्या सेट करता है, --value true एक boolean, और --value '"4"' स्ट्रिंग 4 — यहाँ उद्धरण चिह्न ठीक वैसे ही “यह टेक्स्ट है” कहते हैं जैसे दस्तावेज़ में। --value छोड़ देने से कुछ भी सेट नहीं होता। मैपिंग या सीक्वेंस अस्वीकार किया जाता है, क्योंकि उसे लिखना एक ब्लॉक जोड़ना होता, और यह चार संपादनों में से एक नहीं है।

जो कुछ आपने संपादित नहीं किया वह बना रहता है, और एक ही अनुरोध वही बाइट्स बनाता है

दस्तावेज़ को केवल कंटेनर और उस पंक्ति का पता लगाने के लिए पार्स किया जाता है जहाँ उसका ब्लॉक समाप्त होता है; प्रविष्टि रेंडर की जाती है और पंक्ति के स्तर पर जोड़ी जाती है। टिप्पणियाँ, खाली पंक्तियाँ, उद्धरण की शैली, फ़ोल्डेड और लिटरल स्केलर, टेम्पलेट एक्सप्रेशन और अंतिम न्यूलाइन का स्वरूप सब बिना बदले बने रहते हैं, और नेस्टिंग का अंतर थोपा नहीं जाता, बल्कि दस्तावेज़ के अपने इंडेंटेशन से मापा जाता है — इसलिए प्रविष्टि उसी शैली में आती है जिसमें आप पहले से लिख रहे हैं।

एक ही दस्तावेज़ और एक ही अनुरोध दिए जाने पर, बाइट्स हर बार एक समान होते हैं। इसलिए आप दो रन की तुलना कर सकते हैं, और समीक्षा में एक संपादन एक diff के रूप में पढ़ा जाता है।

परिणाम ऐसा दस्तावेज़ होना चाहिए जिसे आप टाइप कर सकते थे

लेखन इसी शर्त पर होता है। रचे गए दस्तावेज़ की जाँच उसके अपने kind के स्कीमा के विरुद्ध की जाती है, जो आपके द्वारा दिया नहीं जाता बल्कि दस्तावेज़ से पढ़ा जाता है, और बाइट्स डिस्क तक तभी पहुँचते हैं जब यह जाँच सफल हो। जो अनुरोध कुछ ऐसा बनाता जिसे स्कीमा अस्वीकार करता है, वह अस्वीकार किया जाता है, उस प्रॉपर्टी का नाम और स्थान बताते हुए जिसे स्कीमा स्वीकार नहीं करता:

the edit was refused because the resulting document would not be valid, and nothing
was written: document envelope validation failed (Release, at prod.release.yaml);
15:7: spec.components.web.values: … unexpected property: "values"

फ़ाइल बाइट-दर-बाइट वैसी ही छोड़ दी जाती है जैसी थी, और लेखन स्वयं एटॉमिक है, इसलिए अस्वीकृत या बीच में रुका संपादन ऐसे संपादन से अलग नहीं पहचाना जा सकता जिसका कभी प्रयास ही नहीं हुआ, और आप उसी दस्तावेज़ के विरुद्ध सुधारा हुआ अनुरोध फिर से आज़मा सकते हैं जिससे आपने शुरू किया था। इसी कारण यहाँ कोई ऑथरिंग नियम दोहराया नहीं जाता: किसी Release दस्तावेज़ से डेवलपर मान रखने को कहना उसी स्कीमा द्वारा अस्वीकार किया जाता है जो हाथ से टाइप किए गए दस्तावेज़ को अस्वीकार करता।

सिमैंटिक रूप से क्या स्वीकार्य है, यह यहाँ तय नहीं होता। कोई डिपेंडेंसी सॉकेट ऐसा है या नहीं जिसे प्रोड्यूसर घोषित करता है, या किसी Feature की प्रयोज्यता संतुष्ट होती है या नहीं, यह उस रिज़ॉल्यूशन का विषय है जो बिल्ड करता है। इसलिए आप ऐसे कनेक्शन का नाम दे सकते हैं जिसके बारे में इस कमांड ने कभी नहीं सुना, और कोई Aggregate ऐसा सॉकेट ऑथर कर सकता है जिसे उसकी कैटलॉग एंटिटी पहले से घोषित नहीं करती; किसी सॉकेट के पार क्या उपभोग किया जा सकता है, यह घोषित करना प्रोड्यूसर का ही काम रहता है। जब प्रश्न यही हो, तो किसी Release का नाम देते हुए aggrega validate चलाएं।

सहेजे जाने से पहले परिणाम देखना

--dry-run लिखने के अलावा वह सब करता है जो सादा कमांड करता है: संपादित दस्तावेज़ सामग्री के रूप में स्टैंडर्ड आउटपुट पर जाता है, उस फ़ाइल का नाम बताते हुए जिसके लिए वह है, और कुछ भी नहीं बनाया जाता:

Terminal window
aggrega edit-document attach-feature storefront.aggregate.yaml \
--node spec --node components --node web \
--name tls --value core/tls:1.0.0 --dry-run
documents:
- path: storefront.aggregate.yaml
content: |
# The storefront application.
...

इसके बिना दस्तावेज़ लिखा जाता है। डिफ़ॉल्ट लेखन है, क्योंकि इस कमांड का उत्पाद एक संपादित दस्तावेज़ है और जो कमांड उसे बनाता है वह उसे देने के लिए बाध्य है — जो अनुरोध डिलीवरी के बारे में कुछ नहीं कहता, वह फ़ाइल को संपादित करता है।

बाकी हर व्यवहार लेखन वाला ही है, वैलिडेशन गेट सहित। जिस संपादन के परिणाम को स्कीमा अस्वीकार करता, वह --dry-run के अंतर्गत भी अस्वीकार किया जाता है, उसी प्रॉपर्टी का नाम बताते हुए और फ़ाइल को ठीक वैसा ही छोड़ते हुए जैसी वह थी — इसलिए ड्राई रन से मिलने वाला एग्ज़िट कोड वही है जो लेखन आपको देता।

एडिटर या असिस्टेंट से वही संपादन

संपादन चाहे कोई भी सतह लागू करे, बाइट्स एक समान होते हैं। aggrega serve को चलाने वाला एडिटर उस तक aggrega/editDocument पर पहुँचता है, और aggrega mcp के ज़रिए जुड़ा AI असिस्टेंट उस तक उस टूल के रूप में पहुँचता है जिसके अंतर्गत यह कमांड वहाँ उपलब्ध है। प्रविष्टि एक ही जगह रची, जोड़ी और वैलिडेशन से गेट की जाती है, और हर सतह उस पर एक पतला प्रवेश बिंदु है — इसलिए जो दस्तावेज़ आप टर्मिनल पर संपादित करते हैं और जो दस्तावेज़ कोई एडिटर आपके लिए संपादित करता है, वे बाइट-दर-बाइट एक समान होते हैं।

सतहें केवल इस एक बात में भिन्न हैं कि वे कौन-से बाइट्स पढ़ती हैं। यह कमांड और सेशन मेथड दोनों डिस्क पर की फ़ाइल पढ़ते हैं, कभी कोई बिना सहेजा बफ़र नहीं: बफ़र से लिखना एक प्रविष्टि लागू करने के बहाने ऐसी सामग्री पेज पर डाल देता जिसे आपने सहेजा नहीं था। पहले सहेजें, फिर संपादित करें।

उदाहरण

किसी Aggregate के शीर्ष स्तर पर एक component इंस्टेंस जोड़ें:

Terminal window
aggrega edit-document add-component storefront.aggregate.yaml \
--node spec --node components --name checkout --value core/api-server:1.0.0

किसी सबसिस्टम के भीतर ऑथर किए गए component से एक Feature अटैच करें:

Terminal window
aggrega edit-document attach-feature storefront.aggregate.yaml \
--node spec --node subsystems --node billing --node components --node ledger \
--name audit-log --value core/observability/audit-log:1.0.0

किसी सबसिस्टम के भीतर ऑथर किए गए component पर एक मान सेट करें:

Terminal window
aggrega edit-document set-value storefront.aggregate.yaml \
--node spec --node subsystems --node billing --node components --node ledger \
--name replicas --value 5

कुछ भी लिखे जाने से पहले परिणाम की समीक्षा करें:

Terminal window
aggrega edit-document wire-edge storefront.aggregate.yaml \
--node spec --node components --node web \
--socket cache --name sessions --value redis --dry-run

कोई प्रविष्टि किस कंटेनर में होनी चाहिए, यह उसका नाम देने से पहले जानने के लिए, और कुछ भी लागू किए बिना कोई पोज़ीशन पढ़ने के लिए, देखें aggrega serve।