@hitch42/applet 0.1.1-beta.6 → 0.1.1-beta.8
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/dist/_internal/server.d.ts +14 -1
- package/dist/_internal/server.js +23 -74
- package/dist/applet.js +50 -29
- package/dist/build-CFCKKMn7.js +2 -0
- package/dist/{build-DIsKQQT0.js → build-DANx9Hgg.js} +28 -13
- package/dist/{ci-D0nC_Ho7.js → ci-5qWl7lT3.js} +20 -4
- package/dist/client.d.ts +2 -2
- package/dist/{contract-DMrpbaLJ.d.ts → contract-rP_eV9PK.d.ts} +1 -1
- package/dist/{deploy-0dlUvCt3.js → deploy-MQWLG2EA.js} +130 -15
- package/dist/email-DBTVhNB_.js +62 -0
- package/dist/{generate-C6eAL5eo.js → generate-BxYHdoAQ.js} +18 -17
- package/dist/generate-CQ07Hdpo.js +2 -0
- package/dist/index.d.ts +115 -4
- package/dist/index.js +141 -26
- package/dist/{init-tEMeys9M.js → init-jDEgYIXg.js} +5 -5
- package/dist/load-config-BYSxDVAl.js +27 -0
- package/dist/login-C7RKmmTe.js +12 -0
- package/dist/{logs-m00pzr_O.js → logs-DgjgAxj2.js} +3 -3
- package/dist/{manifest-DyoJ1MIL.js → manifest-Bp87Uz0a.js} +6 -0
- package/dist/{manifest-BQCAxATS.d.ts → manifest-DD_SGkS6.d.ts} +5 -0
- package/dist/me-BW7Paary.js +32 -0
- package/dist/{project-mW0vsN8A.js → project-CbYPtpPq.js} +16 -14
- package/dist/prompt-ChS-grYO.js +29 -0
- package/dist/schedules-dhU1yyFr.js +42 -0
- package/dist/server.d.ts +2 -2
- package/dist/telephony-protocol-DRgiYjqQ.d.ts +74 -0
- package/dist/telephony.d.ts +77 -0
- package/dist/telephony.js +607 -0
- package/dist/{variables-CP7Ce3Np.js → variables-Bwnr7oxf.js} +3 -28
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +458 -27
- package/dist/workflow-engine-MogejNfF.js +117 -0
- package/dist/{auth-DaVK0k5R.js → workspace-XVtM12ZC.js} +44 -4
- package/package.json +6 -1
- package/scaffold/.agents/skills/hitch-applets/SKILL.md +32 -16
- package/scaffold/.agents/skills/hitch-applets/references/email-tracking.md +49 -0
- package/scaffold/.agents/skills/hitch-applets/references/files.md +3 -3
- package/scaffold/.agents/skills/hitch-applets/references/manifest.md +21 -2
- package/scaffold/.agents/skills/hitch-applets/references/performance.md +1 -1
- package/scaffold/.agents/skills/hitch-applets/references/records.md +4 -3
- package/scaffold/.agents/skills/hitch-applets/references/schedules.md +7 -2
- package/scaffold/.agents/skills/hitch-applets/references/server.md +0 -3
- package/scaffold/.agents/skills/hitch-applets/references/workflows.md +11 -3
- package/scaffold/.agents/skills/hitch-cli/SKILL.md +24 -22
- package/scaffold/.agents/skills/hitch-data/SKILL.md +2 -2
- package/scaffold/.agents/skills/hitch-data/references/limits.md +10 -10
- package/scaffold/.agents/skills/hitch-theory/SKILL.md +150 -0
- package/scaffold/.github/workflows/hitch.yml +0 -6
- package/dist/build-B70gkDi5.js +0 -2
- package/dist/generate-D5rSXXa-.js +0 -2
- package/dist/load-config-BnxocLAQ.js +0 -56
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hitch-theory
|
|
3
|
+
description: The mental model of Hitch. Read before you design, review, or explain anything that touches Hitch data, applets, access, or query cost. Use when a decision depends on what Hitch is for, what Hitch handles versus what an applet handles, how attributes and references model data, how changesets and releases move together, or who a call acts as. Pairs with hitch-applets, which holds the build procedure.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Theory of Hitch
|
|
7
|
+
|
|
8
|
+
This skill explains how Hitch works and why. For the build procedure, read the `hitch-applets` skill.
|
|
9
|
+
|
|
10
|
+
## 1. What Hitch is
|
|
11
|
+
|
|
12
|
+
Hitch is a platform for internal applications. It is not a CRM, a rostering product, a reporting product, or any other vertical. An organization builds its own rostering, job, or invoice applets on Hitch.
|
|
13
|
+
|
|
14
|
+
Hitch is two layers:
|
|
15
|
+
|
|
16
|
+
1. A durable data system that the organization owns: objects, attributes, records, files, identity, and grants.
|
|
17
|
+
2. A governed runtime for replaceable software: applets that Hitch builds, releases, hosts, and runs.
|
|
18
|
+
|
|
19
|
+
## 2. What an applet is
|
|
20
|
+
|
|
21
|
+
An applet is not an app. An app is the whole machine from the old days of software: its own authentication, its own database, its own permissions, a frontend, a server, caches, a deployment pipeline, and monitoring. Every app rebuilds that machine from scratch. Every app then spends most of its life on the machine, not on the work. The organization never wanted the machine. It wanted the business logic.
|
|
22
|
+
|
|
23
|
+
AI has changed the economics of software. Code is now cheap to write and cheap to change, so software can be personal to one organization, one team, and one workflow. Hitch is built for that world. Hitch flips the model. Instead of one monolithic app designed to serve many unrelated users, an organization gets a set of many applets, completely custom and personalised to its needs. An applet is the closest thing to pure business logic: one workflow, the screens it needs, and the rules that make it correct. Hitch handles everything underneath: the data and its schema, identity, permissions, files, immutable releases, hosting, schedules, and durable workflows. The author never touches the machine. The author builds only what matters to the user.
|
|
24
|
+
|
|
25
|
+
Hitch takes the machine away for correctness and trust as much as for speed. Authentication, access control, schema validation, and release safety are the parts an agent gets wrong, and the parts an organization cannot afford to have wrong. Hitch handles them, so your organisation has the confidence it needs to fully adopt vibe coded software and move off of legacy SaaS systems.
|
|
26
|
+
|
|
27
|
+
In practice an applet is a client-only, server-only, or full-stack application that Hitch builds, releases, hosts, and runs inside the platform trust boundary. It is not a third-party plugin.
|
|
28
|
+
|
|
29
|
+
Every organization has its own tenant on Hitch. Its data, its users, its grants, and its applets all live there. When Hitch runs an applet, it runs it inside that tenant, the way AWS runs a workload inside a customer's account: the provider operates the infrastructure, but the account, the identities, and the data are the customer's. An applet sees its organization's tenant and nothing else.
|
|
30
|
+
|
|
31
|
+
Applets can be used standalone via their `.app` URL or within the Hitch shell. Standalone and embedded operation use the same identity, release, routes, and theme.
|
|
32
|
+
|
|
33
|
+
## 3. What Hitch handles and what an applet handles
|
|
34
|
+
|
|
35
|
+
| Hitch handles | The applet handles |
|
|
36
|
+
| --------------------------------------------------------------- | --------------------------------------------- |
|
|
37
|
+
| Canonical organization records and files | One focused workflow and its presentation |
|
|
38
|
+
| Object and attribute schema, and references | Domain-specific UI composition |
|
|
39
|
+
| Validation, normalization, constraints, versions, audit | External API adapters and translation |
|
|
40
|
+
| Organization identity, authentication, grants | User interactions and app-specific validation |
|
|
41
|
+
| Immutable releases, schedules, the workflow engine, the runtime | Derived views and deliberate derived records |
|
|
42
|
+
| Theme delivery and platform navigation | Ephemeral client state |
|
|
43
|
+
|
|
44
|
+
## 4. Why code and data are separate
|
|
45
|
+
|
|
46
|
+
The organization's Hitch data is the single source of truth. An applet reads and writes that data. It does not keep its own copy.
|
|
47
|
+
|
|
48
|
+
The data layer stands on its own so that every way of using it is a client of the same thing. An applet, the `hitch` command line, an MCP server for an AI agent, an API key in a script, and an import all speak to the same objects, the same schema, and the same permissions. None of them is a bridge bolted on later. Each one is generated from the organization's own schema, so it knows the organization's objects by name. Each one acts as the person or applet behind it, so it sees exactly what that caller may see. The result is that a person in a browser, an agent in a chat window, and a script in a terminal all work on the same records under the same rules, and each gets the interface that suits them. Software stops being one product with one screen and becomes your organizational data with many doors.
|
|
49
|
+
|
|
50
|
+
The boundary gives you:
|
|
51
|
+
|
|
52
|
+
- One source of truth that many applets share.
|
|
53
|
+
- One set of schema and integrity rules for every writer: applets, API keys, imports, and future code.
|
|
54
|
+
- Central permissions that applet UI code cannot weaken.
|
|
55
|
+
- Independent applet release and rollback with no data fork.
|
|
56
|
+
- Direct user-scoped reads from the browser, with no applet server proxy.
|
|
57
|
+
- One place for integrations: sync an external system into Hitch once, then let other applets use the same data.
|
|
58
|
+
|
|
59
|
+
Consequences:
|
|
60
|
+
|
|
61
|
+
- Do not add an applet-owned database, a parallel cache, or a copied object set. If an applet seems to need its own storage, Hitch has a gap. Raise the gap instead.
|
|
62
|
+
- Code rollback is not data recovery. A release switch never moves or restores records.
|
|
63
|
+
- When you install, upgrade, or remove an applet, the canonical data stays where it is.
|
|
64
|
+
- A domain rule can live in applet code when it controls one workflow. If the rule must hold for every writer, express it in the schema, so Hitch enforces it for every applet, API key, and import.
|
|
65
|
+
- Data normalization and UI hierarchy are separate decisions. Model distinct concepts as objects plus references when their lifecycle or permissions differ. Group them on one screen when that matches the user. Do not invent child objects to solve navigation.
|
|
66
|
+
|
|
67
|
+
## 5. Attributes are schema
|
|
68
|
+
|
|
69
|
+
An attribute is schema, not a free JSON field. Hitch validates each value against its type and configuration, normalizes it, stores it in the record, and indexes it when asked. A value that should be a select or a reference, but is stored as free text, cannot be grouped or filtered well later.
|
|
70
|
+
|
|
71
|
+
- Types: text, rich text, integer, decimal, currency, checkbox, date, datetime, time, domain, url, email, phone, select, reference, user, attachment.
|
|
72
|
+
- Cardinality is configuration, not a type. Text, select, reference, user, and attachment can be multi-value. A multi-value is an ordered array.
|
|
73
|
+
- An empty attribute reads as null. A required multi-value attribute rejects an empty array.
|
|
74
|
+
- Uniqueness is a real constraint, per attribute, per organization.
|
|
75
|
+
- Advanced filters and sorting are opt-in per attribute with the `indexed` flag. New attributes default to off. Every attribute still supports equality and not-empty filters. Aggregating or grouping by an attribute needs no flag. Type rules still apply: a reference, user, attachment, rich text, or multi-value attribute never sorts. Do not turn the flag on for every attribute. Turn it on for the attributes a query needs.
|
|
76
|
+
|
|
77
|
+
References model relationships:
|
|
78
|
+
|
|
79
|
+
- A reference attribute names a target object. Cardinality on each side comes from the single or multi setting of each face.
|
|
80
|
+
- A reference can expose an inverse face on the target object. One face owns and stores the edges. The other face is derived. Write the owner face only.
|
|
81
|
+
- Hitch keeps the links typed, clears inbound links when a target is deleted, applies grants through the inverse, and lets you filter through either face. Do not invent a join object for a plain relationship. Use a join object only when the relationship needs its own fields or lifecycle.
|
|
82
|
+
|
|
83
|
+
Special cases:
|
|
84
|
+
|
|
85
|
+
- A user attribute points at a membership in the same organization. Removal of the member sweeps those values.
|
|
86
|
+
- An attachment attribute holds file IDs. Files live outside records, in their own storage. Create the file, upload it, then store the ID on the record.
|
|
87
|
+
|
|
88
|
+
## 6. Changesets and releases move together
|
|
89
|
+
|
|
90
|
+
All schema mutations go through a changeset: an ordered list of object and attribute operations with a stored evaluation.
|
|
91
|
+
|
|
92
|
+
- A hard blocker means invalid schema or data. Examples: a unique constraint that finds duplicates, a required attribute with empty records, a tightened range with violators.
|
|
93
|
+
- A soft blocker means a dependency. Examples: applets, grant conditions, or delegations that depend on the object or attribute.
|
|
94
|
+
- Any blocker stops the apply. A submit with a blocker stages a pending changeset. The apply succeeds after the blocker is resolved.
|
|
95
|
+
|
|
96
|
+
An applet release can bind to a pending changeset. Hitch checks the manifest against the schema the changeset will produce. A mismatch is a deploy warning, not a denial. The unresolved warning becomes a hard blocker on the changeset. A bound release does not go live on deploy. When the changeset applies, the schema and the newest bound release of each applet become active together. Schema and code change together.
|
|
97
|
+
|
|
98
|
+
Adoption folds one pending changeset into another and abandons the source. The source must have no bound releases.
|
|
99
|
+
|
|
100
|
+
The applet manifest lists the objects the applet uses, with create and delete flags, read-only attributes, and read-write attributes. That list is the access declaration. It caps what the applet identity can do: the object actions, and the attributes it can update. It does not change what a user can see.
|
|
101
|
+
|
|
102
|
+
## 7. Identity and access
|
|
103
|
+
|
|
104
|
+
Hitch enforces access control on every Hitch API call. An applet never re-implements it. A UI filter or a hidden control is convenience, never a boundary. An applet's own server procedure is applet code, so it must check the business rules it introduces. Every call carries a principal and Hitch applies that principal's grants.
|
|
105
|
+
|
|
106
|
+
Principals:
|
|
107
|
+
|
|
108
|
+
- A person, through a session or a personal API key. A personal API key inherits the member's capabilities.
|
|
109
|
+
- An impersonated person. The target's capabilities must be a proper subset of the caller's.
|
|
110
|
+
- An applet. The applet identity has no role and no bypass. Its authority is exactly the grants projected from its manifest.
|
|
111
|
+
|
|
112
|
+
The organization roles are member and owner. There is no admin role. The owner holds every capability, bypasses every grant, and cannot be removed or impersonated. Capabilities are ten named org-wide powers: manage members, teams, objects, permissions, applets, and the organization; read all records; write all records; use applets; impersonate members. A capability grant goes to a team only, never to a person or to everyone. When one person needs a capability, put them in a one-person team. A caller can grant only a capability the caller holds.
|
|
113
|
+
|
|
114
|
+
Object grants are the matrix: one row per object and grantee with create, read, update, and delete flags. A grantee is a team, an applet, or the default row that every member holds. A member's access is the union of the default row and their team rows. The read-all and write-all capabilities bypass object grants. Object grants set the verbs. Conditions narrow rows. Attribute grants restrict updates to protected attributes and applet writes. Reads are never masked per attribute.
|
|
115
|
+
|
|
116
|
+
An object grant can delegate through one single-valued owner reference. The linked record then uses the same grantee's grant on the target object.
|
|
117
|
+
|
|
118
|
+
Grant conditions scope rows to the current user. A condition path is a user attribute on the object, or one reference followed by a user attribute on the target object. A record whose user attribute is empty is invisible to that grant. An invisible record behaves as missing. A condition applies to read, update, and delete, never to create. A condition cannot compare a value, such as "where status equals X".
|
|
119
|
+
|
|
120
|
+
Who a call acts as:
|
|
121
|
+
|
|
122
|
+
- A client applet call acts as the current user. The manifest grants do not apply.
|
|
123
|
+
- A schedule run acts as the applet, capped by the manifest.
|
|
124
|
+
- A workflow run acts as whoever started it: the invoking user, or the applet when a schedule started it.
|
|
125
|
+
|
|
126
|
+
Because Hitch enforces access, a client applet needs no server proxy for filtering or access control. Add a server only for secrets, external systems, schedules, workflows, or bounded fan-in.
|
|
127
|
+
|
|
128
|
+
## 8. What makes a good applet
|
|
129
|
+
|
|
130
|
+
A good applet:
|
|
131
|
+
|
|
132
|
+
- Solves one related workflow for one clear group of users.
|
|
133
|
+
- Uses the organization's existing Hitch data, not a private copy.
|
|
134
|
+
- Presents the smallest useful set of decisions and actions. It does not reproduce a legacy product screen for screen.
|
|
135
|
+
- Uses Hitch primitives before custom infrastructure.
|
|
136
|
+
- Feels native through semantic theme tokens, shared interaction patterns, useful empty, loading, and error states, and viewport-safe layouts.
|
|
137
|
+
- Has explicit access, performance, failure, and recovery behavior.
|
|
138
|
+
- Can be replaced or rolled back with no move or rewrite of the canonical data.
|
|
139
|
+
|
|
140
|
+
Split an applet when workflows, audiences, privileges, release cadence, or failure modes differ. Do not split because the UI has another page. A sync applet and a reporting applet are a good split. Ingestion has secrets, schedules, broad write grants, retries, and external failure modes. Reports read already-synced data with narrow grants.
|
|
141
|
+
|
|
142
|
+
## 9. Product-design principles
|
|
143
|
+
|
|
144
|
+
- Build to user outcomes, not to the screens or tables of an older system.
|
|
145
|
+
- Start with the important nouns, relationships, permissions, and failure cases. Design screens after that.
|
|
146
|
+
- Simplify critically. Defer speculative channels and infrastructure.
|
|
147
|
+
- Ship the smallest complete workflow. Add nothing unrequested.
|
|
148
|
+
- Treat thresholds, status rules, timing, channels, and recipients as product decisions for the user.
|
|
149
|
+
- Confirm destructive or external writes. Show the target, the intended change, the stale-source check, and the outcome. A Hitch mutation and a mutation of an external source are not equivalent.
|
|
150
|
+
- Record rejected designs and the reason. Do not rebuild what was deliberately cut.
|
package/dist/build-B70gkDi5.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { a as ORG_CODE_PATTERN, r as appletSourceDefinitionSchema } from "./manifest-DyoJ1MIL.js";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
import { basename, dirname, resolve } from "node:path";
|
|
6
|
-
import { loadConfigFromFile } from "vite";
|
|
7
|
-
//#region src/workspace.ts
|
|
8
|
-
const hitchConfigSchema = z.object({
|
|
9
|
-
sdk: z.string().min(1),
|
|
10
|
-
org: z.string().regex(ORG_CODE_PATTERN)
|
|
11
|
-
});
|
|
12
|
-
const require = createRequire(import.meta.url);
|
|
13
|
-
function readWorkspaceConfig(dir) {
|
|
14
|
-
const path = resolve(dir, "hitch.config.ts");
|
|
15
|
-
if (!existsSync(path)) return void 0;
|
|
16
|
-
let module;
|
|
17
|
-
try {
|
|
18
|
-
module = require(path);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error(`Failed to load ${path}.`, { cause: error });
|
|
21
|
-
}
|
|
22
|
-
const config = hitchConfigSchema.safeParse(module !== null && typeof module === "object" && "default" in module ? module.default : module);
|
|
23
|
-
if (!config.success) throw new Error(`Invalid Hitch config in ${path}: ${config.error.message}`);
|
|
24
|
-
return config.data;
|
|
25
|
-
}
|
|
26
|
-
function resolveWorkspaceOrg(appletRoot) {
|
|
27
|
-
const appletsDir = dirname(appletRoot);
|
|
28
|
-
if (basename(appletsDir) === "applets") {
|
|
29
|
-
const config = readWorkspaceConfig(dirname(appletsDir));
|
|
30
|
-
if (config !== void 0) return config.org;
|
|
31
|
-
}
|
|
32
|
-
throw new Error(`No Hitch workspace found for ${appletRoot}. An applet must live at <workspace>/applets/<code> with hitch.config.ts in the workspace root.`);
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/typegen/load-config.ts
|
|
36
|
-
async function loadAppletSourceDefinition(root) {
|
|
37
|
-
const path = resolve(root, "applet.manifest.ts");
|
|
38
|
-
if (!existsSync(path)) throw new Error(`No applet manifest found at ${path}.`);
|
|
39
|
-
const loaded = await loadConfigFromFile({
|
|
40
|
-
command: "build",
|
|
41
|
-
mode: "production"
|
|
42
|
-
}, path, root);
|
|
43
|
-
if (loaded === null) throw new Error(`No applet manifest found at ${path}.`);
|
|
44
|
-
const parsed = appletSourceDefinitionSchema.safeParse(loaded.config);
|
|
45
|
-
if (!parsed.success) throw new Error(`Invalid applet manifest at ${loaded.path}: ${parsed.error.message}`);
|
|
46
|
-
return parsed.data;
|
|
47
|
-
}
|
|
48
|
-
async function loadAppletConfig(root) {
|
|
49
|
-
const { dependencies: _dependencies, devDependencies: _devDependencies, ...definition } = await loadAppletSourceDefinition(root);
|
|
50
|
-
return {
|
|
51
|
-
org: resolveWorkspaceOrg(root),
|
|
52
|
-
...definition
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { resolveWorkspaceOrg as i, loadAppletSourceDefinition as n, readWorkspaceConfig as r, loadAppletConfig as t };
|