Skip to content

ci: run functional tests for nightshift 794 - #832

Closed
margaretjgu wants to merge 14 commits into
mainfrom
ci/nightshift-ask-buildkite
Closed

margaretjgu wants to merge 14 commits into
mainfrom
ci/nightshift-ask-buildkite

Conversation

@margaretjgu

Copy link
Copy Markdown
Member

Same commit as #794. Fork pull requests do not run Buildkite, and buildkite/elastic-cli/pr is required to merge 794. This pull request only exists so that check runs on that commit. Merge 794, not this one.

flash1293 and others added 14 commits October 19, 2026 11:57
…d chat message command

`nightshift ask` is the generated `kb agent-builder post-chat-message` command
(POST /api/chat/message) with `agent_id` pinned to `nightshift.investigation`.

A new `buildKbPresetCommand` helper re-exposes any generated Kibana command
under a new name with some input fields fixed. Fixed fields are removed from
the flags and schema, and supplying one via JSON input is a validation error
rather than a silent override.

Co-authored-by: Cursor <cursoragent@cursor.com>
`elastic nightshift ask "..."` now works alongside `--message`.

`positionalArg.inputKey` lets a command fill an input schema field from its
positional argument before validation; passing both the argument and the flag
is an error. `buildKbPresetCommand` exposes this as a `positional` option.

Also fixes cli-schema option hoisting, which dropped a positional parameter
whenever a hoisted flag had the same name.

Co-authored-by: Cursor <cursoragent@cursor.com>
Running the emitter in a subprocess, like the other cli-schema tests, checks the
real nightshift ask entry and keeps cli-schema.ts out of in-process coverage,
which pulled branch coverage below the 90% threshold in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
`nightshift` only applies to Serverless Observability projects. The
`serverless` and `default` profiles now allow `nightshift.*` (they previously
blocked it, since their allow-list only covered `stack.*`), and the `stack`
profile blocks it, which also hides it from namespace help and completion.
Without a profile nothing changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
The factory reads JSON input from stdin when it is not a TTY. On Windows CI that read never ends, so test/factory.test.ts hit the 60s timeout. Mark stdin as a TTY like the file's other input tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
…-preset

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	README.md
#	src/factory.ts
#	src/kb/register.ts
#	test/completion/complete.test.ts
… agent

- Resolve the Kibana availability target for the preset and restrict it to
  serverless, so nightshift ask is hidden for stack version hints.
- Pin agent_id to nightshift.assistant, the single-question agent, instead
  of the investigation agent.
- Reword docs to Serverless Observability only.
- Add regression tests for the --json positional conflict error and fold
  the nightshift assertion into the stack profile test.

Co-authored-by: Cursor <cursoragent@cursor.com>
Bun ignores `process.exitCode = undefined`, so the new --json positional
conflict test leaked exit code 1 into later tests under Bun.

Co-authored-by: Cursor <cursoragent@cursor.com>
Print a stderr warning before each nightshift ask request, suppressed by
--accept-experimental or --json, following the elastic docs commands.
Add a matching warning callout to the Nightshift docs page.

Co-authored-by: Cursor <cursoragent@cursor.com>
…commands

Move the --accept-experimental option and the stderr warning into
src/lib/experimental.ts and use it from docs ask, docs search and the
Kibana preset. Warning text is unchanged; the three commands now share
one --accept-experimental description.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 15:03
@github-actions

Copy link
Copy Markdown
Contributor

👋 This PR can use the first-failure repair loop on GitHub Actions and Buildkite.

Labels

  • auto-loop: triage the first CI or Buildkite failure and commit in-repo fixes (also AI review and CodeQL)
  • skip-ai-review: silences the review bot
  • skip-auto-loop: halt the repair loop (also added when you comment /stop)

Comments

  • /stop: halt the repair loop
  • /bad on a finding: the bot writes a short do not re-flag line from the finding and your note into .github/skills/ai-review-memory.md. A reason is optional.
    • Example: /bad false positive. This path is already encoded.

@github-actions

Copy link
Copy Markdown
Contributor

PR type mismatch: title uses ci: run functional tests for nightshift 794, diff looks like feat instead.

The diff adds the user-facing elastic nightshift ask command plus schema, profiles, and docs to support it, which is a feature, not a CI-only change.

