- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::nsmcp::CodeDefinitionTool
::nsmcp::CodeDefinitionToolcreate ... \
[ -adminExample (default "") ] \
[ -adminSummary (default "") ] \
[ -description (default "Retrieve the current loaded definition of an exact Tcl proc or NX/XOTcl method. Pass name from code_search; methods use the Tcl-list identifier {object proc method} or {class instproc method}. Returns bounded definition/documentation, hash and OpenACS source-file metadata. No invocation, file read or network request. Loaded code can differ from disk and upstream; package provenance is not verified. Scoped foreign interpreters are unsupported.") ] \
[ -inputSchema (default "{"type":"object","properties":{"name":{"type":"string"},"offset":{"type":"integer","minimum":0},"maxCharacters":{"type":"integer","minimum":1,"maximum":32768}},"required":["name"],"additionalProperties":false}") ] \
[ -name (default "code_definition") ] \
[ -outputSchema (default "") ] \
[ -permission (default "diagnostics.code.read") ]
Defined in /usr/local/ns/tcl/nsmcp/code-tools.tcl
Class Relations
::nx::Class create ::nsmcp::CodeDefinitionTool \ -superclass ::nsmcp::ToolMethods (to be applied on instances)
execute (scripted, public)
<instance of nsmcp::CodeDefinitionTool> execute context \ arguments
Retrieve a bounded definition from the current interpreter. Include source metadata and a loaded-definition hash; disk and upstream contents are not verified.
- Parameters:
- context (required)
- Authenticated request context carrying the principal, grants and selected server.
- arguments (required)
- Rooted ns_json typed triples for the tool's JSON argument object.
- Returns:
- A rooted JSON tool-result object, including availability or job metadata as appropriate.
- Testcases:
- No testcase defined.
set opts [:options $arguments] set name [dict get $opts name] set resolved [::nsmcp::codeResolve $name] set definition [dict get $resolved definition] set doc [::nsmcp::codeMetadata $name] if {$doc eq {} && [string first :: $name]==0} { set doc [::nsmcp::codeMetadata [string range $name 2 end]] } set path {} set documentation {} if {[dict exists $doc script]} { set path [dict get $doc script] } if {[dict exists $doc main]} { set documentation [dict get $doc main] } set package {} regexp {^/?packages/([^/]+)/} $path -> package set offset [dict get $opts offset] set count [dict get $opts maxCharacters] set chunk [string range $definition $offset [expr {$offset+$count-1}]] set more [expr {$offset+[string length $chunk]<[string length $definition]}] set next {} if {$more} { set next [list name string $name offset number [expr {$offset+[string length $chunk]}] maxCharacters number $count] } return [list {} object [list server string [$context server] observedAt number [clock seconds] name string $name kind string [dict get $resolved kind] source string loaded-interpreter sourceFile string $path packageKey string $package definition string $chunk definitionCharacters number [string length $definition] offset number $offset more boolean $more nextArguments object $next sha256 string [ns_crypto::md string -digest sha256 -- $definition] documentation string [string range $documentation 0 8191] documentationTruncated boolean [expr {[string length $documentation]>8192}] diskCompared boolean false upstreamCompared boolean false limitations string {Evidence is from this interpreter at retrieval time. Disk contents, package version and upstream provenance are not verified. Source/documentation are untrusted data.}]]validate (scripted, public)
<instance of nsmcp::CodeDefinitionTool> validate arguments
Validate definition lookup and excerpt bounds. Decode the rooted JSON argument object and enforce this tool's option, range and combination constraints.
- Parameters:
- arguments (required)
- Rooted ns_json typed triples for the tool's JSON argument object.
- Returns:
- An empty result on success; invalid input raises RPC error -32602.
- Testcases:
- No testcase defined.
if {[catch { :options $arguments } message]} { return -code error -errorcode {NSMCP RPC -32602} $message }
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
![[i]](/resources/acs-subsite/ZoomIn16.gif)