@intentic/need-resolver 1.18.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Artur Kurowski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @intentic/need-resolver
2
+
3
+ The **need resolver**: turns an authored `IntentSet` into the abstract capabilities it requires. It owns the authored intent shapes and the intent → needs derivation — the first stage of the pipeline. Depends only on [`@intentic/graph`](../graph); consumed by [`@intentic/state-resolver`](../state-resolver) and [`@intentic/sdk`](../sdk).
4
+
5
+ ## Responsibilities
6
+
7
+ - Define the authored intent shapes (`IntentSet`, `HostIntent`, `CloudflareIntent`, `AppIntent`, …) and their input types.
8
+ - Derive the abstract `Need`s an intent implies — `source-control`, `docker-registry`, `infra-control`, `deployment-target`, `domain` — each a `Capability` on a `Plane` (control vs application).
9
+ - It stops at *abstract capabilities*: it does **not** choose concrete options (Forgejo/Komodo/etc.) or emit graph nodes — that is `state-resolver`'s job.
10
+
11
+ ## Key files
12
+
13
+ - [src/intent.ts](src/intent.ts) — the authored intent types (`IntentSet` and friends).
14
+ - [src/inputs.ts](src/inputs.ts) — input shapes (`HostInput`, `CloudflareInput`, `EnvironmentInput`, `NotifyInput`, …).
15
+ - [src/needs.ts](src/needs.ts) — `resolveNeeds`, `Capability`/`Need`/`Plane`, `needKey`.
16
+ - [src/index.ts](src/index.ts) — public surface.
17
+
18
+ ## How it fits
19
+
20
+ Stage 1 of intent → needs → desired-state. The `sdk` builds an `IntentSet` from a `deploy.config.ts`; `resolveNeeds` turns it into `Need`s; `state-resolver` assigns each need a catalog option and emits nodes.
21
+
22
+ ## Conventions & gotchas
23
+
24
+ - Needs are intentionally provider-agnostic — keep concrete tech names out of this layer.
25
+ - Each need carries its `Plane`; downstream resolution and ordering rely on it. Co-located tests in [src/needs.test.ts](src/needs.test.ts). See [ARCHITECTURE.md](../../ARCHITECTURE.md).
@@ -0,0 +1,5 @@
1
+ export type { AppTeamGrantInput, BackupInput, BackupRetention, CloudflareInput, DiscordInput, EnvironmentInput, ForgejoRole, GitHubInput, HostInput, KomodoRole, ServiceInput, ServiceKind, TeamInput, UpdatePolicy, UserInput, } from "./inputs.js";
2
+ export type { AppBindingInput, AppIntent, BackingCapability, BackingIntent, BackupIntent, CloudflareIntent, DiscordIntent, GitHubIntent, HostIntent, IntentSet, ServiceIntent, TeamIntent, UserIntent, WorkspaceIntent, } from "./intent.js";
3
+ export type { Capability, Need, Plane } from "./needs.js";
4
+ export { controlPlaneHostId, needKey, resolveNeeds } from "./needs.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EACR,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,UAAU,EACV,eAAe,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { controlPlaneHostId, needKey, resolveNeeds } from "./needs.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { Input, Readiness, SecretRef } from "@intentic/graph";
2
+ export type UpdatePolicy = "pinned" | "guarded";
3
+ export interface HostInput {
4
+ address: string;
5
+ user: string;
6
+ sshKey: SecretRef;
7
+ port?: number;
8
+ updatePolicy?: UpdatePolicy;
9
+ }
10
+ export interface CloudflareInput {
11
+ apiToken: SecretRef;
12
+ }
13
+ export interface GitHubInput {
14
+ token: SecretRef;
15
+ owner?: string;
16
+ }
17
+ export interface EnvironmentInput {
18
+ domain: string;
19
+ branch: string;
20
+ env?: Record<string, Input<string>>;
21
+ readyWhen?: Readiness;
22
+ }
23
+ export interface DiscordInput {
24
+ botToken: SecretRef;
25
+ }
26
+ export interface BackupRetention {
27
+ daily?: number;
28
+ weekly?: number;
29
+ monthly?: number;
30
+ }
31
+ export interface BackupInput {
32
+ repo: string;
33
+ password: SecretRef;
34
+ credentials?: Record<string, SecretRef>;
35
+ schedule?: string;
36
+ retention?: BackupRetention;
37
+ signoz?: boolean;
38
+ }
39
+ export type ServiceKind = "signoz";
40
+ export interface ServiceInput {
41
+ kind: ServiceKind;
42
+ domain: string;
43
+ }
44
+ export interface UserInput {
45
+ username: string;
46
+ email: string;
47
+ }
48
+ export type ForgejoRole = "admin" | "write" | "read";
49
+ export type KomodoRole = "admin" | "execute" | "read";
50
+ export interface TeamInput {
51
+ members: readonly string[];
52
+ komodo: KomodoRole;
53
+ }
54
+ export interface AppTeamGrantInput {
55
+ team: string;
56
+ role: ForgejoRole;
57
+ }
58
+ //# sourceMappingURL=inputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AASnE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAIhD,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAKD,MAAM,WAAW,eAAe;IAC5B,QAAQ,EAAE,SAAS,CAAC;CACvB;AAID,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,SAAS,CAAC;CACzB;AAKD,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAID,MAAM,WAAW,eAAe;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAKD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;AAEnC,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB;AAID,MAAM,WAAW,SAAS;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACjB;AAKD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AACrD,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtD,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,UAAU,CAAC;CACtB;AAID,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACrB"}
package/dist/inputs.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputs.js","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ import type { AppTeamGrantInput, BackupInput, CloudflareInput, DiscordInput, EnvironmentInput, GitHubInput, HostInput, ServiceInput, TeamInput, UserInput } from "./inputs.js";
2
+ export interface HostIntent {
3
+ readonly id: string;
4
+ readonly input: HostInput;
5
+ }
6
+ export interface CloudflareIntent {
7
+ readonly id: string;
8
+ readonly input: CloudflareInput;
9
+ }
10
+ export interface BackupIntent {
11
+ readonly id: string;
12
+ readonly input: BackupInput;
13
+ }
14
+ export interface GitHubIntent {
15
+ readonly id: string;
16
+ readonly input: GitHubInput;
17
+ }
18
+ export interface DiscordIntent {
19
+ readonly id: string;
20
+ readonly input: DiscordInput;
21
+ }
22
+ export interface UserIntent {
23
+ readonly id: string;
24
+ readonly input: UserInput;
25
+ }
26
+ export interface TeamIntent {
27
+ readonly id: string;
28
+ readonly input: TeamInput;
29
+ }
30
+ export type BackingCapability = "database" | "cache" | "auth" | "object-storage";
31
+ export interface BackingIntent {
32
+ readonly id: string;
33
+ readonly capability: BackingCapability;
34
+ readonly on: string;
35
+ readonly expose?: string;
36
+ readonly domain?: string;
37
+ }
38
+ export interface AppBindingInput {
39
+ readonly capability: BackingCapability;
40
+ readonly target: string;
41
+ }
42
+ export interface AppIntent {
43
+ readonly id: string;
44
+ readonly on: string;
45
+ readonly expose: string;
46
+ readonly notify?: string;
47
+ readonly observe?: string;
48
+ readonly use?: readonly AppBindingInput[];
49
+ readonly teams?: readonly AppTeamGrantInput[];
50
+ readonly environments: Readonly<Record<string, EnvironmentInput>>;
51
+ }
52
+ export interface ServiceIntent extends ServiceInput {
53
+ readonly id: string;
54
+ readonly on: string;
55
+ readonly expose: string;
56
+ }
57
+ export interface WorkspaceIntent {
58
+ readonly id: string;
59
+ readonly on: string;
60
+ readonly expose: string;
61
+ readonly platformUrl?: string;
62
+ readonly agentBaseUrl?: string;
63
+ }
64
+ export interface IntentSet {
65
+ readonly hosts: readonly HostIntent[];
66
+ readonly cloudflare?: CloudflareIntent;
67
+ readonly github?: GitHubIntent;
68
+ readonly discord?: DiscordIntent;
69
+ readonly backup?: BackupIntent;
70
+ readonly users: readonly UserIntent[];
71
+ readonly teams: readonly TeamIntent[];
72
+ readonly apps: readonly AppIntent[];
73
+ readonly services: readonly ServiceIntent[];
74
+ readonly workspaces: readonly WorkspaceIntent[];
75
+ readonly backings: readonly BackingIntent[];
76
+ }
77
+ //# sourceMappingURL=intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../src/intent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,SAAS,EACT,SAAS,EACZ,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;CACnC;AAID,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC7B;AAED,MAAM,WAA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KD,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAGxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAG9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAClC;AAKD,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C"}
package/dist/intent.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.js","sourceRoot":"","sources":["../src/intent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { IntentSet } from "./intent.js";
2
+ export type Capability = "source-control" | "docker-registry" | "infra-control" | "deployment-target" | "domain";
3
+ export type Plane = "control" | "application";
4
+ export interface Need {
5
+ readonly capability: Capability;
6
+ readonly scope: string;
7
+ readonly plane: Plane;
8
+ }
9
+ export declare const controlPlaneHostId: (intent: IntentSet) => string | undefined;
10
+ export declare const resolveNeeds: (intent: IntentSet) => Need[];
11
+ export declare const needKey: (need: Need) => string;
12
+ //# sourceMappingURL=needs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"needs.d.ts","sourceRoot":"","sources":["../src/needs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,GAAG,mBAAmB,GAAG,QAAQ,CAAC;AAIjH,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,aAAa,CAAC;AAM9C,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACzB;AAgBD,eAAO,MAAM,kBAAkB,GAAI,QAAQ,SAAS,KAAG,MAAM,GAAG,SAC6B,CAAC;AAK9F,eAAO,MAAM,YAAY,GAAI,QAAQ,SAAS,KAAG,IAAI,EA+BpD,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,MAAM,IAAI,KAAG,MAA4C,CAAC"}
package/dist/needs.js ADDED
@@ -0,0 +1,42 @@
1
+ const planeOf = {
2
+ "source-control": "control",
3
+ "docker-registry": "control",
4
+ "infra-control": "control",
5
+ "deployment-target": "application",
6
+ domain: "application",
7
+ };
8
+ const controlPlaneCapabilities = ["source-control", "docker-registry", "infra-control"];
9
+ export const controlPlaneHostId = (intent) => (intent.hosts.find((h) => intent.apps.some((a) => a.on === h.id)) ?? intent.hosts[0])?.id;
10
+ export const resolveNeeds = (intent) => {
11
+ if (intent.apps.length === 0 && intent.services.length === 0 && intent.workspaces.length === 0 && intent.backings.length === 0) {
12
+ return [];
13
+ }
14
+ const cloudflare = intent.cloudflare;
15
+ if (cloudflare === undefined) {
16
+ throw new Error("intent declares apps/services/workspaces/backings but no Cloudflare; declare it with i.have.cloudflare");
17
+ }
18
+ const declaredHosts = new Set(intent.hosts.map((h) => h.id));
19
+ const activeHostIds = new Set([
20
+ ...intent.apps.map((a) => a.on),
21
+ ...intent.services.map((s) => s.on),
22
+ ...intent.workspaces.map((w) => w.on),
23
+ ...intent.backings.map((b) => b.on),
24
+ ]);
25
+ for (const hostId of activeHostIds) {
26
+ if (!declaredHosts.has(hostId)) {
27
+ throw new Error(`app/service/workspace/backing targets undeclared host "${hostId}"; declare it with i.have.host`);
28
+ }
29
+ }
30
+ const cpHost = controlPlaneHostId(intent);
31
+ if (cpHost === undefined) {
32
+ throw new Error("intent declares apps/services/backings but no host; declare one with i.have.host");
33
+ }
34
+ const needs = controlPlaneCapabilities.map((capability) => ({ capability, scope: cpHost, plane: planeOf[capability] }));
35
+ for (const hostId of activeHostIds) {
36
+ needs.push({ capability: "deployment-target", scope: hostId, plane: planeOf["deployment-target"] });
37
+ }
38
+ needs.push({ capability: "domain", scope: cloudflare.id, plane: planeOf.domain });
39
+ return needs;
40
+ };
41
+ export const needKey = (need) => `${need.capability}:${need.scope}`;
42
+ //# sourceMappingURL=needs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"needs.js","sourceRoot":"","sources":["../src/needs.ts"],"names":[],"mappings":"AAoBA,MAAM,OAAO,GAAwC;IACjD,gBAAgB,EAAE,SAAS;IAC3B,iBAAiB,EAAE,SAAS;IAC5B,eAAe,EAAE,SAAS;IAC1B,mBAAmB,EAAE,aAAa;IAClC,MAAM,EAAE,aAAa;CACxB,CAAC;AAIF,MAAM,wBAAwB,GAA0B,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;AAI/G,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAiB,EAAsB,EAAE,CACxE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,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": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/radarsu/intentic.git",
10
+ "directory": "_libs/need-resolver"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "registry": "https://registry.npmjs.org/"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": {
23
+ "@intentic/src": "./src/index.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "require": {
27
+ "@intentic/src": "./src/index.ts",
28
+ "default": "./dist/index.js"
29
+ }
30
+ }
31
+ },
32
+ "dependencies": {
33
+ "tslib": "2.8.1",
34
+ "@intentic/graph": "1.18.0"
35
+ },
36
+ "devDependencies": {
37
+ "typescript": "5.9.3",
38
+ "vitest": "4.1.9",
39
+ "@intentic/tsconfig": "0.0.0"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc",
43
+ "watch": "tsc --build --watch",
44
+ "test": "vitest run",
45
+ "test:watch": "vitest"
46
+ }
47
+ }