@golden-frijoles/cli 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
package/README.md CHANGED
@@ -80,6 +80,21 @@ else** — no progress lines, no warnings. A failure is a JSON document too, on
80
80
  `--help` output and these envelopes are pinned by golden-file tests. They do not change on a copy
81
81
  edit.
82
82
 
83
+ ## Sending a North Star: `gf north-star set`
84
+
85
+ The `north-star` coach in the Golden Frijoles plugin leaves `Roadmap/00-strategy/north-star.md`, with the metric and
86
+ its inputs in one ```json block under `## Sync payload`. This command sends that block to your project:
87
+
88
+ ```bash
89
+ gf north-star set Roadmap/00-strategy/north-star.md # dry run: shows what would change, sends nothing
90
+ gf north-star set Roadmap/00-strategy/north-star.md --yes # sends it once (project owners only)
91
+ ```
92
+
93
+ A sync never replaces or deletes. A new metric key is **added** beside an existing North Star, and an input key that
94
+ already exists **moves** to this metric. The dry run says so before anything is sent, and to revise a North Star you
95
+ reuse its key. The server validates the block and prints its `issues` on a 400. A file that still has the template's
96
+ `<…>` placeholders is refused before anything is sent.
97
+
83
98
  ## Exit codes
84
99
 
85
100
  | Code | Name | Means |
@@ -181,6 +181,7 @@ exports.whoamiCommand = {
181
181
  return (0, exit_codes_1.exitForServerCode)(result.code);
182
182
  }
183
183
  const { account, credential, projects } = result.body;
