workspai 0.64.0 → 0.65.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/README.md +37 -44
- package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
- package/contracts/runtime-command-surface.v1.json +12 -1
- package/contracts/workspace-contract.v1.json +51 -6
- package/contracts/workspace-intelligence/project-context-agent.v1.json +29 -0
- package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +11 -1
- package/contracts/workspace-intelligence/workspace-model.v1.json +28 -1
- package/contracts/workspace-model-cache.v1.json +4 -0
- package/contracts/workspace-repair-capabilities.v1.json +66 -0
- package/dist/analyze-5PDVWECJ.js +1 -0
- package/dist/autopilot-release-JVIJCTKX.js +1 -0
- package/dist/chunk-2C5ZBVBI.js +2 -0
- package/dist/{chunk-VB6I52ZT.js → chunk-2RL6RRT2.js} +2 -2
- package/dist/{chunk-FQSBOLM7.js → chunk-6JWNDWOA.js} +1 -1
- package/dist/chunk-D5YJOQYK.js +1 -0
- package/dist/{chunk-2VJUAKMS.js → chunk-DFG33SBR.js} +2 -2
- package/dist/chunk-FY4IIAIF.js +1 -0
- package/dist/{chunk-KJXMLBSY.js → chunk-HDNATYW7.js} +1 -1
- package/dist/chunk-HEZZ72V4.js +94 -0
- package/dist/{chunk-KANAJH65.js → chunk-HN7P4T3B.js} +1 -1
- package/dist/chunk-J7QYANXK.js +8 -0
- package/dist/{chunk-DK6JNE6K.js → chunk-JD3A5QM6.js} +1 -1
- package/dist/chunk-KLSSPJTV.js +1 -0
- package/dist/{chunk-DOXNVBX6.js → chunk-MDTI3UEB.js} +1 -1
- package/dist/chunk-MYJQGGIU.js +5 -0
- package/dist/chunk-NOV6723U.js +1 -0
- package/dist/chunk-NYEAMMUL.js +1 -0
- package/dist/chunk-O5B2L3R2.js +1 -0
- package/dist/chunk-OWB5KWSS.js +13 -0
- package/dist/chunk-P5PSZQPB.js +2 -0
- package/dist/chunk-QI3HG6IG.js +144 -0
- package/dist/chunk-SWGSFLTC.js +1 -0
- package/dist/chunk-U5FCQTVL.js +4 -0
- package/dist/chunk-VVJK5NFY.js +2 -0
- package/dist/chunk-VXKWWX7S.js +8 -0
- package/dist/chunk-W322YDHS.js +49 -0
- package/dist/chunk-WCJU3CFG.js +1 -0
- package/dist/chunk-WPRLXKWC.js +8 -0
- package/dist/{chunk-ZGS5NKEO.js → chunk-XGE2FDI4.js} +1 -1
- package/dist/{chunk-5SFCBZOH.js → chunk-YN5X2FTP.js} +1 -1
- package/dist/chunk-YOCN7GF4.js +1 -0
- package/dist/chunk-YYQEWAES.js +1 -0
- package/dist/chunk-ZEEV5J4I.js +1 -0
- package/dist/{create-PWJDTKDN.js → create-ALT2ME6H.js} +1 -1
- package/dist/{doctor-CGXY4IDE.js → doctor-RW4R3O5C.js} +1 -1
- package/dist/{goal-lifecycle-BRFFTIU2.js → goal-lifecycle-VYOKS6E6.js} +1 -1
- package/dist/goal-pack-YWPI43QL.js +1 -0
- package/dist/index.js +144 -144
- package/dist/{pipeline-DF4UIHAD.js → pipeline-U4N2DVD7.js} +1 -1
- package/dist/{project-agent-entry-IWUCV72J.js → project-agent-entry-YAQCHIMP.js} +1 -1
- package/dist/project-intelligence-lens-MRQR2LQW.js +1 -0
- package/dist/verified-goal-WM34TTGE.js +1 -0
- package/dist/{workspace-35Q2IXAR.js → workspace-HGUZWNAB.js} +1 -1
- package/dist/{workspace-agent-sync-FFNSW2PD.js → workspace-agent-sync-GEN3KBAX.js} +1 -1
- package/dist/{workspace-context-IJ36ZP6G.js → workspace-context-4WIWFW26.js} +1 -1
- package/dist/workspace-contract-7DXK4GF5.js +1 -0
- package/dist/{workspace-explain-TITIT5XN.js → workspace-explain-TE2LGOAV.js} +1 -1
- package/dist/{workspace-foundation-GMGDUMPR.js → workspace-foundation-J3NNRMI3.js} +1 -1
- package/dist/workspace-graph-stream-PQI7OGCE.js +1 -0
- package/dist/workspace-graph-token-efficiency-2I4X374C.js +1 -0
- package/dist/{workspace-intelligence-5NO4K5SC.js → workspace-intelligence-6FS26JOQ.js} +1 -1
- package/dist/{workspace-intelligence-runner-FGEBFVVM.js → workspace-intelligence-runner-XYUPCSLN.js} +1 -1
- package/dist/workspace-knowledge-graph-SWCKDTPF.js +1 -0
- package/dist/workspace-knowledge-graph-contract-L3CLAM2M.js +1 -0
- package/dist/{workspace-knowledge-graph-query-ON45H6Y7.js → workspace-knowledge-graph-query-FZXSPWGK.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-M572JRB4.js +1 -0
- package/dist/workspace-mcp-serve-IBMTFQDY.js +3 -0
- package/dist/workspace-model-ZL6WCICX.js +1 -0
- package/dist/{workspace-onboarding-VS3YYNGK.js → workspace-onboarding-X3PWRIIS.js} +1 -1
- package/dist/{workspace-registry-summary-MIDFG6EC.js → workspace-registry-summary-LJN4WHIZ.js} +1 -1
- package/dist/workspace-repair-engine-NX7I632M.js +3 -0
- package/dist/workspace-run-6GT5OBQ5.js +1 -0
- package/dist/{workspace-verify-4R7QHUPO.js → workspace-verify-USRRIM2F.js} +1 -1
- package/dist/workspace-watch-43YZPLF7.js +1 -0
- package/docs/ci-workflows.md +1 -1
- package/docs/commands-reference.md +3 -1
- package/docs/workspace-knowledge-graph.md +36 -0
- package/docs/workspace-operations.md +22 -0
- package/docs/workspace-repair-engine.md +17 -0
- package/package.json +1 -1
- package/dist/analyze-NUGNB256.js +0 -1
- package/dist/autopilot-release-TWJWSVVF.js +0 -1
- package/dist/chunk-3A23KJAQ.js +0 -1
- package/dist/chunk-4PUJVYRM.js +0 -1
- package/dist/chunk-5B2GAZAC.js +0 -5
- package/dist/chunk-6DAQ7PYT.js +0 -13
- package/dist/chunk-CCAXADKP.js +0 -49
- package/dist/chunk-CJHWKXDN.js +0 -1
- package/dist/chunk-CT4IODPG.js +0 -2
- package/dist/chunk-DWB2RRF4.js +0 -1
- package/dist/chunk-ISOOENLW.js +0 -8
- package/dist/chunk-J7RU5WR5.js +0 -2
- package/dist/chunk-KV6PS54A.js +0 -8
- package/dist/chunk-NHTDPXTW.js +0 -4
- package/dist/chunk-Q2WF7D5U.js +0 -2
- package/dist/chunk-RSG2GJXT.js +0 -2
- package/dist/chunk-SFO5GVRT.js +0 -1
- package/dist/chunk-T5YRFRJV.js +0 -1
- package/dist/chunk-TOYN76K4.js +0 -144
- package/dist/chunk-U5WVR74V.js +0 -1
- package/dist/chunk-WY4DOMEA.js +0 -1
- package/dist/chunk-XKDR5BGS.js +0 -6
- package/dist/chunk-ZH7CXQH3.js +0 -94
- package/dist/goal-pack-FG3QDNQH.js +0 -1
- package/dist/project-intelligence-lens-PZPPSCUW.js +0 -1
- package/dist/verified-goal-BBHZRYYH.js +0 -1
- package/dist/workspace-contract-JS4LZZQZ.js +0 -1
- package/dist/workspace-graph-stream-7UU2YVHC.js +0 -1
- package/dist/workspace-graph-token-efficiency-D7CUT6NX.js +0 -1
- package/dist/workspace-knowledge-graph-RSDP2E36.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-3FJHH5IK.js +0 -1
- package/dist/workspace-mcp-serve-WUIQ2AE6.js +0 -3
- package/dist/workspace-model-OKY4CQ3X.js +0 -1
- package/dist/workspace-repair-engine-VUBT77Y7.js +0 -3
- package/dist/workspace-run-SSF6Z26G.js +0 -1
- package/dist/workspace-watch-IOPSHQS5.js +0 -1
|
@@ -116,6 +116,19 @@ symbols are not implied to have been extracted. The graph diagnostic reports
|
|
|
116
116
|
the sampled and indexed candidate counts and must not be read as exhaustive
|
|
117
117
|
symbol coverage.
|
|
118
118
|
|
|
119
|
+
Call binding follows the same proof boundary. Workspai binds a call only when
|
|
120
|
+
its target is uniquely defined in the same file or in a locally imported file
|
|
121
|
+
that the Graph already resolved. Overloads, dynamic dispatch, and ambiguous
|
|
122
|
+
names remain explicit unknowns for compiler or language-server evidence; the
|
|
123
|
+
CLI does not turn a repository-wide text match into semantic certainty.
|
|
124
|
+
|
|
125
|
+
When a previous graph has the same project set, provider versions, and live
|
|
126
|
+
project fingerprints, unchanged project slices are reused and only changed
|
|
127
|
+
projects repeat the expensive semantic scan. Workspace-level CI, governance,
|
|
128
|
+
infrastructure, and topology providers still run against the complete current
|
|
129
|
+
workspace. The `incremental-project-cache` provider receipt records reused and
|
|
130
|
+
rescanned scope counts. A provider-version change forces a full rebuild.
|
|
131
|
+
|
|
119
132
|
### Fast reads without stale answers
|
|
120
133
|
|
|
121
134
|
The read-oriented `search`, `entities`, `evidence`, `path`, and `benchmark`
|
|
@@ -147,6 +160,11 @@ The fingerprint proves compatibility of the exact bounded provider inventory;
|
|
|
147
160
|
if a scope reports `truncated: true`, it must not be interpreted as proof about
|
|
148
161
|
files beyond that declared limit.
|
|
149
162
|
|
|
163
|
+
Workspai-generated agent entry projections are downstream consumers and are
|
|
164
|
+
excluded from Graph inventory and Git diff hashing. Regenerating `AGENTS.md`,
|
|
165
|
+
adapter entry files, or the Amazon Q entry rule therefore cannot invalidate the
|
|
166
|
+
Graph that produced them or become circular architecture evidence.
|
|
167
|
+
|
|
150
168
|
## Pick the command by question
|
|
151
169
|
|
|
152
170
|
| You want to know… | Use |
|
|
@@ -457,6 +475,18 @@ Use full graph export for interchange or offline analysis. Use bounded search
|
|
|
457
475
|
for interactive agents. The latter keeps response size proportional to the
|
|
458
476
|
question instead of workspace size.
|
|
459
477
|
|
|
478
|
+
### Runtime-generated API topology
|
|
479
|
+
|
|
480
|
+
When an authored API contract is wired through framework registration or
|
|
481
|
+
configuration rather than a literal route handler, the
|
|
482
|
+
`dynamic-api-registration-binding` provider creates a proof-backed
|
|
483
|
+
`runtime-unit -> implements -> api` relation. Detection is runtime-specific,
|
|
484
|
+
production-only, filename-aware for routing configuration, and bounded per API.
|
|
485
|
+
It intentionally does not claim endpoint implementation: endpoint coverage
|
|
486
|
+
remains unknown until a method/path or operation-id binding is proven. Consumers
|
|
487
|
+
can distinguish the two guarantees through `bindingCoverage.apiRuntimeRegistration`
|
|
488
|
+
and `bindingCoverage.apiImplementation`.
|
|
489
|
+
|
|
460
490
|
## Measuring retrieval payload reduction
|
|
461
491
|
|
|
462
492
|
Workspai does not publish an unqualified “N× fewer tokens” claim. Such a claim
|
|
@@ -469,6 +499,10 @@ Measure the current workspace instead:
|
|
|
469
499
|
npx workspai workspace graph benchmark "authentication endpoint" --limit 12 --json
|
|
470
500
|
```
|
|
471
501
|
|
|
502
|
+
Use `--kind <entity-kind>` with search when the task requires a precise
|
|
503
|
+
semantic surface, for example `--kind runtime-unit` for dynamic registration
|
|
504
|
+
units or `--kind endpoint` for authored operations.
|
|
505
|
+
|
|
472
506
|
The report compares the readable, proof-indexed source corpus with the bounded
|
|
473
507
|
search payload using a clearly labelled `characters / 4` token estimate. It
|
|
474
508
|
reports corpus size, retrieval size, estimated ratio, percentage reduction,
|
|
@@ -497,6 +531,8 @@ a general performance claim.
|
|
|
497
531
|
- The live-input fingerprint enables whole-graph snapshot reuse; it is not yet
|
|
498
532
|
a per-file incremental graph rebuild or a hosted semantic-vector index.
|
|
499
533
|
- Compiler/LSP-grade symbol resolution belongs in deeper language providers.
|
|
534
|
+
- Runtime registration evidence proves that an API enters the running topology;
|
|
535
|
+
it does not prove that every authored operation has a reachable handler.
|
|
500
536
|
- Missing project edges mean “relationship not proven,” not “projects are
|
|
501
537
|
independent.” Author service contracts or provide API/package/runtime
|
|
502
538
|
evidence to close that gap.
|
|
@@ -226,6 +226,28 @@ npx workspai workspace contract graph --output ./contract-graph.json --json
|
|
|
226
226
|
|
|
227
227
|
Contract file: `.workspai/workspace.contract.json`. Verification checks schema, duplicate slugs, port collisions, and unknown dependencies.
|
|
228
228
|
|
|
229
|
+
Project entries may also declare governance that lives outside the repository:
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"slug": "api",
|
|
234
|
+
"relativePath": "services/api",
|
|
235
|
+
"governance": {
|
|
236
|
+
"ci": { "mode": "external", "provider": "Prow", "reference": "platform/test-infra" },
|
|
237
|
+
"release": { "mode": "external", "provider": "Release Engineering" },
|
|
238
|
+
"ownership": { "mode": "repository" }
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Workspai reconciles each control as `repository`, `external-declared`,
|
|
244
|
+
`external-observed`, or `unknown`. Analyze does not misreport an explicitly
|
|
245
|
+
external control as a missing repository file. Observed-but-undeclared external
|
|
246
|
+
governance stays advisory until the canonical contract names its authority.
|
|
247
|
+
The resolved profile is emitted by the Workspace Model, project lens, agent
|
|
248
|
+
context, facts, and project graph attributes so every consumer sees the same
|
|
249
|
+
truth.
|
|
250
|
+
|
|
229
251
|
`workspace contract graph --json` preserves its original `nodes`, `edges`, and
|
|
230
252
|
summary fields for existing consumers, and now adds an evidence-backed
|
|
231
253
|
`dependencyGraph` using the public `workspace-dependency-graph.v1` contract. It
|
|
@@ -184,6 +184,23 @@ transaction. If a manifest, required executable, isolated environment, project-d
|
|
|
184
184
|
validation, or audit surface is unavailable, the engine returns `decision-required`; it never
|
|
185
185
|
hides the gap behind a model fallback.
|
|
186
186
|
|
|
187
|
+
The same capability contract publishes an executable qualification matrix over
|
|
188
|
+
adapter, scope, failure family, and recovery path. Every failure family has one
|
|
189
|
+
bounded terminal policy: refresh stale/missing evidence, replan no-op/source
|
|
190
|
+
drift/producer failures, require a toolchain decision, rollback failed
|
|
191
|
+
validation, durably resume provider outages or interrupted rollback, and route
|
|
192
|
+
unsupported runtimes to manual repair. Contract generation fails if an adapter
|
|
193
|
+
omits reconcile/audit/test/build closure or a failure family has no recovery
|
|
194
|
+
policy. This matrix is consumed through:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npx workspai workspace repair capabilities --json
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
It describes authority and deterministic recovery; conditional runtime support
|
|
201
|
+
remains conditional until Doctor proves the required executable and project
|
|
202
|
+
surface on the current machine.
|
|
203
|
+
|
|
187
204
|
## Consumer contract
|
|
188
205
|
|
|
189
206
|
The latest transaction is written to:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Open-source workspace intelligence CLI for software systems: create, adopt, govern, verify, and align polyglot workspaces for humans, CI, IDEs, and AI agents.",
|
|
6
6
|
"keywords": [
|
package/dist/analyze-NUGNB256.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as printAnalyzeReport,a as runAnalyze}from'./chunk-KV6PS54A.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{b as AUTOPILOT_RELEASE_ALIAS_FILENAME,a as AUTOPILOT_RELEASE_LAST_RUN_FILENAME,c as runAutopilotRelease}from'./chunk-KJXMLBSY.js';
|
package/dist/chunk-3A23KJAQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {b,c,d as d$1}from'./chunk-ZGS5NKEO.js';import {c as c$2}from'./chunk-W6FHVXNL.js';import {a as a$4}from'./chunk-X7FYEKLI.js';import {c as c$1,d as d$4}from'./chunk-HCFWT42C.js';import {a as a$1,b as b$1}from'./chunk-PYCJWW4B.js';import {p as p$1,a,o,g,d as d$3,f as f$1}from'./chunk-CT4IODPG.js';import {p,l,f as f$2}from'./chunk-CJHWKXDN.js';import {d}from'./chunk-EWZZUQBR.js';import {a as a$2}from'./chunk-Q2WF7D5U.js';import {d as d$2,e as e$1}from'./chunk-CCDGHPEJ.js';import {a as a$3}from'./chunk-AFIFZTOY.js';import {f,e,i,g as g$1,h}from'./chunk-NZ3WZYD5.js';import m from'path';import v from'fs-extra';var fe="rapidkit-blocker-resolution-v1";function pe(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return f$2({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function we(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function me(e){let t=we(e.reason),r=pe({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",...e.sourceCommand?{}:{studioActionId:"run-analyze"}}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:fe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?e.sourceCommand?`Run the source command once: ${e.sourceCommand}, then verify.`:"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function Re(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function Ce(e){return e.length===0||e.every(t=>Re(t))}function ge(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&Ce(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function tt(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ye=f.verify,G=e.verify;function Ae(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ke(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$3(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$3(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let o=s.transitiveImpact.reduce((u,d)=>Math.max(u,d.distance??0),0);s.summary.blastRadius.maxDistance!==o&&i.push("blastRadius.maxDistance does not match transitive impact distances");let k=l(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==k&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ee(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Se(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function We(e$1,t){if(e$1.id==="workspace.doctor")return m.join(t,e.doctor);if(e$1.id==="workspace.contract.verify")return m.join(t,e.contractVerify);if(e$1.id==="workspace.readiness")return m.join(t,e.readiness);if(e$1.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e$1.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e$1.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e$1.id.startsWith("project.")&&e$1.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function je(e){if(!c$1(e,"workspace"))return {status:"fail",message:"Doctor evidence contract is missing or unsupported."};try{d$4(e);}catch(s){return {status:"fail",message:`Doctor evidence semantic validation failed: ${s instanceof Error?s.message:String(s)}`}}let t=a$4(e);return t.hasSystemErrors||t.blockingFindings>0?{status:"fail",message:`Doctor evidence reports ${t.blockingFindings} canonical blocking finding(s).`}:t.advisoryFindings+t.unknownFindings+t.contradictionCount+t.missingDiagnosisProjects>0||t.staleEvidence||t.unknownFreshness||t.minimumDiagnosisCompleteness<100?{status:"warn",message:`Doctor evidence needs attention (${t.advisoryFindings} advisory, ${t.unknownFindings} unknown, ${t.contradictionCount} contradictory; ${t.minimumDiagnosisCompleteness}% complete).`}:{status:"pass",message:"Canonical Doctor evidence is complete, fresh, and healthy."}}function xe(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function Pe(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Ie(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Ve(e){let t=e.schemaVersion===h.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Fe(e,t){let r=await d$2(e,i.doctorRemediationPlan);if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let o=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!o||!t)return true;let k=Date.parse(o),u=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(u)?true:k>=u}catch{return false}}function $e(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Oe(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function De(e,t,r){let s=$e(t),i=c$2(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let o=i.stage;if(s&&o!==s)return {status:"missing",message:`Workspace run evidence is for stage "${o}", expected "${s}".`};let k=Array.isArray(i.projects)?i.projects:[],u=t.project?.toLowerCase();if(!u)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=k.find(g=>{let c=C(g);if(!c)return false;let n=typeof c.projectName=="string"?c.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(f=>c[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return n===u||a.some(f=>f.endsWith(`/${u}`)||f===u)});if(d){let g=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=C(d),n=typeof c?.status=="string"?c.status:"unknown";return n==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:n==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:n==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${n} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function Be(e){if(e.id==="workspace.doctor")return g$1.doctor;if(e.id==="workspace.readiness")return g$1.readiness;if(e.id==="workspace.contract.verify")return g$1.contractVerify;if(e.id==="workspace.analyze")return g$1.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function _e(e,t,r,s){let i=We(e,t),o=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let k=i?await d$2(t,o??""):null;if(!i||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:o,message:o?`Missing evidence report: ${o}`:"No evidence mapping exists for this command."};let u;try{u=await v.readJson(k);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=C(u);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:"Evidence report is not a JSON object."};let g=Be(e);if(g)try{a$3(d,g,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=R(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=je(d);}else if(e.id==="workspace.readiness"){let n=R(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.contract.verify"){let n=R(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.analyze"){let n=R(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=Ie(d);}else if(e.id==="workspace.pipeline"){let n=R(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Oe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===h.doctorFixResult.schemaVersion?d:d.fixResult,a=C(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=R(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await Fe(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Ve(d);}else if(e.id.startsWith("project."))c=De(d,e,s);else {let n=R(d.generatedAt,s,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:o,message:c.message}}function Ne(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,o=e.filter(n=>n.status==="missing").length,k=e.filter(n=>n.status==="skipped").length,u=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,g="ready",c=0;return u.length>0||t.blockingReasons.length>0?(g="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(g="needs-attention",c=1),{verdict:g,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:o,stepsSkipped:k}}function He(e,t){let r=x(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=x(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!s.has(a.toLowerCase()))),o=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let f=a.project.toLowerCase(),y=o.get(f)??[];y.push(a),o.set(f,y);}let k=[],u=[],d=[],g=[],c=false,n=(a,f)=>{let y=o.get(a.toLowerCase())??[];if(y.length===0){d.push(a);return}let P=y.filter(p=>p.status==="fail"),b=P.filter(p=>p.required),I=y.filter(p=>p.status==="missing"),E=I.filter(p=>p.required),V=y.some(p=>p.status==="pass"||p.status==="warn");if(b.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${b.map(p=>p.id).join(", ")}).`);return}if(P.length>0){u.push(a),c=true;return}if(E.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${E.map(p=>p.id).join(", ")}).`);return}if(I.length>0){u.push(a),c=true;return}if(V){k.push(a);return}d.push(a);};for(let a of r)n(a,"directly-changed");for(let a of i)n(a,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(k),uncovered:x(u),unverifiable:x(d)},blockingReasons:g,needsAttention:c}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Me(e$1){let t=m.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let o=Ae(t,e$1.fromImpactPath);return {impact:await ke(o),fromImpactRef:m.relative(t,o).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g);if(await v.pathExists(r))return {impact:await ke(r),fromImpactRef:g,impactFromDisk:true};let s=m.join(t,d$3);if(await v.pathExists(s))return {impact:await p$1({workspacePath:t,fromPath:d$3,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:d$3,impactFromDisk:false};let i=await p({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:f$1,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:e.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:l(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:f.diff,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:e.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Te(e,t){if(t)return e.generatedAt}async function bt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Me(e),o$1=r.diff.currentModel,k=i?await p({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await p$1({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),W=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],A=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(W)!==JSON.stringify(A)&&u.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(k)!==r.diff.toHash&&u.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r.diff.git;if(i&&d$2?.available){let l=a(t,{ref:d$2.ref}),W=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),A=[...l.changedFiles.map(h=>`git.file.changed:${h}`),...l.untrackedFiles.map(h=>`git.untracked:${h}`),...l.deletedFiles.map(h=>`git.deleted:${h}`)].sort();(!l.available||l.commit!==d$2.commit||JSON.stringify(A)!==JSON.stringify(W))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=Te(r,i),c$1=Ee([...o(),...r.verificationPlan]).filter(l=>Se(e.scope,l)),n=[];for(let l of c$1)n.push(await _e(l,t,o$1.contracts.exists===true,g));let a$2=He(r,n),f=a$1(l(o$1)??{nodes:[],edges:[]}),y=b(o$1),P=await Ke(t),b$2=c(y,P?.freshness?.projectHashes),I={verdict:b$2.verdict,baseline:b$2.baseline,changed:b$2.changed,added:b$2.added,removed:b$2.removed,projectHashes:d$1(y)},E=b$1(f),V=o$1.policies?.mode??"warn",p$2=await Le(o$1,t),B=qe(V,p$2),S=Ne(n,{blockingReasons:[...a$2.blockingReasons,...E,...B.blockingReasons,...u],needsAttention:a$2.needsAttention||B.needsAttention}),he=n.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),_=[...n.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a$2.blockingReasons,...E,...B.blockingReasons,...u],ve=p$2.filter(l=>l.severity==="error").length,be=o$1.summary?.projectCount??o$1.projects.length,U=ge({projectCount:be,verdict:S.verdict,exitCode:S.exitCode,blockingReasons:_,policyErrorCount:ve});S.verdict=U.verdict,S.exitCode=U.exitCode;let Y=Array.from(new Set(_.map(l=>l.trim()).filter(Boolean))).slice(0,12).map((l,W)=>{let A=n.find(h=>l.startsWith(`${h.id}:`));return me({reason:l,blockerId:`blocker-${W+1}`,sourceCommand:A?.command.display,sourceArtifact:A?.evidencePath,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G})});return {schemaVersion:ye,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:S,steps:n,missingEvidence:he,blockingReasons:_,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:a$2.subgraph,graphIntegrity:f,freshness:I,policyMode:V,policyViolations:p$2}}async function Le(e$1,t){let r=[];for(let i of e$1.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await d$2(t,e.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let o of i.violations)typeof o=="string"&&o.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:o});}}catch{}return r.sort((i,o)=>i.source!==o.source?i.source.localeCompare(o.source):i.code!==o.code?i.code.localeCompare(o.code):i.message.localeCompare(o.message))}function qe(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function Ke(e){let t=m.join(e,G);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ye?r:null}catch{return null}}async function wt(e,t){return e$1(t,G,a$2(e))}function ze(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function Rt(e,t){return ze(e,t).exitCode}export{fe as a,tt as b,ye as c,G as d,He as e,bt as f,wt as g,ze as h,Rt as i};
|
package/dist/chunk-4PUJVYRM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Z="workspace-knowledge-search.v1";function b(e){return e.trim().toLowerCase()}var F=new WeakMap;function A(e){let t=F.get(e);if(t)return t;let o=new Map(e.relations.map(s=>[s.id,s])),a=new Map(e.entities.map(s=>[s.id,s])),l=new Map(e.proofs.map(s=>[s.id,s])),r=new Map,d=new Map,u=(s,p)=>{let g=d.get(s)??[];g.push(p),d.set(s,g);};for(let s of e.entities){let p=[s.id,s.label,s.identity.key,...s.kind==="project"&&s.projectId?[s.projectId]:[],...s.identity.aliases];for(let g of new Set(p.map(b))){let y=r.get(g)??[];y.push(s),r.set(g,y);}}for(let s of e.relations)u(s.from,{from:s.from,to:s.to,relationId:s.id,kind:s.kind,direction:"forward",proofIds:s.proofIds}),u(s.to,{from:s.to,to:s.from,relationId:s.id,kind:s.kind,direction:"reverse",proofIds:s.proofIds});for(let s of r.values())s.sort((p,g)=>p.id.localeCompare(g.id));for(let s of d.values())s.sort((p,g)=>p.to.localeCompare(g.to)||p.relationId.localeCompare(g.relationId));let c={entitiesById:a,relationsById:o,entitiesByAlias:r,proofsById:l,adjacency:d};return F.set(e,c),c}function O(e,t){let o=A(e),a=o.relationsById.get(t);if(a)return {found:true,targetType:"relation",relation:a};let l=b(t),r=o.entitiesByAlias.get(l)??[];return r.length===1?{found:true,targetType:"entity",entity:r[0]}:{found:false,query:t,candidates:r.map(d=>d.id).sort()}}function fe(e,t){let o=O(e,t);if(!o.found)return {query:t,found:false,target:null,proofs:[],candidates:o.candidates};let a=o.targetType==="entity"?o.entity:o.relation,l=new Set(a.proofIds);return {query:t,found:true,target:a,candidates:[],proofs:[...l].map(r=>A(e).proofsById.get(r)).filter(r=>!!r).sort((r,d)=>r.id.localeCompare(d.id))}}function ke(e,t,o){let a=O(e,t),l=O(e,o);if(!a.found||a.targetType!=="entity"||!l.found||l.targetType!=="entity")return {from:t,to:o,found:false,resolvedFrom:a.found&&a.targetType==="entity"?a.entity.id:null,resolvedTo:l.found&&l.targetType==="entity"?l.entity.id:null,entityPath:[],hops:[],proofs:[]};let r=A(e),d=[a.entity.id],u=new Map,c=new Set(d),s=0;for(;s<d.length&&!c.has(l.entity.id);){let h=d[s++];for(let k of r.adjacency.get(h)??[])c.has(k.to)||(c.add(k.to),u.set(k.to,k),d.push(k.to));}if(!c.has(l.entity.id))return {from:t,to:o,found:false,resolvedFrom:a.entity.id,resolvedTo:l.entity.id,entityPath:[],hops:[],proofs:[]};let p=[],g=l.entity.id;for(;g!==a.entity.id;){let h=u.get(g);if(!h)break;p.push(h),g=h.from;}p.reverse();let y=new Set(p.flatMap(h=>h.proofIds));return {from:t,to:o,found:true,resolvedFrom:a.entity.id,resolvedTo:l.entity.id,entityPath:[a.entity.id,...p.map(h=>h.to)],hops:p,proofs:[...y].map(h=>r.proofsById.get(h)).filter(h=>!!h).sort((h,k)=>h.id.localeCompare(k.id))}}function we(e,t){return e.entities.filter(o=>!t||o.kind===t).sort((o,a)=>o.kind.localeCompare(a.kind)||o.label.localeCompare(a.label))}var m={relations:24,relatedEntities:24,proofs:16,proofIdsPerItem:4,aliasesPerEntity:8,attributeArrayItems:8,attributeStringCharacters:256};function J(e){let t=[],o=new Set;for(let a=0;a<m.proofIdsPerItem&&t.length<m.proofs;a+=1)for(let l of e){let r=l.proofIds[a];if(!(!r||o.has(r))&&(o.add(r),t.push(r),t.length>=m.proofs))break}return t}function ee(e,t,o){let a=e.identity.aliases.slice(0,m.aliasesPerEntity);o.aliases+=e.identity.aliases.length-a.length;let l=Object.fromEntries(Object.entries(e.attributes).map(([d,u])=>{if(Array.isArray(u)){let c=u.slice(0,m.attributeArrayItems);return o.attributeValues+=u.length-c.length,[d,c]}return typeof u=="string"&&u.length>m.attributeStringCharacters?(o.attributeValues+=1,[d,u.slice(0,m.attributeStringCharacters)]):[d,u]})),r=e.proofIds.filter(d=>t.has(d)).slice(0,m.proofIdsPerItem);return o.proofReferences+=e.proofIds.length-r.length,{...e,identity:{...e.identity,aliases:a},attributes:l,proofIds:r}}function te(e){let t=Object.values(e.attributes).flatMap(o=>Array.isArray(o)?o:[o]);return [e.id,e.kind,e.label,e.projectId??"",e.identity.key,...e.identity.aliases,...t.map(o=>String(o??""))].join(" ").toLowerCase()}var ne=new Set(["a","an","and","are","as","at","be","been","being","by","can","check","could","did","do","does","find","for","from","give","had","has","have","how","i","in","into","is","it","its","may","might","of","on","or","our","show","should","that","the","their","them","then","there","these","they","this","those","tell","to","was","we","were","what","when","where","which","who","why","will","with","would","you","your"]);function T(e){let t=o=>b(o).split(/[^a-z0-9]+/u).filter(a=>a.length>1);return [...new Set([...t(e),...t(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2"))])]}function oe(e){let t=b(e.label),o=b(e.identity.key),a=e.identity.aliases.map(b),l=te(e);return {entity:e,label:t,identity:o,aliases:a,haystack:l,labelTokens:new Set(T(e.label)),identityTokens:new Set(T(e.identity.key)),aliasTokens:new Set(e.identity.aliases.flatMap(T)),allTokens:new Set(T(l))}}function S(e,t){return e.has(t)||t.length>=3&&[...e].some(o=>o.startsWith(t))}function G(e,t){return S(e.labelTokens,t)||S(e.identityTokens,t)||S(e.aliasTokens,t)||S(e.allTokens,t)}function se(e,t,o,a){let{label:l,identity:r,aliases:d,haystack:u}=e,c=0;(l===t||r===t||d.includes(t))&&(c+=1e4),(l.startsWith(t)||r.startsWith(t))&&(c+=250),u.includes(t)&&(c+=100);let s=0;for(let p of o){let g=a.get(p)??1,y=S(e.labelTokens,p),h=S(e.identityTokens,p),k=S(e.aliasTokens,p),f=G(e,p);f&&(s+=1),l===p?c+=80*g:y&&(c+=36*g),h&&(c+=24*g),k&&(c+=20*g),f&&(c+=10*g);}return o.length>0&&(c+=s/o.length*120),c}function ae(e,t){return t.filter(o=>G(e,o)).length}var re=new Map([["clojure","clojure"],["cplusplus","cpp"],["cpp","cpp"],["typescript","typescript"],["ts","typescript"],["javascript","javascript"],["js","javascript"],["nodejs","javascript"],["python","python"],["py","python"],["go","go"],["golang","go"],["csharp","csharp"],["dotnet","csharp"],["dart","dart"],["elixir","elixir"],["fsharp","fsharp"],["java","java"],["kotlin","kotlin"],["lua","lua"],["php","php"],["ruby","ruby"],["rust","rust"],["scala","scala"],["svelte","svelte"],["swift","swift"],["vue","vue"]]);function ie(e){return new Set(e.map(t=>re.get(t)).filter(t=>!!t))}function U(e){let t=e.attributes.language;return typeof t=="string"?b(t):null}function ce(e){return {project:1e3,service:900,api:900,package:850,endpoint:800,container:700,deployment:700,environment:650,pipeline:600,"test-suite":550,owner:500,decision:450,document:400}[e.kind]??0}function le(e,t){let o=t.has("language")||t.has("languages"),a=t.has("binding")||t.has("bindings")||t.has("bridge")||t.has("bridges"),l=t.has("dependency")||t.has("dependencies")||t.has("depends"),r=t.has("core")||t.has("runtime"),d=t.has("owner")||t.has("owners")||t.has("ownership")||t.has("maintainer"),u=t.has("ci")||t.has("pipeline")||t.has("pipelines")||t.has("workflow"),c=t.has("deploy")||t.has("deployment")||t.has("infrastructure")||t.has("container"),s=t.has("doc")||t.has("docs")||t.has("document")||t.has("documentation"),p=t.has("service")||t.has("services")||t.has("api")||t.has("rpc"),g=t.has("schema")||t.has("schemas")||t.has("message")||t.has("protobuf")||t.has("proto")||t.has("contract"),y=typeof e.attributes.mechanism=="string"?b(e.attributes.mechanism):"",h=typeof e.attributes.specification=="string"?b(e.attributes.specification):"",k=b(e.label),f=0;if(o&&e.kind==="language"){let j=typeof e.attributes.fileCount=="number"?e.attributes.fileCount:0;f+=900+Math.min(j,1e4)/10;}return a&&e.kind==="protocol"&&(f+=800),l&&e.kind==="package"&&(f+=650),r&&e.kind==="package"&&/(?:^|[_-])core(?:$|[_-])/u.test(k)&&(f+=700),r&&e.kind==="protocol"&&y.includes("core")&&(f+=300),d&&e.kind==="owner"&&(f+=850),u&&e.kind==="pipeline"&&(f+=800),c&&["deployment","container","environment"].includes(e.kind)&&(f+=775),s&&["document","decision"].includes(e.kind)&&(f+=725),p&&["api","endpoint","service"].includes(e.kind)&&(f+=700),g&&(e.kind==="schema"||(e.kind==="api"||e.kind==="protocol")&&(h.includes("protobuf")||y.includes("protobuf")))&&(f+=750),f}function de(e){return [e.has("language")||e.has("languages"),e.has("binding")||e.has("bindings")||e.has("bridge")||e.has("bridges"),e.has("dependency")||e.has("dependencies")||e.has("depends"),e.has("core")||e.has("runtime"),e.has("owner")||e.has("ownership")||e.has("maintainer"),e.has("ci")||e.has("pipeline")||e.has("workflow"),e.has("deploy")||e.has("deployment")||e.has("infrastructure"),e.has("doc")||e.has("docs")||e.has("documentation"),e.has("service")||e.has("api")||e.has("rpc"),e.has("schema")||e.has("protobuf")||e.has("proto")||e.has("contract")].filter(Boolean).length>=3}function ye(e,t){let o=b(t.query),a=[...new Set(T(t.query))],l=new Set(T(t.projectId??"")),r=t.projectId?a.filter(n=>!l.has(n)):a,d=!!(t.projectId&&a.length>0&&r.length===0),u=r.filter(n=>!ne.has(n)),c=u.length>0?u:r,s=ie(c),p=new Set(c),g=de(p),y=c.length<=1?c.length:Math.min(3,Math.ceil(c.length/3)),h=t.minimumTermMatches===void 0?y:Math.min(y,Math.max(1,Math.trunc(t.minimumTermMatches))),k=Math.max(1,Math.min(Math.trunc(t.limit??12),100)),f=Math.max(0,Math.min(Math.trunc(t.relationsPerEntity??4),20)),j=new Set;if(t.projectId){let n=new Set(e.entities.filter(i=>i.kind==="project"&&(i.projectId===t.projectId||i.label===t.projectId)).map(i=>i.id));for(let i of e.relations)n.has(i.from)&&j.add(i.to),n.has(i.to)&&j.add(i.from);}let x=e.entities.filter(n=>(!t.kind||n.kind===t.kind)&&(!t.projectId||n.projectId===t.projectId||n.projectId===void 0&&j.has(n.id))).map(oe),Q=new Map(c.map(n=>{let i=x.filter(w=>G(w,n)).length;return [n,Math.log((x.length+1)/(i+1))+1]})),P=x.map(n=>{let i=ae(n,c),w=U(n.entity),I=w&&s.has(w)?400:0,K=le(n.entity,p);return {entity:n.entity,matchedTerms:i,intentScore:K,score:d?ce(n.entity):se(n,o,c,Q)+I+K}}).filter(n=>{let i=U(n.entity);return (s.size===0||i===null||s.has(i))&&(o.length===0||n.score>0&&(d||n.matchedTerms>=h||n.intentScore>0&&(g||c.length<=2)))}).sort((n,i)=>i.score-n.score||n.entity.kind.localeCompare(i.entity.kind)||n.entity.label.localeCompare(i.entity.label)),E=(g?(()=>{let n=[],i=[],w=new Map,I=new Set;for(let K of P){let V=w.get(K.entity.kind)??0,z=b(K.entity.label);V<2&&!I.has(z)?(n.push(K),w.set(K.entity.kind,V+1),I.add(z)):i.push(K);}return [...n,...i]})():P).slice(0,k).map(n=>n.entity),v=new Set(E.map(n=>n.id)),D=new Map,B=e.relations.filter(n=>{if(!(v.has(n.from)||v.has(n.to)))return false;let w=v.has(n.from)?n.from:n.to,I=D.get(w)??0;return I>=f?false:(D.set(w,I+1),true)}),W=t.projection==="agent",M=W?B.slice(0,m.relations):B,H=A(e),_=[...new Set(M.flatMap(n=>[n.from,n.to]).filter(n=>!v.has(n)))].map(n=>H.entitiesById.get(n)).filter(n=>!!n).map(({id:n,kind:i,label:w,projectId:I})=>({id:n,kind:i,label:w,...I?{projectId:I}:{}})).sort((n,i)=>n.kind.localeCompare(i.kind)||n.label.localeCompare(i.label)),L=W?_.slice(0,m.relatedEntities):_,N=new Set([...E.flatMap(n=>n.proofIds),...M.flatMap(n=>n.proofIds)]),$=W?J([...E,...M]):[...N],C=new Set($),R={entities:P.length-E.length,relations:B.length-M.length,relatedEntities:_.length-L.length,proofs:N.size-C.size,proofReferences:0,aliases:0,attributeValues:0},q=W?E.map(n=>ee(n,C,R)):E,Y=W?M.map(n=>{let i=n.proofIds.filter(w=>C.has(w)).slice(0,m.proofIdsPerItem);return R.proofReferences+=n.proofIds.length-i.length,{...n,proofIds:i}}):M,X=[...C].map(n=>H.proofsById.get(n)).filter(n=>!!n).sort((n,i)=>n.id.localeCompare(i.id));return {schemaVersion:Z,query:t.query,kind:t.kind??null,...t.projectId?{projectId:t.projectId}:{},limit:k,totalMatches:P.length,truncated:P.length>q.length||W&&Object.values(R).some(n=>n>0),entities:q,relatedEntities:L,relations:Y,proofs:X,...W?{budget:{mode:"agent",limits:{...m},omitted:R}}:{}}}export{Z as a,O as b,fe as c,ke as d,we as e,ye as f};
|
package/dist/chunk-5B2GAZAC.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {d,b,e}from'./chunk-W6FHVXNL.js';import {a}from'./chunk-2647BYBC.js';import {a as a$1}from'./chunk-27UR373Z.js';import {d as d$2}from'./chunk-S5KTATOU.js';import {p as p$1,w,t as t$1}from'./chunk-J7RU5WR5.js';import {h,j,f,e as e$2}from'./chunk-XKDR5BGS.js';import {d as d$1}from'./chunk-CCDGHPEJ.js';import {e as e$1,i}from'./chunk-NZ3WZYD5.js';import {a as a$2}from'./chunk-TQEMLBAG.js';import {t,p,s}from'./chunk-MOSXTVPU.js';import {e as e$3,g}from'./chunk-RGNCL5OB.js';import U from'fs';import k from'path';import T from'chalk';import {execa}from'execa';function Le(e){return U.existsSync(k.join(e,"bun.lock"))||U.existsSync(k.join(e,"bunfig.toml"))?"bun":U.existsSync(k.join(e,"pnpm-lock.yaml"))?"pnpm":U.existsSync(k.join(e,"yarn.lock"))?"yarn":(U.existsSync(k.join(e,"package-lock.json")),"npm")}function Ge(e,r,t=Le(e)){return t==="npm"?`npm run ${r}`:`${t} run ${r}`}function Be(e,r=Le(e)){return `${r} install`}var ct={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},dt={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],c:["cmake -S . -B build"],cpp:["cmake -S . -B build"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],c:["ctest --test-dir build --output-on-failure"],cpp:["ctest --test-dir build --output-on-failure"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],c:["cmake --build build"],cpp:["cmake --build build"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],c:[],cpp:[],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function te(e,r){if(r){let t=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=e$2(r),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:t==="fiber"?"fiber":t==="aspnetcore"||t==="asp-net-core"?"aspnetcore":t}`;return ct[s]}}function He(e,r,t){if(r){let n=te(e,r);if(n&&n.commands[t])return n.commands[t]}if(["init","test","build","start"].includes(t)){let n=dt[t]?.[e]??[];return n.length>0?n[0]:void 0}}var lt={test:"test",build:"build",start:"start"};function ge(e){if(e.stage==="init")return e.runtime==="node"?Be(e.projectPath):He(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let r=lt[e.stage];if(r){let t=t$1(e.projectPath,r,{framework:e.framework});if(t)return Ge(e.projectPath,t.scriptName)}}return He(e.runtime,e.framework,e.stage)}function mt(e){let r=h(e).map(t=>t==="python"?"python":t==="node"||t==="bun"?"node":t==="go"?"go":t==="java"?"java":t==="php"?"php":t==="rust"?"rust":t==="dotnet"?"dotnet":t==="elixir"?"elixir":t==="ruby"?"ruby":t==="clojure"||t==="scala"||t==="kotlin"?"jvm-generic":null).filter(t=>t!==null).filter((t,n,o)=>o.indexOf(t)===n);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function ze(e){return mt(e).primary}function ye(e,r){if(!e)return "unknown";r||(r={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[t,n]of Object.entries(r))for(let o of n)if(new RegExp(o,"i").test(e))return t;return "unknown"}async function re(e){let r=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(r))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[r],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${r}' not found or not executable`}}function Je(e,r,t){if(!r)return e;let n=typeof r=="object"&&!Array.isArray(r)&&("dev"in r||"staging"in r||"prod"in r||"default"in r)&&!Object.keys(r).some(o=>["init","test","build","start"].includes(o))?r:{};return t&&typeof n[t]=="string"?n[t]:typeof n.default=="string"?n.default:e}async function qe(e,r){if(!e)return {healthy:true};switch(e.type){case "port":{let t=e.value;try{let n=await import('net');return new Promise(o=>{let s=new n.Socket,u=5e3;s.setTimeout(u),s.on("connect",()=>{s.destroy(),o({healthy:true,reason:`Port ${t} is listening`});}),s.on("timeout",()=>{s.destroy(),o({healthy:false,reason:`Port ${t} timeout after ${u}ms`});}),s.on("error",c=>{s.destroy(),o({healthy:false,reason:`Port ${t} error: ${String(c)}`});}),s.connect(t,"localhost");})}catch(n){return {healthy:false,reason:`Port check error: ${n instanceof Error?n.message:String(n)}`}}}case "http":{let t=e.value,n;try{let o=new AbortController;n=setTimeout(()=>o.abort(),5e3);let s=await fetch(t,{method:"GET",signal:o.signal});return {healthy:s.status===200,reason:`HTTP ${s.status}`,metadata:{status:s.status}}}catch(o){return {healthy:false,reason:`HTTP check error: ${o instanceof Error?o.message:String(o)}`}}finally{n&&clearTimeout(n);}}case "log":{let t=e.value;if(!r)return {healthy:true};try{let n=[k.join(r,".workspai","last-run.log"),k.join(r,".rapidkit","last-run.log")].find(o=>U.existsSync(o));if(n){let o=U.readFileSync(n,"utf-8"),s=new RegExp(t,"i");return {healthy:s.test(o),reason:s.test(o)?"Log pattern found":"Log pattern not found"}}return {healthy:true,reason:"No log file to check"}}catch(n){return {healthy:false,reason:`Log check error: ${n instanceof Error?n.message:String(n)}`}}}case "command":{let t=e.value;try{let n=await execa(t,[],{cwd:r,reject:false,shell:true});return {healthy:n.exitCode===0,reason:n.exitCode===0?"Health check passed":"Health check failed",metadata:{exitCode:n.exitCode}}}catch(n){return {healthy:false,reason:`Command check error: ${n instanceof Error?n.message:String(n)}`}}}default:return {healthy:true}}}var Ye={init:"init",test:"test",build:"build",start:"start"};function pt(e){return e in Ye?Ye[e]:null}function ft(e,r){let n=p$1(e)?.contextJson?.commands;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n[r];if(typeof o=="string"&&o.trim().length>0)return o.trim();if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,u=s.default??s.dev;if(typeof u=="string"&&u.trim().length>0)return u.trim()}}function Qe(e,r,t=w(e)){let n=pt(r);if(!n)return ft(e,r)?{supported:true}:{supported:false,reason:`Workspace stage "${r}" is not part of the Workspai fleet contract.`};if(!t.projectRoot)return {supported:false,reason:"No Workspai project metadata was detected for this target."};let o=t.commandMap[n];if(!o||o.status!=="supported"){let s=t.runtimeSupportTier==="observed"||t.frameworkSupportTier==="observed";return {supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`,shouldFail:!s}}return {supported:true}}var gt=new Set(["init","test","build","start"]),yt=new Set([".git","node_modules",".workspai",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function B(e){try{return await U.promises.access(e,U.constants.F_OK),true}catch{return false}}async function ht(e){for(let r of e)if(await B(r))return true;return false}async function kt(e,r,t){if(r==="python"){let o=[k.join(e,".workspai","cli.py"),k.join(e,".rapidkit","cli.py")];for(let s of o)if(await B(s))return {valid:true};return {valid:false,reason:"Project-local .workspai/cli.py is missing. Run `workspai init` in this project first."}}let n=t.trim().split(/\s+/)[0];if(n&&["npm","npx","pnpm","yarn"].includes(n)){let o=e$3(n);if((await execa(o.command,[...o.prefixArgs,"--version"],{reject:false,env:g()})).exitCode===0)return {valid:true}}return re(t)}async function ne(e){let r=await U.promises.readFile(e,"utf-8");return JSON.parse(r)}function D(e){return e.replace(/\\/g,"/")}function bt(e){let r=e?.trim();return r?r.startsWith("project:")?r.slice(8).trim()||null:r:null}async function wt(e){let r=k.join(e,e$1.model);if(await B(r))try{let n=((await ne(r)).projects??[]).map(o=>typeof o.path=="string"?k.resolve(e,o.path):null).filter(o=>!!o).filter((o,s,u)=>u.indexOf(o)===s).filter(o=>U.existsSync(o));if(n.length>0)return n.sort()}catch{}return a$1(e,{skipDirs:yt,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t$1,n)=>await ht([...t(t$1,"context.json"),...t(t$1,"project.json")])?true:k.resolve(t$1)===k.resolve(n)?false:h(t$1).length>0})}async function xt(e){for(let r of [k.join(".workspai","project.json"),k.join(".workspai","context.json"),k.join(".rapidkit","project.json"),k.join(".rapidkit","context.json")]){let t=k.join(e,r);if(await B(t))try{let n=await ne(t),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function vt(e,r,t){let n=bt(t);if(!n)return {projects:r,normalizedScope:null};let o=D(n).toLowerCase(),s=[];for(let u of r){let c=D(k.relative(e,u)),m=k.basename(u),p=await xt(u);[c,m,p].filter(i=>typeof i=="string"&&i.length>0).map(i=>D(i).toLowerCase()).includes(o)&&s.push(u);}if(s.length===0)throw new Error(`Workspace run scope did not match any project: ${t}`);return {projects:s,normalizedScope:n}}async function Rt(e,r,t){let n=await execa("git",["diff","--name-only",`${t}...HEAD`],{cwd:e,reject:false,env:a$2()});if(n.exitCode!==0)return new Set(r);let o=n.stdout.split(/\r?\n/).map(u=>u.trim()).filter(u=>u.length>0).map(u=>D(u));if(o.length===0)return new Set;let s=new Set;for(let u of r){let c=D(k.relative(e,u));if(!c||c===".")continue;let m=`${c}/`;o.some(p=>p===c||p.startsWith(m))&&s.add(u);}return s}async function St(e,r,t){let n=await d$1(e,i.workspaceContract)??p(e,"workspace.contract.json");if(await B(n))try{let d=await Ct(e,r,t,n);if(d.graphStatus!=="missing")return d}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let o=await d$1(e,".workspai/workspace-dependency-graph.json")??p(e,"workspace-dependency-graph.json");if(!await B(o))return {expanded:t,graphStatus:"missing",expansionDepth:0};let s;try{s=await ne(o);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let u=new Set(r.map(d=>k.resolve(d))),c=new Map;if(!s||typeof s!="object"||Array.isArray(s))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let m=Array.isArray(s.projects)?s.projects:[];for(let d of m){if(!d||typeof d!="object"||Array.isArray(d))continue;let i=d,l=typeof i.path=="string"?i.path:"",y=k.resolve(e,l);if(!u.has(y))continue;let b=Array.isArray(i.dependsOn)?i.dependsOn.filter(S=>typeof S=="string"):[];for(let S of b){let g=k.resolve(e,S);u.has(g)&&(c.has(g)||c.set(g,new Set),c.get(g)?.add(y));}}let p$1=d$2(c,t);return {expanded:p$1.reached,graphStatus:"loaded",expansionDepth:p$1.added}}async function Ct(e,r,t,n){let o=await ne(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let s=o,u=Array.isArray(s.projects)?s.projects:null;if(!u)return {expanded:t,graphStatus:"invalid",expansionDepth:0};let c=new Map,m=new Map;for(let y of r){let b=D(k.relative(e,y));m.set(b,k.resolve(y));}let p=new Map,d=new Map,i=new Map;for(let y of u){if(!y||typeof y!="object"||Array.isArray(y))continue;let b=y,S=typeof b.slug=="string"?b.slug:"",g=typeof b.relativePath=="string"?D(b.relativePath):S,v=m.get(g);!S||!v||c.set(S,v);}for(let y of u){if(!y||typeof y!="object"||Array.isArray(y))continue;let b=y,S=typeof b.slug=="string"?b.slug:"",g=c.get(S);if(!g)continue;let v=b.contracts&&typeof b.contracts=="object"&&!Array.isArray(b.contracts)?b.contracts:{},E=Array.isArray(v.dependsOn)?v.dependsOn.filter(R=>typeof R=="string"):[],W=Array.isArray(v.publishes)?v.publishes.filter(R=>typeof R=="string"):[],_=Array.isArray(v.consumes)?v.consumes.filter(R=>typeof R=="string"):[];for(let R of E){let j=c.get(R);j&&(i.has(j)||i.set(j,new Set),i.get(j)?.add(g));}for(let R of W)p.has(R)||p.set(R,new Set),p.get(R)?.add(g);for(let R of _)d.has(R)||d.set(R,new Set),d.get(R)?.add(g);}for(let[y,b]of p.entries()){let S=d.get(y);if(S)for(let g of b){i.has(g)||i.set(g,new Set);for(let v of S)v!==g&&i.get(g)?.add(v);}}let l=d$2(i,t);return {expanded:l.reached,graphStatus:"loaded",expansionDepth:l.added}}async function Et(e,r){if(typeof r=="boolean")return r;let t=s(e,"policies.yml").find(s=>U.existsSync(s))??p(e,"policies.yml");if(!await B(t))return true;let n="";try{n=await U.promises.readFile(t,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[1]==="true":true}function jt(e){let r=process.env.RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS;if(r){let t=Number.parseInt(r,10);if(Number.isFinite(t)&&t>0)return t}return e==="init"?12e4:9e4}function Xe(e,r){let t=Number.parseInt(process.env[e]??"",10);return Number.isFinite(t)&&t>0?t:r}function he(e){return new Promise(r=>setTimeout(r,e))}async function Pt(e){let r=process.argv[1];if(e.useRapidkitWrapper&&!r)return {exitCode:1,stdout:"",stderr:"Workspai entrypoint is unavailable for startup verification.",healthStatus:{healthy:false,reason:"Workspai entrypoint is unavailable."}};let t=e.useRapidkitWrapper&&r?execa(process.execPath,[r,"start"],{cwd:e.projectPath,reject:false,timeout:e.timeoutMs,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}}):execa(e.finalCommand,[],{cwd:e.projectPath,reject:false,shell:true,timeout:e.timeoutMs}),n=Promise.resolve(t).then(d=>({kind:"exit",result:d}),d=>({kind:"error",error:d})),o=Xe("WORKSPAI_WORKSPACE_RUN_STARTUP_GRACE_MS",2e3),s=await Promise.race([n,he(o).then(()=>({kind:"alive"}))]);if(s.kind==="error"){let d=typeof s.error=="object"&&s.error!==null&&"timedOut"in s.error&&!!s.error.timedOut;return {exitCode:d?124:1,stdout:"",stderr:s.error instanceof Error?s.error.message:String(s.error),timedOut:d,healthStatus:{healthy:false,reason:"The start command failed before readiness."}}}if(s.kind==="exit"){let d=Number(s.result.exitCode??0);return {exitCode:d,stdout:String(s.result.stdout??""),stderr:String(s.result.stderr??""),healthStatus:{healthy:d===0,reason:d===0?"The start command completed successfully.":`The start command exited with code ${d} before readiness.`}}}let u=te(e.runtime,e.framework)?.healthCheck,c=u?{healthy:false,reason:"The configured health check has not passed yet."}:{healthy:true,reason:`The service remained alive for ${o}ms (bounded startup smoke).`};if(u){let d=Xe("WORKSPAI_WORKSPACE_RUN_STARTUP_HEALTH_TIMEOUT_MS",15e3),i=Date.now()+d;for(;Date.now()<i;){let l=await qe(u,e.projectPath);if(c={healthy:l.healthy,reason:l.reason},l.healthy)break;if((await Promise.race([n,he(350).then(()=>({kind:"alive"}))])).kind!=="alive"){c={healthy:false,reason:"The service exited before its configured health check passed."};break}}}try{t.kill?.("SIGTERM",{forceKillAfterDelay:1e3});}catch{try{t.kill?.();}catch{}}let m=await Promise.race([n,he(2e3).then(()=>({kind:"alive"}))]),p=m.kind==="exit"?m.result:void 0;return {exitCode:c.healthy?0:1,stdout:String(p?.stdout??""),stderr:String(p?.stderr??""),healthStatus:c}}async function ke(e,r,t){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};try{let o=await execa(process.execPath,[n,...e],{cwd:r,reject:false,timeout:t,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}catch(o){return {exitCode:typeof o=="object"&&o!==null&&"timedOut"in o&&!!o.timedOut?124:1,stdout:typeof o=="object"&&o!==null&&"stdout"in o?String(o.stdout??""):"",stderr:typeof o=="object"&&o!==null&&"stderr"in o?String(o.stderr??""):o instanceof Error?o.message:String(o)}}}function At(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"||e==="rust"||e==="php"}function Ft(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}function Ot(e,r=8){if(e.length<=r)return e.join(`
|
|
2
|
-
`);let t=3;return [...e.slice(0,t),...e.slice(-(r-t))].join(`
|
|
3
|
-
`)}function Tt(e){let r=/(?:\bnot found\b|\bno such\b|\bmissing\b|\bfailed\b|\berror\b|\bexception\b|\bcannot\b|\bdenied\b|\btimeout\b|\btimed out\b|\benoent\b|\beacces\b|\beperm\b)/i;return [...e].reverse().find(t=>r.test(t))??e.at(-1)}async function Mt(e){let r=process.cwd();try{process.chdir(e);let{handleInitCommand:t}=await import('./index.js');return {exitCode:await t(["init"]),stdout:"",stderr:""}}finally{process.chdir(r);}}async function Ze(e){let r=i=>{let l=f(i);return l==="node"||l==="bun"?"node":l==="python"?"python":l==="go"?"go":l==="java"?"java":l==="php"?"php":l==="ruby"?"ruby":l==="rust"?"rust":l==="dotnet"?"dotnet":l==="elixir"?"elixir":l==="clojure"||l==="scala"||l==="kotlin"?"jvm-generic":ze(e)},t=i=>{if(!i)return;let l=e$2(i);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(l))return l},n=p$1(e),o=n?.detection??j(e,n?.projectJson??null),s=n?.contextJson,u=r(o.runtime),c=t(o.key),m={},p=new Set(["init","test","build","start"]);if(s?.commands&&typeof s.commands=="object")for(let[i,l]of Object.entries(s.commands))typeof l=="string"&&p.has(i)&&(m[i]=l);let d;if(s?.commandEnvironments&&typeof s.commandEnvironments=="object"){let i=s.commandEnvironments;d={dev:typeof i.dev=="string"?i.dev:void 0,staging:typeof i.staging=="string"?i.staging:void 0,prod:typeof i.prod=="string"?i.prod:void 0,default:typeof i.default=="string"?i.default:void 0};}return {runtime:u,framework:c,commandOverrides:Object.keys(m).length>0?m:void 0,environmentCommandVariants:d,environment:typeof s?.environment=="string"?s.environment:void 0}}async function et(e,r,t,n,o,s,u){let c=!o?.[r]&&At(t),m;if(o&&o[r]?m=o[r]:c?m=`rapidkit ${r}`:m=ge({projectPath:e,runtime:t,framework:n,stage:r}),!m)return {exitCode:127,command:`<stage not supported for ${t}>`,message:`No stage command found for runtime '${t}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let p=Je(m,s,u);if(!p)return {exitCode:127,command:m,message:"Failed to resolve stage command",errorCategory:"runtime"};let d=ge({projectPath:e,runtime:t,framework:n,stage:r});if(c){if(d){let x=c?await kt(e,t,d):await re(d);if(!x.valid)return {exitCode:127,command:p,message:x.reason||"Command not available",errorCategory:"setup"}}}else {let x=await re(p);if(!x.valid)return {exitCode:127,command:p,message:x.reason||"Command not available",errorCategory:"setup"}}let i=0,l="",y="",b,S,g=jt(r),v=Date.now();try{let x=r==="start"?await Pt({projectPath:e,finalCommand:p,useRapidkitWrapper:c,runtime:t,framework:n,timeoutMs:g}):c?r==="init"&&Ft()?await Mt(e):await ke([r],e,g):await execa(p,[],{cwd:e,reject:false,shell:true,timeout:g});if(i=Number(x.exitCode??0),l=x.stdout,y=x.stderr,S=r==="start"?x.healthStatus:void 0,i!==0){let I=`${l}
|
|
4
|
-
${y}`,V=Date.now()-v;b=i===124||ye(I)==="timeout"||i===143&&V>=Math.floor(g*.8)?"timeout":ye(I);}}catch(x){let I=typeof x=="object"&&x!==null&&"timedOut"in x&&!!x.timedOut;return {exitCode:I?124:1,command:p,message:I?`Stage timed out after ${g}ms`:x instanceof Error?x.message:"Command execution failed",errorCategory:I?"timeout":"runtime"}}let E=`${l}
|
|
5
|
-
${y}`.split(/\r?\n/).map(x=>x.trim()).filter(Boolean),W=Ot(E),_=Tt(E),R=Date.now()-v,j=i===124||b==="timeout"||i===143&&R>=Math.floor(g*.8),P=i===0?void 0:j?"timeout":b,$=i===0||!P?void 0:{category:P,exitCode:i,command:p,timedOut:j,timeoutMs:g,...W?{outputExcerpt:W}:{}};return {exitCode:i,command:p,errorCategory:P,healthStatus:S,failureDiagnostic:$,message:j?`Stage timed out after ${g}ms`:i!==0?_?`Stage failed with exit code ${i}: ${_}`:`Stage failed with exit code ${i}`:void 0}}function tt(e){try{return JSON.parse(e)}catch{return null}}function Nt(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx workspai setup dotnet` or `npx workspai init`.";case "go":return "Install Go 1.21+, then rerun `npx workspai setup go` or `npx workspai init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx workspai setup java` or `npx workspai init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx workspai setup node` or `npx workspai init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx workspai setup python` or `npx workspai init`.";default:return null}}async function Dt(e){let r=[],t=await ke(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let s=tt(t.stdout)?.healthScore,u=Number(s?.errors??0);Number.isFinite(u)&&u>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${u} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let n=await ke(["readiness","--json"],e);if(n.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let o=tt(n.stdout),s=String(o?.overallStatus??"").toLowerCase();s==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):s==="warn"?r.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):r.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return r}var Wt=new Set(["dev","stop"]);function $t(e){let r=e.trim();return !r||Wt.has(r.toLowerCase())?false:gt.has(r)?true:/^[a-z][a-z0-9_-]*$/i.test(r)}function rt(e,r,t){let n=D(k.relative(t,r));return (Array.isArray(e.projects)?e.projects:[]).some(s=>{if(!s||typeof s!="object")return false;let u=s,c=[u.relativePath,u.path].filter(m=>typeof m=="string"&&m.length>0).map(m=>D(m));return u.status==="passed"&&(c.includes(n)||c.some(m=>m.endsWith(`/${n}`)))})}function It(e,r){return te(e,r)?.dependencies??[]}function _t(e,r){let t=Math.max(1,Math.min(4,r)),n=Number(e??t);return Number.isFinite(n)?Math.max(1,Math.min(16,Math.trunc(n))):t}async function vr(e$1){if(!$t(e$1.stage))throw new Error(`Unsupported workspace run stage: ${e$1.stage}`);let r=Date.now(),t=k.resolve(e$1.workspacePath),n=await d(t),o=await wt(t),{projects:s,normalizedScope:u}=await vt(t,o,e$1.scope),c=e$1.affected===true,m=e$1.blastRadius===true,p=e$1.since?.trim()||"HEAD~1",d$1=c?await Rt(t,s,p):new Set(s),i,l="not-applicable",y=0,b$1="all";if(c&&m){let f=await St(t,o,d$1);i=f.expanded,l=f.graphStatus,y=f.expansionDepth,b$1="affected+blast-radius";}else c?(i=d$1,b$1="affected"):(i=d$1,b$1="all");let S=e$1.stage==="init"||e$1.planOnly===true?false:await Et(t,e$1.enforceGates),g=S?await Dt(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],v=g.find(f=>f.status==="fail"),E=s.filter(f=>i.has(f)),W=e$1.continueOnError===true||e$1.stage==="init",_=e$1.parallel===true,R=_t(e$1.maxWorkers,E.length),j=E.length,P=0;e$1.json||console.log(T.gray(`Workspace run (${e$1.stage}) started: ${j} target(s), ${_?`parallel x${R}`:"sequential"}`));let $=new Map;for(let f of o){let h=D(k.relative(t,f)),a=s.includes(f),M=a&&i.has(f);$.set(f,{path:f,relativePath:h,projectName:k.basename(h)||k.basename(f),selected:M,affected:M,status:"skipped",exitCode:null,durationMs:0,reason:M?void 0:a?"not affected":"outside scope",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});}if(v)for(let f of E){let h=$.get(f);h&&(h.status="skipped",h.reason=`blocked by ${v.gate}`);}else {let f=async h=>{let a$1=$.get(h);if(!a$1)return;let M=D(k.relative(t,h));e$1.json||console.log(T.gray(`\u23F3 [${P}/${j}] ${e$1.stage} ${M}`)),a$1.selected=true,a$1.affected=true;let A=Date.now(),N=a(h),F=e$1.runtime?.trim().toLowerCase(),L=N.units.filter(w=>!F||w.runtime===F).map(w=>({unit:w,stage:w.stages.find(O=>O.stage===e$1.stage)})).filter(w=>!!w.stage),z=L.map(({unit:w,stage:O})=>({unitId:w.id,runtime:w.runtime,role:w.role,root:w.root,manifest:w.manifest,stage:O.stage,command:O.command,status:"planned",exitCode:null,durationMs:0}));if(a$1.runtimeExecutions=z,e$1.planOnly){a$1.runtimeDetected=L[0]?.unit.runtime,a$1.status="skipped",a$1.reason=L.length>0?`plan only: ${L.length} runtime unit(s)`:F?`no ${F} runtime unit supports stage "${e$1.stage}"`:`no runtime unit supports stage "${e$1.stage}"`,a$1.durationMs=Date.now()-A,P+=1;return}if(N.polyglot||F){if(L.length===0){a$1.status="failed",a$1.reason=F?`No ${F} runtime unit supports stage "${e$1.stage}"`:`No runtime unit supports stage "${e$1.stage}"`,a$1.errorCategory="setup",a$1.errorMessage=a$1.reason,a$1.exitCode=127,a$1.durationMs=Date.now()-A,P+=1;return}let w;for(let C=0;C<L.length;C+=1){let{unit:ve,stage:Re}=L[C],Y=z[C],Se=k.resolve(h,ve.root),ut=Date.now(),ue=await Ze(Se),K=await et(Se,e$1.stage,ve.runtime,ue.framework,{[e$1.stage]:Re.command},ue.environmentCommandVariants,ue.environment);if(Y.durationMs=Date.now()-ut,Y.exitCode=K.exitCode,Y.status=K.exitCode===0?"passed":"failed",Y.reason=K.message,K.exitCode!==0&&!w&&(w=K.message??Re.command),K.exitCode!==0&&!W){for(let Ce of z.slice(C+1))Ce.status="skipped",Ce.reason="stopped after runtime-unit failure";break}}let O=z.find(C=>C.status==="failed");a$1.runtimeDetected=L[0]?.unit.runtime,a$1.executionCommand=z.filter(C=>C.status!=="skipped").map(C=>`[${C.runtime}:${C.root}] ${C.command}`).join(" && "),a$1.durationMs=Date.now()-A,a$1.exitCode=O?.exitCode??0,a$1.status=O?"failed":"passed",a$1.reason=O?w??"runtime-unit stage failed":void 0,a$1.errorCategory=O?"runtime":void 0,a$1.errorMessage=a$1.reason,P+=1;return}let{runtime:se,framework:ae,commandOverrides:st,environmentCommandVariants:at,environment:it}=await Ze(h);a$1.runtimeDetected=se,a$1.framework=ae;let ie=Qe(h,e$1.stage);if(!ie.supported){a$1.status=ie.shouldFail===false?"skipped":"failed",a$1.reason=ie.reason??`stage "${e$1.stage}" unsupported for project`,a$1.durationMs=Date.now()-A,a$1.exitCode=a$1.status==="failed"?127:null,a$1.status==="failed"&&(a$1.errorCategory="setup",a$1.errorMessage=a$1.reason),P+=1;return}if(e$1.reusePassed&&n){let w=n.stages[e$1.stage]??n.stages[e$1.stage];if(w&&rt(w,h,t)){a$1.status="passed",a$1.reason="reused passed result from workspace-run-last.json",a$1.durationMs=Date.now()-A,a$1.exitCode=0,P+=1,e$1.json||console.log(T.gray(`\u21BA reused passed cache for ${M}`));return}}let xe=It(se,ae).filter(w=>w!==e$1.stage);if(xe.length>0&&n){let w=xe.find(O=>{let C=n.stages[O];return !C||!rt(C,h,t)});if(w){a$1.status="skipped",a$1.reason=`dependency stage "${w}" not satisfied in workspace-run-last.json`,a$1.durationMs=Date.now()-A,a$1.exitCode=null,P+=1;return}}let G=await et(h,e$1.stage,se,ae,st,at,it);if(a$1.executionCommand=G.command,a$1.errorCategory=G.errorCategory,a$1.healthStatus=G.healthStatus,a$1.failureDiagnostic=G.failureDiagnostic,a$1.durationMs=Date.now()-A,a$1.exitCode=G.exitCode,G.exitCode===0?(a$1.status="passed",a$1.reason=void 0):(a$1.status="failed",a$1.reason=G.message||"stage command failed",a$1.errorMessage=G.message),P+=1,!e$1.json){let w=j>0?Math.round(P/j*100):100,O=a$1.status==="passed"?T.green("\u2705"):T.red("\u274C");if(console.log(T.gray(`${O} [${P}/${j}] (${w}%) ${M} ${a$1.durationMs}ms`)),a$1.status==="failed"){a$1.reason&&console.log(T.red(` Reason: ${a$1.reason}`)),a$1.executionCommand&&console.log(T.gray(` Command: ${a$1.executionCommand}`));let C=Nt(a$1.runtimeDetected);C&&a$1.errorCategory==="setup"&&console.log(T.gray(` Hint: ${C}`));}}};if(_&&E.length>1){let h=0,a=false,M=new Array(R).fill(null).map(async()=>{for(;h<E.length;){if(a&&!W)return;let A=h;h+=1;let N=E[A];await f(N),$.get(N)?.status==="failed"&&(a=true);}});if(await Promise.all(M),!W&&a){let A=false;for(let N of E){let F=$.get(N);if(F){if(F.status==="failed"){A=true;continue}A&&F.status==="skipped"&&(F.reason=F.reason||"stopped after failure");}}}}else for(let h of E){await f(h);let a=$.get(h);if(!W&&a?.status==="failed"){let M=E.slice(E.indexOf(h)+1);for(let A of M){let N=$.get(A);N&&(N.status="skipped",N.reason="stopped after failure");}break}}}let x=[];for(let f of o){let h=$.get(f);h&&x.push(h);}let I=x.filter(f=>f.status==="passed").length,V=x.filter(f=>f.status==="failed").length,oe=x.filter(f=>f.status==="skipped").length,be=e$1.strict===true,nt=V>0||be&&g.some(f=>f.status==="fail"||f.status==="warn")?1:0,we={schemaVersion:"1.0",workspacePath:t,stage:e$1.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:c,blastRadius:m,since:c?p:null,parallel:_,maxWorkers:R,continueOnError:W,strict:be,enforceGates:S,scope:u,reusePassed:e$1.reusePassed===true,planOnly:e$1.planOnly===true,runtime:e$1.runtime?.trim()||null},selection:{mode:b$1,since:c?p:null,scope:u,graphStatus:l,expansionDepth:y},gates:{enforced:S,results:g,blocked:!!v,blockingGate:v?.gate},summary:{projectCount:o.length,selectedCount:E.length,passed:I,failed:V,skipped:oe,exitCode:nt},projects:x,enterpriseControls:{jsonReady:true,evidencePath:b}},ot=k.join(t,b);return await e(t,we),e$1.json||(v&&(console.log(T.red(`\u274C Workspace run blocked by ${v.gate}`)),console.log(T.gray(` ${v.summary}`))),console.log(T.cyan(`Workspace run (${e$1.stage}) => passed: ${I}, failed: ${V}, skipped: ${oe}`)),console.log(T.gray(`Report: ${ot}`))),we}export{vr as a};
|
package/dist/chunk-6DAQ7PYT.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-JEI6BTZI.js';import {a}from'./chunk-PXWKMPPI.js';import {c,e,d}from'./chunk-YUGKQ44M.js';import {d as d$1,b}from'./chunk-3A23KJAQ.js';import {g}from'./chunk-CT4IODPG.js';import {p as p$1,l}from'./chunk-CJHWKXDN.js';import {m,a as a$2}from'./chunk-Q2WF7D5U.js';import {e as e$1}from'./chunk-CCDGHPEJ.js';import {b as b$2}from'./chunk-D65FCQIO.js';import {a as a$3}from'./chunk-AFIFZTOY.js';import v from'path';import b$1 from'fs-extra';function J(e$1){switch(e$1){case "why":return d;case "trace":return e;default:return c}}async function P(e,o,n){try{if(!await b$1.pathExists(e))return null;let r=await b$1.readJson(e);return o?b$2(o,r,e):n&&a$3(r,n,e),r}catch(r){if((o||n)&&await b$1.pathExists(e))throw r;return null}}function G(e,o){if(!e)return null;let n=o.trim().toLowerCase();return e.projects.find(r=>r.slug.toLowerCase()===n||r.relativePath.toLowerCase()===n)??null}function X(e,o,n){let r=n.trim().toLowerCase(),t=(l(e)?.nodes.map(a=>a.id)??e.projects.map(a=>a.name)).find(a=>a.toLowerCase()===r);if(t)return t;let d=e.projects.find(a=>[a.name,a.path,v.basename(a.path)].filter(u=>u.trim().length>0).some(u=>u.toLowerCase()===r));if(d)return d.name;let c=G(o,n);if(c){let a=e.projects.find(u=>u.path===c.relativePath||u.path.endsWith(`/${c.relativePath}`));if(a)return a.name}return n}function Y(e,o){if(!e)return [];let n=o.trim().toLowerCase(),r=new Set;for(let l of e.projects){l.contracts.dependsOn?.some(t=>t.toLowerCase()===n)&&r.add(l.slug);for(let t of l.contracts.consumes??[])for(let d of e.projects)d.contracts.publishes?.includes(t)&&d.slug===n&&r.add(l.slug);}return [...r].sort()}function q(e,o){if(!e)return [];let n=o.trim().toLowerCase();return e.steps.filter(r=>r.scope==="project"&&r.project?.toLowerCase()===n&&r.command?.display).map(r=>r.command.display).slice(0,8)}function p(e,o,n){return {id:e,title:o,body:n.trim()}}async function fe(e){let o=v.resolve(e.workspacePath),n=(e.now??new Date).toISOString(),r=e.model??await p$1({workspacePath:o,includeEvidence:true}),l$1=e.contract;if(l$1===void 0)try{l$1=(await m({workspacePath:o})).contract;}catch{l$1=null;}let t=e.verify;t===void 0&&(t=await P(v.join(o,d$1),d$1));let d=e.impact;if(d===void 0&&(d=await P(v.join(o,g),g)),e.target.kind==="release-blocked"){let s=t?.blockingReasons??[],i=(r.summary?.projectCount??r.projects.length)===0,g=[p("verdict",i?"Workspace scaffold posture":"Release verdict",t?i?`Scaffold posture: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Freshness: **${t.freshness.verdict}**. No registered projects yet \u2014 release gates apply after the first project is added.`:`Verdict: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Risk: **${t.impact.risk}**. Freshness: **${t.freshness.verdict}**.`:"No workspace verify report found. Run `npx workspai workspace verify --json --write` first."),p("blockers",i?"Pre-project signals":"Blocking reasons",s.length?s.map(h=>`- ${h}`).join(`
|
|
2
|
-
`):i?"No pre-project signals in the latest verify report.":"No blocking reasons in the latest verify report.")];return t?.resolutionHints?.length&&g.push(p("resolution","Resolution hints",t.resolutionHints.map(h=>`- **${h.blockerId}** (${h.resolutionClass}): ${h.commandRetryHint??h.fixHints[0]?.detail??"See fix hints"}`).join(`
|
|
3
|
-
`))),{schemaVersion:a,generatedAt:n,workspacePath:o,target:e.target,summary:t?i?b(s.length,t.summary.verdict):s.length>0||t.summary.verdict==="blocked"?`Release blocked: ${t.summary.verdict} with ${s.length} blocking reason(s).`:t.summary.verdict==="needs-attention"?"Release needs attention: advisory or incomplete verification evidence remains; no blocking reason was reported.":`Release posture: ${t.summary.verdict}; no blocking reason was reported.`:"Release posture unknown \u2014 verify report missing.",sections:g,releaseVerdict:t?.summary.verdict,evidenceFreshness:t?.freshness.verdict,blocking:!!(t&&(t.summary.verdict==="blocked"||s.length>0)),releaseRisk:t?.impact.risk,blockingReasons:s,resolutionHints:t?.resolutionHints}}if(e.target.kind==="blocker"){let s=e.target,m=t?.resolutionHints?.find(g=>g.blockerId===s.blockerId),i=t?.blockingReasons.find(g=>g.includes(s.blockerId))??t?.blockingReasons[0];return {schemaVersion:a,generatedAt:n,workspacePath:o,target:s,summary:m?`Blocker ${s.blockerId}: ${m.resolutionClass}`:`Blocker ${s.blockerId} (no structured hint)`,sections:[p("reason","Blocking signal",i??"No matching blocking reason in verify."),p("hint","Resolution class",m?`${m.resolutionClass}
|
|
4
|
-
|
|
5
|
-
${m.commandRetryHint??""}
|
|
6
|
-
|
|
7
|
-
${m.fixHints.map(g=>`- ${g.detail}`).join(`
|
|
8
|
-
`)}`:"Run workspace verify to emit resolutionHints for this blocker.")],blockingReasons:i?[i]:[],resolutionHints:m?[m]:[]}}if(e.target.kind==="trace"){let s=v.isAbsolute(e.target.diffRef)?e.target.diffRef:v.join(o,e.target.diffRef),m=await P(s,void 0,"contracts/workspace-intelligence/workspace-model-diff.v1.json"),i=m?.summary?.changedProjects??[...new Set((m?.changes??[]).map(f=>f.project).filter(Boolean))],h=(r.summary?.projectCount??r.projects.length)===0,_=d?.transitiveImpact?.map(f=>`${f.project?.name??f.target} (d${f.distance??0}, via ${f.via??"\u2014"})`)??[],y=t?.affectedSubgraph;return {schemaVersion:a,generatedAt:n,workspacePath:o,target:e.target,summary:i?.length?`Trace from ${i.length} changed project(s) through blast radius to gate coverage.`:h?"Trace: workspace scaffold baseline \u2014 no project changes in the latest diff.":"Trace: diff baseline present with no project changes.",sections:[p("origin","Change origin",i?.length?i.map(f=>`- ${f}`).join(`
|
|
9
|
-
`):"No changed projects in diff."),p("blast-radius","Transitive impact",_.length?_.map(f=>`- ${f}`).join(`
|
|
10
|
-
`):"No transitive impact report."),p("gate","Subgraph gate",y?`Directly changed: ${y.directlyChanged}; transitive dependents: ${y.transitiveDependents}; covered: ${y.covered}; uncovered: ${y.uncovered}; unverifiable: ${y.unverifiable}.`:"No verify subgraph coverage available.")],releaseRisk:d?.summary?.risk??t?.impact.risk,blockingReasons:t?.blockingReasons}}let c=e.target.project,a$2=X(r,l$1,c),u=l(r),k=u?a$1(u,a$2):{found:false,centrality:null,directDependents:[],transitiveDependents:[]},j=G(l$1,c),E=Y(l$1,c),x=q(t,c),w=r.projects.find(s=>s.name.toLowerCase()===c.toLowerCase()),I=[p("overview","Project overview",w?`${w.name} (${w.frameworkDisplayName}, ${w.runtime}) at \`${w.path}\`.`:`Project **${c}** ${k.found?"exists in graph":"not found in workspace model"}.`),p("consumers","Consumers / dependents",[`Direct dependents: ${k.directDependents.join(", ")||"none"}`,`Contract consumers: ${E.join(", ")||"none"}`,`Transitive dependents (blast radius): ${k.transitiveDependents.length}`].join(`
|
|
11
|
-
`)),p("contracts","Critical contracts",j?[`Owns: ${j.contracts?.owns?.join(", ")||"none"}`,`Publishes: ${j.contracts.publishes.join(", ")||"none"}`,`Consumes: ${j.contracts.consumes.join(", ")||"none"}`,`APIs: ${j.contracts.apis.map(s=>s.name).join(", ")||"none"}`].join(`
|
|
12
|
-
`):"No workspace.contract.json entry for this project."),p("verification","Required verification",x.length?x.map(s=>`- ${s}`).join(`
|
|
13
|
-
`):"- `npx workspai workspace verify --json`\n- Project test/build via `workspace run` when configured")];k.centrality&&I.push(p("centrality","Graph centrality",`fanIn ${k.centrality.fanIn}, fanOut ${k.centrality.fanOut}, reach ${k.centrality.reach}, hotspot ${k.centrality.isHotspot?"yes":"no"}.`));let A=c.trim().toLowerCase(),T=s=>s.project?.name?.toLowerCase()===A||s.target.toLowerCase()===A,S=d?.affectedProjects?.find(T)?.risk??d?.transitiveImpact?.find(T)?.risk??t?.impact.risk??"unknown";return {schemaVersion:a,generatedAt:n,workspacePath:o,target:e.target,summary:`${c}: ${E.length} consumer(s), release risk **${S}**.`,sections:I,releaseRisk:String(S)}}async function ue(e,o,n="explain"){let r=J(n);return await e$1(o,r,a$2(e)),r}export{J as a,fe as b,ue as c};
|
package/dist/chunk-CCAXADKP.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {b as b$3,a}from'./chunk-THIOE2PB.js';import {h,g as g$2}from'./chunk-TOYN76K4.js';import {b as b$4,g as g$1}from'./chunk-DK6JNE6K.js';import {b as b$1,f as f$2,s,t,u,P,v,q,r,R as R$1,Q,n,o,p as p$2,h as h$2,i as i$2,m as m$1,j,k as k$1,l,O,w,x,y,z as z$1,A as A$1,B,C,E,G as G$1,I,D,F as F$1,H,J,K,L as L$1,M,N,S,T,U,V as V$1,Y,X,W,a as a$2}from'./chunk-YUGKQ44M.js';import {b,c,d as d$1}from'./chunk-RSG2GJXT.js';import {b as b$2}from'./chunk-LNXIMF3O.js';import {d as d$2}from'./chunk-3A23KJAQ.js';import {p as p$1,k as k$2,f as f$3}from'./chunk-CJHWKXDN.js';import {m}from'./chunk-Q2WF7D5U.js';import {d}from'./chunk-CCDGHPEJ.js';import {a as a$1,b as b$5}from'./chunk-D65FCQIO.js';import {f,e,i,h as h$3}from'./chunk-NZ3WZYD5.js';import {f as f$1,g,h as h$1}from'./chunk-MOSXTVPU.js';import i$1 from'path';import k from'fs-extra';var ie=["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"];var qt="workspace-operational-skill.v1";function Ht(e){if(typeof e!="string")return null;let t=e.trim();return !t||t.includes("/")||t.includes("..")?null:t}function bt(e){let t=Ht(e.skillId);if(!t)throw new Error(`Invalid skill id: ${e.skillId}`);return {schemaVersion:qt,skillId:t,canonicalPath:W(t),title:e.title,triggers:[...e.triggers].sort((r,a)=>r.localeCompare(a)),requiredReports:[...e.requiredReports].sort((r,a)=>r.localeCompare(a)),scopedProjects:[...e.scopedProjects??[]].sort((r,a)=>r.localeCompare(a)),verificationCommands:[...e.verificationCommands],answerContractSections:[...ie],...e.promptStem?{promptStem:e.promptStem}:{},markdown:e.markdown}}var Mt=f.skillsIndex;function It(e){let t=[...e.skills].sort((a,s)=>a.skillId.localeCompare(s.skillId)),r=e.inputsHash??f$3({skillIds:t.map(a=>a.skillId),paths:t.map(a=>a.canonicalPath)});return {schemaVersion:Mt,generatedAt:e.generatedAt,inputsHash:r,skills:t.map(a=>({skillId:a.skillId,path:a.canonicalPath,schemaVersion:a.schemaVersion,title:a.title}))}}var Et=[e.agentIndex,b,d$2],ce="<!-- WORKSPAI:GENERATED-OPERATIONAL-SKILL -->",Ut=[{skillId:"workspai-diagnose-api-failure",title:"Diagnose API failure",triggers:["api failure","500 error","integration test failed","service unreachable"],objective:"Investigate a failing API or service using Workspai evidence before editing application code.",steps:[`Read \`${e.agentIndex}\` and identify fail/warn reports for the scoped project.`,`Read \`${e.doctor}\`, \`doctor-project-last-run.json\`, and project-scoped run evidence if present.`,"If a fix was requested, read `artifact-remediation-plan-last-run.json` for cross-artifact next steps, then `doctor-remediation-plan-last-run.json` for Doctor-specific file edits.","Map the failure to workspace vs project scope; cite exit codes and blocker messages.","Propose the smallest safe fix (config, env, dependency) with explicit verification commands."]},{skillId:"workspai-release-readiness",title:"Release readiness",triggers:["release","ship","production","readiness gate"],objective:"Assess whether this workspace is release-ready using governed Workspai gates.",steps:[`Read \`${e.readiness}\` and \`pipeline-last-run.json\`.`,`Read \`${e.verify}\` for verdict and blocking reasons.`,`Read \`${i.artifactRemediationPlan}\` when a Studio or agent repair path is needed.`,"List blocking gates first; never claim ready without cited report fields.","Provide one safe next command and a verification checklist."]},{skillId:"workspai-safe-schema-migration",title:"Safe schema migration",triggers:["migration","schema change","database migration","db migrate"],objective:"Plan and verify a schema migration with blast-radius awareness.",steps:["Identify affected projects from workspace model and dependency graph.","Run or review impact/verify evidence for transitive dependents.","Require project-scoped test/build commands before promoting the migration.","Document rollback and verification signals."]},{skillId:"workspai-dependency-upgrade",title:"Dependency upgrade",triggers:["upgrade dependency","bump package","security advisory","outdated deps"],objective:"Upgrade dependencies with graph-aware verification.",steps:["Scope the upgrade to the owning project from workspace model.","Check transitive dependents via workspace graph / impact reports.","Prefer workspace run test/build for affected projects.","Re-run `workspace verify` after evidence refresh."]},{skillId:"workspai-rename-contract",title:"Rename contract safely",triggers:["rename contract","rename event","breaking api","contract change"],objective:"Rename or change a shared contract with consumer awareness.",steps:[`Read \`${i.workspaceContract}\` for publishes/consumes/owns edges.`,"List all consumer projects before proposing renames.","Update contract file and regenerate workspace model.","Verify contract gate and integration tests for consumers."]}];function se(e){return `npx workspai ${e}`.trim()}function Vt(e){let t=["---",`name: ${e.template.skillId}`,`description: ${e.template.objective}`,"---","",ce,"",`# ${e.template.title}`,"",`> Workspace: **${e.workspaceName}** \xB7 Skill: \`${e.template.skillId}\``,"","## Objective","",e.template.objective,"","## Triggers","",...e.template.triggers.map(r=>`- ${r}`),"","## Required evidence (read first)","",...Et.map(r=>`- \`${r}\``),"","## Procedure","",...e.template.steps.map((r,a)=>`${a+1}. ${r}`),""];if(e.scopedProjects.length>0&&t.push("## Scoped projects","",...e.scopedProjects.map(r=>`- ${r}`),""),e.contractSummary&&t.push("## Contract context","",e.contractSummary,""),e.verificationCommands.length>0){t.push("## Verification commands (this workspace)","");for(let r of e.verificationCommands)t.push(`- \`${r}\``);t.push("");}return t.push("## Answer contract","","Return: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",se("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
|
|
2
|
-
`)}function Ft(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function zt(e){let t=new Map;for(let d of e.projects){let u=Ft(d.runtime);if(!u||u==="unknown")continue;let o=t.get(u)??[];o.push(d.name),t.set(u,o);}let r=[];for(let[d,u]of [...t.entries()].sort(([o],[w])=>o.localeCompare(w)))r.push({skillId:`workspai-${d}-runtime-validation`,title:`${d.toUpperCase()} runtime validation`,triggers:[`${d} build`,`${d} test`,`${d} runtime failure`],objective:`Validate ${d} changes against the detected project commands and canonical Workspai evidence.`,steps:["Read the scoped project lens and current fail/warn evidence before changing source.","Use the registered project commands; do not substitute a different runtime toolchain.","Run only the affected project validation first, then verify the workspace when the change crosses a contract boundary."],scopedProjects:[...u].sort()});t.size>1&&r.push({skillId:"workspai-polyglot-change-validation",title:"Polyglot change validation",triggers:["cross-language change","polyglot change","binding change","multi-runtime validation"],objective:"Plan and verify a cross-runtime change without assuming that one runtime command proves the whole system.",steps:["Use the project topology and bounded Graph query to identify runtime and contract boundaries.","Validate each affected runtime with its registered project command.","Run workspace impact and canonical verification before declaring the change complete."]});let a=e.projects.filter(d=>d.commands.supported.includes("test")).map(d=>d.name).sort();a.length>0&&r.push({skillId:"workspai-test-evidence-recovery",title:"Test evidence recovery",triggers:["test failure","coverage","regression","test evidence"],objective:"Repair a test or coverage blocker by proving changed behavior, not merely improving a metric.",steps:["Read the exact Analyze, Doctor, or Goal evidence that owns the test finding.","Inspect the behavior and relevant test boundary before proposing a source change.","Run the scoped test command, then the exact producer and canonical verification."],scopedProjects:a});let s=e.projects.filter(d=>d.importantFiles.some(u=>/(?:^|\/)(?:Dockerfile|docker-compose|compose\.|Chart\.yaml|\.github\/workflows)/i.test(u))).map(d=>d.name).sort();return s.length>0&&r.push({skillId:"workspai-delivery-evidence",title:"Delivery evidence and CI recovery",triggers:["ci failure","workflow failure","container build","deployment evidence"],objective:"Diagnose delivery evidence with the owning project and CI/container artifacts before changing application source.",steps:["Identify whether the failing evidence is project-owned or workspace-owned.","Inspect the referenced workflow or delivery artifact and its bounded proof paths.","Validate the affected project first, then refresh the exact evidence producer and verify the workspace."],scopedProjects:s}),r}function Jt(e){return e?.safeCommands?.length?e.safeCommands.slice(0,8).map(t=>t.display):[se("workspace verify --json"),se("doctor workspace --json")]}function Bt(e){return e?.projects?.length?e.projects.slice(0,12).map(r=>{let a=r.contracts?.owns?.join(", ")||"none",s=r.contracts?.publishes?.join(", ")||"none",d=r.contracts?.consumes?.join(", ")||"none";return `- **${r.slug}**: owns \`${a}\`; publishes \`${s}\`; consumes \`${d}\``}).join(`
|
|
3
|
-
`):void 0}function xt(e){let t=e.model.workspace.name,r=Jt(e.context??null),a=Bt(e.contract??null);return [...Ut,...zt(e.model)].map(s=>{let d=s.scopedProjects??e.model.projects.map(o=>o.name),u=Vt({template:s,workspaceName:t,scopedProjects:d,verificationCommands:r,contractSummary:a});return bt({skillId:s.skillId,title:s.title,triggers:s.triggers,requiredReports:[...Et],scopedProjects:d,verificationCommands:r,...X(s.skillId)?{promptStem:Y[s.skillId]}:{},markdown:u})})}async function Ct(e){let t=i$1.resolve(e.workspacePath),r=[],a=f$3({skills:e.skills.map(o=>({id:o.skillId,path:o.canonicalPath,hash:f$3({markdown:o.markdown})}))}),s=It({generatedAt:e.generatedAt,skills:e.skills,inputsHash:a}),d=new Set(e.skills.map(o=>o.skillId)),u=[];if(e.write){let o=i$1.join(t,".workspai","skills");if(await k.pathExists(o))for(let m of await k.readdir(o,{withFileTypes:true})){if(!m.isFile()||!m.name.endsWith(".md"))continue;let g=m.name.slice(0,-3);if(d.has(g))continue;let I=i$1.join(o,m.name);(await k.readFile(I,"utf8")).includes(ce)&&(await k.remove(I),u.push(g));}for(let m of e.skills){let g=i$1.join(t,m.canonicalPath);await k.ensureDir(i$1.dirname(g)),await k.writeFile(g,m.markdown,"utf8"),r.push(m.canonicalPath);}let w=i$1.join(t,b$1);await k.ensureDir(i$1.dirname(w)),await k.writeJson(w,s,{spaces:2}),r.push(b$1);}return {skills:e.skills,index:s,writtenPaths:r,removedSkillIds:u.sort()}}function Ot(e){return ["## Operational skills (canonical)","","Read workspace-native playbooks from `.workspai/skills/` before generic repo scans. Legacy `.rapidkit/skills/` playbooks are read only when already present from older workspaces:","",...e.skills.map(r=>`- \`${r.path}\` \u2014 ${r.title} (\`${r.skillId}\`)`),"","Regenerate:","","```bash",se("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
4
|
-
`)}var Yt={"workspai-diagnose-api-failure":A$1,"workspai-release-readiness":E},ze="## Workspace verification (hydrated)";function Xt(e){let t=[ze,"","Verification commands for this workspace:","",...e.verificationCommands.length?e.verificationCommands.map(r=>`- \`${r}\``):["- `npx workspai workspace verify --json`"]];return e.scopedProjects.length>0&&t.push("","Scoped projects:","",...e.scopedProjects.map(r=>`- ${r}`)),t.push(""),t.join(`
|
|
5
|
-
`)}async function _t(e){let t=i$1.resolve(e.workspacePath),r=[];for(let a of e.skills){let s=Yt[a.skillId];if(!s)continue;let d=i$1.join(t,s);if(!await k.pathExists(d))continue;let u=await k.readFile(d,"utf8"),o=Xt(a),w=u.includes(ze)?u.replace(new RegExp(`${ze}[\\s\\S]*$`),o.trimEnd()):`${u.trimEnd()}
|
|
6
|
-
|
|
7
|
-
${o}`;e.write&&await k.writeFile(d,`${w.trimEnd()}
|
|
8
|
-
`,"utf8"),r.push(s);}return r}var Qt="workspai-agent-customization-pack-capabilities.v1";function Tt(){return {schemaVersion:Qt,presets:{minimal:{meaning:"Generate the portable grounding index, AGENTS.md, and provider-specific lightweight instructions.",requiredOutputs:[e.agentIndex,e.agentCustomizationPack,e.agents]},enterprise:{meaning:"Generate the full VS Code-native pack: instructions, prompts, skills, custom agents, and validation metadata.",requiredOutputs:[e.agentIndex,e.agentCustomizationPack,e.agents,w,A$1,M,".github/agents/workspai-advisor.agent.md",S,b$1]}},targets:{all:{meaning:"Generate every supported customization surface.",outputFamilies:["portable","vscode","copilot","cursor","claude","gemini","qwen","kimi","grok","windsurf","amazon-q"]},vscode:{meaning:"Generate VS Code-native customizations for Copilot Chat and agent workflows.",outputFamilies:["instructions","prompts","skills","agents","hooks"]},agents:{meaning:"Generate portable AGENTS.md grounding for any agent.",outputFamilies:["portable"]},copilot:{meaning:"Generate GitHub Copilot instructions, prompts, and skills.",outputFamilies:["instructions","prompts","skills"]},cursor:{meaning:"Generate Cursor rules.",outputFamilies:["rules"]},claude:{meaning:"Generate Claude Code grounding files.",outputFamilies:["rules","portable"]},codex:{meaning:"Use AGENTS.md and the report index as the Codex grounding layer.",outputFamilies:["portable"]},gemini:{meaning:"Generate Gemini CLI grounding through GEMINI.md and canonical AGENTS.md.",outputFamilies:["adapter","portable"]},qwen:{meaning:"Generate Qwen Code grounding through QWEN.md and canonical AGENTS.md.",outputFamilies:["adapter","portable"]},kimi:{meaning:"Use AGENTS.md and the report index as the Kimi Code grounding layer.",outputFamilies:["portable"]},grok:{meaning:"Use AGENTS.md and the report index as the xAI Grok grounding layer.",outputFamilies:["portable"]},windsurf:{meaning:"Use AGENTS.md and the report index as the Windsurf grounding layer.",outputFamilies:["portable"]},"amazon-q":{meaning:"Generate an Amazon Q project rule that routes agents to canonical evidence.",outputFamilies:["rules","portable"]},orca:{meaning:"Legacy compatibility alias for AGENTS.md consumers; prefer the grok target.",outputFamilies:["portable"]}},standardAnswerContract:[...ie],requiredReports:V.map(e=>({path:e.relativePath,label:e.label,required:e.required})),strictRules:["Required reports must exist.","Generated report paths must stay inside the workspace root.","Generated customization text must be English-only.","Agent answers must not claim pass, ready, or healthy without cited evidence.","Commands must distinguish display guidance from execution requests.","Agent hook files must be advisory and disabled by default unless the user explicitly enables them.","MCP design artifacts must stay read-mostly until write tools have explicit approval boundaries."],outputKinds:["report","grounding","instruction","prompt","skill","skill-resource","operational-skill","skills-index","explain-report","agent","rule","hook","mcp-design"],pathLayers:{l1CanonicalRoots:[".workspai/reports/",`${a$2}/`],l2PrefixedMirrorRoots:[".github/",".cursor/",".claude/",".amazonq/"],l3SharedIndustryFiles:["AGENTS.md",".github/copilot-instructions.md","CLAUDE.md","GEMINI.md","QWEN.md"]}}}var Zt=f.agentIndex,er=f.agentCustomizationPack,z=e.agentIndex,F=e.agentCustomizationPack;var V=[{relativePath:i.goalIndex,label:"Active Goal Pack index",required:false},{relativePath:i.goalPackLastRun,label:"Latest governed Goal Pack",required:false},{relativePath:b,label:"Agent context pack",required:true},{relativePath:b$1,label:"Operational skills index",required:true},{relativePath:e.model,label:"Workspace model",required:false},{relativePath:e.knowledgeGraph,label:"Workspace knowledge graph",required:false},{relativePath:e.evaluationLastRun,label:"Workspace Intelligence evaluation",required:false},{relativePath:e.doctor,label:"Workspace doctor",required:false},{relativePath:i.doctorProject,label:"Project doctor",required:false},{relativePath:i.doctorRemediationPlan,label:"Doctor remediation plan",required:false},{relativePath:i.artifactRemediationPlan,label:"Artifact remediation plan",required:false},{relativePath:i.doctorFixResult,label:"Doctor fix result",required:false},{relativePath:e.analyze,label:"Workspace analyze",required:false},{relativePath:i.pipelineLastRun,label:"Governance pipeline",required:false},{relativePath:e.readiness,label:"Release readiness",required:false},{relativePath:e.impact,label:"Workspace impact",required:false},{relativePath:e.verify,label:"Workspace verify",required:false},{relativePath:e.snapshot,label:"Workspace model snapshot",required:false},{relativePath:e.diff,label:"Workspace model diff",required:false},{relativePath:e.explain,label:"Workspace explain",required:false},{relativePath:e.contractVerify,label:"Workspace contract verify",required:false},{relativePath:e.history,label:"Workspace intelligence history",required:false}];function tr(){let e=V.map(r=>r.relativePath),t=b$2().consumers.agents.canonicalReadOrder;return [...new Set(t.filter(r=>r!==z&&e.includes(r)))]}async function rr(e){try{let{contract:t}=await m({workspacePath:e});if(t?.workspace?.name)return `workspace:${t.workspace.name}`}catch{}for(let t of [".workspai/workspace.json",".rapidkit/workspace.json"])try{let r=await k.readJson(i$1.join(e,t)),a=typeof r.workspace_name=="string"?r.workspace_name:typeof r.name=="string"?r.name:null;if(a?.trim())return `workspace:${a.trim()}`}catch{}return `workspace:${i$1.basename(i$1.resolve(e))}`}function A(e){return `npx workspai ${e}`.trim()}function Ze(e){return e&&typeof e=="object"?e:null}function Je(e,t=12){return Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0).slice(0,t):[]}function nr(e){let t=Je(e.blockers,12);if(t.length>0)return t;let r=Je(e.blockingReasons,12);if(r.length>0)return r;let a=Ze(e.summary);return a&&Array.isArray(a.blockingReasons)?Je(a.blockingReasons,12):[]}function ar(e){let t=[...new Set(e.map(r=>r.trim()).filter(Boolean))];return t.filter(r=>{let a=r.toLowerCase();return !t.some(s=>{if(s===r||!s.includes(":"))return false;let d=s.toLowerCase();return d.length>a.length&&d.endsWith(a)})})}function or(e){for(let t of ["generatedAt","updatedAt","timestamp"]){let r=e[t];if(typeof r=="string"&&r.trim())return r.trim()}if(Array.isArray(e.entries)){let t=e.entries.map(r=>Ze(r)?.generatedAt).filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim()).filter(r=>Number.isFinite(Date.parse(r)));if(t.length>0)return t.reduce((r,a)=>Date.parse(a)>Date.parse(r)?a:r)}}function ir(e,t,r){if(!e)return true;let a=Date.parse(e);return Number.isFinite(a)?r.getTime()-a>t*60*60*1e3:true}function sr(e$1,t,r){return e$1.path===e.snapshot?false:ir(e$1.generatedAt,t,r)}function cr(e){let t=e&&e.length>0?e:["all"];return t.includes("all")?new Set(["all","vscode","agents","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"]):new Set(t)}function R(e,t){return e.has("all")||e.has(t)}function $t(e){return R(e,"copilot")||R(e,"vscode")}function lr(e,t){return t==="generic"?R(e,"agents"):t==="copilot"?$t(e):t==="grok"?R(e,"grok")||R(e,"orca"):R(e,t)}function dr(e){return e??"enterprise"}function pr(e){return e===b$1?"skills-index":e.includes("workspace-explain-last-run.json")?"explain-report":(e.startsWith(`${a$2}/`)||e.startsWith(".rapidkit/skills/"))&&e.endsWith(".md")?"operational-skill":e.includes("hooks")||e===U||e===V$1?"hook":e.includes("mcp")||e===S||e===T?"mcp-design":e.endsWith(".json")?"report":e.includes("/instructions/")||e.endsWith("copilot-instructions.md")?"instruction":e.includes("/prompts/")?"prompt":e.includes("/skills/")&&e.endsWith("/SKILL.md")?"skill":e.includes("/skills/")?"skill-resource":e.includes("/agents/")?"agent":e.includes("/rules/")||e.endsWith(".mdc")?"rule":"grounding"}function ur(e){return e.startsWith(".github/")?["vscode","copilot"]:e.startsWith(".cursor/")?["cursor"]:e.startsWith(".claude/")||e==="CLAUDE.md"?["claude"]:e==="GEMINI.md"?["gemini"]:e==="QWEN.md"?["qwen"]:e.startsWith(".amazonq/")?["amazon-q"]:e===".windsurfrules"||e.startsWith(".windsurf/")?["windsurf"]:e.startsWith(".grok/")?["grok"]:e.startsWith(".agents/")?["codex","kimi","grok","orca"]:e==="AGENTS.md"||e.startsWith(".rapidkit/")?["agents","codex","kimi","grok","copilot","cursor","claude","gemini","qwen","amazon-q","windsurf","orca","vscode"]:e.startsWith(".vscode/")?["vscode"]:["agents"]}function Wt(e){return [{target:"agents",path:`.agents/skills/${e}/SKILL.md`},{target:"copilot",path:`.github/skills/${e}/SKILL.md`},{target:"claude",path:`.claude/skills/${e}/SKILL.md`},{target:"cursor",path:`.cursor/skills/${e}/SKILL.md`},{target:"grok",path:`.grok/skills/${e}/SKILL.md`}]}async function gr(e,t){let r=i$1.join(e,t);!await k.pathExists(r)||!(await k.readFile(r,"utf8")).includes(ce)||await k.remove(r);}function mr(e,t){return Tt().presets[t].requiredOutputs.includes(e)}async function fr(e,t){if(t)return t;let r=await d(e,k$2)??i$1.join(e,k$2);if(await k.pathExists(r))try{let a=await k.readJson(r);return b$5(k$2,a,r),a}catch{}return p$1({workspacePath:e,includeEvidence:true})}function kr(e){return e.length>0&&!i$1.isAbsolute(e)&&!e.split(/[\\/]+/).includes("..")}function hr(e){return Object.fromEntries(["all","vscode","agents","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"].map(r=>[r,{enabled:e.targets.includes("all")||e.targets.includes(r),outputs:e.outputs.filter(a=>a.targets.includes(r)).map(a=>a.path).sort()}]))}async function wr(e,t){try{if(!await k.pathExists(e))return {payload:null,exists:false,validity:"missing"};let r=await k.readJson(e),a=Ze(r);return a?a$1(t)?(b$5(t,a,e),{payload:a,exists:true,validity:"valid"}):{payload:a,exists:true,validity:"uncontracted"}:{payload:null,exists:true,validity:"invalid",validationError:"Artifact root must be a JSON object"}}catch(r){return {payload:null,exists:true,validity:"invalid",validationError:r instanceof Error?r.message:String(r)}}}async function jt(e){let t=e.now??new Date,r=e.staleAfterHours??24,a=[],s=[];for(let o of V){let w=await d(e.workspacePath,o.relativePath)??i$1.join(e.workspacePath,o.relativePath),m=await wr(w,o.relativePath),g=m.payload;m.validity==="invalid"?s.push(`Invalid evidence contract: ${o.relativePath}`):g&&s.push(...nr(g)),a.push({path:o.relativePath,label:o.label,required:o.required,exists:m.exists,validity:m.validity,validationError:m.validationError,generatedAt:g?or(g):void 0,commandId:typeof g?.commandId=="string"?g.commandId:void 0,exitCode:typeof g?.exitCode=="number"?g.exitCode:void 0});}let d$1=ar(s).slice(0,16),u=b$2();return {schemaVersion:Zt,generatedAt:t.toISOString(),workspaceRoot:await rr(e.workspacePath),intelligenceChain:{schemaVersion:u.schemaVersion,contractPath:u.contractPath,currentStep:"agent-sync"},readOrder:tr(),blockers:d$1,staleAfterHours:r,reports:a,refreshCommand:A("workspace agent-sync --write --refresh-context")}}function Ar(e$1){let t=["# Workspai agent grounding","","Cross-tool instructions for Copilot, Cursor, Claude Code, Codex, Grok, and other agents.","","## Read order (mandatory before workspace diagnosis)","",`1. \`${e.agentIndex}\` \u2014 latest blockers, timestamps, and report paths`,`2. \`${i.goalIndex}\` \u2014 when present, read the active Goal Pack and its handoff before choosing work.`,`3. \`${e.agentContext}\` \u2014 read only task-relevant context`,`4. \`${e.skillsIndex}\` \u2014 select only the Skill that matches the task.`,"5. Read only the task-relevant evidence artifacts listed in the index.","6. Use the Goal Pack retrieval queries, `workspace graph search <query> --limit 12 --json`, or MCP `searchWorkspaceGraph` before loading the full graph.","","Do **not** full-repo scan or inject the complete graph when a bounded query can answer the task.","","## Regenerate intelligence","","```bash",A("workspace agent-sync --write --refresh-context"),A("workspace context --for-agent --json --write"),A("pipeline --json --write"),"```",""];if(e$1.index.blockers.length>0){t.push("## Current blockers","");for(let r of e$1.index.blockers.slice(0,12))t.push(`- ${r}`);t.push("");}if(e$1.context?.safeCommands?.length){t.push("## Safe commands (prefer these)","");for(let r of e$1.context.safeCommands.slice(0,10))t.push(`- \`${r.display}\` \u2014 ${r.description}`);t.push("");}return t.push("## Rules","","- Treat `.workspai/reports/*` as the source of truth for health, gates, and release posture.","- Prefer deterministic Workspai CLI commands over heuristic framework guesses.","- If evidence is missing or stale, run the refresh commands above before proposing fixes.","- Keep project-scoped advice aligned with the active project named in the context pack.","- Never claim that an active goal is satisfied until its CLI-owned verification lifecycle is `verified`.",""),t.join(`
|
|
9
|
-
`)}function Rr(e$1){return ["# Workspai agent grounding","",`Generated: ${e$1.generatedAt}`,"",`This file is tool-agnostic. Synced agents should read it together with \`${e.agentIndex}\`.`,"","## Mandatory read order","",...e$1.readOrder.map((t,r)=>`${r+1}. \`${t}\``),"",e$1.blockers.length>0?"## Blockers":"",...e$1.blockers.length>0?e$1.blockers.map(t=>`- ${t}`):[],"","## Refresh","","```bash",e$1.refreshCommand,"```",""].filter(t=>t!=="").join(`
|
|
10
|
-
`)}function Pr(){return ["# Workspai workspace grounding","","Before answering workspace, release, or architecture questions:","","1. Read `AGENTS.md` (managed Workspai section).",`2. Read \`${e.agentIndex}\` and only task-relevant context from \`${e.agentContext}\`.`,"3. Use bounded `workspace graph search` or MCP `searchWorkspaceGraph` before scanning the full repository.","","Regenerate stale intelligence:","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
11
|
-
`)}function Sr(){return ["## Claude Code","",`- Load \`${e.agentIndex}\` before diagnosing blockers.`,"- Use `.claude/rules/workspai-evidence.md` for scoped Workspai evidence rules.","- Treat `.claude/rules/rapidkit-evidence.md` as a legacy compatibility mirror.","- Refresh grounding with `npx workspai workspace agent-sync --write`.",""].join(`
|
|
12
|
-
`)}function Be(e$1){return [`## ${e$1}`,"","- Treat `AGENTS.md` as the portable workspace instruction authority.",`- Load \`${e.agentIndex}\` before diagnosing blockers or architecture.`,`- Read only task-relevant context from \`${e.agentContext}\`.`,"- Use bounded Workspace Knowledge Graph search before broad source discovery.","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","- Refresh grounding with `workspai workspace agent-sync --write --refresh-context`.",""].join(`
|
|
13
|
-
`)}function vr(){return ["---","description: Workspai workspace evidence and intelligence grounding","globs: []","alwaysApply: true","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. Read \`${e.agents}\` and \`${e.agentIndex}\`.`,`2. Read only task-relevant context from \`${e.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${e.agentIndex}\`; read only task-relevant context and evidence.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Intelligent loop","","When applying changes, follow the full repair loop:","","1. Discover \u2014 read bounded workspace context, select a matching Skill, and query the graph for the task.","2. Inspect \u2014 read relevant evidence and source files.","3. Patch \u2014 apply changes through the CLI-owned repair transaction.","4. Verify \u2014 run verification to confirm workspace health.","5. Complete \u2014 only after verified evidence confirms success.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
14
|
-
`)}function yr(){return ["---","description: Workspai evidence artifact discipline",'globs: [".workspai/**", "**/.workspai/**", ".rapidkit/**", "**/.rapidkit/**"]',"alwaysApply: false","---","","When reading or editing `.workspai/` or legacy `.rapidkit/` artifacts:","",`- Start from \`${e.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. Never include comments, trailing commas, or non-standard syntax.","","Regenerate evidence:","","```bash",A("workspace intelligence run"),"```",""].join(`
|
|
15
|
-
`)}function et(e$1){return ["---",`description: ${e$1.description}`,`globs: ${e$1.globs}`,"alwaysApply: false","---","",e$1.objective,"","Read first:","",`- \`${e.agentIndex}\``,`- \`${e.agentContext}\``,"- Any report referenced by the current blocker or task","","Steps:","",...e$1.steps.map((t,r)=>`${r+1}. ${t}`),"","Use the standard Workspai answer contract: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
16
|
-
`)}function br(){return et({description:"Diagnose Workspai workspace blockers from evidence reports",globs:"[]",objective:"Diagnose this workspace using Workspai evidence only.",steps:["Root cause grounded in report blockers","Smallest safe fix path (commands + file edits)","One verification command to prove recovery"]})}function Ir(){return et({description:"Repair Workspai blockers with evidence and verification",globs:"[]",objective:"Plan the smallest safe repair for the current Workspai blocker.",steps:["Blocker and affected workspace/project scope","Evidence paths and exact failing signals","Minimal fix plan","Human-run commands","Verification command and expected success signal"]})}function Er(){return et({description:"Assess Workspai release readiness from evidence",globs:"[]",objective:"Assess whether this workspace is release-ready using Workspai gates.",steps:["Readiness verdict with cited reports","Blocking gates","Safe next command","Verification checklist"]})}function xr(){return ["---","trigger: always_on","description: Workspai workspace evidence and intelligence grounding","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${e.agents}\` and \`${e.agentIndex}\`.`,`2. Only task-relevant context from \`${e.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${e.agentIndex}\`; read only task-relevant context.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
17
|
-
`)}function Cr(){return ["---","trigger: glob","description: Workspai evidence artifact discipline",'globs: [".workspai/**", ".rapidkit/**"]',"---","","When reading or editing `.workspai/` or legacy `.rapidkit/` artifacts:","",`- Start from \`${e.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.",""].join(`
|
|
18
|
-
`)}function Or(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${e.agents}\` and \`${e.agentIndex}\`.`,`2. Only task-relevant context from \`${e.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${e.agentIndex}\`; read only task-relevant context.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
19
|
-
`)}function _r(){return ["# Workspai evidence artifact discipline","","Applies when reading or editing `.workspai/` or legacy `.rapidkit/` artifacts.","",`- Start from \`${e.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.","","Regenerate evidence:","","```bash",A("workspace intelligence run"),"```",""].join(`
|
|
20
|
-
`)}function Tr(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${e.agents}\` and \`${e.agentIndex}\`.`,`2. Only task-relevant context from \`${e.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${e.agentIndex}\`; read only task-relevant context.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
21
|
-
`)}function Wr(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${e.agents}\` and \`${e.agentIndex}\`.`,`2. Only task-relevant context from \`${e.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${e.agentIndex}\`; read only task-relevant context.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Evidence discipline","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
22
|
-
`)}function jr(){return ["# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Read order","",`1. \`${e.agents}\` and \`${e.agentIndex}\`.`,`2. Only task-relevant context from \`${e.agentContext}\`.`,"3. Prefer bounded graph search and evidence reports over full-repo exploration.","","## Scope rules","",`- Start from \`${e.agentIndex}\`; read only task-relevant context and evidence.`,"- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","","## Intelligent loop","","When applying changes, follow the full repair loop:","","1. Discover \u2014 read bounded workspace context, select a matching Skill, and query the graph for the task.","2. Inspect \u2014 read relevant evidence and source files.","3. Patch \u2014 apply changes through the CLI-owned repair transaction.","4. Verify \u2014 run verification to confirm workspace health.","5. Complete \u2014 only after verified evidence confirms success.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh when stale","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""].join(`
|
|
23
|
-
`)}function Nr(){return ["---",'applyTo: ".workspai/**,**/.workspai/**,.rapidkit/**,**/.rapidkit/**"',"description: Workspai evidence and intelligence artifacts","---","","When working under `.workspai/` or legacy `.rapidkit/`:","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.",`- Start from \`${e.agentIndex}\` for read order and blockers.`,"- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.",""].join(`
|
|
24
|
-
`)}function Lr(){return ["---",'applyTo: "**"',"description: Workspai workspace scope, evidence, and command discipline","---","","# Workspai Workspace Intelligence","","Use Workspai reports as the workspace source of truth before giving architectural, repair, release, or project lifecycle advice.","","## Scope rules","",`- Start from \`${e.agentIndex}\`; read only task-relevant context and evidence.`,"- Prefer bounded `workspace graph search` or MCP `searchWorkspaceGraph` over loading the complete graph.","- Distinguish workspace-level blockers from project-level blockers.","- When a project is active, cite its name, path, framework, and evidence source.","- Do not translate unsupported stack requests into unrelated native kits.","","## Answer contract","","Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
25
|
-
`)}function Gr(){return ["---","paths:",' - ".workspai/**"',' - ".rapidkit/**"',"---","","# Workspai evidence","","When reading or editing `.workspai/` or legacy `.rapidkit/` artifacts:","",`- Start from \`${e.agentIndex}\` for read order and active blockers.`,"- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- JSON files (.json) require strictly valid JSON. No comments, no trailing commas.","","Regenerate evidence:","","```bash",A("workspace intelligence run"),"```",""].join(`
|
|
26
|
-
`)}function $r(){return ["# Legacy RapidKit evidence alias","","Compatibility path only. Use `.claude/rules/workspai-evidence.md` as the canonical rule.",""].join(`
|
|
27
|
-
`)}function Dr(){return ["---","description: Legacy RapidKit metadata compatibility alias",'globs: [".rapidkit/**", "**/.rapidkit/**"]',"alwaysApply: false","---","","Use `.cursor/rules/workspai-grounding.mdc` for canonical Workspai grounding.",""].join(`
|
|
28
|
-
`)}function Nt(e){return ["---",'applyTo: ".rapidkit/**,**/.rapidkit/**"',"description: Legacy RapidKit metadata compatibility alias","---","",`Use \`.github/instructions/workspai-${e}.instructions.md\` as the canonical Workspai instruction.`,""].join(`
|
|
29
|
-
`)}function Lt(){return ["---","description: Diagnose Workspai workspace blockers from evidence reports","---","","Diagnose this workspace using Workspai evidence only.","","Read:","",`- \`${e.agentIndex}\``,`- \`${e.agentContext}\``,"- Any fail/warn reports referenced in the index","","Return:","","1. Root cause grounded in report blockers","2. Smallest safe fix path (commands + file edits)","3. One verification command to prove recovery",""].join(`
|
|
30
|
-
`)}function le(e$1){return ["---",`description: ${e$1.description}`,"---","",e$1.objective,"","Read first:","",`- \`${e.agentIndex}\``,`- \`${e.agentContext}\``,"- Any report referenced by the current blocker or task","","Return:","",...e$1.expectedOutput.map((t,r)=>`${r+1}. ${t}`),"","Use the standard Workspai answer contract: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.",""].join(`
|
|
31
|
-
`)}function G(e){return ["# "+e.title,"",...e.lines,""].join(`
|
|
32
|
-
`)}function Kr(){return G({title:"MCP Tool Design",lines:["Workspai MCP is a read-mostly bridge over contract-validated workspace artifacts.","","Candidate read tools:",`- \`getWorkspaceModel\` \u2014 read \`${e.model}\`.`,`- \`getWorkspaceKnowledgeGraph\` \u2014 read \`${e.knowledgeGraph}\`.`,`- \`getWorkspaceEvaluation\` \u2014 read \`${e.evaluationLastRun}\` (or the live evaluation when requested).`,"- `queryWorkspaceEntities` \u2014 filter proof-backed graph entities by kind.","- `searchWorkspaceGraph` \u2014 retrieve bounded proof-backed context by text query.","- `getWorkspaceGraphEvidence` \u2014 resolve evidence for an entity or relation.","- `findWorkspaceGraphPath` \u2014 find a shortest proof-carrying relationship path.",`- \`getEvidenceIndex\` \u2014 read \`${e.agentIndex}\`.`,"- `getBlockers` \u2014 derive current blockers from INDEX and gate reports.","- `getSafeCommands` \u2014 read safe commands from `workspace-context-agent.json`.","- `getProjectContext` \u2014 return one project-scoped slice of the workspace model.","- `getArtifact` \u2014 read one explicit artifact path inside the workspace root.",`- \`listOperationalSkills\` \u2014 read \`${e.skillsIndex}\`.`,"- `getWorkspaceExplain` \u2014 read/build workspace explain for release-blocked or project scope.","- `refreshWorkspaceIntelligence` \u2014 explicit user-approved refresh command only.","","Write or repair tools require explicit approval boundaries and are intentionally not part of the first read-mostly design."]})}function qr(e$1){return `${JSON.stringify({schemaVersion:h$3.workspaiMcpDesign.schemaVersion,generatedAt:e$1.generatedAt,workspaceRoot:e$1.workspaceRef,status:"design-only",mode:"read-mostly",safety:{writeToolsEnabled:false,approvalRequiredForRefresh:true,artifactReadsMustStayInsideWorkspace:true},candidateTools:[{name:"getWorkspaceModel",reads:[e.model],mutates:false},{name:"getWorkspaceKnowledgeGraph",reads:[e.knowledgeGraph],mutates:false},{name:"getWorkspaceEvaluation",reads:[e.evaluationLive,e.evaluationLastRun],mutates:false},{name:"queryWorkspaceEntities",reads:[e.knowledgeGraph],mutates:false},{name:"searchWorkspaceGraph",reads:[e.knowledgeGraph],mutates:false},{name:"getWorkspaceGraphEvidence",reads:[e.knowledgeGraph],mutates:false},{name:"findWorkspaceGraphPath",reads:[e.knowledgeGraph],mutates:false},{name:"getEvidenceIndex",reads:[e.agentIndex],mutates:false},{name:"getBlockers",reads:[e.agentIndex,e.verify,i.pipelineLastRun],mutates:false},{name:"getSafeCommands",reads:[e.agentContext],mutates:false},{name:"getProjectContext",reads:[e.model,e.agentContext],mutates:false},{name:"getArtifact",reads:["requested workspace-relative artifact path"],mutates:false},{name:"listOperationalSkills",reads:[e.skillsIndex],mutates:false},{name:"getWorkspaceExplain",reads:[e.explain,e.verify,e.impact],mutates:false},{name:"refreshWorkspaceIntelligence",command:A("workspace agent-sync --write --refresh-context"),mutates:true,approvalRequired:true}]},null,2)}
|
|
33
|
-
`}function Hr(e$1){return `${JSON.stringify({schemaVersion:h$3.agentHooks.schemaVersion,generatedAt:e$1.generatedAt,workspaceRoot:e$1.workspaceRef,enabledByDefault:false,mode:"advisory",hooks:[{name:"workspai-pre-tool-use-workspace-boundary",event:"PreToolUse",purpose:"Block or warn on state-changing commands outside the active workspace root.",defaultAction:"warn",rules:["Allow read-only commands.","Warn before write/delete commands outside workspaceRoot.","Never run destructive commands without explicit user approval."]},{name:"workspai-post-tool-use-verify-suggestion",event:"PostToolUse",purpose:"Suggest non-destructive verification commands after edits.",defaultAction:"suggest",commands:[A("doctor workspace"),A("workspace verify --strict --json")]},{name:"workspai-user-prompt-submit-scope-hint",event:"UserPromptSubmit",purpose:"Inject lightweight workspace scope and evidence index hints.",defaultAction:"inject-context-hint",reads:[e.agentIndex,e.agentContext]}]},null,2)}
|
|
34
|
-
`}function Gt(e$1){let t=["---","name: workspai-workspace-intelligence","description: Use Workspai workspace intelligence reports to answer, repair, verify, and release with evidence","---","","# Workspai Workspace Intelligence","","Use this skill for workspace architecture, project lifecycle, blocker repair, release readiness, agent grounding, and CI evidence questions.","","## Decision flow","","1. Load `resources/scope-model.md`.",`2. Load \`${e.agentIndex}\`.`,`3. Load \`${e.agentContext}\`.`,`4. Load \`${e.skillsIndex}\` when operational playbooks are needed.`,"5. Load the smallest evidence report required for the task.","6. Answer with Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Rules","","- Prefer Workspai reports over full-repo scans.","- Never claim a gate passed without a cited report.","- Separate display commands from execution requests.","- Keep project-scoped fixes inside the active project unless workspace evidence says otherwise.",""];return e$1?.trim()&&t.push(e$1.trim(),""),t.join(`
|
|
35
|
-
`)}function de(e$1){return ["---",`name: ${e$1.name}`,`description: ${e$1.description}`,`tools: [${e$1.tools.map(t=>`'${t}'`).join(", ")}]`,"---","",`You are the ${e$1.name} agent for Workspai Workspace Intelligence.`,"",`Mode: ${e$1.mode}.`,"",`Start every task by reading \`${e.agentIndex}\` and \`${e.agentContext}\`.`,"","Use this answer contract:","","- Scope","- Evidence","- Diagnosis","- Fix Plan","- Run","- Verify","- Assumptions","","Do not invent health, readiness, or policy status. Cite report paths and command outputs.",""].join(`
|
|
36
|
-
`)}function L(e$1){let t=["---","name: workspai-grounding","description: Load Workspai workspace intelligence reports before diagnosing or changing code","---","","# Workspai grounding","","Use when the user asks about workspace health, release gates, doctor/pipeline failures, or project structure.","","## Workflow","",`1. Read \`${e.agentIndex}\``,`2. Read \`${e.agentContext}\``,"3. Read fail/warn evidence artifacts listed in the index","4. Propose the smallest safe fix with explicit verification commands",""],r=e$1.model?.projects?.map(a=>a.name||a.slug).filter(Boolean).slice(0,10);if(r&&r.length>0){t.push("## Projects in this workspace","");for(let a of r)t.push(`- ${a}`);t.push("");}if(e$1.index.blockers.length>0){t.push("## Current blockers","");for(let a of e$1.index.blockers.slice(0,8))t.push(`- ${a}`);t.push("");}if(e$1.context?.safeCommands?.length){t.push("## Safe commands (prefer these)","");for(let a of e$1.context.safeCommands.slice(0,6))t.push(`- \`${a.display}\` \u2014 ${a.description}`);t.push("");}return t.push("## Rules","","- Treat `.workspai/reports/*` JSON reports as canonical gate and health evidence.","- Do not invent pass/fail state \u2014 cite `exitCode`, `blockers`, and `generatedAt` fields.","- Return answers with: Scope, Evidence, Diagnosis, Fix Plan, Run, Verify, Assumptions.","","## Refresh stale evidence","","```bash",A("workspace agent-sync --write --refresh-context"),"```",""),t.join(`
|
|
37
|
-
`)}async function p(e,t,r){return r?(await k.ensureDir(i$1.dirname(e)),await k.writeFile(e,t,"utf8"),"written"):"skipped"}async function Ye(e){if(!e.write)return "skipped";await tt(e.workspacePath,e.absolutePath);let t=await k.pathExists(e.absolutePath)?await k.readFile(e.absolutePath,"utf8"):null,{upsertManagedAgentSection:r}=await import('./managed-agent-markers-COE5DJ3W.js'),a=r(t,e.generatedBody),s=e.preamble?`${e.preamble.trimEnd()}
|
|
38
|
-
|
|
39
|
-
${a}`:a;return await k.ensureDir(i$1.dirname(e.absolutePath)),await k.writeFile(e.absolutePath,s,"utf8"),"written"}async function Xe(e){if(!e.write)return "skipped";await tt(e.workspacePath,e.absolutePath);let t=await k.pathExists(e.absolutePath)?await k.readFile(e.absolutePath,"utf8"):"",{upsertManagedAgentSection:r}=await import('./managed-agent-markers-COE5DJ3W.js'),a=r(t,e.generatedBody),s=a.includes(e.importLine)?a:`${e.importLine}
|
|
40
|
-
|
|
41
|
-
${a}`;return await k.ensureDir(i$1.dirname(e.absolutePath)),await k.writeFile(e.absolutePath,s,"utf8"),"written"}async function tt(e,t){let r=i$1.resolve(e),a=i$1.resolve(t),s=i$1.relative(r,a);if(!s||s===".."||s.startsWith(`..${i$1.sep}`)||i$1.isAbsolute(s))throw new Error("Agent output path must remain inside the canonical workspace.");let d=s.split(i$1.sep),u=r;for(let[o,w]of d.entries()){u=i$1.join(u,w);let m=await k.lstat(u).catch(I=>{if(I.code==="ENOENT")return null;throw I});if(!m)return;let g=o===d.length-1;if(m.isSymbolicLink()||(g?!m.isFile():!m.isDirectory()))throw new Error(`Agent output path is blocked by authored repository state: ${s}`)}}function $n(e){if(!e?.trim())return;let t=new Set(["all","vscode","agents","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"]),r=e.split(",").map(a=>a.trim().toLowerCase()).filter(a=>t.has(a));return r.length>0?r:void 0}function Mr(e){let t=[...e.outputs].sort((a,s)=>a.path.localeCompare(s.path)),r=b$2();return {schemaVersion:er,generatedAt:e.generatedAt,workspaceRoot:e.workspaceRef,preset:e.preset,targets:[...e.targets].sort(),sourceReports:e.index.reports.filter(a=>a.exists).map(a=>a.path).sort(),intelligenceChain:{schemaVersion:r.schemaVersion,contractPath:r.contractPath,currentStep:"agent-sync"},outputInventory:t,capabilityMatrix:hr({targets:e.targets,outputs:t}),drift:{missingRequired:e.missingRequired,staleReports:e.staleReports,strictViolations:e.strictViolations},answerContract:["Scope","Evidence","Diagnosis","Fix Plan","Run","Verify","Assumptions"],refreshCommand:A(`workspace agent-sync --write --refresh-context --preset ${e.preset}`),experimental:{hooksEnabled:e.experimentalHooks,mcpReady:t.some(a=>a.kind==="mcp-design")}}}async function Qe(e){let t$1=i$1.resolve(e.workspacePath),r$1=e.now??new Date,a=e.staleAfterHours??24,s$1=cr(e.targets),d=[...s$1].sort(),u$1=dr(e.preset),o$1=e.write===true,w$1=e.strict===true,m$2,g=null,I$1=e.model;e.refreshContext&&(I$1??=await p$1({workspacePath:t$1,includeEvidence:true}),g=await c({workspacePath:t$1,model:I$1,agent:e.agent??"generic",scope:e.scope,includeEvidence:true}),o$1&&(m$2=await d$1(g,t$1)));let y$1=[],W=[],pe=[],ue=[],l$1=(c,f)=>{c==="written"?W.push(f):pe.push(f),ue.push({path:f,kind:pr(f),targets:ur(f),required:mr(f,u$1),status:c==="written"?"written":e.dryRun?"planned":"skipped"});},ge="",C$1=await fr(t$1,I$1),me=null;try{me=(await m({workspacePath:t$1})).contract;}catch{me=null;}let Dt=xt({model:C$1,context:g,contract:me}),J$1=await Ct({workspacePath:t$1,skills:Dt,generatedAt:r$1.toISOString(),write:o$1});for(let c of J$1.skills){l$1(o$1?"written":"skipped",c.canonicalPath);for(let f of Wt(c.skillId))R(s$1,f.target)&&l$1(await p(i$1.join(t$1,f.path),c.markdown,o$1),f.path);}for(let c of J$1.removedSkillIds)for(let f of Wt(c))!R(s$1,f.target)||!o$1||await gr(t$1,f.path);l$1(o$1?"written":"skipped",b$1),ge=Ot(J$1.index);let P$1=await jt({workspacePath:t$1,staleAfterHours:a,now:r$1});if(l$1(await p(i$1.join(t$1,z),`${JSON.stringify(P$1,null,2)}
|
|
42
|
-
`,o$1),z),l$1(await p(i$1.join(t$1,f$2),`${Rr(P$1)}
|
|
43
|
-
`,o$1),f$2),["agents","vscode","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"].some(c=>R(s$1,c))&&l$1(await Ye({workspacePath:t$1,absolutePath:i$1.join(t$1,"AGENTS.md"),generatedBody:Ar({index:P$1,context:g}),write:o$1}),"AGENTS.md"),R(s$1,"claude")){let c=i$1.join(t$1,"CLAUDE.md");if(o$1){await tt(t$1,c);let{upsertManagedAgentSection:f}=await import('./managed-agent-markers-COE5DJ3W.js'),h=await k.pathExists(c)?await k.readFile(c,"utf8"):"",v=f(h,Sr()),O=v.includes("@AGENTS.md")?v:`@AGENTS.md
|
|
44
|
-
|
|
45
|
-
${v}`;await k.ensureDir(i$1.dirname(c)),await k.writeFile(c,O,"utf8"),W.push("CLAUDE.md");}else pe.push("CLAUDE.md");l$1(await p(i$1.join(t$1,s),`${Gr()}
|
|
46
|
-
`,o$1),s),l$1(await p(i$1.join(t$1,t),`${jr()}
|
|
47
|
-
`,o$1),t),l$1(await p(i$1.join(t$1,u),`${$r()}
|
|
48
|
-
`,o$1),u),l$1(await p(i$1.join(t$1,P),L({index:P$1,context:g,model:C$1}),o$1),P);}if(R(s$1,"gemini")&&l$1(await Xe({workspacePath:t$1,absolutePath:i$1.join(t$1,"GEMINI.md"),importLine:"@./AGENTS.md",generatedBody:Be("Gemini CLI"),write:o$1}),"GEMINI.md"),R(s$1,"qwen")&&l$1(await Xe({workspacePath:t$1,absolutePath:i$1.join(t$1,"QWEN.md"),importLine:"@AGENTS.md",generatedBody:Be("Qwen Code"),write:o$1}),"QWEN.md"),R(s$1,"amazon-q")&&(l$1(await Xe({workspacePath:t$1,absolutePath:i$1.join(t$1,".amazonq/rules/workspai-agent-entry.md"),importLine:"@../../AGENTS.md",generatedBody:Be("Amazon Q Developer"),write:o$1}),".amazonq/rules/workspai-agent-entry.md"),l$1(await p(i$1.join(t$1,v),Tr(),o$1),v)),R(s$1,"grok")&&(l$1(await p(i$1.join(t$1,q),Or(),o$1),q),l$1(await p(i$1.join(t$1,r),_r(),o$1),r),l$1(await p(i$1.join(t$1,R$1),L({index:P$1,context:g,model:C$1}),o$1),R$1)),R(s$1,"codex")&&l$1(await p(i$1.join(t$1,Q),L({index:P$1,context:g,model:C$1}),o$1),Q),R(s$1,"windsurf")&&(l$1(await Ye({workspacePath:t$1,absolutePath:i$1.join(t$1,n),generatedBody:Wr(),write:o$1}),n),l$1(await p(i$1.join(t$1,o),xr(),o$1),o),l$1(await p(i$1.join(t$1,p$2),Cr(),o$1),p$2)),R(s$1,"cursor")&&(l$1(await p(i$1.join(t$1,h$2),vr(),o$1),h$2),l$1(await p(i$1.join(t$1,i$2),yr(),o$1),i$2),l$1(await p(i$1.join(t$1,m$1),Dr(),o$1),m$1),u$1==="enterprise"&&(l$1(await p(i$1.join(t$1,j),br(),o$1),j),l$1(await p(i$1.join(t$1,k$1),Ir(),o$1),k$1),l$1(await p(i$1.join(t$1,l),Er(),o$1),l)),l$1(await p(i$1.join(t$1,O),L({index:P$1,context:g,model:C$1}),o$1),O)),$t(s$1)){if(l$1(await Ye({workspacePath:t$1,absolutePath:i$1.join(t$1,".github/copilot-instructions.md"),generatedBody:Pr(),write:o$1}),".github/copilot-instructions.md"),l$1(await p(i$1.join(t$1,w),Lr(),o$1),w),l$1(await p(i$1.join(t$1,x),Nt("workspace"),o$1),x),l$1(await p(i$1.join(t$1,y),Nr(),o$1),y),l$1(await p(i$1.join(t$1,z$1),Nt("evidence"),o$1),z$1),l$1(await p(i$1.join(t$1,A$1),Lt(),o$1),A$1),l$1(await p(i$1.join(t$1,B),Lt(),o$1),B),u$1==="enterprise"){let c=[[C,le({description:"Repair Workspai blockers with evidence and verification",objective:"Plan the smallest safe repair for the current Workspai blocker.",expectedOutput:["Blocker and affected workspace/project scope","Evidence paths and exact failing signals","Minimal fix plan","Human-run commands","Verification command and expected success signal"]})],[E,le({description:"Assess Workspai release readiness from evidence",objective:"Assess whether this workspace is release-ready using Workspai gates.",expectedOutput:["Readiness verdict with cited reports","Blocking gates","Safe next command","Verification checklist"]})],[G$1,le({description:"Onboard a project into Workspai Workspace Intelligence",objective:"Guide project onboarding using workspace model and create planner capabilities.",expectedOutput:["Target project scope","Native create, official generator, or existing lane","Safe commands","Post-onboarding verification"]})],[I,le({description:"Adopt an existing project into Workspai governance",objective:"Adopt an existing project without changing its runtime behavior.",expectedOutput:["Detected stack and confidence","Adoption plan","Generated metadata expectations","Doctor and workspace model verification"]})]];for(let[h,v]of c)l$1(await p(i$1.join(t$1,h),v,o$1),h);let f=[[D,c[0][1]],[F$1,c[1][1]],[H,c[2][1]],[J,c[3][1]]];for(let[h,v]of f)l$1(await p(i$1.join(t$1,h),v,o$1),h);if(e.hydratePrompts===true)for(let h of await _t({workspacePath:t$1,skills:J$1.skills,write:o$1}))l$1(o$1?"written":"skipped",h);}if(l$1(await p(i$1.join(t$1,K),L({index:P$1,context:g,model:C$1}),o$1),K),l$1(await p(i$1.join(t$1,L$1),L({index:P$1,context:g,model:C$1}),o$1),L$1),u$1==="enterprise"){l$1(await p(i$1.join(t$1,M),Gt(ge),o$1),M),l$1(await p(i$1.join(t$1,N),Gt(ge),o$1),N);let c=[["artifact-map.md",G({title:"Artifact Map",lines:V.map(h=>`- \`${h.relativePath}\` \u2014 ${h.label}`)})],["command-map.md",G({title:"Command Map",lines:["- `npx workspai workspace agent-sync --write --refresh-context` \u2014 refresh agent grounding.","- `npx workspai workspace model --json --write` \u2014 refresh workspace model.","- `npx workspai doctor workspace` \u2014 refresh health evidence.","- `npx workspai workspace verify --strict --json` \u2014 verify release gates."]})],["scope-model.md",G({title:"Scope Model",lines:["- Workspace scope is the default source of truth.","- Project scope is selected only when the active task targets a specific project.","- Always name the workspace and project when giving repair or lifecycle advice."]})],["runtime-support.md",G({title:"Runtime Support",lines:["- Native create is available only for Workspai-owned scaffold contracts.","- Unsupported stacks should use the official lane when a stable ecosystem generator exists.","- Existing projects should use the existing lane when native create is unavailable."]})],["create-planner-capabilities.md",G({title:"Create Planner Capabilities",lines:["- Use `contracts/create-planner-capabilities.v1.json` to decide native, official, or existing.","- Do not map PHP, WordPress, Laravel, Rails, or Symfony requests to unrelated native kits.","- Explain unsupported native create requests and guide users to adopt/import."]})],["mcp-tools.md",Kr()]];for(let[h,v]of c){let O=`${i$1.dirname(M)}/resources/${h}`;l$1(await p(i$1.join(t$1,O),v,o$1),O);let nt=`${i$1.dirname(N)}/resources/${h}`;l$1(await p(i$1.join(t$1,nt),v,o$1),nt);}let f=[["workspai-advisor.agent.md",de({name:"Workspai Advisor",description:"Read-only workspace and project guidance using Workspai evidence",mode:"read-only",tools:["search","read"]})],["workspai-repair.agent.md",de({name:"Workspai Repair",description:"Turn Workspai blockers into minimal fixes and verification steps",mode:"repair",tools:["search","read","edit"]})],["workspai-release.agent.md",de({name:"Workspai Release",description:"Assess readiness, governance gates, and release safety from evidence",mode:"release",tools:["search","read"]})],["workspai-project-onboarder.agent.md",de({name:"Workspai Project Onboarder",description:"Guide create, import, and adopt flows with Workspai contracts",mode:"onboard",tools:["search","read","edit"]})]];for(let[h,v]of f){let O=`.github/agents/${h}`;l$1(await p(i$1.join(t$1,O),v,o$1),O);}}}if(u$1==="enterprise"){let c=qr({workspaceRef:P$1.workspaceRoot,generatedAt:P$1.generatedAt});b$5(S,JSON.parse(c)),l$1(await p(i$1.join(t$1,S),c,o$1),S),l$1(await p(i$1.join(t$1,T),c,o$1),T);}if(u$1==="enterprise"&&e.experimentalHooks===true){let c=Hr({workspaceRef:P$1.workspaceRoot,generatedAt:P$1.generatedAt});b$5(U,JSON.parse(c)),l$1(await p(i$1.join(t$1,U),c,o$1),U),l$1(await p(i$1.join(t$1,V$1),c,o$1),V$1);}let B$1=o$1?await jt({workspacePath:t$1,staleAfterHours:a,now:r$1}):P$1,Y=B$1.reports.filter(c=>c.required&&!c.exists).map(c=>c.path),X=B$1.reports.filter(c=>c.exists&&sr(c,a,r$1)).map(c=>c.path);if(w$1){Y.length>0&&y$1.push(`Missing required reports: ${Y.join(", ")}`),X.length>0&&y$1.push(`Stale reports (>${a}h): ${X.join(", ")}`);let c=ue.map(f=>f.path).filter(f=>!kr(f));c.length>0&&y$1.push(`Unsafe generated output paths: ${c.join(", ")}`);}let j$1=o$1?await g$2({workspacePath:t$1,mode:e.projectGrounding??"managed",now:r$1}):void 0;if(w$1&&j$1&&j$1.skipped.length>0&&y$1.push(`Project grounding incomplete: ${j$1.skipped.map(c=>`${c.name} (${c.reason})`).join(", ")}`),w$1&&j$1){let c=j$1.projects.flatMap(f=>(f.hostCoverage??[]).filter(h=>h.status==="blocked"&&lr(s$1,h.id)).map(h=>`${i$1.basename(f.projectPath)}:${h.id}`));c.length>0&&y$1.push(`Project agent entry coverage blocked: ${c.join(", ")}`);}let rt=Mr({workspaceRef:B$1.workspaceRoot,generatedAt:r$1.toISOString(),preset:u$1,targets:d,index:B$1,outputs:[...ue,{path:F,kind:"report",targets:["agents","vscode","copilot","cursor","claude","codex","gemini","qwen","kimi","grok","windsurf","amazon-q","orca"],required:true,status:o$1?"written":e.dryRun?"planned":"skipped"}],missingRequired:Y,staleReports:X,strictViolations:y$1,experimentalHooks:e.experimentalHooks===true});if(o$1&&process.env.WORKSPAI_TEST_FAIL_AGENT_SYNC_BEFORE_PACK==="1")throw new Error("Injected agent-sync failure before generation commit.");return l$1(await p(i$1.join(t$1,F),`${JSON.stringify(rt,null,2)}
|
|
49
|
-
`,o$1),F),{workspacePath:t$1,indexPath:i$1.join(t$1,z),packPath:i$1.join(t$1,F),pack:rt,contextPath:m$2,writtenFiles:W,skippedFiles:pe,blockers:P$1.blockers,missingRequired:Y,staleReports:X,strictViolations:y$1,projectLenses:j$1}}async function Dn(e){if(e.write!==true)return Qe(e);let t=i$1.resolve(e.workspacePath),r=i$1.join(t,".workspai","transactions","agent-sync");await b$3(r);let a$1=await Qe({...e,write:false,dryRun:true});if(!a$1.pack)throw new Error("Agent-sync dry run did not produce an output inventory.");let s=[...a$1.pack.outputInventory.map(u=>u.path),z,F],d=await a({journalDirectory:r});try{for(let w of [...new Set(s)].sort()){let m=i$1.resolve(t,w),g=i$1.relative(t,m);if(g===".."||g.startsWith(`..${i$1.sep}`)||i$1.isAbsolute(g))throw new Error(`Agent-sync output escapes workspace root: ${w}`);await d.captureFile(m);}let u=await h(t);for(let w of u.resolved)for(let m of [f$1,g,h$1,b$4,...g$1,"AGENTS.md",".gitignore"]){let g=i$1.join(w.projectPath,m);(m==="AGENTS.md"||g$1.some(y=>y===m))&&(await k.lstat(g).catch(W=>{if(W.code==="ENOENT")return null;throw W}))?.isSymbolicLink()||await d.captureFile(g);}let o=await Qe(e);return await d.commit(),o}catch(u){try{await d.rollback();}catch(o){throw new AggregateError([u,o],"Agent-sync generation failed and rollback was incomplete.")}throw u}}export{qt as a,Mt as b,Qt as c,Zt as d,er as e,z as f,F as g,V as h,tr as i,jt as j,$n as k,Dn as l};
|