@intentius/chant-lexicon-k8s 0.31.0 → 0.33.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 (103) hide show
  1. package/dist/api/classify.d.ts +10 -0
  2. package/dist/api/classify.d.ts.map +1 -1
  3. package/dist/api/owner-chain.d.ts +46 -0
  4. package/dist/api/owner-chain.d.ts.map +1 -0
  5. package/dist/api/sweep-types.d.ts +17 -0
  6. package/dist/api/sweep-types.d.ts.map +1 -0
  7. package/dist/deep-observe-hooks.d.ts +86 -0
  8. package/dist/deep-observe-hooks.d.ts.map +1 -0
  9. package/dist/deep-observe.d.ts +146 -0
  10. package/dist/deep-observe.d.ts.map +1 -0
  11. package/dist/describe-resources.d.ts +15 -0
  12. package/dist/describe-resources.d.ts.map +1 -1
  13. package/dist/export-resources.d.ts +6 -2
  14. package/dist/export-resources.d.ts.map +1 -1
  15. package/dist/integrity.json +2 -2
  16. package/dist/kube/apply.d.ts +26 -0
  17. package/dist/kube/apply.d.ts.map +1 -0
  18. package/dist/kube/connect.d.ts +30 -0
  19. package/dist/kube/connect.d.ts.map +1 -0
  20. package/dist/kube/delete.d.ts +27 -0
  21. package/dist/kube/delete.d.ts.map +1 -0
  22. package/dist/kube/describe.d.ts +19 -0
  23. package/dist/kube/describe.d.ts.map +1 -0
  24. package/dist/kube/events.d.ts +34 -0
  25. package/dist/kube/events.d.ts.map +1 -0
  26. package/dist/kube/flags.d.ts +40 -0
  27. package/dist/kube/flags.d.ts.map +1 -0
  28. package/dist/kube/get.d.ts +21 -0
  29. package/dist/kube/get.d.ts.map +1 -0
  30. package/dist/kube/group.d.ts +19 -0
  31. package/dist/kube/group.d.ts.map +1 -0
  32. package/dist/kube/logs.d.ts +16 -0
  33. package/dist/kube/logs.d.ts.map +1 -0
  34. package/dist/kube/project.d.ts +59 -0
  35. package/dist/kube/project.d.ts.map +1 -0
  36. package/dist/kube/render.d.ts +75 -0
  37. package/dist/kube/render.d.ts.map +1 -0
  38. package/dist/kube/source.d.ts +19 -0
  39. package/dist/kube/source.d.ts.map +1 -0
  40. package/dist/kube/target.d.ts +52 -0
  41. package/dist/kube/target.d.ts.map +1 -0
  42. package/dist/kube/testing.d.ts +21 -0
  43. package/dist/kube/testing.d.ts.map +1 -0
  44. package/dist/kube/top.d.ts +23 -0
  45. package/dist/kube/top.d.ts.map +1 -0
  46. package/dist/kube/verdict.d.ts +45 -0
  47. package/dist/kube/verdict.d.ts.map +1 -0
  48. package/dist/kube/wait.d.ts +23 -0
  49. package/dist/kube/wait.d.ts.map +1 -0
  50. package/dist/manifest.json +1 -1
  51. package/dist/op/activities/index.d.ts +6 -3
  52. package/dist/op/activities/index.d.ts.map +1 -1
  53. package/dist/op/activities/kubectl.d.ts +91 -9
  54. package/dist/op/activities/kubectl.d.ts.map +1 -1
  55. package/dist/plugin.d.ts.map +1 -1
  56. package/package.json +3 -3
  57. package/src/api/classify.ts +13 -0
  58. package/src/api/owner-chain.test.ts +171 -0
  59. package/src/api/owner-chain.ts +144 -0
  60. package/src/api/sweep-types.ts +36 -0
  61. package/src/deep-observe-hooks.ts +125 -0
  62. package/src/deep-observe.test.ts +668 -0
  63. package/src/deep-observe.ts +299 -0
  64. package/src/describe-resources.test.ts +224 -1
  65. package/src/describe-resources.ts +86 -1
  66. package/src/export-resources.ts +6 -22
  67. package/src/kube/apply.test.ts +105 -0
  68. package/src/kube/apply.ts +101 -0
  69. package/src/kube/connect.ts +54 -0
  70. package/src/kube/delete.test.ts +123 -0
  71. package/src/kube/delete.ts +174 -0
  72. package/src/kube/describe.test.ts +106 -0
  73. package/src/kube/describe.ts +195 -0
  74. package/src/kube/events.test.ts +115 -0
  75. package/src/kube/events.ts +160 -0
  76. package/src/kube/flags.test.ts +65 -0
  77. package/src/kube/flags.ts +114 -0
  78. package/src/kube/get.test.ts +195 -0
  79. package/src/kube/get.ts +190 -0
  80. package/src/kube/group.test.ts +33 -0
  81. package/src/kube/group.ts +125 -0
  82. package/src/kube/logs.test.ts +126 -0
  83. package/src/kube/logs.ts +96 -0
  84. package/src/kube/project.test.ts +57 -0
  85. package/src/kube/project.ts +106 -0
  86. package/src/kube/render.test.ts +142 -0
  87. package/src/kube/render.ts +252 -0
  88. package/src/kube/source.test.ts +138 -0
  89. package/src/kube/source.ts +139 -0
  90. package/src/kube/target.test.ts +67 -0
  91. package/src/kube/target.ts +89 -0
  92. package/src/kube/testing.ts +42 -0
  93. package/src/kube/top.test.ts +149 -0
  94. package/src/kube/top.ts +120 -0
  95. package/src/kube/verdict.test.ts +48 -0
  96. package/src/kube/verdict.ts +77 -0
  97. package/src/kube/wait.test.ts +125 -0
  98. package/src/kube/wait.ts +160 -0
  99. package/src/op/activities/index.ts +6 -3
  100. package/src/op/activities/kubectl.test.ts +298 -26
  101. package/src/op/activities/kubectl.ts +313 -20
  102. package/src/plugin.test.ts +58 -1
  103. package/src/plugin.ts +29 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `chant kube get` (chant #1079) — kubectl's own muscle-memory verb, plus the
3
+ * chant verdict column the issue's acceptance criterion names.
4
+ *
5
+ * The cluster edge is the typed client (chant #1074/#1177), reached the same
6
+ * way every other read does: `--env` resolves and honors the cluster
7
+ * binding (chant #1100/#1155, refusing loudly on a mismatch), `--context` is
8
+ * an explicit override, neither given falls back to the ambient kubeconfig
9
+ * context. A connect failure, an RBAC-denied read, or a kind the cluster's
10
+ * discovery has never heard of all render as an honest message rather than
11
+ * an empty table — "No resources found." is reserved for the one case that
12
+ * actually means it: the kind is real and there are zero live instances.
13
+ */
14
+ import { type K8sConnector } from "../api/connect.js";
15
+ import { type KubeProjectContext } from "./project.js";
16
+ export interface GetDeps {
17
+ connect?: K8sConnector;
18
+ loadProject?: (cwd?: string) => Promise<KubeProjectContext | undefined>;
19
+ }
20
+ export declare function runGet(rawArgs: string[], deps?: GetDeps): Promise<number>;
21
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../src/kube/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKxE,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAgB5E,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CACzE;AAMD,wBAAsB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CA2InF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `chant kube` — the terminal surface over the typed client (chant #1079),
3
+ * mounted through the command-group seam #1078 built and reserved this exact
4
+ * namespace for (`lexicons/k8s/src/plugin.ts`'s `commands()`).
5
+ *
6
+ * Every verb below except `version` dynamically imports its own module. That
7
+ * is not a style choice: `describe-resources.ts`, `api/connect.ts` and the
8
+ * rest of the read/write paths sit behind a dynamic import specifically so
9
+ * `chant build` never has to resolve `@intentius/chant-k8s-client`
10
+ * (chant #1074, `examples/k8s-client-boundary.test.ts`). This module IS
11
+ * statically reachable from `plugin.ts` — it is plain data, a list of verb
12
+ * names and descriptions — so every verb whose implementation touches the
13
+ * client must be reached from here only through `await import(...)`, exactly
14
+ * like `version`'s existing `await import("../spec/fetch.js")`.
15
+ */
16
+ import type { CommandGroup } from "@intentius/chant/cli/command-group";
17
+ /** The full `chant kube` verb group. */
18
+ export declare function kubeCommandGroup(): CommandGroup;
19
+ //# sourceMappingURL=group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/kube/group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,oCAAoC,CAAC;AAuB5F,wCAAwC;AACxC,wBAAgB,gBAAgB,IAAI,YAAY,CAoF/C"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `chant kube logs` (chant #1079) — a Pod's `/log` subresource, over the
3
+ * typed client's new `readLog` (`packages/k8s-client/src/client.ts`). A
4
+ * snapshot only: `--follow`/`-f` would need the transport seam to expose a
5
+ * stream rather than a completed response body, which it does not today —
6
+ * left out deliberately (see `readLog`'s own doc) rather than faked with a
7
+ * poll loop that isn't actually following anything.
8
+ */
9
+ import { type K8sConnector } from "../api/connect.js";
10
+ import { type KubeProjectContext } from "./project.js";
11
+ export interface LogsDeps {
12
+ connect?: K8sConnector;
13
+ loadProject?: (cwd?: string) => Promise<KubeProjectContext | undefined>;
14
+ }
15
+ export declare function runLogs(rawArgs: string[], deps?: LogsDeps): Promise<number>;
16
+ //# sourceMappingURL=logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/kube/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKxE,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE5E,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CACzE;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,QAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAyErF"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Best-effort chant-project context for `chant kube` (chant #1079).
3
+ *
4
+ * `get`'s chant-verdict column and `source` both need to answer "does a
5
+ * declared entity in this project's source name this live object" — which
6
+ * needs the project built (chant.config.ts read, source discovered and
7
+ * resolved). `chant kube` is also usable against a bare cluster with no
8
+ * chant project in sight (a checkout of someone else's manifests, a
9
+ * throwaway directory) — the acceptance criterion is that reads still work
10
+ * there and only the chant-specific parts degrade, quietly, to
11
+ * "unavailable" rather than erroring. Every failure mode here — no
12
+ * `chant.config.ts`, a project with build errors, an unreadable directory —
13
+ * collapses to `undefined` for exactly that reason.
14
+ *
15
+ * Deliberately does not import anything client-shaped: this runs before a
16
+ * cluster is ever reached (`source`/`get` need it to compute a verdict for
17
+ * objects the client already read), and matching is pure once given a live
18
+ * object's coordinates.
19
+ */
20
+ import { type ChantConfig } from "@intentius/chant/config";
21
+ import { type EntityProvenance } from "@intentius/chant/provenance";
22
+ import type { Declarable } from "@intentius/chant/declarable";
23
+ export interface KubeProjectContext {
24
+ cwd: string;
25
+ config: ChantConfig;
26
+ entities: Map<string, Declarable>;
27
+ }
28
+ /**
29
+ * Build the project rooted at `cwd` (or its configured `sourceDir`) with the
30
+ * k8s serializer, so `entities` carries resolved props (composites expanded,
31
+ * AttrRefs resolved) and build provenance (chant #1064's entity-level
32
+ * `sourceFile`/`composite`, stamped during discovery). Returns undefined —
33
+ * never throws — for anything that stops the project from resolving: no
34
+ * `chant.config.ts` here or above, a build with errors, an inaccessible
35
+ * directory. This IS the "outside a chant project" signal every caller
36
+ * checks for.
37
+ */
38
+ export declare function loadKubeProjectContext(cwd?: string): Promise<KubeProjectContext | undefined>;
39
+ export interface DeclaredMatch {
40
+ entityName: string;
41
+ entity: Declarable;
42
+ props: Record<string, unknown> | undefined;
43
+ }
44
+ /**
45
+ * Reverse-map a live object's coordinates (apiVersion/kind/name/namespace) to
46
+ * the declared k8s entity that names it, if this project declares one.
47
+ * `operationFor` is the same generated operation surface `describeResources`
48
+ * addresses entities with, so a match here is addressed exactly the way the
49
+ * live read that produced the object was — no separate naming convention.
50
+ */
51
+ export declare function findDeclaredMatch(entities: Map<string, Declarable>, ref: {
52
+ apiVersion: string;
53
+ kind: string;
54
+ name: string;
55
+ namespace?: string;
56
+ }): DeclaredMatch | undefined;
57
+ /** Provenance for a matched entity, relative to the project root when possible. */
58
+ export declare function relativeProvenance(ctx: KubeProjectContext, entity: Declarable): EntityProvenance | undefined;
59
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/kube/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAI9D,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAkBjH;AAMD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EACjC,GAAG,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1E,aAAa,GAAG,SAAS,CAY3B;AAED,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,GAAG,gBAAgB,GAAG,SAAS,CAM5G"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Output rendering for `chant kube get`/`describe` (chant #1079).
3
+ *
4
+ * kubectl's own `-o` vocabulary, minus the one form the issue says to drop
5
+ * openly rather than half-implement: `-o go-template[-file]` is Go template
6
+ * syntax, and chant does not carry a Go template engine — {@link parseOutput}
7
+ * refuses it by name rather than pretending a partial implementation covers
8
+ * it. `-o jsonpath` and `-o custom-columns` are "tractable" per the issue's
9
+ * own notes, and are implemented here as a deliberately small subset: dot
10
+ * paths, bracket indices, and a `[*]` wildcard — the paths kubectl one-liners
11
+ * actually use — not the full jsonpath grammar (filters, `range`/`end`
12
+ * templates). `-o chant` is chant's own addition: a live object rendered as
13
+ * the typed source that would declare it, reusing `./import/live-export.ts`
14
+ * and the lexicon's own `K8sGenerator` — the same machinery `chant import`
15
+ * uses, so every read is an adoption path, per the issue's framing.
16
+ */
17
+ import type { K8sObject } from "@intentius/chant-k8s-client";
18
+ import type { KubeVerdict } from "./verdict.js";
19
+ export type OutputFormat = {
20
+ kind: "text";
21
+ } | {
22
+ kind: "wide";
23
+ } | {
24
+ kind: "json";
25
+ } | {
26
+ kind: "yaml";
27
+ } | {
28
+ kind: "name";
29
+ } | {
30
+ kind: "chant";
31
+ } | {
32
+ kind: "jsonpath";
33
+ expr: string;
34
+ } | {
35
+ kind: "custom-columns";
36
+ spec: string;
37
+ };
38
+ /** Parse an `-o`/`--output` value. Throws on `go-template[-file]`. */
39
+ export declare function parseOutput(value: string | undefined): OutputFormat;
40
+ export interface KubeRow {
41
+ namespace?: string;
42
+ name: string;
43
+ kind: string;
44
+ status: string;
45
+ age?: string;
46
+ verdict?: KubeVerdict;
47
+ labels?: Record<string, string>;
48
+ object: K8sObject;
49
+ }
50
+ /** kubectl-style relative age, e.g. "45s", "12m", "3h", "5d". */
51
+ export declare function relativeAge(creationTimestamp: string | undefined, now?: number): string;
52
+ /** Render a fixed-width table. `columns` is header → per-row value. */
53
+ export declare function renderTable(headers: string[], rows: string[][]): string;
54
+ export declare function renderKubeTable(rows: KubeRow[], opts: {
55
+ allNamespaces: boolean;
56
+ wide: boolean;
57
+ showVerdict: boolean;
58
+ }): string;
59
+ export declare function renderJson(objects: readonly K8sObject[]): string;
60
+ export declare function renderYaml(objects: readonly K8sObject[]): string;
61
+ /** `kubectl get -o name`: `<lowercased-kind>.<group>/<name>` (`<lowercased-kind>/<name>` for the core group). */
62
+ export declare function renderName(objects: readonly K8sObject[]): string;
63
+ /** Render live objects as the typed chant source that would declare them. */
64
+ export declare function renderChantSource(objects: readonly K8sObject[]): string;
65
+ /**
66
+ * Evaluate a kubectl-style jsonpath template against one root value: literal
67
+ * text passes through, `{"..."}` is a quoted literal, `{.a.b[*].c}` extracts
68
+ * and space-joins matches. Multiple `{...}` blocks concatenate directly, as
69
+ * kubectl's own `-o jsonpath` does.
70
+ */
71
+ export declare function evalJsonPath(template: string, root: unknown): string;
72
+ /** `-o jsonpath=`: kubectl runs the whole template once per top-level object printed. */
73
+ export declare function renderJsonPath(expr: string, objects: readonly K8sObject[]): string;
74
+ export declare function renderCustomColumns(spec: string, objects: readonly K8sObject[]): string;
75
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/kube/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAI7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE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AC,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAShE;AAID,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAIvE;AA+CD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAkBpE;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAGlF;AAmBD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,MAAM,CAKvF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `chant kube source` (chant #1079) — resolve a live object back to the
3
+ * `.ts` file and composite that declared it, reusing the exact build
4
+ * provenance the gitlab/forgejo lexicons' own `:source` context tools already
5
+ * expose (`@intentius/chant/provenance`, stamped during discovery — chant
6
+ * #1064). That precedent is explicit that provenance here is **entity-level
7
+ * (file + composite), not a YAML-line source map** — chant does not carry
8
+ * one, for k8s or for anything else — so this verb reports the same two
9
+ * facts (never a fabricated line number) and says so plainly rather than
10
+ * silently coming up one field short of the issue's wording.
11
+ */
12
+ import { type K8sConnector } from "../api/connect.js";
13
+ import { type KubeProjectContext } from "./project.js";
14
+ export interface SourceDeps {
15
+ connect?: K8sConnector;
16
+ loadProject?: (cwd?: string) => Promise<KubeProjectContext | undefined>;
17
+ }
18
+ export declare function runSource(rawArgs: string[], deps?: SourceDeps): Promise<number>;
19
+ //# sourceMappingURL=source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/kube/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAIxE,OAAO,EAA8C,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGhG,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CACzE;AAMD,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CA6GzF"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Resolving `chant kube <verb> <target...>`'s positional arguments to an
3
+ * addressable resource (chant #1079).
4
+ *
5
+ * "Every verb resolves entity names through chant's own vocabulary where
6
+ * applicable ... while also accepting raw kind/name kubectl-style." Both
7
+ * forms share one positional shape, disambiguated by arity:
8
+ *
9
+ * - One token, and it names a declared entity in this project → chant's own
10
+ * vocabulary: the entity's `metadata.name`(/`namespace`) is looked up in
11
+ * its own source, not typed twice.
12
+ * - One or two tokens otherwise → kubectl's own shape, `<kind> [name]`; a
13
+ * bare kind with no name is a list, matching `kubectl get <kind>`.
14
+ *
15
+ * `<kind>` is never parsed here beyond splitting the `.group` suffix — that
16
+ * job belongs to the typed client's own `resolve()` (kubectl's own
17
+ * plural/singular/kind/short-name precedence, `packages/k8s-client/src/client.ts`),
18
+ * so a raw kind string reaches the cluster exactly as `kubectl get raycluster.ray.io`
19
+ * would.
20
+ */
21
+ import type { ResourceSelector } from "@intentius/chant-k8s-client";
22
+ import { type DeclaredMatch, type KubeProjectContext } from "./project.js";
23
+ export interface KubeTarget {
24
+ selector: ResourceSelector;
25
+ /** Object name. Undefined means "list every object this selector addresses". */
26
+ name?: string;
27
+ namespace?: string;
28
+ /** Set when resolution went through chant's own vocabulary rather than a kubectl kind string. */
29
+ declaredMatch?: DeclaredMatch;
30
+ }
31
+ export interface KubeTargetError {
32
+ error: string;
33
+ }
34
+ export declare function isTargetError(t: KubeTarget | KubeTargetError): t is KubeTargetError;
35
+ /**
36
+ * Resolve `positional` (whatever's left after flags) plus an explicit
37
+ * `-n/--namespace`, against `project`'s declared entities when available.
38
+ */
39
+ export declare function resolveKubeTarget(positional: readonly string[], namespaceFlag: string | undefined, project: KubeProjectContext | undefined): KubeTarget | KubeTargetError;
40
+ /**
41
+ * After a live read resolves an object's real `apiVersion`/`kind` (a kubectl
42
+ * kind string like `deploy` isn't one), reverse-map it against the project
43
+ * for the verdict column / `source` — reusing the exact match `resolveKubeTarget`
44
+ * would have made had the caller spelled out the entity name.
45
+ */
46
+ export declare function matchLiveObject(project: KubeProjectContext | undefined, ref: {
47
+ apiVersion: string;
48
+ kind: string;
49
+ name: string;
50
+ namespace?: string;
51
+ }): DeclaredMatch | undefined;
52
+ //# sourceMappingURL=target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/kube/target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAqB,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG3F,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iGAAiG;IACjG,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,GAAG,eAAe,GAAG,CAAC,IAAI,eAAe,CAEnF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,EAAE,kBAAkB,GAAG,SAAS,GACtC,UAAU,GAAG,eAAe,CAwB9B;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,GAAG,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1E,aAAa,GAAG,SAAS,CAG3B"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Test doubles for `chant kube` (chant #1079).
3
+ *
4
+ * `./project.ts`'s real `loadKubeProjectContext` builds an actual project
5
+ * (`chant.config.ts` read, source discovered, serialized) — every verb takes
6
+ * it as an injectable dependency for exactly this reason: a unit test builds
7
+ * a `KubeProjectContext` by hand instead, the same way `../api/fake-cluster.ts`
8
+ * lets a test build a client without a socket.
9
+ */
10
+ import { type Declarable } from "@intentius/chant/declarable";
11
+ import { type EntityProvenance } from "@intentius/chant/provenance";
12
+ import type { ChantConfig } from "@intentius/chant/config";
13
+ import type { KubeProjectContext } from "./project.js";
14
+ export type FakeDeclarable = Declarable & {
15
+ props: Record<string, unknown>;
16
+ };
17
+ /** A minimal `Declarable` carrying `props`, optionally stamped with build provenance. */
18
+ export declare function fakeDeclarable(entityType: string, props: Record<string, unknown>, provenance?: EntityProvenance): FakeDeclarable;
19
+ /** A `KubeProjectContext` built from a plain name → entity map, no disk I/O. */
20
+ export declare function fakeProjectContext(entities: Record<string, Declarable>, config?: ChantConfig, cwd?: string): KubeProjectContext;
21
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/kube/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAE7E,yFAAyF;AACzF,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,UAAU,CAAC,EAAE,gBAAgB,GAC5B,cAAc,CAUhB;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACpC,MAAM,GAAE,WAAgB,EACxB,GAAG,SAAa,GACf,kBAAkB,CAEpB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `chant kube top pods|nodes` (chant #1079).
3
+ *
4
+ * `metrics.k8s.io` is not part of the standard Kubernetes OpenAPI schema chant's
5
+ * codegen ingests — it is an aggregated API a cluster may or may not be running
6
+ * (metrics-server). It needs no entry in the generated operation surface either
7
+ * way: the typed client's kubectl-style selector (`{ resource, group }`) resolves
8
+ * purely off the *cluster's own* discovery, the same path `waitForReady`'s `kind`
9
+ * argument already uses for CRDs — so this needs no client change, only the
10
+ * right selector.
11
+ *
12
+ * Kubectl's own `top` sums each Pod's per-container usage into one CPU/memory
13
+ * figure, which needs real quantity-unit arithmetic (`250m` + `100m`, `128Mi` +
14
+ * `64Mi`). That normalization is not implemented here — each container's raw
15
+ * usage string is shown as the API reported it, unsummed. Good enough for "is
16
+ * anything obviously starved", not a replacement for `kubectl top --containers`.
17
+ */
18
+ import { type K8sConnector } from "../api/connect.js";
19
+ export interface TopDeps {
20
+ connect?: K8sConnector;
21
+ }
22
+ export declare function runTop(rawArgs: string[], deps?: TopDeps): Promise<number>;
23
+ //# sourceMappingURL=top.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"top.d.ts","sourceRoot":"","sources":["../../src/kube/top.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMxE,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAWD,wBAAsB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,OAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAiFnF"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The chant verdict column `chant kube get` carries on every row (chant
3
+ * #1079's acceptance criterion: "get annotates each row with the declared /
4
+ * owned / drifted / foreign-owned verdict").
5
+ *
6
+ * Four states:
7
+ *
8
+ * - `declared` — this project's source names an entity at this exact
9
+ * apiVersion/kind/name(/namespace), and the live object agrees with it on
10
+ * every field the source declares.
11
+ * - `drifted` — same match, but the live object disagrees with the source on
12
+ * at least one declared field.
13
+ * - `owned` — no declared match, but the live object carries chant's
14
+ * ownership marker (`app.kubernetes.io/managed-by=chant`) — something
15
+ * chant applied that source no longer declares, or a stack/entity this
16
+ * project's build didn't resolve.
17
+ * - `foreign-owned` — no declared match and no marker: chant does not
18
+ * consider this object its own.
19
+ *
20
+ * `unavailable` is not a verdict about the object; it is what every row gets
21
+ * when the project context could not be loaded at all (chant #1079's
22
+ * "degrades gracefully outside a chant project" — `get` and `describe` still
23
+ * work, this column just has nothing to say).
24
+ *
25
+ * The drift check here is a fast, best-effort *declared-subset* comparison —
26
+ * every path the source sets must agree on the live object — not the
27
+ * managed-fields-precise diff `chant lifecycle diff --live --deep` computes
28
+ * (chant #1076). It exists for a table column that must render for dozens of
29
+ * rows in one `get` call; the deep, field-ownership-aware answer stays the
30
+ * lifecycle command's job. A live object can disagree with the source on a
31
+ * field a controller owns (Kubernetes rewriting `spec.replicas` under an
32
+ * HPA, say) and still show `drifted` here — reach for the deep diff before
33
+ * treating this column as a verdict rather than a hint.
34
+ */
35
+ import type { K8sObject } from "@intentius/chant-k8s-client";
36
+ import type { DeclaredMatch } from "./project.js";
37
+ export type KubeVerdict = "declared" | "owned" | "drifted" | "foreign-owned" | "unavailable";
38
+ /**
39
+ * True when every path `declared` sets is present and equal on `live`.
40
+ * Extra fields on `live` (server defaults, status, anything the source never
41
+ * mentions) are not drift — chant never declared an opinion about them.
42
+ */
43
+ export declare function declaredSubsetMatches(declared: unknown, live: unknown): boolean;
44
+ export declare function verdictFor(live: K8sObject, match: DeclaredMatch | undefined): KubeVerdict;
45
+ //# sourceMappingURL=verdict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../src/kube/verdict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,eAAe,GAAG,aAAa,CAAC;AAM7F;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAU/E;AAWD,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,WAAW,CAKzF"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `chant kube wait` (chant #1079) — the issue names this one explicitly:
3
+ * "`wait` should use the existing readiness-spec registry in
4
+ * `op/activities/wait-for-ready.ts`, which already handles the Argo case
5
+ * where health and sync replace a `Ready` condition — something `kubectl
6
+ * wait --for` cannot express without jsonpath gymnastics." This verb is a
7
+ * thin CLI shell around that exact registry (`readinessFor`/`isReady`/
8
+ * `firstTerminal`/`waitForReady`) — not a second implementation of it.
9
+ *
10
+ * `--for=condition=<Type>[=<Status>]` overrides the registry with a single
11
+ * condition check, matching kubectl's own flag. `--for=delete` polls for
12
+ * absence instead. Neither given falls back to the registry: the generic
13
+ * `Ready` condition, or a resource-specific override (Argo's `Application`
14
+ * today).
15
+ */
16
+ import { type K8sConnector } from "../api/connect.js";
17
+ import { type KubeProjectContext } from "./project.js";
18
+ export interface WaitDeps {
19
+ connect?: K8sConnector;
20
+ loadProject?: (cwd?: string) => Promise<KubeProjectContext | undefined>;
21
+ }
22
+ export declare function runWait(rawArgs: string[], deps?: WaitDeps): Promise<number>;
23
+ //# sourceMappingURL=wait.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait.d.ts","sourceRoot":"","sources":["../../src/kube/wait.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAWxE,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG5E,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CACzE;AAkBD,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,QAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA6FrF"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k8s",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "K8s",
6
6
  "intrinsics": [],
@@ -2,7 +2,10 @@
2
2
  * k8s Op activities — resolved by the core activity registry when a project's
3
3
  * `chant.config.ts` lists the `k8s` lexicon. Relocated from the temporal lexicon
4
4
  * (#809) so Kubernetes-facing imperative activities live with their product:
5
- * - kubectlApply — `kubectl apply` a rendered manifest
5
+ * - kubectlApply — server-side apply a rendered manifest (and, since chant
6
+ * #1075, prune chant-owned objects it no longer declares; `applyManifest`
7
+ * is the same work with a report of what it did, which is what the
8
+ * Temporal lexicon's `nativeApply` dispatcher calls for a kubectl target)
6
9
  * - k3dUp / k3dDown — boot/tear down a local k3d cluster
7
10
  * - waitForArgoSync — block until an Argo CD Application is Healthy && Synced
8
11
  *
@@ -11,8 +14,8 @@
11
14
  * dependency-light — it shells out to a CLI and does not import the k8s declarable
12
15
  * surface — so a Temporal worker loads it cheaply.
13
16
  */
14
- export { kubectlApply, readManifestDocuments } from "./kubectl.js";
15
- export type { KubectlApplyArgs } from "./kubectl.js";
17
+ export { kubectlApply, applyManifest, readManifestDocuments } from "./kubectl.js";
18
+ export type { KubectlApplyArgs, ApplyManifestResult, AppliedRef, ApplyDeleteMode } from "./kubectl.js";
16
19
  export { k3dUp, k3dDown, k3dUpCommand, k3dDownCommand, k3dExistsCommand } from "./k3d.js";
17
20
  export type { K3dUpArgs, K3dDownArgs } from "./k3d.js";
18
21
  export { waitForArgoSync, defaultArgoStatusFetcher, ArgoSyncFailedError } from "./argo.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACvF,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AACxF,YAAY,EAAE,mBAAmB,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EAChB,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,SAAS,GACV,MAAM,kBAAkB,CAAC;AAW1B,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACrG,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
@@ -7,20 +7,37 @@
7
7
  * that signature; what changed is underneath. The name is kept for the same
8
8
  * reason.
9
9
  *
10
+ * chant #1075 finished the job on two axes:
11
+ *
12
+ * - **Identity.** The field manager is no longer the bare `chant` but
13
+ * `chant:<stack>`, derived from the project's `ownership.stack` — the same
14
+ * identity the ownership label already carries. See
15
+ * `@intentius/chant-k8s-client`'s `field-manager.ts`.
16
+ * - **Deletes.** `nativeApply`'s kubectl branch used to shell
17
+ * `kubectl apply --prune --selector <marker>`; that branch now routes here,
18
+ * so the prune had to come with it. {@link applyManifest} implements it
19
+ * against the typed client, scoped to the ownership marker exactly as the
20
+ * shelled prune was, and never touching an object that does not carry it.
21
+ *
10
22
  * Consequences worth knowing:
11
23
  *
12
24
  * - **A worker image needs no `kubectl` binary.** That was the point.
13
- * - **It is a server-side apply**, with `chant` as the field manager, rather
14
- * than the client-side three-way merge `kubectl apply` performs by default.
15
- * Server-side apply is the direction Kubernetes itself has taken, it removes
16
- * the `last-applied-configuration` annotation from the story, and it is what
17
- * chant #1075 builds the field-ownership and conflict surface on. A conflict
18
- * with another field manager arrives here as a typed 409 rather than a line
19
- * of stderr; #1075 is where it gets a proper presentation.
25
+ * - **It is a server-side apply**, rather than the client-side three-way merge
26
+ * `kubectl apply` performs by default. A conflict with another field manager
27
+ * arrives as a `FieldManagerConflictError` naming the competing manager and
28
+ * the contested paths never as a silent overwrite, and never force-resolved
29
+ * on chant's initiative.
20
30
  * - **Documents apply in file order**, as `kubectl apply -f` does, and a
21
31
  * directory's files are read in sorted order.
22
32
  */
23
33
  import { type K8sConnector } from "../../api/connect.js";
34
+ /**
35
+ * How the apply treats chant-owned objects that are no longer declared. The
36
+ * same three values `nativeApply` has always taken; `gated` differs from
37
+ * `owned-only` only in that the workflow pauses for approval first, which is
38
+ * the composite's business, not this activity's.
39
+ */
40
+ export type ApplyDeleteMode = "never" | "owned-only" | "gated";
24
41
  export interface KubectlApplyArgs {
25
42
  /** Path to a manifest file, or a directory of them. */
26
43
  manifest: string;
@@ -37,13 +54,78 @@ export interface KubectlApplyArgs {
37
54
  * the previous behavior of using whatever the kubeconfig selects.
38
55
  */
39
56
  environment?: string;
40
- /** Field manager recorded on the applied objects. Default `chant`. */
57
+ /**
58
+ * Field manager recorded on the applied fields. Omitted derives it from the
59
+ * project's `ownership.stack` (chant #1075) — `chant:<stack>`, or the bare
60
+ * `chant` when the project sets none.
61
+ */
41
62
  fieldManager?: string;
42
- /** Take ownership of fields another manager owns instead of failing (chant #1075). */
63
+ /**
64
+ * Ownership stack, when the caller already knows it and would rather not
65
+ * have the project config read. Ignored if `fieldManager` is set.
66
+ */
67
+ stack?: string;
68
+ /**
69
+ * Take ownership of fields another manager owns instead of failing with a
70
+ * `FieldManagerConflictError`. **Never defaulted on** — see chant #1075.
71
+ */
43
72
  force?: boolean;
73
+ /**
74
+ * Delete chant-owned objects that are no longer declared. Default `never`.
75
+ * Deletes are scoped to the ownership marker, so an object chant did not
76
+ * stamp is never a candidate.
77
+ */
78
+ deleteMode?: ApplyDeleteMode;
79
+ /**
80
+ * Server-side dry run — every document is validated and would-be-applied,
81
+ * nothing is persisted, and pruning is skipped entirely (a prune candidate
82
+ * list computed from a state that was never written would be misleading).
83
+ * Optional and additive (chant #1079): `chant kube apply`'s confirmation
84
+ * gate uses this to preview an apply before anything mutates the cluster;
85
+ * Op callers keep the previous behavior by leaving it unset.
86
+ */
87
+ dryRun?: boolean;
88
+ /** Project directory whose `chant.config.ts` carries `ownership`. Defaults to cwd. */
89
+ cwd?: string;
90
+ }
91
+ /** One object the apply touched. */
92
+ export interface AppliedRef {
93
+ apiVersion: string;
94
+ kind: string;
95
+ name: string;
96
+ namespace?: string;
97
+ }
98
+ /** What {@link applyManifest} did. */
99
+ export interface ApplyManifestResult {
100
+ /** The field manager every object was applied as. */
101
+ fieldManager: string;
102
+ applied: AppliedRef[];
103
+ /** Objects deleted because they carried chant's marker and are no longer declared. */
104
+ pruned: AppliedRef[];
44
105
  }
45
106
  /** Read a manifest path — one file, or every YAML/JSON file in a directory. */
46
107
  export declare function readManifestDocuments(path: string): Record<string, unknown>[];
108
+ /**
109
+ * The field manager to apply as: an explicit one, else `chant:<stack>` from a
110
+ * caller-supplied stack, else `chant:<stack>` from the project's `ownership`
111
+ * config, else the bare `chant`.
112
+ *
113
+ * A project config that cannot be read falls back to the bare `chant` with a
114
+ * warning rather than failing the apply — an activity handed a manifest path
115
+ * and nothing else is a supported way to call this, and its cwd need not be a
116
+ * chant project at all. The warning is there because a *silent* downgrade
117
+ * would change which fields chant owns without saying so.
118
+ */
119
+ export declare function resolveFieldManager(args: KubectlApplyArgs): Promise<string>;
120
+ /**
121
+ * Apply every document in `args.manifest`, then prune when asked.
122
+ *
123
+ * Returns what it did. `kubectlApply` is the registered activity and keeps its
124
+ * `Promise<void>` contract; this is the function `nativeApply` calls, because a
125
+ * dispatcher that reports "applied 12, pruned 2" is worth more than one that
126
+ * reports the shell command it ran.
127
+ */
128
+ export declare function applyManifest(args: KubectlApplyArgs, signal?: AbortSignal, connect?: K8sConnector): Promise<ApplyManifestResult>;
47
129
  /**
48
130
  * Apply every document in `args.manifest`.
49
131
  * Uses longInfra profile — 20m timeout, heartbeat every 15s.
@@ -1 +1 @@
1
- {"version":3,"file":"kubectl.d.ts","sourceRoot":"","sources":["../../../src/op/activities/kubectl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;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AC;CACd;AAED,oCAAoC;AACpC,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,sFAAsF;IACtF,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiB7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEjF;AAoCD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,gBAAgB,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,GAAE,YAAkC,GAC1C,OAAO,CAAC,mBAAmB,CAAC,CAoD9B;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,gBAAgB,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,GAAE,YAAkC,GAC1C,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,0BAA0B,CAAC;AAmBjG,eAAO,MAAM,SAAS,EAAE,aAilBvB,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAqC,MAAM,0BAA0B,CAAC;AAsBjG,eAAO,MAAM,SAAS,EAAE,aA2mBvB,CAAC"}