@sequenceholdings/studio-cli 0.9.20 → 0.9.21

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 (55) hide show
  1. package/README.md +131 -11
  2. package/dist/app/commands.js +2 -0
  3. package/dist/app/deploy.js +2 -0
  4. package/dist/app/lockfile-preflight.d.ts +31 -0
  5. package/dist/app/lockfile-preflight.js +47 -0
  6. package/dist/app/repository-index.d.ts +5 -1
  7. package/dist/app/repository-index.js +9 -3
  8. package/dist/auth.d.ts +13 -9
  9. package/dist/auth.js +98 -20
  10. package/dist/cli-errors.js +6 -1
  11. package/dist/command-contract.d.ts +13 -1
  12. package/dist/command-contract.js +3 -1
  13. package/dist/command-help.d.ts +1 -1
  14. package/dist/command-help.js +8 -1
  15. package/dist/config.d.ts +14 -0
  16. package/dist/config.js +29 -3
  17. package/dist/docs/commands.d.ts +16 -0
  18. package/dist/docs/commands.js +168 -0
  19. package/dist/docs/help.d.ts +2 -0
  20. package/dist/docs/help.js +12 -0
  21. package/dist/envs/commands.js +10 -2
  22. package/dist/host-token.d.ts +19 -4
  23. package/dist/host-token.js +50 -10
  24. package/dist/main.d.ts +1 -0
  25. package/dist/main.js +20 -2
  26. package/dist/orm/discover-operations.d.ts +1 -1
  27. package/dist/orm/discover-operations.js +3 -3
  28. package/dist/orm/discover-schema.d.ts +0 -5
  29. package/dist/orm/discover-schema.js +0 -3
  30. package/dist/pipeline/commands.d.ts +0 -7
  31. package/dist/pipeline/commands.js +16 -67
  32. package/dist/pipeline/discovery.d.ts +1 -1
  33. package/dist/pipeline/discovery.js +6 -6
  34. package/dist/process/build.d.ts +2 -5
  35. package/dist/process/build.js +4 -49
  36. package/dist/repos/commands.d.ts +11 -1
  37. package/dist/repos/commands.js +78 -11
  38. package/dist/repos/git-credential.d.ts +12 -5
  39. package/dist/repos/git-credential.js +63 -36
  40. package/dist/repos/github-connect-command.d.ts +35 -0
  41. package/dist/repos/github-connect-command.js +250 -0
  42. package/dist/repos/github-init-command.d.ts +5 -0
  43. package/dist/repos/github-init-command.js +106 -0
  44. package/dist/repos/github-init.d.ts +133 -0
  45. package/dist/repos/github-init.js +265 -0
  46. package/dist/scaffold-guidance.d.ts +10 -2
  47. package/dist/scaffold-guidance.js +27 -2
  48. package/dist/templates/guidance/AGENTS.md +15 -8
  49. package/package.json +7 -7
  50. package/release-summary.json +2 -1
  51. package/templates/guidance/AGENTS.md +15 -8
  52. package/dist/pipeline/active-orm-contracts.d.ts +0 -16
  53. package/dist/pipeline/active-orm-contracts.js +0 -36
  54. package/dist/pipeline/repin-orm.d.ts +0 -2
  55. package/dist/pipeline/repin-orm.js +0 -207
@@ -1,15 +1,22 @@
1
1
  # Sequence development
2
2
 
3
- Before every development task, read the live documentation for this project's
4
- target environment. Find the environment's URL with `seq-studio envs list`
5
- (or the project configuration), then open `<environment-url>/docs`.
3
+ Before every development task, read the Sequence developer docs for this
4
+ project's target environment. They match the platform version that environment
5
+ runs, so prefer them over memory, other repositories, or copied snippets.
6
6
 
7
- Start with that site's `/docs/llms.txt` index and follow the relevant pages as
8
- needed. The hosted docs are the single source of truth for platform usage;
9
- do not duplicate their instructions in this file. If docs access is blocked,
10
- open the same URL in the signed-in browser.
7
+ ```sh
8
+ seq-studio envs list # find the environment name
9
+ seq-studio docs search "<what you need>" -e <env> # find the right page
10
+ seq-studio docs read <slug> -e <env> # read it in full
11
+ ```
12
+
13
+ Search before running an unfamiliar `seq-studio` command, and read the matching
14
+ page before changing a manifest. If the CLI cannot reach the docs, open
15
+ `<environment-url>/docs` (index at `/docs/llms.txt`) in the signed-in browser.
16
+ The docs are the single source of truth for platform usage; do not duplicate
17
+ their instructions in this file.
11
18
 
