@yagni-app/code-staging 0.3.1-staging.1101.1 → 0.3.1-staging.1107.1

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.
@@ -29,6 +29,18 @@ export declare const MAX_CRASH_STACK_FRAMES = 40;
29
29
  export declare const MAX_CRASH_PAYLOAD_BYTES = 16384;
30
30
  /** Same truthiness rule as updateChecksDisabled: set and not "" / "0". */
31
31
  export declare function crashReportsDisabled(env?: NodeJS.ProcessEnv): boolean;
32
+ /**
33
+ * True when this process is a test run. A crash reporter that phones home
34
+ * from a test suite files FICTIONAL crashes against real production
35
+ * telemetry — see the twin comment in `pi-extension-yagni/src/crashReport.ts`
36
+ * (Sentry YAGNI-BACKEND-2P / -2Q). Kept in sync with that copy.
37
+ *
38
+ * Deliberately broad: a false positive costs one unreported crash on a
39
+ * developer machine, a false negative pollutes production.
40
+ */
41
+ export declare function runningUnderTest(env?: NodeJS.ProcessEnv): boolean;
42
+ /** Reporting is off when the user disabled it OR this is a test process. */
43
+ export declare function crashReportsSuppressed(env?: NodeJS.ProcessEnv): boolean;
32
44
  export interface SanitizeCrashOptions {
33
45
  /** Environment whose values get redacted (defaults to process.env). */
34
46
  env?: NodeJS.ProcessEnv;
@@ -33,6 +33,33 @@ export function crashReportsDisabled(env = process.env) {
33
33
  const value = env[CRASH_REPORT_DISABLE_ENV];
34
34
  return value !== undefined && value !== "" && value !== "0";
35
35
  }
36
+ /**
37
+ * True when this process is a test run. A crash reporter that phones home
38
+ * from a test suite files FICTIONAL crashes against real production
39
+ * telemetry — see the twin comment in `pi-extension-yagni/src/crashReport.ts`
40
+ * (Sentry YAGNI-BACKEND-2P / -2Q). Kept in sync with that copy.
41
+ *
42
+ * Deliberately broad: a false positive costs one unreported crash on a
43
+ * developer machine, a false negative pollutes production.
44
+ */
45
+ export function runningUnderTest(env = process.env) {
46
+ if (env.NODE_ENV === "test")
47
+ return true;
48
+ // node:test sets this in every spawned test-file process.
49
+ if (env.NODE_TEST_CONTEXT)
50
+ return true;
51
+ if (env.VITEST || env.JEST_WORKER_ID)
52
+ return true;
53
+ // npm/pnpm export the script name being run (`pnpm test`, `pnpm test:file`).
54
+ const script = env.npm_lifecycle_event;
55
+ if (script === "test" || (script !== undefined && script.startsWith("test:")))
56
+ return true;
57
+ return false;
58
+ }
59
+ /** Reporting is off when the user disabled it OR this is a test process. */
60
+ export function crashReportsSuppressed(env = process.env) {
61
+ return crashReportsDisabled(env) || runningUnderTest(env);
62
+ }
36
63
  // Mirrors scrubSecrets (backend yagniCode/scrubSecrets.ts and
37
64
  // pi-extension-yagni pipeline/scrubSecrets.ts) — keep in sync.
38
65
  const SECRET_PATTERNS = [
@@ -147,7 +174,7 @@ export function sanitizeCrashError(err, opts = {}) {
147
174
  export async function sendCrashReport(input) {
148
175
  try {
149
176
  const env = input.env ?? process.env;
150
- if (crashReportsDisabled(env))
177
+ if (crashReportsSuppressed(env))
151
178
  return;
152
179
  const opts = { env, repoRoot: input.repoRoot };
153
180
  const stack = input.stack !== undefined
@@ -33,6 +33,24 @@ export declare const MAX_CRASH_STACK_FRAMES = 40;
33
33
  export declare const MAX_CRASH_PAYLOAD_BYTES = 16384;
34
34
  /** Same truthiness rule as the CLI's YAGNI_DISABLE_* family. */
35
35
  export declare function crashReportsDisabled(env?: NodeJS.ProcessEnv): boolean;
36
+ /**
37
+ * True when this process is a test run.
38
+ *
39
+ * A crash reporter that phones home from a test suite reports FICTIONAL
40
+ * crashes against real production telemetry. That is not theoretical: the
41
+ * `/go` terminal catch builds a live reporter whenever its caller doesn't
42
+ * inject one, so `goCommand.test.ts`'s deliberate `throw new Error("boom")`
43
+ * POSTed to https://yagni.app on every run — 915 events across Sentry
44
+ * YAGNI-BACKEND-2P / -2Q, from a team that had never witnessed a crash.
45
+ *
46
+ * Injecting a stub at each call site fixes one test; this makes the whole
47
+ * class impossible, so a future test that forgets cannot re-open the leak.
48
+ * Detection is deliberately broad — a false positive costs one unreported
49
+ * crash on a developer machine, a false negative pollutes production.
50
+ */
51
+ export declare function runningUnderTest(env?: NodeJS.ProcessEnv): boolean;
52
+ /** Reporting is off when the user disabled it OR this is a test process. */
53
+ export declare function crashReportsSuppressed(env?: NodeJS.ProcessEnv): boolean;
36
54
  export interface SanitizeCrashOptions {
37
55
  env?: NodeJS.ProcessEnv;
38
56
  repoRoot?: string;
@@ -40,6 +40,39 @@ export function crashReportsDisabled(env = process.env) {
40
40
  const value = env[CRASH_REPORT_DISABLE_ENV];
41
41
  return value !== undefined && value !== "" && value !== "0";
42
42
  }
43
+ /**
44
+ * True when this process is a test run.
45
+ *
46
+ * A crash reporter that phones home from a test suite reports FICTIONAL
47
+ * crashes against real production telemetry. That is not theoretical: the
48
+ * `/go` terminal catch builds a live reporter whenever its caller doesn't
49
+ * inject one, so `goCommand.test.ts`'s deliberate `throw new Error("boom")`
50
+ * POSTed to https://yagni.app on every run — 915 events across Sentry
51
+ * YAGNI-BACKEND-2P / -2Q, from a team that had never witnessed a crash.
52
+ *
53
+ * Injecting a stub at each call site fixes one test; this makes the whole
54
+ * class impossible, so a future test that forgets cannot re-open the leak.
55
+ * Detection is deliberately broad — a false positive costs one unreported
56
+ * crash on a developer machine, a false negative pollutes production.
57
+ */
58
+ export function runningUnderTest(env = process.env) {
59
+ if (env.NODE_ENV === "test")
60
+ return true;
61
+ // node:test sets this in every spawned test-file process.
62
+ if (env.NODE_TEST_CONTEXT)
63
+ return true;
64
+ if (env.VITEST || env.JEST_WORKER_ID)
65
+ return true;
66
+ // npm/pnpm export the script name being run (`pnpm test`, `pnpm test:file`).
67
+ const script = env.npm_lifecycle_event;
68
+ if (script === "test" || (script !== undefined && script.startsWith("test:")))
69
+ return true;
70
+ return false;
71
+ }
72
+ /** Reporting is off when the user disabled it OR this is a test process. */
73
+ export function crashReportsSuppressed(env = process.env) {
74
+ return crashReportsDisabled(env) || runningUnderTest(env);
75
+ }
43
76
  const HOME_DIR_RE = /(?:\/(?:Users|home)\/|[A-Za-z]:\\Users\\)[^\s/\\]+/g;
44
77
  // Spaces deliberately allowed inside the token (real directories contain
45
78
  // them); prose after a path may fold into the kept basename — over-redacts
@@ -122,7 +155,7 @@ export function makeCrashReporter(opts) {
122
155
  return async (error, context, repoRoot) => {
123
156
  try {
124
157
  const env = opts.env ?? process.env;
125
- if (crashReportsDisabled(env))
158
+ if (crashReportsSuppressed(env))
126
159
  return;
127
160
  const token = opts.getToken();
128
161
  const sanitized = sanitizeCrashError(error, { env, repoRoot });
@@ -191,7 +224,7 @@ const DETACHED_SENDER_SRC = [
191
224
  export function reportFatalCrash(error, opts, context) {
192
225
  try {
193
226
  const env = opts.env ?? process.env;
194
- if (crashReportsDisabled(env))
227
+ if (crashReportsSuppressed(env))
195
228
  return;
196
229
  const token = opts.getToken();
197
230
  if (!token)
@@ -36,5 +36,5 @@ export declare function promptEnrichmentDisabled(env: NodeJS.ProcessEnv): boolea
36
36
  * model, and the load-bearing instructions (ask_yagni contract, delegation)
37
37
  * live elsewhere in the prompt.
38
38
  */
39
- export declare const ENGINEERING_PRACTICE_SECTION = "Engineering practice:\n\nBias to action: when the user asks you to implement, fix, or change something, use your tools to make the actual edits and run the actual commands \u2014 do not answer with a description of what you would do, or with code for the user to apply themselves. When the user asks HOW to approach something, answer the question first; do not jump into making changes they have not asked for.\n\nConventions:\n- Never assume a library is available, however well known. Before using one, confirm the project already depends on it (its package manifest, or imports in neighboring files).\n- When editing, read the surrounding code and its imports first; match the file's existing style, naming, and patterns rather than introducing your own.\n- When creating a new file or component, study an existing sibling first and follow its structure.\n- Never write code that logs or exposes secrets, keys, or credentials.\n\nVerification:\n- Consider what the code you are changing is supposed to do (from its name, location, and callers) before you change it.\n- Verify changes with the project's own tests when possible. Never assume a test framework or command \u2014 check the README, package scripts, or neighboring tests for the real one.\n- After completing a task, run the project's lint and typecheck commands if you know them; if you cannot find them, ask the user and suggest recording them in AGENTS.md for next time.\n\nVersion control:\n- No unsolicited commits: commit only when the user asked for one or the task at hand clearly calls for it.\n\nGit safety:\n- You may be in a dirty git worktree. Never revert existing changes you did not make unless explicitly asked \u2014 these were made by the user.\n- If there are unrelated changes in files you are touching, read and work with them rather than reverting.\n- If changes appear in unrelated files, ignore them and do not revert.\n- Do not amend a commit unless explicitly asked.\n- If you notice unexpected changes you did not make while working, stop immediately and ask the user.\n- Never use destructive git commands (git reset --hard, git checkout --) unless the user explicitly requests or approves them.\n\nTodo discipline:\n- Track multi-step work with todo_write: keep exactly one item in_progress at a time, mark items completed the moment they are done, and add newly discovered steps as pending.\n- Do not batch-complete items or create single-step plans. Skip planning for trivially small work (~25% of tasks).\n\nMode awareness:\n- In auto mode, proactively run tests, lint, and typecheck after your changes.\n- In review mode, propose verification steps but wait for approval before running them.\n- In plan mode, explore and design only \u2014 the gate holds all writes.\n\nCommunication:\n- Answer directly, without preamble or postamble (\"Here is what I will do next...\", \"Based on the information provided...\"). Match the length of your answer to the question.\n- After making edits, report the outcome briefly; do not restate the diff or explain the code you just wrote unless asked.\n- Do not add code comments that narrate what you changed or why the change is correct; comments are for future readers of the code.\n- Reference code as file_path:line_number so the user can jump to it.\n- Before running a non-trivial command that changes state, say in one line what it does and why.\n- Never guess or fabricate URLs. Only use URLs the user provided or that appear in local files.\n- No emojis unless the user asks for them.";
39
+ export declare const ENGINEERING_PRACTICE_SECTION = "Engineering practice:\n\nAnswering vs acting: distinguish what the user is asking for before responding. When the user asks you to analyze, investigate, find a root cause, study how something works, explore an approach, or asks a strategic or advisory question (\"should we...\", \"what's your read on...\", \"go/no-go on...\"), answer in prose \u2014 do not start coding or editing files. When the user asks you to implement, fix, or change something, use your tools to make the actual edits and run the actual commands \u2014 do not answer with a description of what you would do, or with code for the user to apply themselves.\n\nConventions:\n- Never assume a library is available, however well known. Before using one, confirm the project already depends on it (its package manifest, or imports in neighboring files).\n- When editing, read the surrounding code and its imports first; match the file's existing style, naming, and patterns rather than introducing your own.\n- When creating a new file or component, study an existing sibling first and follow its structure.\n- Never write code that logs or exposes secrets, keys, or credentials.\n\nVerification:\n- Consider what the code you are changing is supposed to do (from its name, location, and callers) before you change it.\n- Verify changes with the project's own tests when possible. Never assume a test framework or command \u2014 check the README, package scripts, or neighboring tests for the real one.\n- After completing a task, run the project's lint and typecheck commands if you know them; if you cannot find them, ask the user and suggest recording them in AGENTS.md for next time.\n\nVersion control:\n- No unsolicited commits: commit only when the user asked for one or the task at hand clearly calls for it.\n\nGit safety:\n- You may be in a dirty git worktree. Never revert existing changes you did not make unless explicitly asked \u2014 these were made by the user.\n- If there are unrelated changes in files you are touching, read and work with them rather than reverting.\n- If changes appear in unrelated files, ignore them and do not revert.\n- Do not amend a commit unless explicitly asked.\n- If you notice unexpected changes you did not make while working, stop immediately and ask the user.\n- Never use destructive git commands (git reset --hard, git checkout --) unless the user explicitly requests or approves them.\n\nTodo discipline:\n- Track multi-step work with todo_write: keep exactly one item in_progress at a time, mark items completed the moment they are done, and add newly discovered steps as pending.\n- Do not batch-complete items or create single-step plans. Skip planning for trivially small work (~25% of tasks).\n\nMode awareness:\n- In auto mode, proactively run tests, lint, and typecheck after your changes.\n- In review mode, propose verification steps but wait for approval before running them.\n- In plan mode, explore and design only \u2014 the gate holds all writes.\n\nCommunication:\n- Answer directly, without preamble or postamble (\"Here is what I will do next...\", \"Based on the information provided...\"). Match the length of your answer to the question.\n- After making edits, report the outcome briefly; do not restate the diff or explain the code you just wrote unless asked.\n- Do not add code comments that narrate what you changed or why the change is correct; comments are for future readers of the code.\n- Reference code as file_path:line_number so the user can jump to it.\n- Before running a non-trivial command that changes state, say in one line what it does and why.\n- Never guess or fabricate URLs. Only use URLs the user provided or that appear in local files.\n- No emojis unless the user asks for them.";
40
40
  //# sourceMappingURL=promptEnrichment.d.ts.map
@@ -41,7 +41,7 @@ export function promptEnrichmentDisabled(env) {
41
41
  */
42
42
  export const ENGINEERING_PRACTICE_SECTION = `Engineering practice:
43
43
 
44
- Bias to action: when the user asks you to implement, fix, or change something, use your tools to make the actual edits and run the actual commands — do not answer with a description of what you would do, or with code for the user to apply themselves. When the user asks HOW to approach something, answer the question first; do not jump into making changes they have not asked for.
44
+ Answering vs acting: distinguish what the user is asking for before responding. When the user asks you to analyze, investigate, find a root cause, study how something works, explore an approach, or asks a strategic or advisory question ("should we...", "what's your read on...", "go/no-go on..."), answer in prose — do not start coding or editing files. When the user asks you to implement, fix, or change something, use your tools to make the actual edits and run the actual commands — do not answer with a description of what you would do, or with code for the user to apply themselves.
45
45
 
46
46
  Conventions:
47
47
  - Never assume a library is available, however well known. Before using one, confirm the project already depends on it (its package manifest, or imports in neighboring files).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "0.3.1-staging.1101.1",
3
+ "version": "0.3.1-staging.1107.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -39,5 +39,5 @@
39
39
  "smol-toml": "^1.8.0",
40
40
  "typebox": "^1.3.11"
41
41
  },
42
- "yagniSourceSha": "9433338f90e3be351fac886eb10f15a4562696da"
42
+ "yagniSourceSha": "7029b03b5a6d5eac5c16a0a25670cc64ea989f82"
43
43
  }