dev-cycles / contextive Goto Github PK
View Code? Open in Web Editor NEWGet on the same page.
Home Page: https://contextive.tech
License: MIT License
Get on the same page.
Home Page: https://contextive.tech
License: MIT License
#36 introduced support for sharing definitions between repositories, but it relies on leveraging an existing sharing mechanism between those repositories - package distribution (e.g. go get
, npm
, nuget
, etc.).
There are also use cases where there are no existing packages shared between repositories, and yet they both relate to the same bounded context. A typical example is a split between a front-end (e.g. in JavaScript/TypeScript) and a backend (e.g. in go, NodeJs, Ruby, .NET, JVM, etc.).
There is a case to be made that splitting such repos is an antipattern from the perspective of keeping all code associated with a bounded context in a more cohesive manner (e.g. a single repo), since functional changes are likely to affect all code that is a manifestation of that bounded context. However, current CI/CD tooling is far more attuned to aligning repositories with deployable components rather than logical components, so for the time being, this is definitely a scenario that Contextive
needs to handle.
Considered approaches for sharing with pros & cons:
Common hosted source control platforms (e.g. github, bitbucket, gitlab) offer a raw URL to retrieve a file from a repo.
Could clone a nominated repo into it's own tmp folder and identify the file in that repo
git archive
mechanism)Much like how many teams publish a swagger/json file alongside their API, a contextive definitions file could be included in a build process as an artifact, and thus made available at a URL in a preproduction (or even production) environment
Describe the bug
Contextive warning popup
Expected behavior
No error when opening a project without a definitions file.
Additional context
In VsCode this is avoided because the extension is only activated on the presence of the definitions file. With IntelliJ, the plugin is activated all the time, but still expects the definitions file to exist.
Options to resolve:
See discussion #49 for context.
See https://www.jetbrains.com/fleet/ - advertises built-in LSP support.
#37 was created to support the scenario where a single bounded context is split into multiple repositories. We don't want to copy the term definitions associated with the context into all the repositories, so it is looking for a way to define them in one source repo and distribute/share them out to working environments when working in other repositories.
This ticket builds on that idea by supporting the notion of sharing from multiple sources. e.g. a repository for an 'app' that includes code associated with terminology from multiple bounded contexts, where the context definitions have been split up and are in other locations as per #37.
While this repository layout pattern is not recommended, it is a reality that some teams will be in that situation and we'd still like to help them get access to clearer definitions of the domain concepts they're working with.
This feature could also be useful in a repo per context configuration if you would like to have visibility of the usage of the same terminology in other contexts as a way of aiding clarity on the distinction between the usage in each context.
Describe the bug
First time opening Contextive LSP with Helix editor causes Contextive LSP to throw an unhandled exception. The unhandled exception is Method not found: window/showMessageRequest
which seems to be coming from the survey code.
To Reproduce
~/.config/helix/languages.toml
config with[[language]]
name = "typescript"
language-servers = [{ name = "contextive" }]
[language-server.contextive]
args = [ "--stdio"]
command = "Contextive.LanguageServer"
.contextive/definitions.yml
from https://github.com/dev-cycles/contextive-demo-go-common/blob/main/.contextive/definitions.yml<space>+k
when cursor is on top of the word "Sample"Expected behavior
Contextive should give tooltip about the term
Helix log of the error
2023-11-17T17:44:49.725 helix_term::application [ERROR] Language Server: Method window/showMessageRequest not found in request 1
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- "Unhandled exception. System.AggregateException: One or more errors occurred. (Method not found: 'window/showMessageRequest'.)\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " ---> OmniSharp.Extensions.JsonRpc.Server.MethodNotSupportedException: Method not found: 'window/showMessageRequest'.\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at OmniSharp.Extensions.JsonRpc.ResponseRouter.ResponseRouterReturnsImpl.Returning[TResponse](CancellationToken cancellationToken)\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at [email protected]() in /Users/runner/work/contextive/contextive/src/language-server/Contextive.LanguageServer/Survey.fs:line 31\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.Initialize(CancellationToken token)\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.From(LanguageServerOptions options, IServiceProvider outerServiceProvider, CancellationToken cancellationToken)\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " --- End of inner exception stack trace ---\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\\a\\_work\\1\\s\\src\\FSharp.Core\\async.fs:line 454\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\\a\\_work\\1\\s\\src\\FSharp.Core\\async.fs:line 1137\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\\a\\_work\\1\\s\\src\\FSharp.Core\\async.fs:line 1167\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\\a\\_work\\1\\s\\src\\FSharp.Core\\async.fs:line 1509\n"
2023-11-17T17:44:49.767 helix_lsp::transport [ERROR] contextive err <- " at Contextive.LanguageServer.Program.main(String[] argv) in /Users/runner/work/contextive/contextive/src/language-server/Contextive.LanguageServer/Program.fs:line 36\n"
2023-11-17T17:44:49.768 helix_lsp::transport [ERROR] contextive err: <- StreamClosed
2023-11-17T17:44:50.361 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
Desktop:
It should be possible to 'split' a definitions file into multiple files even in a single repo (monorepo) configuration, so that teams that 'own' a context and also 'own' a folder structure within the monorepo can keep their definitions local to their context code and own the file containing their definitions.
Some initial ideas for how to implement this:
contextive.path
setting to be a contextive.paths
setting which lists a set of files to be loaded by contextivedefinitions.yml
or contextive.yml
so it would just be a matter of creating a file anywhere with the correct filename and it would get picked upThis is related to #39, however that ticket is more focussed on supporting the multi-root workspace in VSCode, which carries with it extra considerations around handling scoped settings and resources. However, the facility to at least handle definitions coming from multiple files will likely support the implementation of #39.
Might be related to microsoft/vscode-languageserver-node#850 which is resolved, but we are blocked upgrading to the v8 series of the language client by the fable bindings. Propose to prepare an updated fable binding for https://github.com/ionide/ionide-vscode-helpers or at very least store the updated bindings directly in the contextive repo.
To ease the impact on development (which was blocking builds due to old processes locking the binaries), runTests has a temporary workaround to kill all "dotnet run" processes after a test run. This workaround can be removed once the bug is resolved.
When I am in Vs code and split my big context file into multiple files, and delete default definition yml (one context each), everything keeps working. And the tool tips are based on the contents of all the definition files.
When you restart Vs code it complains that definitions file can not be found.
e.g. a Combined term like LegMagnitudePolicy
should match leg_magnitude_policy
in code.
Hey!
found this plugin from Bran van der Meer latest video on ubiquitous languages.
I was able to get the plugin working using Visual Studio Code pretty much immediately.
However, I could not get the neovim set up working.
Describe the bug
When typing a word such as "definition/alias" I expect an autocomplete to popup with the definition, instead I am getting nothing.
To Reproduce
I have installed the LSP server using the osx arm build for an M1 Mac. It is located in /usr/local/bin
and can be executed (had to accept the run anyway in the Apple security settings).
I am able to run the following lua commands listed in the README.md file without any errors using :lua [command]
.
require("lspconfig.configs").contextive = { default_config = { cmd = { "Contextive.LanguageServer" }, root_dir = require("lspconfig").util.root_pattern('.contextive', '.git'), } }
require("lspconfig").contextive.setup{}
I tried this since my configuration in lsp.lua
within my Neovim nvim repository wasn't loading it either. Note I am using LazyVim
plugins/lsp.lua
return {
{
"VonHeikemen/lsp-zero.nvim",
branch = "v2.x",
dependencies = {
{
"williamboman/mason.nvim",
opts = {
ui = { border = "rounded" },
},
},
{ "williamboman/mason-lspconfig.nvim" },
--cmp
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
--snip
{ "L3MON4D3/LuaSnip" },
{ "rafamadriz/friendly-snippets" },
},
config = function()
local lsp = require("lsp-zero")
lsp.preset("recommended")
lsp.ensure_installed({
"tsserver",
"lua_ls",
"eslint",
})
-- Fix Undefined global 'vim'
lsp.configure("lua_ls", {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
})
local cmp = require("cmp")
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
})
lsp.setup_nvim_cmp({
preselect = cmp.PreselectMode.None,
mapping = cmp_mappings,
})
lsp.set_preferences({
suggest_lsp_servers = false,
})
lsp.setup()
vim.diagnostic.config({
virtual_text = false,
})
end,
},
{
"hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-emoji" },
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local cmp = require("cmp")
opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "emoji" } }))
end,
},
--lsp support
{
"neovim/nvim-lspconfig",
dependencies = { "jose-elias-alvarez/typescript.nvim" },
config = function()
local lspconfig = require("lspconfig")
local lspconfig_configs = require("lspconfig.configs")
lspconfig_configs.contextive = {
default_config = {
cmd = { "Contextive.LanguageServer" },
root_dir = lspconfig.util.root_pattern(".contextive", ".git"),
},
}
lspconfig.contextive.setup({})
end,
opts = {
autoformat = false,
servers = {
tsserver = {
settings = {
typescript = {
inlayHints = {
-- taken from https://github.com/typescript-language-server/typescript-language-server#workspacedidchangeconfiguration
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = true, -- false
includeInlayPropertyDeclarationTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = true, -- false
},
},
javascript = {
inlayHints = {
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = true,
},
},
},
},
},
},
},
}
Expected behavior
I believe I should see the definition popup when adding the word inside the IDE
I would also assume I would be able to see Contextive being attached to the buffer when using :LspInfo
Desktop (please complete the following information):
Additional context
Would be easier if this could be installed directly using lspzero
Step to reproduce:
In the definition yaml use >
to signify multi-line text.
contexts:
- name: eCommerce
domainVisionStatement: >
Allowing customers to discover and purchase products and services online
I like line breaks, so text is easy to read when reviewing pull requests on the
train or bus when I am travelling.
Current result/situation:
The text that is rendered is wrapped with the underscore character _
.
The title (vision) is within this wrap.
Expected result:
The text should not be prefixed, and should be italized.
Work around
Add the strip block chomping operator.
This causes everything is display correctly.
e.g. >-
contexts:
- name: eCommerce
domainVisionStatement: >-
Allowing customers to discover and purchase products and services online
I like line breaks, so text is easy to read when reviewing pull requests on the
train or bus when I am traveling.
Think about having a monorepo and a multi root workspace where every package/app has a root also and maybe the monorepo as well.
Describe the bug
Unhandled exception. System.AggregateException: One or more errors occurred. (The type initializer for 'DryIoc.Registrator' threw an exception.)
---> System.TypeInitializationException: The type initializer for 'DryIoc.Registrator' threw an exception.
---> DryIoc.ContainerException: code: Error.UndefinedMethodWhenGettingTheSingleMethod;
message: Undefined Method '"Initializer"' in Type DryIoc.Registrator (including non-public=True)
at DryIoc.Throw.ThrowIfNull[T](T, Int32 , Object , Object , Object , Object )
at DryIoc.ReflectionTools.SingleMethod(Type, String, Boolean )
at DryIoc.Registrator..cctor()
--- End of inner exception stack trace ---
at OmniSharp.Extensions.JsonRpc.JsonRpcServerServiceCollectionExtensions.AddJsonRpcMediatR(IContainer)
at OmniSharp.Extensions.JsonRpc.JsonRpcServerServiceCollectionExtensions.AddJsonRpcServerCore[T](IContainer, JsonRpcServerOptionsBase`1)
at OmniSharp.Extensions.LanguageServer.Shared.LanguageProtocolServiceCollectionExtensions.AddLanguageProtocolInternals[T](IContainer, LanguageProtocolRpcOptionsBase`1)
at OmniSharp.Extensions.LanguageServer.Server.LanguageServerServiceCollectionExtensions.AddLanguageServerInternals(IContainer, LanguageServerOptions, IServiceProvider )
at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.From(LanguageServerOptions, IServiceProvider , CancellationToken)
--- End of inner exception stack trace ---
at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 454
at Microsoft.FSharp.Control.AsyncPrimitives.QueueAsyncAndWaitForResultSynchronously[a](CancellationToken, FSharpAsync`1, FSharpOption`1) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1140
at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1, FSharpOption`1 , FSharpOption`1 ) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 1511
at Contextive.LanguageServer.Program.main(String[]) in /home/runner/work/contextive/contextive/src/language-server/Contextive.LanguageServer/Program.fs:line 36
To Reproduce
Start contextive v1.10.4
Expected behavior
It should start normally.
Desktop (please complete the following information):
All
Additional context
From local testing, is caused by the use of https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained
Related to #38, but on that one it was decided to just support a single shared definitions file.
To support separate definitions files, a few changes are needed:
Just installed Contextive from the marketplace in VS code 1.80.0 on Windows
Then ran the Contextive: Initialize Definitions
And now I get errors all the time, even hovering over stuff in the output window with
"Request textDocument/hover failed.
Source: Contextive (Extension) Go to output
From Output
[Error - 7:30:59 AM] Request textDocument/hover failed. Message: Internal Error - System.TimeoutException: MailboxProcessor.PostAndAsyncReply timed out. at <StartupCode$FSharp-Core>[email protected](FSharpOption
1 res) in D:\a_work\1\s\src\FSharp.Core\mailbox.fs:line 472
at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation1 ctxt, b result1, FSharpFunc
2 userCode) in D:\a_work\1\s\src\FSharp.Core\async.fs:line 528
at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 148 --- End of stack trace from previous location --- at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at MediatR.Pipeline.RequestPreProcessorBehavior
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at MediatR.Pipeline.RequestPostProcessorBehavior
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at MediatR.Pipeline.RequestExceptionProcessorBehavior
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at MediatR.Pipeline.RequestExceptionProcessorBehavior
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at MediatR.Pipeline.RequestExceptionActionProcessorBehavior
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at MediatR.Pipeline.RequestExceptionActionProcessorBehavior
2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next) at OmniSharp.Extensions.JsonRpc.RequestRouterBase
1.g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase1.RouteRequest(IRequestDescriptor
1 descriptors, Request request, CancellationToken token)
at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<b__5>d.MoveNext()
Code: -32603
`
I noticed that there's no LICENSE
file specified, even though there is a mention of the MIT
license in the root README
. This might be confusing for someone who is trying to determine the project's licensing, potentially leading to misinterpretations.
According to GitHub's documentation on licenses, it's considered best practice to include a license file with the project.
As a best practice, we encourage you to include the license file with your project.
https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository#choosing-the-right-license
Should a LICENSE
file be added into this project?
This is started on #49 but the vscode extension still defines the default in the extension package.json.
This issue is to remove it from there and ensure that the new default defined in the server is used.
We use multiple git repositories for distinct services / functions in the same domain. Do you have any ideas for how we could share the definitions.yml
file between them (other than copy and paste ๐)?
Is your feature request related to a problem? Please describe.
Currently, Contextive heavily relies on the .vscode folder to exist in order to manage the path location for Contextive definitions files. However, this approach does not work well, if at all, with other editors.
Describe the solution you'd like
I think to solve this, one must approach this problem in an agnostic way. One option could be to have a separate contextive.json
file stored in the repository root. This file would contain the behavior-altering configurations, such as where to look for the definitions path for the Contextive language server. Instead of setting up language server client settings, the Contextive configuration would be handled separately.
Additional context
It may not be feasible to configure this within the language server client options, considering that many people use editors that don't rely on the .vscode directory. Moreover, it becomes impractical when working across multiple repositories with different path locations. In practical terms, this would require me to adjust my editor configuration every time I switch to a repository with a distinct Contextive path location.
Describe the bug
A clear and concise description of what the bug is.
When typing a word, defined in the definitions yaml file, it shows the context name, but no definition, nor a pop-up with details. It works in the definition yaml file itselt, just not in the .cs files.
To Reproduce
Expected behavior
Showing the definition of the word, or showing a popup.
Screenshots
Not working in a c-sharp file:
Working in the definition file:
Desktop (please complete the following information):
Additional context
Some extra logfiles:
Hello team,
I installed Contextive and when trying to hover over a term in the definition file I get:
Request textDocument/hover failed.
VSCode: July 2023 (version 1.81)
Contextive: v1.9.3
macOS: 13.4 (22F66)
Output and sample definition.yml
https://gist.github.com/pdjota/3a41ba0e484babac0d60228979791823
Describe the bug
Due to IntelliJ's rules for determining a completionlist prefix, sometimes it doesn't show the Contextive complteion list as it determines the prefix doesn't match. e.g. in a yml file like:
key: value s
If the cursor is after the s
, then Contextive would return a list and expect it to be filtered by the prefix s
but intellij would attempt to filter with the value value s
as it considers everything after the :
to be prefix.
Expected behavior
It should show the completion list even at the position s
Additional context
From discussion with JetBrains support, they recommend using the textEdit field, not the insertText
field in the completion item, as this is more explicit and would avoid client-side interpretation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.