fullstackgtm 0.10.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 (77) hide show
  1. package/CHANGELOG.md +381 -0
  2. package/INSTALL_FOR_AGENTS.md +87 -0
  3. package/LICENSE +202 -0
  4. package/README.md +230 -0
  5. package/dist/audit.d.ts +7 -0
  6. package/dist/audit.js +202 -0
  7. package/dist/bin.d.ts +2 -0
  8. package/dist/bin.js +6 -0
  9. package/dist/cli.d.ts +38 -0
  10. package/dist/cli.js +915 -0
  11. package/dist/config.d.ts +36 -0
  12. package/dist/config.js +85 -0
  13. package/dist/connector.d.ts +30 -0
  14. package/dist/connector.js +94 -0
  15. package/dist/connectors/hubspot.d.ts +20 -0
  16. package/dist/connectors/hubspot.js +409 -0
  17. package/dist/connectors/hubspotAuth.d.ts +42 -0
  18. package/dist/connectors/hubspotAuth.js +189 -0
  19. package/dist/connectors/salesforce.d.ts +26 -0
  20. package/dist/connectors/salesforce.js +318 -0
  21. package/dist/connectors/salesforceAuth.d.ts +44 -0
  22. package/dist/connectors/salesforceAuth.js +120 -0
  23. package/dist/connectors/stripe.d.ts +27 -0
  24. package/dist/connectors/stripe.js +176 -0
  25. package/dist/credentials.d.ts +75 -0
  26. package/dist/credentials.js +197 -0
  27. package/dist/demo.d.ts +20 -0
  28. package/dist/demo.js +169 -0
  29. package/dist/diff.d.ts +46 -0
  30. package/dist/diff.js +107 -0
  31. package/dist/format.d.ts +3 -0
  32. package/dist/format.js +109 -0
  33. package/dist/index.d.ts +18 -0
  34. package/dist/index.js +17 -0
  35. package/dist/mappings.d.ts +8 -0
  36. package/dist/mappings.js +123 -0
  37. package/dist/mcp-bin.d.ts +2 -0
  38. package/dist/mcp-bin.js +33 -0
  39. package/dist/mcp.d.ts +1 -0
  40. package/dist/mcp.js +140 -0
  41. package/dist/merge.d.ts +48 -0
  42. package/dist/merge.js +145 -0
  43. package/dist/planStore.d.ts +31 -0
  44. package/dist/planStore.js +116 -0
  45. package/dist/rules.d.ts +24 -0
  46. package/dist/rules.js +512 -0
  47. package/dist/sampleData.d.ts +2 -0
  48. package/dist/sampleData.js +115 -0
  49. package/dist/types.d.ts +294 -0
  50. package/dist/types.js +8 -0
  51. package/docs/api.md +72 -0
  52. package/docs/roadmap-to-1.0.md +121 -0
  53. package/llms.txt +25 -0
  54. package/package.json +76 -0
  55. package/src/audit.ts +242 -0
  56. package/src/bin.ts +7 -0
  57. package/src/cli.ts +1042 -0
  58. package/src/config.ts +113 -0
  59. package/src/connector.ts +140 -0
  60. package/src/connectors/hubspot.ts +528 -0
  61. package/src/connectors/hubspotAuth.ts +246 -0
  62. package/src/connectors/salesforce.ts +420 -0
  63. package/src/connectors/salesforceAuth.ts +167 -0
  64. package/src/connectors/stripe.ts +215 -0
  65. package/src/credentials.ts +282 -0
  66. package/src/demo.ts +200 -0
  67. package/src/diff.ts +158 -0
  68. package/src/format.ts +162 -0
  69. package/src/index.ts +129 -0
  70. package/src/mappings.ts +157 -0
  71. package/src/mcp-bin.ts +32 -0
  72. package/src/mcp.ts +185 -0
  73. package/src/merge.ts +235 -0
  74. package/src/planStore.ts +155 -0
  75. package/src/rules.ts +539 -0
  76. package/src/sampleData.ts +117 -0
  77. package/src/types.ts +372 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,381 @@