This affects the version bump and changelog entry release-please generates on merge. Update the PR title (and squash commit message) to match, or push a follow-up commit that justifies the current prefix.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🔍 Preview links for changed docs

@github-actions

Copy link
Copy Markdown
Contributor

Elastic Docs Style Checker (Vale)

Summary: 1 suggestion found

💡 Suggestions (1): Optional style improvements. Apply when helpful.
File Line Rule Message
docs/cli/nightshift/index.md 4 Elastic.Semicolons Use semicolons sparingly. Consider splitting the sentence or using a comma or conjunction.

The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.

@github-actions

Copy link
Copy Markdown
Contributor

✅MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 0.56s
✅ REPOSITORY gitleaks yes no no 33.94s
✅ REPOSITORY git_diff yes no no 0.1s
✅ REPOSITORY secretlint yes no no 5.84s
✅ REPOSITORY trivy yes no no 18.02s
✅ TYPESCRIPT eslint 16 0 0 3.52s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@github-actions

Copy link
Copy Markdown
Contributor

Startup perf: PR vs merge-base ✅

command PR base delta
elastic 44.4 ms 44.1 ms +0.6%
elastic --help 45.0 ms 44.3 ms +1.5%
elastic es --help 86.6 ms 87.6 ms -1.1%
elastic es 87.3 ms 87.2 ms +0.1%
elastic cloud --help 47.5 ms 47.3 ms +0.4%
elastic cloud 47.6 ms 47.8 ms -0.5%
elastic kb --help 90.8 ms 89.1 ms +1.9%
elastic kb 90.8 ms 90.5 ms +0.3%
elastic es indices --help 81.2 ms 81.7 ms -0.6%
elastic es indices update-aliases --help 150.2 ms 152.0 ms -1.2%

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Registration fails when presets pin path parameters, and completion suggests version-incompatible commands because it omits the active context’s version hint.

2 open issues
What changed in this PR

This PR mirrors #794 to run the required Buildkite check unavailable to fork pull requests; #794 remains the intended merge target. Its changes add elastic nightshift ask using the generated Kibana chat-message command.

Changes:

  • Add a Serverless-only Nightshift preset with positional input, a fixed assistant agent, and experimental warnings.
  • Integrate command profiles, completion, and schema generation.
  • Add regression tests and update command documentation.
File Description
test/​namespaces.test.ts Test Nightshift requests and version visibility.
test/​lib/​experimental.test.ts Test shared warnings and suppression.
test/​kb/​preset.test.ts Test preset input, requests, and availability.
test/​factory.test.ts Test positional input mapping and profile rules.
test/​completion/​complete.test.ts Test Nightshift completion and profile filtering.
test/​cli-schema.test.ts Test preservation of positional parameters.
src/​namespaces.ts Register the Serverless-only Nightshift command.
src/​lib/​experimental.ts Centralize experimental flags and warnings.
src/​kb/​register.ts Add generated-command presets and shared target lookup.
src/​factory.ts Map positional arguments into validated input.
src/​factory-core.ts Extend positional configuration and profile handling.
src/​docs/​search.ts Reuse the shared experimental warning utility.
src/​docs/​ask.ts Reuse the shared experimental warning utility.
src/​config/​profiles.ts Define Nightshift access by profile.
src/​completion/​complete.ts Add lazy Nightshift completion registration.
src/​cli-schema.ts Preserve positionals when hoisting flags.
docs/​cli/​schema.json Publish Nightshift parameters and updated warning descriptions.
docs/​cli/​nightshift/​index.md Document usage, availability, and experimental status.
docs/​cli/​configuration_reference.md Update profile descriptions for Nightshift.

Review effort: Balanced

// `nightshift` — deep-load on exact match, stub otherwise.
if (firstWord === 'nightshift') {
const { NAMESPACES } = await import('../namespaces.ts')
root.addCommand(await NAMESPACES.find(ns => ns.name === 'nightshift')!.load())
Comment thread src/kb/register.ts
const properties = { ...(def.input?.['properties'] as Record<string, unknown> | undefined) }
for (const key of Object.keys(opts.fixed)) {
if (!(key in properties)) throw new Error(`fixed field ${JSON.stringify(key)} is not an input of ${opts.apiId}`)
delete properties[key]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants