@sequenceholdings/studio-cli 0.9.20 → 0.9.22
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/README.md +159 -12
- package/dist/app/commands.js +37 -7
- package/dist/app/deploy.js +2 -0
- package/dist/app/lockfile-preflight.d.ts +31 -0
- package/dist/app/lockfile-preflight.js +47 -0
- package/dist/app/repository-index.d.ts +5 -1
- package/dist/app/repository-index.js +9 -3
- package/dist/app/scaffold.d.ts +3 -1
- package/dist/app/scaffold.js +5 -3
- package/dist/auth.d.ts +13 -9
- package/dist/auth.js +98 -20
- package/dist/cli-errors.js +6 -1
- package/dist/command-contract.d.ts +13 -1
- package/dist/command-contract.js +3 -1
- package/dist/command-help.d.ts +1 -1
- package/dist/command-help.js +8 -1
- package/dist/config.d.ts +14 -0
- package/dist/config.js +29 -3
- package/dist/docs/commands.d.ts +16 -0
- package/dist/docs/commands.js +168 -0
- package/dist/docs/help.d.ts +2 -0
- package/dist/docs/help.js +12 -0
- package/dist/envs/commands.js +10 -2
- package/dist/host-token.d.ts +19 -4
- package/dist/host-token.js +50 -10
- package/dist/main.d.ts +1 -0
- package/dist/main.js +20 -2
- package/dist/orm/discover-operations.d.ts +1 -1
- package/dist/orm/discover-operations.js +3 -3
- package/dist/orm/discover-schema.d.ts +0 -5
- package/dist/orm/discover-schema.js +0 -3
- package/dist/pipeline/commands.d.ts +0 -7
- package/dist/pipeline/commands.js +16 -67
- package/dist/pipeline/discovery.d.ts +1 -1
- package/dist/pipeline/discovery.js +6 -6
- package/dist/process/build.d.ts +2 -5
- package/dist/process/build.js +4 -49
- package/dist/repos/commands.d.ts +11 -1
- package/dist/repos/commands.js +78 -11
- package/dist/repos/git-credential.d.ts +12 -5
- package/dist/repos/git-credential.js +63 -36
- package/dist/repos/github-connect-command.d.ts +35 -0
- package/dist/repos/github-connect-command.js +250 -0
- package/dist/repos/github-init-command.d.ts +16 -0
- package/dist/repos/github-init-command.js +116 -0
- package/dist/repos/github-init.d.ts +146 -0
- package/dist/repos/github-init.js +355 -0
- package/dist/repos/init-github.d.ts +50 -0
- package/dist/repos/init-github.js +181 -0
- package/dist/repos/pulls.d.ts +5 -1
- package/dist/repos/pulls.js +31 -9
- package/dist/scaffold-guidance.d.ts +10 -2
- package/dist/scaffold-guidance.js +27 -2
- package/dist/templates/github/pr-type.mjs +285 -0
- package/dist/templates/github/pr-types.json +40 -0
- package/dist/templates/guidance/AGENTS.md +15 -8
- package/package.json +7 -7
- package/release-summary.json +3 -1
- package/templates/github/pr-type.mjs +285 -0
- package/templates/github/pr-types.json +40 -0
- package/templates/guidance/AGENTS.md +15 -8
- package/dist/pipeline/active-orm-contracts.d.ts +0 -16
- package/dist/pipeline/active-orm-contracts.js +0 -36
- package/dist/pipeline/repin-orm.d.ts +0 -2
- package/dist/pipeline/repin-orm.js +0 -207
package/dist/repos/pulls.js
CHANGED
|
@@ -9,10 +9,10 @@ import { parseRepoPath, reposContext } from './commands.js';
|
|
|
9
9
|
export const PULLS_USAGE = `usage:
|
|
10
10
|
seq-studio repos pulls list <ns>/<name> -e <env> [--state open|closed|merged] [--limit N] [--cursor <cursor>]
|
|
11
11
|
seq-studio repos pulls show <ns>/<name> <number> -e <env>
|
|
12
|
-
seq-studio repos pulls create <ns>/<name> --head <branch> --base <branch> --title <title> -e <env> [--body-file <path>]
|
|
12
|
+
seq-studio repos pulls create <ns>/<name> --head <branch> --base <branch> --title <title> -e <env> [--body-file <path>] [--type <type>]
|
|
13
13
|
seq-studio repos pulls diff <ns>/<name> <number> -e <env> [--max-files N]
|
|
14
14
|
seq-studio repos pulls merge <ns>/<name> <number> -e <env> [--method squash|merge|ff] [--message <text>] [--yes]
|
|
15
|
-
seq-studio repos pulls edit <ns>/<name> <number> -e <env> [--title <title>] [--body <text> | --body-file <path>]
|
|
15
|
+
seq-studio repos pulls edit <ns>/<name> <number> -e <env> [--title <title>] [--body <text> | --body-file <path>] [--type <type>]
|
|
16
16
|
seq-studio repos pulls close <ns>/<name> <number> -e <env>
|
|
17
17
|
seq-studio repos pulls comment <ns>/<name> <number> -e <env> (--body <text> | --body-file <path>)
|
|
18
18
|
[--path <file> --line N [--side LEFT|RIGHT] [--commit <sha>]] [--reply-to <comment-id>]
|
|
@@ -35,7 +35,11 @@ export const PULLS_USAGE = `usage:
|
|
|
35
35
|
diff compares live base/head branches for open Pulls, recorded SHAs for terminal
|
|
36
36
|
Pulls, and reports truncated when its file
|
|
37
37
|
limit is reached (default 100, maximum 500).
|
|
38
|
-
|
|
38
|
+
Every Pull has a type: bug, performance, enhancement, feature, or chore. It is
|
|
39
|
+
required to merge and feeds bug/performance/feature trend metrics. Pass --type
|
|
40
|
+
on create (agents: always pick one); omit it and a classifier assigns one
|
|
41
|
+
shortly after the Pull opens. edit --type corrects it.
|
|
42
|
+
edit changes an open Pull's title, description, and/or type (at least one). It needs the
|
|
39
43
|
Pull's author or repository write; merged and closed Pulls cannot be edited. It
|
|
40
44
|
prints the updated Pull like show.
|
|
41
45
|
close needs to be the Pull's author or have repository write; it is idempotent.
|
|
@@ -71,10 +75,10 @@ function actionFlags(action) {
|
|
|
71
75
|
switch (action) {
|
|
72
76
|
case 'list': return { state: 'string', limit: 'string', cursor: 'string' };
|
|
73
77
|
case 'show': return {};
|
|
74
|
-
case 'create': return { head: 'string', base: 'string', title: 'string', 'body-file': 'string' };
|
|
78
|
+
case 'create': return { head: 'string', base: 'string', title: 'string', 'body-file': 'string', type: 'string' };
|
|
75
79
|
case 'diff': return { 'max-files': 'string' };
|
|
76
80
|
case 'merge': return { method: 'string', message: 'string', yes: 'boolean' };
|
|
77
|
-
case 'edit': return { title: 'string', body: 'string', 'body-file': 'string' };
|
|
81
|
+
case 'edit': return { title: 'string', body: 'string', 'body-file': 'string', type: 'string' };
|
|
78
82
|
case 'close': return {};
|
|
79
83
|
case 'comment': return { body: 'string', 'body-file': 'string', path: 'string', line: 'string', side: 'string', commit: 'string', 'reply-to': 'string' };
|
|
80
84
|
case 'comments':
|
|
@@ -86,6 +90,17 @@ function actionFlags(action) {
|
|
|
86
90
|
default: throw new Error(`Unknown pulls command: ${action}. See: seq-studio repos pulls --help`);
|
|
87
91
|
}
|
|
88
92
|
}
|
|
93
|
+
/** Mirrors the server's Pull types (atlas git-service `pull-types.ts`); the server is the authority. */
|
|
94
|
+
export const PULL_TYPES = ['bug', 'performance', 'enhancement', 'feature', 'chore'];
|
|
95
|
+
export function pullTypeFlag(args) {
|
|
96
|
+
const value = args.flags.type;
|
|
97
|
+
if (value === undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
if (typeof value !== 'string' || !PULL_TYPES.includes(value)) {
|
|
100
|
+
throw new Error(`--type must be one of: ${PULL_TYPES.join(', ')}.`);
|
|
101
|
+
}
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
89
104
|
async function createBody(args) {
|
|
90
105
|
const headRef = requiredStringFlag({ args, key: 'head' });
|
|
91
106
|
const baseRef = requiredStringFlag({ args, key: 'base' });
|
|
@@ -94,7 +109,8 @@ async function createBody(args) {
|
|
|
94
109
|
const body = typeof bodyFile === 'string' ? await readFile(bodyFile, 'utf8') : undefined;
|
|
95
110
|
if (body !== undefined && body.length > 65_536)
|
|
96
111
|
throw new Error('--body-file exceeds 65,536 characters.');
|
|
97
|
-
|
|
112
|
+
const type = pullTypeFlag(args);
|
|
113
|
+
return { headRef, baseRef, title, ...(body === undefined ? {} : { body }), ...(type === undefined ? {} : { type }) };
|
|
98
114
|
}
|
|
99
115
|
/** Atlas web URL for a Pull: <env origin>/repositories/<ns>/<name>/pull/<number>. */
|
|
100
116
|
export function pullWebUrl({ baseUrl, repoPath, number }) {
|
|
@@ -180,9 +196,15 @@ export async function editBody(args) {
|
|
|
180
196
|
if (typeof title === 'string' && title.length > MAX_TITLE_LENGTH)
|
|
181
197
|
throw new Error('--title exceeds 512 characters.');
|
|
182
198
|
const body = await bodyText(args);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
199
|
+
const type = pullTypeFlag(args);
|
|
200
|
+
if (title === undefined && body === undefined && type === undefined) {
|
|
201
|
+
throw new Error('edit requires --title <title>, --body <text>, --body-file <path>, or --type <type>.');
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
...(typeof title === 'string' ? { title } : {}),
|
|
205
|
+
...(body !== undefined ? { body } : {}),
|
|
206
|
+
...(type !== undefined ? { type } : {}),
|
|
207
|
+
};
|
|
186
208
|
}
|
|
187
209
|
export async function reviewInput(args) {
|
|
188
210
|
const chosen = Object.keys(REVIEW_STATES).filter((flag) => args.flags[flag] === true);
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
/** Add documentation pointers without replacing project-specific instructions. */
|
|
1
|
+
/** Add documentation pointers without replacing project-specific instructions. Returns the files it created. */
|
|
2
2
|
export declare function writeScaffoldGuidance({ directory }: {
|
|
3
3
|
directory: string;
|
|
4
|
-
}): Promise<
|
|
4
|
+
}): Promise<string[]>;
|
|
5
|
+
/**
|
|
6
|
+
* A cloned repository may predate the guidance or carry its own. Add the guidance only when it has no AGENTS.md;
|
|
7
|
+
* otherwise leave the owner's file alone and say how to point it at the docs.
|
|
8
|
+
*/
|
|
9
|
+
export declare function guideClonedCheckout({ directory, envName }: {
|
|
10
|
+
directory: string;
|
|
11
|
+
envName: string;
|
|
12
|
+
}): Promise<string>;
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
|
|
3
|
+
const GUIDANCE_FILES = ['AGENTS.md', 'CLAUDE.md'];
|
|
4
|
+
/** Present in every guidance template revision that points agents at `seq-studio docs`. */
|
|
5
|
+
const DOCS_POINTER = 'seq-studio docs search';
|
|
6
|
+
/** Add documentation pointers without replacing project-specific instructions. Returns the files it created. */
|
|
4
7
|
export async function writeScaffoldGuidance({ directory }) {
|
|
5
|
-
|
|
8
|
+
const created = [];
|
|
9
|
+
for (const name of GUIDANCE_FILES) {
|
|
6
10
|
const body = await readFile(new URL(`../templates/guidance/${name}`, import.meta.url), 'utf8');
|
|
7
11
|
try {
|
|
8
12
|
await writeFile(join(directory, name), body, { flag: 'wx' });
|
|
13
|
+
created.push(name);
|
|
9
14
|
}
|
|
10
15
|
catch (error) {
|
|
11
16
|
if (!(error instanceof Error && 'code' in error && error.code === 'EEXIST'))
|
|
12
17
|
throw error;
|
|
13
18
|
}
|
|
14
19
|
}
|
|
20
|
+
return created;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A cloned repository may predate the guidance or carry its own. Add the guidance only when it has no AGENTS.md;
|
|
24
|
+
* otherwise leave the owner's file alone and say how to point it at the docs.
|
|
25
|
+
*/
|
|
26
|
+
export async function guideClonedCheckout({ directory, envName }) {
|
|
27
|
+
const agents = await readFile(join(directory, 'AGENTS.md'), 'utf8').catch((error) => {
|
|
28
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
29
|
+
return null;
|
|
30
|
+
throw error;
|
|
31
|
+
});
|
|
32
|
+
const docsHint = `seq-studio docs search "<topic>" -e ${envName}`;
|
|
33
|
+
if (agents === null) {
|
|
34
|
+
const created = await writeScaffoldGuidance({ directory });
|
|
35
|
+
return `added ${created.join(' + ')} so coding agents read the platform docs (${docsHint}); commit them to share with your team`;
|
|
36
|
+
}
|
|
37
|
+
if (agents.includes(DOCS_POINTER))
|
|
38
|
+
return `AGENTS.md already points agents at the platform docs (${docsHint})`;
|
|
39
|
+
return `AGENTS.md has no docs pointer; add a line telling agents to run \`${docsHint}\` before using seq-studio`;
|
|
15
40
|
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// Enforces exactly one `type: *` label on every pull request, so merged work can
|
|
2
|
+
// be measured by kind (bug / performance / enhancement / feature / chore).
|
|
3
|
+
//
|
|
4
|
+
// When a PR has no type label, Claude picks one from the title, description and
|
|
5
|
+
// changed paths, applies it, and leaves a comment saying how to change it. The
|
|
6
|
+
// check fails only when the PR has more than one type label, or when no label
|
|
7
|
+
// is present and classification is unavailable.
|
|
8
|
+
//
|
|
9
|
+
// The taxonomy is pr-types.json beside this file (PR_TYPES_PATH). The workflow
|
|
10
|
+
// reads both from the trusted base commit, never the PR head, because this job
|
|
11
|
+
// holds a write-scoped token and an API key. `seq-studio repo init` writes this
|
|
12
|
+
// file into GitHub-hosted Sequence repos; the canonical copy is in studio-cli's
|
|
13
|
+
// templates/github.
|
|
14
|
+
|
|
15
|
+
import { readFile } from 'node:fs/promises'
|
|
16
|
+
|
|
17
|
+
const MODEL = 'claude-opus-5-5'
|
|
18
|
+
const MAX_BODY_CHARS = 6_000
|
|
19
|
+
const MAX_FILES = 300
|
|
20
|
+
const COMMENT_MARKER = '<!-- pr-type-check -->'
|
|
21
|
+
|
|
22
|
+
export async function loadTypes(path) {
|
|
23
|
+
const parsed = JSON.parse(await readFile(path, 'utf8'))
|
|
24
|
+
if (!Array.isArray(parsed.types) || parsed.types.length === 0) throw new Error(`${path} has no types`)
|
|
25
|
+
return parsed.types
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Pure decision: which type labels does this PR carry? */
|
|
29
|
+
export function evaluateLabels({ labelNames, types }) {
|
|
30
|
+
const byLabel = new Map(types.map((t) => [t.label.toLowerCase(), t]))
|
|
31
|
+
const found = labelNames.map((name) => byLabel.get(name.toLowerCase())).filter(Boolean)
|
|
32
|
+
if (found.length === 1) return { status: 'ok', type: found[0] }
|
|
33
|
+
if (found.length === 0) return { status: 'missing' }
|
|
34
|
+
return { status: 'multiple', types: found }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function buildPrompt({ types, title, body, files }) {
|
|
38
|
+
const taxonomy = types.map((t) => `- ${t.id}: ${t.description}. ${t.guidance}`).join('\n')
|
|
39
|
+
const fileList = files.slice(0, MAX_FILES).join('\n')
|
|
40
|
+
const more = files.length > MAX_FILES ? `\n(${files.length - MAX_FILES} more files not shown)` : ''
|
|
41
|
+
return [
|
|
42
|
+
'Classify this pull request into exactly one type. The labels feed engineering metrics:',
|
|
43
|
+
'how many bugs we fix over time, how much performance work we do, how often we fill gaps',
|
|
44
|
+
'in existing features, how much net-new feature work we ship, and how much maintenance.',
|
|
45
|
+
'',
|
|
46
|
+
'Types:',
|
|
47
|
+
taxonomy,
|
|
48
|
+
'',
|
|
49
|
+
'Pick by the main intent of the change, not by incidental edits. A fix to something that',
|
|
50
|
+
'was broken is a bug even when it touches infrastructure files. A change that only moves',
|
|
51
|
+
'or tidies code, bumps dependencies, or edits CI/docs is a chore.',
|
|
52
|
+
'',
|
|
53
|
+
`<title>${title}</title>`,
|
|
54
|
+
`<description>${(body ?? '').slice(0, MAX_BODY_CHARS)}</description>`,
|
|
55
|
+
`<changed_files>\n${fileList}${more}\n</changed_files>`,
|
|
56
|
+
].join('\n')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Validates the structured-output JSON; returns a known type id or throws. */
|
|
60
|
+
export function parseClassification({ text, types }) {
|
|
61
|
+
const parsed = JSON.parse(text)
|
|
62
|
+
const ids = new Set(types.map((t) => t.id))
|
|
63
|
+
if (typeof parsed?.type !== 'string' || !ids.has(parsed.type)) {
|
|
64
|
+
throw new Error(`classifier returned an unknown type: ${JSON.stringify(parsed?.type)}`)
|
|
65
|
+
}
|
|
66
|
+
const reason = typeof parsed.reason === 'string' ? parsed.reason.slice(0, 300) : ''
|
|
67
|
+
return { id: parsed.type, reason }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function classify({ apiKey, types, title, body, files }) {
|
|
71
|
+
const res = await fetch('https://api.anthropic.com/v1/messages', {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
'content-type': 'application/json',
|
|
75
|
+
'x-api-key': apiKey,
|
|
76
|
+
'anthropic-version': '2026-10-21',
|
|
77
|
+
'anthropic-beta': 'server-side-fallback-2026-07-01',
|
|
78
|
+
},
|
|
79
|
+
body: JSON.stringify({
|
|
80
|
+
model: MODEL,
|
|
81
|
+
max_tokens: 2_000,
|
|
82
|
+
fallbacks: 'default',
|
|
83
|
+
output_config: {
|
|
84
|
+
effort: 'low',
|
|
85
|
+
format: {
|
|
86
|
+
type: 'json_schema',
|
|
87
|
+
schema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
type: { type: 'string', enum: types.map((t) => t.id) },
|
|
91
|
+
reason: { type: 'string' },
|
|
92
|
+
},
|
|
93
|
+
required: ['type', 'reason'],
|
|
94
|
+
additionalProperties: false,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
messages: [{ role: 'user', content: buildPrompt({ types, title, body, files }) }],
|
|
99
|
+
}),
|
|
100
|
+
})
|
|
101
|
+
if (!res.ok) throw new Error(`Anthropic API ${res.status}: ${(await res.text()).slice(0, 500)}`)
|
|
102
|
+
const message = await res.json()
|
|
103
|
+
if (message?.stop_reason === 'refusal') throw new Error('classifier declined the request')
|
|
104
|
+
const text = Array.isArray(message?.content) ? message.content.find((b) => b?.type === 'text')?.text : undefined
|
|
105
|
+
if (typeof text !== 'string') throw new Error('classifier returned no text block')
|
|
106
|
+
return parseClassification({ text, types })
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function github({ token, repo }) {
|
|
110
|
+
const base = `https://api.github.com/repos/${repo}`
|
|
111
|
+
return async (method, path, body) => {
|
|
112
|
+
const res = await fetch(`${base}${path}`, {
|
|
113
|
+
method,
|
|
114
|
+
headers: {
|
|
115
|
+
authorization: `Bearer ${token}`,
|
|
116
|
+
accept: 'application/vnd.github+json',
|
|
117
|
+
'x-github-api-version': '2022-11-28',
|
|
118
|
+
...(body ? { 'content-type': 'application/json' } : {}),
|
|
119
|
+
},
|
|
120
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
121
|
+
})
|
|
122
|
+
if (!res.ok) {
|
|
123
|
+
const error = new Error(`GitHub ${method} ${path}: ${res.status} ${(await res.text()).slice(0, 300)}`)
|
|
124
|
+
error.status = res.status
|
|
125
|
+
throw error
|
|
126
|
+
}
|
|
127
|
+
return res.status === 204 ? null : res.json()
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Creates or updates every label in the taxonomy. Idempotent. */
|
|
132
|
+
export async function syncLabels({ gh, types }) {
|
|
133
|
+
for (const t of types) {
|
|
134
|
+
const fields = { color: t.color, description: t.description.slice(0, 100) }
|
|
135
|
+
try {
|
|
136
|
+
await gh('PATCH', `/labels/${encodeURIComponent(t.label)}`, fields)
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error.status !== 404) throw error
|
|
139
|
+
await gh('POST', '/labels', { name: t.label, ...fields })
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function listFiles({ gh, number }) {
|
|
145
|
+
const files = []
|
|
146
|
+
for (let page = 1; page <= 3; page += 1) {
|
|
147
|
+
const batch = await gh('GET', `/pulls/${number}/files?per_page=100&page=${page}`)
|
|
148
|
+
files.push(...batch.map((f) => f.filename))
|
|
149
|
+
if (batch.length < 100) break
|
|
150
|
+
}
|
|
151
|
+
return files
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const WEEK_MS = 7 * 24 * 60 * 60 * 1000
|
|
155
|
+
|
|
156
|
+
/** Monday 00:00 UTC of the week containing `date`, as YYYY-MM-DD. */
|
|
157
|
+
export function weekStart(date) {
|
|
158
|
+
const day = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()))
|
|
159
|
+
day.setUTCDate(day.getUTCDate() - ((day.getUTCDay() + 6) % 7))
|
|
160
|
+
return day.toISOString().slice(0, 10)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Merged PRs per week per type; PRs without exactly one type label count as `untyped`. */
|
|
164
|
+
export function bucketMergedPulls({ pulls, types, since }) {
|
|
165
|
+
const buckets = new Map()
|
|
166
|
+
for (const pull of pulls) {
|
|
167
|
+
if (!pull.merged_at) continue
|
|
168
|
+
const mergedAt = new Date(pull.merged_at)
|
|
169
|
+
if (mergedAt < since) continue
|
|
170
|
+
const week = weekStart(mergedAt)
|
|
171
|
+
const row = buckets.get(week) ?? Object.fromEntries([...types.map((t) => [t.id, 0]), ['untyped', 0]])
|
|
172
|
+
const verdict = evaluateLabels({ labelNames: (pull.labels ?? []).map((l) => l.name), types })
|
|
173
|
+
row[verdict.status === 'ok' ? verdict.type.id : 'untyped'] += 1
|
|
174
|
+
buckets.set(week, row)
|
|
175
|
+
}
|
|
176
|
+
return [...buckets.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([week, counts]) => ({ week, ...counts }))
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function renderReport({ rows, types }) {
|
|
180
|
+
const columns = [...types.map((t) => t.id), 'untyped']
|
|
181
|
+
const lines = [`| week of | ${columns.join(' | ')} | total | bug share |`, `|---|${columns.map(() => '---:').join('|')}|---:|---:|`]
|
|
182
|
+
for (const row of rows) {
|
|
183
|
+
const total = columns.reduce((sum, c) => sum + row[c], 0)
|
|
184
|
+
const typed = total - row.untyped
|
|
185
|
+
const share = typed > 0 ? `${Math.round((100 * row.bug) / typed)}%` : '—'
|
|
186
|
+
lines.push(`| ${row.week} | ${columns.map((c) => row[c]).join(' | ')} | ${total} | ${share} |`)
|
|
187
|
+
}
|
|
188
|
+
return lines.join('\n')
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Closed PRs updated since `since`, newest first, stopping once a page is entirely older. */
|
|
192
|
+
async function listClosedPulls({ gh, since }) {
|
|
193
|
+
const pulls = []
|
|
194
|
+
for (let page = 1; page <= 50; page += 1) {
|
|
195
|
+
const batch = await gh('GET', `/pulls?state=closed&sort=updated&direction=desc&per_page=100&page=${page}`)
|
|
196
|
+
pulls.push(...batch)
|
|
197
|
+
if (batch.length < 100 || batch.every((p) => new Date(p.updated_at) < since)) break
|
|
198
|
+
}
|
|
199
|
+
return pulls
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function fixInstructions(types) {
|
|
203
|
+
const list = types.map((t) => `\`${t.label}\``).join(', ')
|
|
204
|
+
return `Add exactly one of ${list}, e.g. \`gh pr edit <number> --add-label "${types[0].label}"\`.`
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function main() {
|
|
208
|
+
const types = await loadTypes(process.env.PR_TYPES_PATH ?? '.github/pr-types.json')
|
|
209
|
+
const repo = process.env.GITHUB_REPOSITORY
|
|
210
|
+
const gh = github({ token: process.env.GITHUB_TOKEN, repo })
|
|
211
|
+
|
|
212
|
+
if (process.argv[2] === 'report') {
|
|
213
|
+
const weeksIndex = process.argv.indexOf('--weeks')
|
|
214
|
+
const weeks = weeksIndex > 0 ? Number(process.argv[weeksIndex + 1]) : 12
|
|
215
|
+
if (!Number.isInteger(weeks) || weeks < 1 || weeks > 52) throw new Error('--weeks must be an integer from 1 to 52')
|
|
216
|
+
const since = new Date(`${weekStart(new Date(Date.now() - (weeks - 1) * WEEK_MS))}T00:00:00Z`)
|
|
217
|
+
const rows = bucketMergedPulls({ pulls: await listClosedPulls({ gh, since }), types, since })
|
|
218
|
+
console.log(`Merged PRs on ${repo} by type, weekly (UTC, weeks start Monday). Bug share is of typed PRs.\n`)
|
|
219
|
+
console.log(renderReport({ rows, types }))
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (process.argv[2] === 'sync-labels') {
|
|
224
|
+
await syncLabels({ gh, types })
|
|
225
|
+
console.log(`Synced ${types.length} type labels on ${repo}.`)
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const event = JSON.parse(await readFile(process.env.GITHUB_EVENT_PATH, 'utf8'))
|
|
230
|
+
const number = event.pull_request?.number
|
|
231
|
+
if (!number) throw new Error('This check runs on pull_request events only.')
|
|
232
|
+
|
|
233
|
+
// Re-read labels: the event payload is a snapshot from when the event fired.
|
|
234
|
+
const pull = await gh('GET', `/pulls/${number}`)
|
|
235
|
+
const verdict = evaluateLabels({ labelNames: pull.labels.map((l) => l.name), types })
|
|
236
|
+
|
|
237
|
+
if (verdict.status === 'ok') {
|
|
238
|
+
console.log(`PR #${number} is typed as ${verdict.type.label}.`)
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
if (verdict.status === 'multiple') {
|
|
242
|
+
console.error(`PR #${number} has ${verdict.types.length} type labels (${verdict.types.map((t) => t.label).join(', ')}). Keep exactly one.`)
|
|
243
|
+
process.exitCode = 1
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Label events only re-check: classifying on `unlabeled` would race an author
|
|
248
|
+
// who removed one type label to add another.
|
|
249
|
+
if (process.env.PR_TYPE_CLASSIFY !== 'true') {
|
|
250
|
+
console.error(`PR #${number} has no type label. ${fixInstructions(types)}`)
|
|
251
|
+
process.exitCode = 1
|
|
252
|
+
return
|
|
253
|
+
}
|
|
254
|
+
const apiKey = process.env.ANTHROPIC_API_KEY
|
|
255
|
+
if (!apiKey) {
|
|
256
|
+
console.error(`PR #${number} has no type label and no classifier key is available. ${fixInstructions(types)}`)
|
|
257
|
+
process.exitCode = 1
|
|
258
|
+
return
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let picked
|
|
262
|
+
try {
|
|
263
|
+
picked = await classify({ apiKey, types, title: pull.title, body: pull.body, files: await listFiles({ gh, number }) })
|
|
264
|
+
} catch (error) {
|
|
265
|
+
console.error(`Could not classify PR #${number}: ${error.message}\n${fixInstructions(types)}`)
|
|
266
|
+
process.exitCode = 1
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const type = types.find((t) => t.id === picked.id)
|
|
271
|
+
await syncLabels({ gh, types: [type] })
|
|
272
|
+
await gh('POST', `/issues/${number}/labels`, { labels: [type.label] })
|
|
273
|
+
const others = types.filter((t) => t.id !== type.id).map((t) => `\`${t.label}\``).join(', ')
|
|
274
|
+
await gh('POST', `/issues/${number}/comments`, {
|
|
275
|
+
body: `${COMMENT_MARKER}\nLabelled this PR **\`${type.label}\`**: ${picked.reason}\n\nIf that's wrong, swap it for one of ${others}. Every PR needs exactly one type label; they feed our bug / performance / feature trend metrics.\n\n---\n_Generated by [Claude Code](https://claude.ai/code)_`,
|
|
276
|
+
})
|
|
277
|
+
console.log(`PR #${number} had no type label; applied ${type.label} (${picked.reason}).`)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
281
|
+
main().catch((error) => {
|
|
282
|
+
console.error(error)
|
|
283
|
+
process.exitCode = 1
|
|
284
|
+
})
|
|
285
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Every pull request carries exactly one type label. Canonical copy: studio shared/services/studio-cli/templates/github/pr-types.json; Git Service Pulls mirror it in atlas git-service/pull-types.ts (a test enforces it). Add a type, never rename one: renaming splits the trend lines.",
|
|
3
|
+
"types": [
|
|
4
|
+
{
|
|
5
|
+
"id": "bug",
|
|
6
|
+
"label": "type: bug",
|
|
7
|
+
"color": "d73a4a",
|
|
8
|
+
"description": "Fixes behavior that is broken or wrong",
|
|
9
|
+
"guidance": "Something that used to work, or was meant to work, does the wrong thing: an error, a crash, wrong data, a regression."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "performance",
|
|
13
|
+
"label": "type: performance",
|
|
14
|
+
"color": "fbca04",
|
|
15
|
+
"description": "Makes something faster, cheaper, or more reliable under load",
|
|
16
|
+
"guidance": "Latency, memory, cost, timeouts, rate limits, query plans, bundle size. Behavior is correct before and after; it is just slow or expensive."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "enhancement",
|
|
20
|
+
"label": "type: enhancement",
|
|
21
|
+
"color": "a2eeef",
|
|
22
|
+
"description": "Fills a gap in an existing feature",
|
|
23
|
+
"guidance": "A capability that already exists but is missing something users would reasonably expect it to have: a missing filter, an edge case, a missing field, better UX on an existing flow."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "feature",
|
|
27
|
+
"label": "type: feature",
|
|
28
|
+
"color": "0e8a16",
|
|
29
|
+
"description": "Adds a new capability",
|
|
30
|
+
"guidance": "Something users or developers could not do at all before: a new product surface, app, integration, command, or workflow."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "chore",
|
|
34
|
+
"label": "type: chore",
|
|
35
|
+
"color": "c5def5",
|
|
36
|
+
"description": "Maintenance with no user-facing behavior change",
|
|
37
|
+
"guidance": "Infrastructure, CI, dependencies, refactors, docs, tests, tooling, config, and agent guides."
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
# Sequence development
|
|
2
2
|
|
|
3
|
-
Before every development task, read the
|
|
4
|
-
target environment.
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/studio-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.22",
|
|
4
4
|
"description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth whoami`. Includes Auth0 browser login shared with seqapi.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"tsx": "^4.20.3",
|
|
46
46
|
"yaml": "^2.8.4",
|
|
47
47
|
"zod": "4.6.6",
|
|
48
|
-
"@sequenceholdings/
|
|
49
|
-
"@sequenceholdings/
|
|
50
|
-
"@sequenceholdings/lattice": "0.1.8",
|
|
48
|
+
"@sequenceholdings/artifact-studio": "0.11.19",
|
|
49
|
+
"@sequenceholdings/lattice": "0.1.9",
|
|
51
50
|
"@sequenceholdings/managed-functions": "0.5.13",
|
|
52
51
|
"@sequenceholdings/storage": "0.1.8",
|
|
53
|
-
"@sequenceholdings/platform": "0.1.5"
|
|
52
|
+
"@sequenceholdings/platform": "0.1.5",
|
|
53
|
+
"@sequenceholdings/agent-spec": "0.1.6"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@sequenceholdings/
|
|
57
|
-
"@sequenceholdings/
|
|
56
|
+
"@sequenceholdings/orm": "2.11.0",
|
|
57
|
+
"@sequenceholdings/pipeline-spec": "0.3.12"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@sequenceholdings/orm": {
|
package/release-summary.json
CHANGED
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
"0.9.18-next.0": "Preview build for testing automatic CLI updates on the next track. No command behavior changes.",
|
|
4
4
|
"0.9.18": "Artifact builds now use Atlas UI 3.7.0, including DatePicker and DateRangePicker.",
|
|
5
5
|
"0.9.19": "Next.js artifact manifests can name secrets without a version (and in another org with secret_org), name a service account by slug, and key storage by workspace name, so one manifest deploys to every environment.",
|
|
6
|
-
"0.9.20": "Lattice date forms now use DatePicker instead of the browser's native date popup."
|
|
6
|
+
"0.9.20": "Lattice date forms now use DatePicker instead of the browser's native date popup.",
|
|
7
|
+
"0.9.21": "New seq-studio docs search|read|list; repos clone adds agent docs guidance. Clones roll back on failure; new repos attach-login. Devbox sign-in no longer uses a shared identity. Browser login fails fast without a terminal. envs add accepts local:<name>. init and deploy flag lockfiles CI can't use.",
|
|
8
|
+
"0.9.22": "New init --github <owner>/<name> --org <org> starts an app in its own new private GitHub repository. repos pulls create and edit take --type (bug, performance, enhancement, feature, chore); a Pull needs one to merge. repo init adds a required pr-type check."
|
|
7
9
|
}
|