1
+ # Changelog
2
+
3
+ All notable changes to the `fullstackgtm` package are documented here.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
+ and the project adheres to [Semantic Versioning](https://semver.org/).
6
+ The path to 1.0 is planned in [docs/roadmap-to-1.0.md](./docs/roadmap-to-1.0.md).
7
+
8
+ ## [0.10.0] — 2026-06-10
9
+
10
+ **Versioning reset to reflect beta status.** The 1.x numbering below
11
+ (1.0.0–1.2.2) overstated maturity: those versions were development
12
+ milestones, not a frozen public contract. 0.10.0 continues the 0.x line
13
+ (0.9.0 was the last pre-1.x milestone) and is functionally identical to
14
+ 1.2.2 plus the status/docs corrections below. `fullstackgtm@1.2.1` and
15
+ `@1.2.2` were briefly on npm (2026-06-10) and were unpublished the same
16
+ week; those version numbers are permanently burned per npm policy. The real
17
+ 1.0 will be declared via [docs/roadmap-to-1.0.md](./docs/roadmap-to-1.0.md)
18
+ once the API surface has survived external usage.
19
+
20
+ ### Changed
21
+
22
+ - README status: "1.0 — stable" → "beta (0.x)"; API surfaces may break in
23
+ minor releases until 1.0 (each break will be called out here). The safety
24
+ invariants are explicitly not beta.
25
+ - `docs/api.md` reframed as the 1.0 contract *candidate*.
26
+ - MCP server now reports the real package version instead of a hardcoded
27
+ string.
28
+
29
+ ## [1.2.2] — 2026-06-10 (unpublished)
30
+
31
+ Release mechanics.
32
+
33
+ ### Changed
34
+
35
+ - **Releases publish via npm Trusted Publishing (OIDC)** from GitHub Actions
36
+ on the public repo — no tokens, no 2FA bypass. (1.2.1 was published
37
+ manually to bootstrap the package on npm.)
38
+ - Bin paths canonicalized (no `./` prefix) to silence npm 11's
39
+ normalization warning during pack/publish.
40
+
41
+ ## [1.2.1] — 2026-06-10 (unpublished)
42
+
43
+ First version published to npm.
44
+
45
+ Onboarding polish: first-run verification, agent install docs, and a working
46
+ zero-install MCP path.
47
+
48
+ ### Added
49
+
50
+ - **`fullstackgtm doctor [--json]`**: offline install check — package/node
51
+ versions, credential-store and config presence, per-provider credential
52
+ source (env / stored / broker / none), MCP peer status, and the suggested
53
+ next command. `--json` for agents and orchestration.
54
+ - **`INSTALL_FOR_AGENTS.md`**: deterministic install-and-verify steps with
55
+ expected outputs and exit codes, for AI agents installing the CLI.
56
+ - **`llms.txt`**: documentation map and key invariants for LLM consumption.
57
+
58
+ ### Fixed
59
+
60
+ - **`fullstackgtm-mcp` no longer crashes with a raw module-not-found stack
61
+ trace** when the optional peers are missing — it prints install guidance
62
+ instead (`npx fullstackgtm-mcp` alone never installs optional peers).
63
+ - README MCP instructions now use a working zero-install invocation
64
+ (`npx -p fullstackgtm -p @modelcontextprotocol/sdk -p zod fullstackgtm-mcp`)
65
+ and include copy-paste Claude Code / generic MCP client configuration.
66
+
67
+ ## [1.2.0] — Unreleased
68
+
69
+ Feature-completeness fan-out: filled every remaining capability gap found by
70
+ an exhaustive census of the package and the hosted app.
71
+
72
+ ### Added (package)
73
+
74
+ - **Stripe incremental fetch** (`fetchChanges`): filters customers and
75
+ subscriptions on `created[gte]`, so frequent syncs no longer re-pull the
76
+ full account. (Catches newly-created records; Stripe list endpoints can't
77
+ filter on a modification timestamp — documented on the method.)
78
+ - **HubSpot and Salesforce now populate `lastActivityAt` and
79
+ `forecastCategory`** on deals (`hs_last_sales_activity_timestamp` /
80
+ `LastActivityDate`, and stage/`ForecastCategory` → canonical category).
81
+ `forecastCategory` was a dead canonical field; stale-deal detection now
82
+ uses true engagement time instead of falling back to sync time.
83
+ - **`diffSnapshots` covers the activities collection** (added/removed/changed),
84
+ rendered in `diffToMarkdown` — previously only users/accounts/contacts/deals
85
+ were diffed.
86
+ - **`patchPlanToMarkdown` renders each operation's id**, so the approval flow
87
+ (`plans approve --operations <ids>`) no longer requires reading JSON.
88
+ - **MCP audit honors config** via a new `configPath` input — policy overrides
89
+ and third-party rule packages now work over MCP, matching the CLI.
90
+
91
+ ### Hosted app (not part of the package's semver surface)
92
+
93
+ - **Real multi-touch attribution**: `attribution.ts` replaces a single
94
+ synthetic touchpoint per deal and a fabricated 8%-of-revenue budget with
95
+ first/last/linear/time-decay crediting (7-day half-life) over real
96
+ touchpoints; budget/spend read only from real fields.
97
+ - **Consistent least-privilege role gating**: 84 write mutations across the
98
+ backend that lacked an admin/manager check now require one (via a new
99
+ `requireManager` helper); HubSpot/Salesforce `disconnect` aligned to
100
+ admin-or-manager. No IDOR/cross-tenant gaps existed; this closes the
101
+ role-gating inconsistency. Removed an unused public `getByClerkId` query.
102
+
103
+ ## [1.1.0] — Unreleased
104
+
105
+ Feature-completeness pass: no operation type is a stub.
106
+
107
+ ### Added
108
+
109
+ - **Connectors apply every operation type.** HubSpot and Salesforce
110
+ `applyOperation` now implement `link_record` (HubSpot deal→company
111
+ association; Salesforce `AccountId`), `create_task` (HubSpot task
112
+ engagement with the correct association type id; Salesforce `Task` with
113
+ `WhatId`/`WhoId`), and `archive_record` (HubSpot archive / Salesforce
114
+ delete), in addition to `set_field`/`clear_field`. Previously these were
115
+ silently skipped — so applying a real audit plan (whose built-in rules emit
116
+ `link_record` and `create_task`) now actually applies, with nothing dropped.
117
+ - An end-to-end test proves a full demo audit plan applies with zero
118
+ unsupported-skips.
119
+
120
+ ### Fixed
121
+
122
+ - HubSpot connector tolerates empty (204) response bodies from DELETE and
123
+ association writes instead of throwing on success.
124
+ - App (hosted): patch-plan apply dispatches through the shared operation
125
+ registry, so every `set`/`do` operation a plan can be created for is also
126
+ applyable — the previous path only handled `deal.next_step` and threw
127
+ "not implemented" for everything else.
128
+
129
+ ## [1.0.1] — Unreleased
130
+
131
+ Security and correctness fixes from an adversarial review.
132
+
133
+ ### Security
134
+
135
+ - **Fail-closed backend auth** (app): the Convex demo bypass is enabled only
136
+ by an explicit `FSGTM_ENABLE_DEMO_DATA=true`, never inferred from a missing
137
+ Clerk issuer — a deployment that forgot to configure auth now rejects
138
+ requests instead of granting admin access to the direct Convex endpoint.
139
+ - **Secrets off argv**: `login` no longer accepts tokens/client secrets as
140
+ flags (they leak via `ps` and shell history). Secrets are read from stdin
141
+ (`echo "$T" | fullstackgtm login hubspot`) or a muted interactive prompt;
142
+ passing `--token`/`--client-secret` is rejected.
143
+ - **Broker tokens expire** (90-day TTL) and pairing requests are swept; a
144
+ leaked credentials file no longer grants indefinite org access.
145
+ - **Device-code phishing defense**: pairing requests carry a self-reported
146
+ requester label shown to the approver, who is warned before granting access.
147
+ - **Enforced credential permissions**: the home dir is forced to 0700 and
148
+ credential/plan files to 0600 even when pre-created at looser modes.
149
+ - **Per-IP rate limiting** on the public pairing endpoints (replacing a global
150
+ counter that was a self-DoS); timing-safe smoke-bypass comparison that is
151
+ refused in production; provider error bodies no longer interpolated into
152
+ thrown errors; `openInBrowser` validates the URL scheme and fixes argument
153
+ injection / the Windows opener.
154
+
155
+ ### Fixed
156
+
157
+ - `mergeSnapshots` no longer auto-merges accounts that merely share a name
158
+ with different/absent domains (a data-corrupting false merge); such
159
+ collisions are reported as `suggestions` for human review.
160
+ - Apply paths require an `approved` plan unconditionally; a `not_required`
161
+ draft can no longer write to a provider.
162
+ - The Stripe connector leaves a subscription's amount undefined for
163
+ metered/tiered prices instead of silently reporting 0.
164
+ - `sampleData` probabilities corrected to the canonical 0..1 unit (were
165
+ 0..100), matching the connectors and demo dataset.
166
+ - Pagination loops guard against a repeated provider cursor (HubSpot and
167
+ Salesforce) so a misbehaving API can't loop forever; HubSpot incremental
168
+ search stops at its 10,000-result cap instead of erroring mid-sync.
169
+ - The CLI pairing `describe` lookup is gated to authenticated admins/managers
170
+ so a requester's hostname isn't exposed to anonymous callers.
171
+
172
+ ## [1.0.0] — Unreleased
173
+
174
+ **The contract.** From this release, the surfaces documented in
175
+ [docs/api.md](./docs/api.md) — the canonical data model, the rule interface,
176
+ the patch-plan format and apply safety contract, the connector contract,
177
+ merge/diff, configuration, CLI commands and exit codes, and MCP tool
178
+ schemas — are covered by semver: breaking changes require a major version.
179
+ New providers and new rules are minor releases; the model only breaks at 2.0.
180
+
181
+ No code changes beyond version identifiers; 1.0.0 is 0.9.0 with the
182
+ stability commitment attached.
183
+
184
+ ## [0.9.0] — Unreleased
185
+
186
+ ### Added
187
+
188
+ - **API freeze document** (`docs/api.md`, shipped in the package): the exact
189
+ surfaces covered by the 1.0 semver commitment — canonical model, rule
190
+ engine, plan/apply contract, connector contract, merge/diff, config, CLI
191
+ commands and exit codes, MCP tools.
192
+ - **Performance guards in CI**: auditing and diffing a 2,000-account /
193
+ 10,000-deal generated org must stay within linear-time budgets, catching
194
+ any regression to quadratic behavior.
195
+
196
+ ### Security
197
+
198
+ - Rate limiting on the public CLI pairing endpoint (device-flow `start`),
199
+ bounding pairing-request floods deployment-wide.
200
+ - Auth-surface review pass: hashed-at-rest device codes and broker tokens,
201
+ state-checked loopback OAuth, 0600 credential files, role-gated approvals,
202
+ and per-CLI revocation were verified; no further findings.
203
+
204
+ ## [0.8.0] — Unreleased
205
+
206
+ ### Added
207
+
208
+ - **Stripe connector** (`createStripeConnector`) — the first non-CRM
209
+ connector, proving the contract generalizes to billing: customers map to
210
+ accounts (email domain becomes the cross-system merge key) and contacts,
211
+ subscriptions map to deals (cents converted to major units, status mapped
212
+ to won/lost/open). Read-only by design: `applyOperation` always returns
213
+ `skipped`. CLI `--provider stripe`, `login stripe --token sk_...`, and the
214
+ MCP audit source complete the wiring.
215
+ - **Incremental fetch** (`fetchChanges(sinceIso)`): HubSpot via the CRM
216
+ search API (`hs_lastmodifieddate`/`lastmodifieddate` filters with paging),
217
+ Salesforce via `SystemModstamp` SOQL filters — frequent syncs no longer
218
+ re-pull whole orgs. CLI: `snapshot --provider <name> --since <iso>`.
219
+ Change feeds may omit associations; documented on the contract.
220
+ - **One plan vocabulary in the hosted app**: `patchPlans.get` now returns
221
+ `document` — the package-typed `PatchPlan` converted from legacy rows via
222
+ `convex/lib/patchPlanCompat.ts` — so the dashboard review queue and
223
+ `fullstackgtm apply` consume the same document shape.
224
+
225
+ ## [0.7.0] — Unreleased
226
+
227
+ ### Added
228
+
229
+ - **Conflict surfacing (compare-and-set)**: connectors gain `readField`, and
230
+ `applyPatchPlan` reads the live provider value before every field write —
231
+ if it no longer matches the plan's `beforeValue`, the operation returns a
232
+ new `conflict` result (with the current value) instead of writing blind.
233
+ On by default when the connector supports it; `checkConflicts: false` opts
234
+ out. Both HubSpot and Salesforce connectors implement `readField` through
235
+ the same field mappings as writes.
236
+
237
+ ### Notes
238
+
239
+ - Incremental fetch (provider change cursors) is the remaining 0.7.x work.
240
+
241
+ ## [0.6.0] — Unreleased
242
+
243
+ ### Added
244
+
245
+ - **Entity resolution across systems** (`mergeSnapshots`): collapses users
246
+ and contacts on email, accounts on normalized domain (then name), keeps
247
+ every original system id as an identity claim, gap-fills missing fields
248
+ (first source wins), and reports every conflicting value instead of
249
+ silently resolving it. Deals and activities are never merged — they are
250
+ provider-unique — but references are re-pointed at merged records.
251
+ - CLI `merge --input a.json --input b.json --out merged.json` with a
252
+ conflict report; audit the merged view like any snapshot.
253
+ - New cross-system rule `account-single-source` (info): on merged
254
+ multi-system snapshots, flags accounts known to only one source. Inert on
255
+ single-provider snapshots, so existing audits are unaffected.
256
+
257
+ ## [0.5.0] — Unreleased
258
+
259
+ ### Added
260
+
261
+ - **Snapshot diffing** (`diffSnapshots`): added/removed records and
262
+ field-level changes per collection, ignoring sync-noise fields.
263
+ - **Hygiene drift** (`diffFindings`): new vs. resolved vs. persisting
264
+ findings between two audits, keyed on stable finding ids.
265
+ - CLI `diff --before <a.json> --after <b.json>` renders both (markdown or
266
+ `--json`) and exits 2 with `--fail-on-new-findings` — a hygiene
267
+ *regression* gate for nightly CI, not just a hygiene presence gate.
268
+ - CLI `snapshot --archive <dir>` writes timestamped
269
+ `<provider>-<generatedAt>.json` files for snapshot history.
270
+
271
+ ## [0.4.0] — Unreleased
272
+
273
+ ### Added
274
+
275
+ - **Configuration file** (`fullstackgtm.config.json`, or `--config <path>`):
276
+ policy thresholds, rule selection (`enabled`/`disabled`), and
277
+ `rulePackages` — modules exporting `rules: GtmAuditRule[]` — so a team's
278
+ audit standard lives in version control. CLI flags still win over config.
279
+ - **Five new built-in rules** (10 total), each with a `category`:
280
+ `missing-deal-amount` (forecast), `duplicate-account-domain` and
281
+ `duplicate-contact-email` (data-quality, case-insensitive grouping),
282
+ `active-deal-account-without-contacts` (coverage), and
283
+ `closing-soon-inactive` (forecast, severity critical) — open deals inside
284
+ the closing window with no recent activity, i.e. silent slip risk.
285
+ - Policy gains optional `requireDealAmount`, `closingSoonDays`, and
286
+ `closingSoonIdleDays` thresholds.
287
+ - `rules` command resolves the configured set (including rule packages) and
288
+ shows categories.
289
+
290
+ ### Changed
291
+
292
+ - Demo-dataset golden counts updated for the new rules (69 → 79 findings;
293
+ the duplicate rules fire on realistic generated data).
294
+
295
+ ## [0.3.0] — Unreleased
296
+
297
+ ### Added
298
+
299
+ - **Durable plan workflow** (`PlanStore` + `createFilePlanStore`): plans stay
300
+ immutable proposals; the store tracks the lifecycle around them — approved
301
+ operation ids, human-supplied value overrides, and every apply run. The
302
+ file store keeps one JSON document per plan under `~/.fullstackgtm/plans`.
303
+ - CLI lifecycle: `audit --save`, `plans list|show|approve|reject`, and
304
+ `apply --plan-id <id>` — the store enforces that nothing applies before
305
+ approval and records the run afterward. Approving operations can carry
306
+ `--value <opId>=<v>` overrides that persist with the plan.
307
+
308
+ ### Notes
309
+
310
+ - The hosted app's Convex plan tables are the second `PlanStore`
311
+ implementation target; unifying them onto these types is the remaining
312
+ 0.3.x work (see docs/roadmap-to-1.0.md).
313
+
314
+ ## [0.2.0] — Unreleased
315
+
316
+ ### Added
317
+
318
+ - **Salesforce connector** (`createSalesforceConnector`) behind the same
319
+ `GtmConnector` contract: SOQL reads with cursor pagination, PATCH
320
+ write-back (correctly handling Salesforce's `204 No Content`), per-org
321
+ field mappings, probabilities normalized to canonical 0..1, and the same
322
+ never-drop-records guarantee as HubSpot.
323
+ - **Salesforce CLI auth**: `login salesforce --device --client-id <consumer
324
+ key>` uses Salesforce's native device-authorization grant — a code
325
+ confirmed on any device, no localhost server, no client secret, silent
326
+ refresh. Manual `--token --instance-url` also supported.
327
+ - **Broker mint for Salesforce**: paired CLIs exchange their broker token for
328
+ `accessToken + instanceUrl + fieldMappings` from the org's stored sync
329
+ credentials. `resolveSalesforceConnection` joins the resolution ladder.
330
+ - CLI/MCP provider surfaces accept `salesforce` everywhere `hubspot` was
331
+ accepted (`--provider`, apply, MCP enums).
332
+
333
+ ## [0.1.0] — Unreleased
334
+
335
+ Initial public release.
336
+
337
+ ### Core
338
+
339
+ - Canonical, provider-independent GTM data model (users, accounts, contacts,
340
+ deals, activities) with multi-system identity claims (`identities:
341
+ {provider, externalId}[]`) and provider payload escape hatches.
342
+ - Pluggable deterministic audit-rule engine (`GtmAuditRule`). Five built-in
343
+ hygiene rules: orphan accounts, ownerless deals, unlinked deals, past close
344
+ dates, stale pipeline. Finding and operation ids are stable hashes, so runs
345
+ over the same data are diffable.
346
+ - Dry-run patch plans: every proposed write is a typed operation with
347
+ before/after values, a reason, a risk level, and an approval flag.
348
+ - `applyPatchPlan` orchestrator enforcing the safety contract for all
349
+ connectors: explicit per-operation approval, no `requires_human_*`
350
+ placeholder writes without a concrete value override, per-operation result
351
+ records (`PatchPlanRun`).
352
+ - `GtmConnector` contract (`fetchSnapshot` / `applyOperation`) and a HubSpot
353
+ reference connector (plain `fetch`, injected token, per-org field mappings).
354
+ The connector never drops unresolvable records — audits surface them.
355
+ - Seeded deterministic demo dataset (`generateDemoSnapshot`): a realistic,
356
+ deliberately messy mid-market CRM with injected real-world failure modes.
357
+
358
+ ### CLI (`fullstackgtm`)
359
+
360
+ - `snapshot` / `audit` / `apply` / `rules` — composable, JSON-everywhere,
361
+ meaningful exit codes (`0` success, `1` error, `2` findings at/above
362
+ `--fail-on` threshold).
363
+ - Rule scoping (`--rules`), policy overrides (`--today`, `--stale-days`),
364
+ demo and file sources, severity gating for CI and agent loops.
365
+ - `login hubspot` — private app token (zero web flow, validated) or
366
+ bring-your-own-app OAuth via RFC 8252 loopback with silent refresh.
367
+ - `login --via <hosted url>` — broker pairing: device-flow handshake against
368
+ a hosted FullStackGTM deployment; the CLI exchanges a revocable broker
369
+ token for short-lived provider tokens minted from the org's stored sync
370
+ credentials, inheriting org field mappings.
371
+ - Credential resolution ladder: `--token-env` → ambient env → stored direct
372
+ login → broker pairing. Stored in `~/.fullstackgtm/credentials.json`
373
+ (0600, `FSGTM_HOME` overridable).
374
+
375
+ ### MCP (`fullstackgtm-mcp`)
376
+
377
+ - `fullstackgtm_audit` (sample/demo/file/live sources, rule scoping),
378
+ `fullstackgtm_rules`, and `fullstackgtm_apply` (requires explicit
379
+ `approvedOperationIds`) over stdio.
380
+
381
+ [0.1.0]: https://github.com/fullstackgtm/fullstackgtm/tree/main/packages/fullstackgtm
@@ -0,0 +1,87 @@
1
+ # Installing fullstackgtm (for AI agents)
2
+
3
+ Deterministic install-and-verify steps. Every command is non-interactive, every
4
+ check has an expected output, and nothing here writes to a CRM.
5
+
6
+ ## 1. Install
7
+
8
+ ```bash
9
+ npm install -g fullstackgtm
10
+ # or project-local: npm install fullstackgtm
11
+ # or zero-install: prefix the commands below with `npx`
12
+ ```
13
+
14
+ Requires Node >= 20. No other runtime dependencies.
15
+
16
+ ## 2. Verify
17
+
18
+ ```bash
19
+ fullstackgtm doctor --json
20
+ ```
21
+
22
+ Expect a JSON object with `node.ok: true` and `package.version` set. The
23
+ `providers` map shows `"source": "none"` for every provider on a fresh
24
+ machine — that is normal and does not block the next step.
25
+
26
+ ## 3. First value, zero credentials
27
+
28
+ ```bash
29
+ fullstackgtm audit --demo --json
30
+ ```
31
+
32
+ Expect a JSON patch plan with `dryRun: true` and ~80 findings over a generated,
33
+ deliberately messy CRM. Deterministic per seed: `--seed 7` is the default, so
34
+ two runs produce identical finding and operation ids. Exit code 0.
35
+
36
+ This proves the whole pipeline (snapshot → audit → plan) without any account.
37
+
38
+ ## 4. Connect a real provider (requires a human or stored credentials)
39
+
40
+ Credential resolution ladder, first match wins:
41
+
42
+ 1. `--token-env <NAME>` — explicit env var for one invocation
43
+ 2. Ambient env: `HUBSPOT_ACCESS_TOKEN`, or `SALESFORCE_ACCESS_TOKEN` + `SALESFORCE_INSTANCE_URL`, or `STRIPE_SECRET_KEY`
44
+ 3. Stored login: `fullstackgtm login <provider>` (interactive; a human runs this once)
45
+ 4. Broker pairing: `fullstackgtm login --via <hosted url>` (a human approves the pairing code)
46
+
47
+ In an agent sandbox, prefer rung 1 or 2. Never echo tokens into argv —
48
+ `login` reads secrets from stdin only.
49
+
50
+ ```bash
51
+ HUBSPOT_ACCESS_TOKEN=$TOKEN fullstackgtm audit --provider hubspot --json --out plan.json
52
+ ```
53
+
54
+ Exit codes everywhere: `0` success, `1` error, `2` findings at/above `--fail-on`.
55
+
56
+ ## 5. Writes are approval-gated — by design
57
+
58
+ `audit` never mutates anything. `apply` writes only operation ids explicitly
59
+ passed via `--approve`, and refuses `requires_human_*` placeholder values
60
+ unless a concrete `--value <opId>=<v>` override is supplied. Do not attempt to
61
+ bypass this; surface the plan to a human instead:
62
+
63
+ ```bash
64
+ fullstackgtm audit --provider hubspot --save # persists plan to ~/.fullstackgtm/plans
65
+ fullstackgtm plans list # a human reviews and approves
66
+ ```
67
+
68
+ ## 6. MCP server (optional)
69
+
70
+ The MCP entrypoint needs optional peers that plain `npx fullstackgtm-mcp`
71
+ does not install:
72
+
73
+ ```bash
74
+ npx -p fullstackgtm -p @modelcontextprotocol/sdk -p zod fullstackgtm-mcp
75
+ ```
76
+
77
+ Tools exposed over stdio: `fullstackgtm_audit` (read-only),
78
+ `fullstackgtm_rules`, `fullstackgtm_apply` (requires `approvedOperationIds`).
79
+
80
+ ## Troubleshooting
81
+
82
+ | Symptom | Fix |
83
+ | --- | --- |
84
+ | `fullstackgtm: command not found` | Re-run with `npx fullstackgtm`, or check global npm bin is on PATH |
85
+ | `No HubSpot credentials` (exit 1) | Set `HUBSPOT_ACCESS_TOKEN` or have a human run `fullstackgtm login hubspot` |
86
+ | MCP server prints peer-dependency help | Install `@modelcontextprotocol/sdk` and `zod` (see step 6) |
87
+ | Need machine state for orchestration | `fullstackgtm doctor --json` |
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.