184
+ const workspaces = result.body.workspaces ?? [];
184
185
  context.emit.ok({
185
186
  account,
186
187
  // The credential's id and LABEL. Never the token — `gf doctor`'s rule applies here too, and
@@ -190,9 +191,12 @@ exports.whoamiCommand = {
190
191
  tokenSource: context.auth.source,
191
192
  activeProject: context.auth.activeProject,
192
193
  projects,
194
+ workspaces,
193
195
  }, [
194
196
  `${account.email ?? account.userId} on ${context.api.baseUrl}`,
195
197
  `credential: ${credential.label} (from ${describeSource(context.auth.source)})`,
198
+ // The tenant (workspaces S2.3): one line per workspace, so a person in two sees both.
199
+ ...workspaces.map((workspace) => `workspace: ${workspace.name}`),
196
200
  `active project: ${context.auth.activeProject ?? 'none — run `gf projects use <slug>`'}`,
197
201
  '',
198
202
  (0, output_1.table)(['PROJECT', 'ROLE'], projects.map((project) => [
@@ -13,6 +13,7 @@ const flags_read_1 = require("./flags-read");
13
13
  const flags_write_1 = require("./flags-write");
14
14
  const flags_history_1 = require("./flags-history");
15
15
  const flags_sync_1 = require("./flags-sync");
16
+ const north_star_1 = require("./north-star");
16
17
  const keys_1 = require("./keys");
17
18
  const doctor_1 = require("./doctor");
18
19
  const config_1 = require("./config");
@@ -39,6 +40,7 @@ exports.COMMANDS = [
39
40
  flags_history_1.flagsDiffCommand,
40
41
  flags_history_1.flagsHistoryCommand,
41
42
  flags_sync_1.flagsSyncCommand,
43
+ north_star_1.northStarSetCommand,
42
44
  keys_1.keysLsCommand,
43
45
  keys_1.keysCreateCommand,
44
46
  keys_1.keysRevokeCommand,
@@ -0,0 +1,46 @@
1
+ import type { Command } from '../command';
2
+ type SyncPayload = {
3
+ metric?: {
4
+ key?: unknown;
5
+ name?: unknown;
6
+ description?: unknown;
7
+ };
8
+ inputs?: unknown;
9
+ };
10
+ type CurrentInput = {
11
+ key: string;
12
+ name: string;
13
+ valueSource: string;
14
+ sourceEvent: string | null;
15
+ };
16
+ type CurrentMetric = {
17
+ key: string;
18
+ name: string;
19
+ description: string | null;
20
+ inputs: CurrentInput[];
21
+ };
22
+ /** The one ```json block under `## Sync payload`. Throws a sentence a person can act on. */
23
+ export declare function readSyncBlock(markdown: string): unknown;
24
+ /** Every string value still shaped like a template placeholder, as a path: `metric.key`, `inputs[1].sourceEvent`. */
25
+ export declare function unfilledPaths(value: unknown, path?: string): string[];
26
+ export type InputChange = {
27
+ key: string;
28
+ name: string;
29
+ change: string;
30
+ };
31
+ export type SyncPlan = {
32
+ metric: {
33
+ key: string;
34
+ name: string;
35
+ change: 'new' | 'updated' | 'unchanged';
36
+ };
37
+ otherMetrics: string[];
38
+ inputs: InputChange[];
39
+ };
40
+ /**
41
+ * What a sync of `proposed` would do to `current`, in the route's own terms (upsert on key, never delete).
42
+ * Presentation only: whether the payload is VALID is the server's question, answered on `--yes`.
43
+ */
44
+ export declare function planSync(current: CurrentMetric[], proposed: SyncPayload): SyncPlan;
45
+ export declare const northStarSetCommand: Command;
46
+ export {};
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ // think-skills S3 (D6) — `gf north-star set <file>`: the North Star workshop's metric reaches the engine.
3
+ //
4
+ // ── A thin shell over one route ───────────────────────────────────────────────────────────────────────────────────
5
+ // The `north-star` coach leaves `Roadmap/00-strategy/north-star.md`, whose `## Sync payload` section holds exactly one
6
+ // ```json block. This command reads that block and nothing else, and sends it to `/api/v1/cli/north-star`. The SERVER
7
+ // validates it (`northStarSyncSchema`) and its `issues` are printed verbatim on a 400, the same rule `flags-write.ts`
8
+ // follows: one judge of what a valid North Star is, and it lives on the server.
9
+ //
10
+ // ── Dry run by default ────────────────────────────────────────────────────────────────────────────────────────────
11
+ // Without `--yes` it makes ONE request, a GET of the project's current North Star, prints what a sync would do, and
12
+ // sends nothing. A sync never replaces or deletes (think-skills C2): a new metric key is ADDED beside any existing
13
+ // metric, and an input key that already exists MOVES to this metric. Both effects are named before anything is sent,
14
+ // because neither can be undone by syncing again.
15
+ //
16
+ // ── An unfilled template is refused here ──────────────────────────────────────────────────────────────────────────
17
+ // The template's `<metric_key>` placeholders satisfy the schema (any non-empty string does), so the server would store
18
+ // them. A value still shaped `<…>` is a file the coach never finished, not a North Star; `--yes` refuses it with
19
+ // nothing sent. That is a check on the TEMPLATE, not a second copy of the schema.
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.northStarSetCommand = void 0;
22
+ exports.readSyncBlock = readSyncBlock;
23
+ exports.unfilledPaths = unfilledPaths;
24
+ exports.planSync = planSync;
25
+ const node_fs_1 = require("node:fs");
26
+ const node_path_1 = require("node:path");
27
+ const args_1 = require("../args");
28
+ const exit_codes_1 = require("../exit-codes");
29
+ const output_1 = require("../output");
30
+ const flags_read_1 = require("./flags-read");
31
+ const SECTION = '## Sync payload';
32
+ /** The one ```json block under `## Sync payload`. Throws a sentence a person can act on. */
33
+ function readSyncBlock(markdown) {
34
+ const lines = markdown.replace(/\r\n/g, '\n').split('\n');
35
+ const start = lines.findIndex((line) => line.trim() === SECTION);
36
+ if (start === -1)
37
+ throw new Error(`no "${SECTION}" section — is this the file the north-star coach wrote?`);
38
+ const end = lines.findIndex((line, i) => i > start && line.startsWith('## '));
39
+ const body = lines.slice(start + 1, end === -1 ? undefined : end).join('\n');
40
+ const fences = [...body.matchAll(/^```json\n([\s\S]*?)\n```$/gm)];
41
+ if (fences.length !== 1) {
42
+ throw new Error(`expected exactly one \`\`\`json block under "${SECTION}", found ${fences.length}`);
43
+ }
44
+ let parsed;
45
+ try {
46
+ parsed = JSON.parse(fences[0][1]);
47
+ }
48
+ catch (err) {
49
+ throw new Error(`the json block does not parse: ${err instanceof Error ? err.message : String(err)}`);
50
+ }
51
+ // An object, or it is not a North Star at all: `null` or a list would otherwise reach the planner as a stack trace.
52
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
53
+ throw new Error('the json block must be an object with `metric` and `inputs`');
54
+ }
55
+ return parsed;
56
+ }
57
+ /** Every string value still shaped like a template placeholder, as a path: `metric.key`, `inputs[1].sourceEvent`. */
58
+ function unfilledPaths(value, path = '') {
59
+ if (typeof value === 'string')
60
+ return /^<.*>$/.test(value.trim()) ? [path || '(value)'] : [];
61
+ if (Array.isArray(value))
62
+ return value.flatMap((item, i) => unfilledPaths(item, `${path}[${i}]`));
63
+ if (value && typeof value === 'object') {
64
+ return Object.entries(value).flatMap(([key, item]) => unfilledPaths(item, path ? `${path}.${key}` : key));
65
+ }
66
+ return [];
67
+ }
68
+ /**
69
+ * What a sync of `proposed` would do to `current`, in the route's own terms (upsert on key, never delete).
70
+ * Presentation only: whether the payload is VALID is the server's question, answered on `--yes`.
71
+ */
72
+ function planSync(current, proposed) {
73
+ const metricKey = String(proposed.metric?.key ?? '');
74
+ const metricName = String(proposed.metric?.name ?? '');
75
+ const existing = current.find((m) => m.key === metricKey);
76
+ const description = proposed.metric?.description ?? null;
77
+ const metricChange = !existing
78
+ ? 'new'
79
+ : existing.name !== metricName || (existing.description ?? null) !== description
80
+ ? 'updated'
81
+ : 'unchanged';
82
+ const owner = new Map();
83
+ for (const metric of current)
84
+ for (const input of metric.inputs)
85
+ owner.set(input.key, { metric: metric.key, input });
86
+ const inputs = (Array.isArray(proposed.inputs) ? proposed.inputs : []).map((input) => {
87
+ const key = String(input?.key ?? '');
88
+ const name = String(input?.name ?? '');
89
+ const found = owner.get(key);
90
+ let change;
91
+ if (!found)
92
+ change = 'new';
93
+ else if (found.input.valueSource !== input?.valueSource) {
94
+ // The route refuses this (an existing input's value source never changes), so say so before sending.
95
+ change = `refused: value source is ${found.input.valueSource}`;
96
+ }
97
+ else if (found.metric !== metricKey)
98
+ change = `moved from ${found.metric}`;
99
+ else if (found.input.name !== name ||
100
+ (found.input.sourceEvent ?? undefined) !== (input?.sourceEvent ?? undefined))
101
+ change = 'updated';
102
+ else
103
+ change = 'unchanged';
104
+ return { key, name, change };
105
+ });
106
+ return {
107
+ metric: { key: metricKey, name: metricName, change: metricChange },
108
+ otherMetrics: current.filter((m) => m.key !== metricKey).map((m) => m.key),
109
+ inputs,
110
+ };
111
+ }
112
+ function describePlan(project, plan, unfilled) {
113
+ const lines = [
114
+ `North Star for ${project}:`,
115
+ '',
116
+ ` metric ${plan.metric.key} "${plan.metric.name}" ${plan.metric.change}`,
117
+ ];
118
+ if (plan.otherMetrics.length > 0) {
119
+ lines.push(` This project already has ${plan.otherMetrics.length === 1 ? 'another North Star' : `${plan.otherMetrics.length} other North Stars`}: ${plan.otherMetrics.join(', ')}.`, ' A sync ADDS this one beside it. It never replaces or deletes. To revise one, reuse its key.');
120
+ }
121
+ lines.push('', (0, output_1.table)(['INPUT', 'NAME', 'CHANGE'], plan.inputs.map((input) => [input.key, input.name, input.change])));
122
+ if (unfilled.length > 0) {
123
+ lines.push('', `Not filled in yet (still a template placeholder): ${unfilled.join(', ')}.`);
124
+ }
125
+ return lines.join('\n');
126
+ }
127
+ /** Zod's flattened `issues`, as lines. Anything else is shown as JSON rather than guessed at. */
128
+ function issueLines(issues) {
129
+ if (!issues || typeof issues !== 'object')
130
+ return [];
131
+ const { formErrors, fieldErrors } = issues;
132
+ if (!Array.isArray(formErrors) && (!fieldErrors || typeof fieldErrors !== 'object')) {
133
+ return [` ${JSON.stringify(issues)}`];
134
+ }
135
+ const out = (Array.isArray(formErrors) ? formErrors : []).map((message) => ` - ${String(message)}`);
136
+ for (const [field, messages] of Object.entries((fieldErrors ?? {}))) {
137
+ for (const message of Array.isArray(messages) ? messages : [messages])
138
+ out.push(` - ${field}: ${String(message)}`);
139
+ }
140
+ return out;
141
+ }
142
+ /** The dry run's last sentence. It never invites a `--yes` that is certain to be refused. */
143
+ function nextStep(plan, unfilled) {
144
+ if (unfilled.length > 0)
145
+ return 'Fill in the placeholders first: --yes refuses a file that still has them.';
146
+ const refused = plan.inputs.filter((input) => input.change.startsWith('refused'));
147
+ if (refused.length > 0) {
148
+ return `--yes would be refused: an existing input's value source never changes (${refused.map((i) => i.key).join(', ')}). Use a new key, or keep its value source.`;
149
+ }
150
+ return 'Run again with --yes to send it.';
151
+ }
152
+ async function readCurrent(context, project) {
153
+ const response = await context.api.get('/api/v1/cli/north-star', { project });
154
+ if (response.kind === 'network') {
155
+ context.emit.fail('network', response.message);
156
+ return exit_codes_1.EXIT.SERVER;
157
+ }
158
+ if (response.kind === 'error') {
159
+ context.emit.fail(response.code, response.message);
160
+ return (0, exit_codes_1.exitForServerCode)(response.code);
161
+ }
162
+ return Array.isArray(response.body.metrics) ? response.body.metrics : [];
163
+ }
164
+ exports.northStarSetCommand = {
165
+ path: ['north-star', 'set'],
166
+ summary: "send a North Star workshop's metric and inputs to the project",
167
+ usage: 'gf north-star set <file> [--yes] [--project <slug>]',
168
+ needsAuth: true,
169
+ detail: `Reads the one \`\`\`json block under "## Sync payload" in <file> — the
170
+ Roadmap/00-strategy/north-star.md the north-star coach writes.
171
+
172
+ Without --yes it is a DRY RUN: it reads the project's current North Star, prints what a sync
173
+ would do, and sends nothing. With --yes it sends the block once and prints the result.
174
+
175
+ ⚠️ A sync never replaces or deletes. A new metric key is ADDED beside an existing North Star,
176
+ and an input key that already exists MOVES to this metric. To revise a North Star, reuse its key.
177
+ Owner-only to send; any member can dry-run.`,
178
+ flags: [
179
+ { name: 'yes', describe: 'send it (without this, nothing is sent)' },
180
+ { name: 'project', value: '<slug>', describe: 'the project (default: the remembered one)' },
181
+ ],
182
+ async run(context) {
183
+ const file = context.args.positionals[0];
184
+ if (!file) {
185
+ context.emit.fail('invalid', 'Usage: `gf north-star set <file>` — e.g. Roadmap/00-strategy/north-star.md.');
186
+ return exit_codes_1.EXIT.USAGE;
187
+ }
188
+ const project = (0, flags_read_1.resolveProject)(context);
189
+ if (!project)
190
+ return (0, flags_read_1.missingProject)(context);
191
+ let payload;
192
+ try {
193
+ payload = readSyncBlock((0, node_fs_1.readFileSync)((0, node_path_1.resolve)(context.cwd, file), 'utf8'));
194
+ }
195
+ catch (err) {
196
+ context.emit.fail('invalid', `${file}: ${err instanceof Error ? err.message : String(err)}. Nothing was sent.`);
197
+ return exit_codes_1.EXIT.USAGE;
198
+ }
199
+ const unfilled = unfilledPaths(payload);
200
+ const send = (0, args_1.boolFlag)(context.args, 'yes');
201
+ // Refused BEFORE any request: a template the coach never finished is not something to read the project for, let
202
+ // alone write.
203
+ if (send && unfilled.length > 0) {
204
+ context.emit.fail('invalid', `${file} still has template placeholders (${unfilled.join(', ')}). Fill them in, then run this again. Nothing was sent.`, { unfilled });
205
+ return exit_codes_1.EXIT.USAGE;
206
+ }
207
+ const current = await readCurrent(context, project);
208
+ if (typeof current === 'number')
209
+ return current;
210
+ const plan = planSync(current, payload);
211
+ if (!send) {
212
+ context.emit.ok({ dryRun: true, project, ...plan, unfilled }, `${describePlan(project, plan, unfilled)}\n\nDry run: nothing was sent. ${nextStep(plan, unfilled)}`);
213
+ return exit_codes_1.EXIT.OK;
214
+ }
215
+ const response = await context.api.post('/api/v1/cli/north-star', { project, sync: payload });
216
+ if (response.kind === 'network') {
217
+ context.emit.fail('network', `${response.message} It may or may not have been applied — run the dry run to see.`);
218
+ return exit_codes_1.EXIT.SERVER;
219
+ }
220
+ if (response.kind === 'error') {
221
+ const issues = response.body.issues;
222
+ if (context.emit.json)
223
+ context.emit.fail(response.code, response.message, issues ? { issues } : undefined);
224
+ else
225
+ context.emit.fail(response.code, [response.message, ...issueLines(issues)].join('\n'));
226
+ return (0, exit_codes_1.exitForServerCode)(response.code);
227
+ }
228
+ context.emit.ok({ project, metric: response.body.metric, inputsSynced: response.body.inputsSynced, plan }, `${describePlan(project, plan, [])}\n\nok · North Star ${response.body.metric} synced to ${project} · ${response.body.inputsSynced} input${response.body.inputsSynced === 1 ? '' : 's'}.`);
229
+ return exit_codes_1.EXIT.OK;
230
+ },
231
+ };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.2.1";
1
+ export declare const VERSION = "0.4.0";
package/dist/version.js CHANGED
@@ -10,4 +10,4 @@ exports.VERSION = void 0;
10
10
  //
11
11
  // It is a literal, and `version.test.ts` asserts it equals `package.json`'s — so the two cannot
12
12
  // drift, and the drift is caught by the unit gate rather than by someone reading `gf --version`.
13
- exports.VERSION = '0.2.1';
13
+ exports.VERSION = '0.4.0';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@golden-frijoles/cli",
3
3
  "private": false,
4
- "version": "0.2.1",
4
+ "version": "0.4.0",
5
5
  "description": "The Golden Frijoles CLI — create, roll out and kill feature flags from a terminal, or from an agent.",
6
6
  "bin": {
7
7
  "gf": "./dist/bin.js"
@@ -21,7 +21,7 @@
21
21
  "golden-frijoles",
22
22
  "agent"
23
23
  ],
24
- "license": "UNLICENSED",
24
+ "license": "Apache-2.0",
25
25
  "sideEffects": false,
26
26
  "publishConfig": {
27
27
  "access": "public"
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@golden-frijoles/kit": "0.5.2",
36
- "@golden-frijoles/sdk": "^0.5.0"
36
+ "@golden-frijoles/sdk": ">=0.5.0 <0.7.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "typescript": "^5.5.4"