12
19
  After concrete CLI friction costs time or retries, finish the task, then follow
13
- the live `/seq-studio/feedback` guide and run `seq-studio feedback submit`
20
+ the `seq-studio/feedback` docs page and run `seq-studio feedback submit`
14
21
  before the final response. Include the confirmed receipt ID and ticket URL, or
15
22
  the sanitized draft and submission evidence if no receipt is confirmed.
@@ -1,16 +0,0 @@
1
- import type { OrmSyncedTableContract } from '@sequenceholdings/orm';
2
- import type { ResolvedEnv } from '../config.js';
3
- type OrmModule = typeof import('@sequenceholdings/orm');
4
- interface ContractStage {
5
- readonly satisfies: {
6
- readonly namespace: string;
7
- readonly table: string;
8
- };
9
- }
10
- export declare function loadActiveOrmContracts({ env, orm, stages, token, }: {
11
- env: ResolvedEnv;
12
- orm: OrmModule;
13
- stages: readonly ContractStage[];
14
- token: string;
15
- }): Promise<Record<string, OrmSyncedTableContract>>;
16
- export {};
@@ -1,36 +0,0 @@
1
- import { z } from 'zod';
2
- import { getJson } from '../atlas-client.js';
3
- const namespaceResponseSchema = z.object({
4
- active_definition: z.unknown().nullable(),
5
- active_definition_format: z.number().int().nullable(),
6
- });
7
- export async function loadActiveOrmContracts({ env, orm, stages, token, }) {
8
- const namespaces = [...new Set(stages.map((stage) => stage.satisfies.namespace))];
9
- const definitions = new Map();
10
- await Promise.all(namespaces.map(async (namespace) => {
11
- const response = namespaceResponseSchema.parse(await getJson({
12
- baseUrl: env.url,
13
- token,
14
- path: `/api/orm/namespaces/${encodeURIComponent(namespace)}`,
15
- }));
16
- if (response.active_definition_format !== 2 || response.active_definition === null) {
17
- throw new Error(`ORM namespace '${namespace}' has no active v2 definition in ${env.name}`);
18
- }
19
- definitions.set(namespace, orm.canonicalDefinitionSchema.parse(response.active_definition));
20
- }));
21
- const contracts = {};
22
- for (const stage of stages) {
23
- const binding = stage.satisfies;
24
- const key = `${binding.namespace}.${binding.table}`;
25
- const definition = definitions.get(binding.namespace);
26
- const table = definition?.tables.find((candidate) => candidate.table === binding.table);
27
- if (!table) {
28
- throw new Error(`active ORM definition does not contain synced table '${key}'`);
29
- }
30
- contracts[key] = orm.extractOrmSyncedTableContract({
31
- namespace: binding.namespace,
32
- table,
33
- });
34
- }
35
- return contracts;
36
- }
@@ -1,2 +0,0 @@
1
- import type { ParsedArgs } from '../process/commands.js';
2
- export declare function pipelineRepinOrmCommand(args: ParsedArgs): Promise<number>;
@@ -1,207 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import { join, resolve } from 'node:path';
3
- import { z } from 'zod';
4
- import { getAccessToken } from '../auth.js';
5
- import { resolveConfiguredEnv } from '../config.js';
6
- import { explicitOrSandboxEnv } from '../env-flags.js';
7
- import { isSandboxTokenMode } from '../sandbox-auth.js';
8
- import { loadActiveOrmContracts } from './active-orm-contracts.js';
9
- import { commitFileWrites } from './atomic-file-writes.js';
10
- import { resolvePipelineTarget } from './lifecycle.js';
11
- const LOG = '[seq-studio]';
12
- const ORM_CONTRACTS_FILENAME = 'orm-contracts.json';
13
- async function loadModules() {
14
- return {
15
- spec: await import('@sequenceholdings/pipeline-spec'),
16
- orm: await import('@sequenceholdings/orm'),
17
- };
18
- }
19
- function requestedEnvironment(args) {
20
- const value = args.flags.e ?? args.flags.env;
21
- return explicitOrSandboxEnv(typeof value === 'string' ? value : undefined);
22
- }
23
- function hasOrmPin(stage) {
24
- return stage.type === 'serving' && stage.satisfies !== undefined;
25
- }
26
- async function loadExistingCatalog({ path, spec, }) {
27
- let raw;
28
- try {
29
- raw = await readFile(path, 'utf8');
30
- }
31
- catch (error) {
32
- if (error instanceof Error && Reflect.get(error, 'code') === 'ENOENT')
33
- return {};
34
- throw error;
35
- }
36
- const parsed = JSON.parse(raw);
37
- spec.ormContractCatalogSchema.parse(parsed);
38
- return z.record(z.string(), z.unknown()).parse(parsed);
39
- }
40
- function assertNoUntargetedContractCollisions({ contracts, pinnedStages, target, }) {
41
- for (const stage of pinnedStages) {
42
- if (stage.environments.includes(target))
43
- continue;
44
- const key = `${stage.satisfies.namespace}.${stage.satisfies.table}`;
45
- const refreshed = contracts[key];
46
- if (refreshed && refreshed.content_hash !== stage.satisfies.content_hash) {
47
- throw new Error(`cannot repin '${key}' for target '${target}': untargeted stage '${stage.stage}' ` +
48
- `pins ${stage.satisfies.content_hash.slice(0, 12)}… while ${target} requires ` +
49
- `${refreshed.content_hash.slice(0, 12)}…; align the environments' ORM contracts first`);
50
- }
51
- }
52
- }
53
- function environmentNameForTarget(target) {
54
- if (target === 'dev')
55
- return 'local';
56
- if (target === 'staging' || target === 'production' || target === 'banksouth')
57
- return target;
58
- return undefined;
59
- }
60
- async function assertSharedStageContractsAgree({ contracts, orm, stages, target, }) {
61
- const otherTargets = new Set(stages.flatMap((stage) => stage.environments.filter((candidate) => candidate !== target)));
62
- for (const otherTarget of otherTargets) {
63
- const environmentName = environmentNameForTarget(otherTarget);
64
- if (!environmentName) {
65
- throw new Error(`cannot verify shared ORM pins for target '${otherTarget}'; ` +
66
- 'split multi-target stages or use environment-specific pins');
67
- }
68
- if (isSandboxTokenMode()) {
69
- // Every name resolves to the sandbox deployment, which is not this target's.
70
- throw new Error(`cannot verify shared ORM pins for target '${otherTarget}' from an agent sandbox; ` +
71
- 'it reaches only its own deployment');
72
- }
73
- const otherEnv = await resolveConfiguredEnv({ requested: environmentName });
74
- const otherToken = await getAccessToken({ env: otherEnv.name, targetUrl: otherEnv.url });
75
- const sharedStages = stages.filter((stage) => stage.environments.includes(otherTarget));
76
- const otherContracts = await loadActiveOrmContracts({
77
- env: otherEnv,
78
- orm,
79
- stages: sharedStages,
80
- token: otherToken,
81
- });
82
- for (const stage of sharedStages) {
83
- const key = `${stage.satisfies.namespace}.${stage.satisfies.table}`;
84
- if (contracts[key]?.content_hash !== otherContracts[key]?.content_hash) {
85
- throw new Error(`cannot repin shared stage '${stage.stage}': active ORM contract '${key}' ` +
86
- `differs between targets '${target}' and '${otherTarget}'`);
87
- }
88
- }
89
- }
90
- }
91
- function replacePinnedHash({ contents, currentHash, nextHash, file, }) {
92
- const pattern = new RegExp(`(^\\s*content_hash:\\s*)(["']?)${currentHash}\\2(\\s*(?:#.*)?$)`, 'gm');
93
- const matches = [...contents.matchAll(pattern)];
94
- if (matches.length !== 1) {
95
- throw new Error(`${file}: expected exactly one satisfies.content_hash value '${currentHash}', found ${matches.length}`);
96
- }
97
- return contents.replace(pattern, `$1$2${nextHash}$2$3`);
98
- }
99
- export async function pipelineRepinOrmCommand(args) {
100
- const requested = requestedEnvironment(args);
101
- if (!requested) {
102
- console.error('usage: seq-studio pipeline repin-orm [dir] -e <env> [--target <id>] [--dry-run]');
103
- return 1;
104
- }
105
- const dirArg = args.positional[0] ?? '.';
106
- const dir = resolve(dirArg);
107
- const dryRun = args.flags['dry-run'] === true || args.flags['dry-run'] === 'true';
108
- try {
109
- const { spec, orm } = await loadModules();
110
- const pipeline = await spec.loadSpecDirectory(dir);
111
- const allPinnedStages = pipeline.stages.filter(hasOrmPin);
112
- if (allPinnedStages.length === 0) {
113
- console.log(`${LOG} no ORM satisfies pins found in ${dirArg}`);
114
- return 0;
115
- }
116
- const env = await resolveConfiguredEnv({ requested });
117
- const token = await getAccessToken({ env: env.name, targetUrl: env.url });
118
- const target = (await resolvePipelineTarget({ args, env, token })).id;
119
- const pinnedStages = allPinnedStages.filter((stage) => stage.environments.includes(target));
120
- if (pinnedStages.length === 0) {
121
- console.log(`${LOG} no ORM satisfies pins target ${target} in ${dirArg}`);
122
- return 0;
123
- }
124
- const contracts = await loadActiveOrmContracts({ env, orm, stages: pinnedStages, token });
125
- const nextHashes = new Map();
126
- for (const stage of pinnedStages) {
127
- const binding = stage.satisfies;
128
- const key = `${binding.namespace}.${binding.table}`;
129
- const contract = contracts[key];
130
- if (!contract)
131
- throw new Error(`missing active ORM contract for '${key}'`);
132
- nextHashes.set(stage.stage, contract.content_hash);
133
- }
134
- await assertSharedStageContractsAgree({
135
- contracts,
136
- orm,
137
- stages: pinnedStages,
138
- target,
139
- });
140
- assertNoUntargetedContractCollisions({
141
- contracts,
142
- pinnedStages: allPinnedStages,
143
- target,
144
- });
145
- const catalogPath = join(dir, ORM_CONTRACTS_FILENAME);
146
- const existingContracts = await loadExistingCatalog({ path: catalogPath, spec });
147
- const mergedContracts = { ...existingContracts, ...contracts };
148
- const catalog = spec.ormContractCatalogSchema.parse(mergedContracts);
149
- const compatibilityErrors = pinnedStages.flatMap((stage) => {
150
- const contentHash = nextHashes.get(stage.stage);
151
- if (!contentHash)
152
- throw new Error(`missing active ORM contract for stage '${stage.stage}'`);
153
- const key = `${stage.satisfies.namespace}.${stage.satisfies.table}`;
154
- return spec
155
- .checkServingSatisfiesOrmContract({
156
- projection: {
157
- columns: spec.requireResolvedColumns(stage.projection.columns, `${stage.stage}.projection.columns`),
158
- primary_key: stage.projection.primary_key,
159
- },
160
- satisfies: { ...stage.satisfies, content_hash: contentHash },
161
- contract: catalog[key],
162
- })
163
- .filter((finding) => finding.severity === 'error');
164
- });
165
- if (compatibilityErrors.length > 0) {
166
- compatibilityErrors.forEach((finding) => console.error(`error(${finding.code}): ${finding.message}`));
167
- console.error(`${LOG} refusing to repin: active ORM contracts are incompatible`);
168
- return 1;
169
- }
170
- const writes = [];
171
- for (const stage of pinnedStages) {
172
- const file = pipeline.files.find((candidate) => {
173
- const basename = candidate.split('/').at(-1);
174
- return basename === `${stage.stage}.stage.yml` || basename === `${stage.stage}.stage.yaml`;
175
- });
176
- if (!file)
177
- throw new Error(`could not find the source file for stage '${stage.stage}'`);
178
- const current = await readFile(join(dir, file), 'utf8');
179
- const nextHash = nextHashes.get(stage.stage);
180
- if (!nextHash)
181
- throw new Error(`missing active ORM contract for stage '${stage.stage}'`);
182
- writes.push({
183
- path: join(dir, file),
184
- contents: replacePinnedHash({
185
- contents: current,
186
- currentHash: stage.satisfies.content_hash,
187
- nextHash,
188
- file,
189
- }),
190
- });
191
- }
192
- writes.push({
193
- path: catalogPath,
194
- contents: `${JSON.stringify(mergedContracts, null, 2)}\n`,
195
- });
196
- if (!dryRun) {
197
- await commitFileWrites({ writes });
198
- }
199
- const changed = pinnedStages.filter((stage) => stage.satisfies.content_hash !== nextHashes.get(stage.stage)).length;
200
- console.log(`${LOG} ${dryRun ? 'would repin' : 'repinned'} ${changed} of ${pinnedStages.length} ORM contract pin(s) from ${env.name}`);
201
- return 0;
202
- }
203
- catch (error) {
204
- console.error(`${LOG} ORM repin failed: ${error instanceof Error ? error.message : String(error)}`);
205
- return 1;
206
- }
207
- }