ineedcodes 0.1.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.
Files changed (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -0
  3. package/docs/assets/ineed-logo.svg +161 -0
  4. package/docs/configuration.md +71 -0
  5. package/docs/skills.md +58 -0
  6. package/package.json +41 -0
  7. package/packages/agent/dist/boost.d.ts +34 -0
  8. package/packages/agent/dist/boost.js +138 -0
  9. package/packages/agent/dist/boost.js.map +1 -0
  10. package/packages/agent/dist/events.d.ts +67 -0
  11. package/packages/agent/dist/events.js +16 -0
  12. package/packages/agent/dist/events.js.map +1 -0
  13. package/packages/agent/dist/index.d.ts +6 -0
  14. package/packages/agent/dist/index.js +7 -0
  15. package/packages/agent/dist/index.js.map +1 -0
  16. package/packages/agent/dist/lead-agent.d.ts +85 -0
  17. package/packages/agent/dist/lead-agent.js +235 -0
  18. package/packages/agent/dist/lead-agent.js.map +1 -0
  19. package/packages/agent/dist/orchestrator.d.ts +43 -0
  20. package/packages/agent/dist/orchestrator.js +135 -0
  21. package/packages/agent/dist/orchestrator.js.map +1 -0
  22. package/packages/agent/dist/runtime.d.ts +44 -0
  23. package/packages/agent/dist/runtime.js +265 -0
  24. package/packages/agent/dist/runtime.js.map +1 -0
  25. package/packages/agent/dist/system-prompts.d.ts +24 -0
  26. package/packages/agent/dist/system-prompts.js +91 -0
  27. package/packages/agent/dist/system-prompts.js.map +1 -0
  28. package/packages/agent/package.json +21 -0
  29. package/packages/cli/dist/index.d.ts +3 -0
  30. package/packages/cli/dist/index.js +567 -0
  31. package/packages/cli/dist/index.js.map +1 -0
  32. package/packages/cli/dist/setup.d.ts +37 -0
  33. package/packages/cli/dist/setup.js +240 -0
  34. package/packages/cli/dist/setup.js.map +1 -0
  35. package/packages/cli/dist/tools-setup.d.ts +12 -0
  36. package/packages/cli/dist/tools-setup.js +28 -0
  37. package/packages/cli/dist/tools-setup.js.map +1 -0
  38. package/packages/cli/dist/ui/approval.d.ts +12 -0
  39. package/packages/cli/dist/ui/approval.js +52 -0
  40. package/packages/cli/dist/ui/approval.js.map +1 -0
  41. package/packages/cli/dist/ui/colors.d.ts +14 -0
  42. package/packages/cli/dist/ui/colors.js +21 -0
  43. package/packages/cli/dist/ui/colors.js.map +1 -0
  44. package/packages/cli/dist/ui/prompts.d.ts +46 -0
  45. package/packages/cli/dist/ui/prompts.js +135 -0
  46. package/packages/cli/dist/ui/prompts.js.map +1 -0
  47. package/packages/cli/dist/ui/renderer.d.ts +13 -0
  48. package/packages/cli/dist/ui/renderer.js +95 -0
  49. package/packages/cli/dist/ui/renderer.js.map +1 -0
  50. package/packages/cli/package.json +23 -0
  51. package/packages/core/dist/config/config.d.ts +32 -0
  52. package/packages/core/dist/config/config.js +43 -0
  53. package/packages/core/dist/config/config.js.map +1 -0
  54. package/packages/core/dist/context/engine.d.ts +25 -0
  55. package/packages/core/dist/context/engine.js +98 -0
  56. package/packages/core/dist/context/engine.js.map +1 -0
  57. package/packages/core/dist/index.d.ts +20 -0
  58. package/packages/core/dist/index.js +21 -0
  59. package/packages/core/dist/index.js.map +1 -0
  60. package/packages/core/dist/llm/openai-compatible.d.ts +23 -0
  61. package/packages/core/dist/llm/openai-compatible.js +177 -0
  62. package/packages/core/dist/llm/openai-compatible.js.map +1 -0
  63. package/packages/core/dist/memory/icm-adapter.d.ts +31 -0
  64. package/packages/core/dist/memory/icm-adapter.js +98 -0
  65. package/packages/core/dist/memory/icm-adapter.js.map +1 -0
  66. package/packages/core/dist/permissions/permissions.d.ts +28 -0
  67. package/packages/core/dist/permissions/permissions.js +89 -0
  68. package/packages/core/dist/permissions/permissions.js.map +1 -0
  69. package/packages/core/dist/security/secrets.d.ts +4 -0
  70. package/packages/core/dist/security/secrets.js +43 -0
  71. package/packages/core/dist/security/secrets.js.map +1 -0
  72. package/packages/core/dist/session/store.d.ts +16 -0
  73. package/packages/core/dist/session/store.js +54 -0
  74. package/packages/core/dist/session/store.js.map +1 -0
  75. package/packages/core/dist/shell/process.d.ts +26 -0
  76. package/packages/core/dist/shell/process.js +128 -0
  77. package/packages/core/dist/shell/process.js.map +1 -0
  78. package/packages/core/dist/skills/loader.d.ts +9 -0
  79. package/packages/core/dist/skills/loader.js +163 -0
  80. package/packages/core/dist/skills/loader.js.map +1 -0
  81. package/packages/core/dist/tools/fs.d.ts +10 -0
  82. package/packages/core/dist/tools/fs.js +409 -0
  83. package/packages/core/dist/tools/fs.js.map +1 -0
  84. package/packages/core/dist/tools/git.d.ts +7 -0
  85. package/packages/core/dist/tools/git.js +251 -0
  86. package/packages/core/dist/tools/git.js.map +1 -0
  87. package/packages/core/dist/tools/mcp.d.ts +42 -0
  88. package/packages/core/dist/tools/mcp.js +158 -0
  89. package/packages/core/dist/tools/mcp.js.map +1 -0
  90. package/packages/core/dist/tools/registry.d.ts +21 -0
  91. package/packages/core/dist/tools/registry.js +50 -0
  92. package/packages/core/dist/tools/registry.js.map +1 -0
  93. package/packages/core/dist/tools/search.d.ts +2 -0
  94. package/packages/core/dist/tools/search.js +243 -0
  95. package/packages/core/dist/tools/search.js.map +1 -0
  96. package/packages/core/dist/tools/shell.d.ts +8 -0
  97. package/packages/core/dist/tools/shell.js +164 -0
  98. package/packages/core/dist/tools/shell.js.map +1 -0
  99. package/packages/core/dist/tools/web.d.ts +14 -0
  100. package/packages/core/dist/tools/web.js +125 -0
  101. package/packages/core/dist/tools/web.js.map +1 -0
  102. package/packages/core/dist/types.d.ts +202 -0
  103. package/packages/core/dist/types.js +7 -0
  104. package/packages/core/dist/types.js.map +1 -0
  105. package/packages/core/dist/util/fs.d.ts +5 -0
  106. package/packages/core/dist/util/fs.js +33 -0
  107. package/packages/core/dist/util/fs.js.map +1 -0
  108. package/packages/core/dist/util/shell-quote.d.ts +7 -0
  109. package/packages/core/dist/util/shell-quote.js +20 -0
  110. package/packages/core/dist/util/shell-quote.js.map +1 -0
  111. package/packages/core/dist/workspace/workspace.d.ts +15 -0
  112. package/packages/core/dist/workspace/workspace.js +84 -0
  113. package/packages/core/dist/workspace/workspace.js.map +1 -0
  114. package/packages/core/package.json +21 -0
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Shared types for the iNeedCodes runtime.
3
+ * These types are intentionally model-independent: tools receive JSON,
4
+ * return JSON, and never depend on a specific LLM SDK.
5
+ */
6
+ export type JsonObject = Record<string, unknown>;
7
+ export type JsonValue = string | number | boolean | null | JsonObject | JsonValue[];
8
+ export type PermissionCategory = 'read' | 'write' | 'execute' | 'network' | 'outside_workspace' | 'git_remote' | 'destructive' | 'secret_access';
9
+ export type PermissionMode = 'ask' | 'workspace' | 'autonomous';
10
+ export type PermissionDecision = {
11
+ allowed: true;
12
+ } | {
13
+ allowed: false;
14
+ reason: string;
15
+ };
16
+ export interface ToolParameterSchema {
17
+ type: 'object';
18
+ properties: Record<string, unknown>;
19
+ required?: string[];
20
+ [key: string]: unknown;
21
+ }
22
+ export interface ToolResult {
23
+ ok: boolean;
24
+ /** Human-readable summary (safe to show the user). */
25
+ summary: string;
26
+ /** Structured payload for the model. */
27
+ data?: JsonValue;
28
+ error?: string;
29
+ }
30
+ export interface Tool {
31
+ name: string;
32
+ description: string;
33
+ inputSchema: ToolParameterSchema;
34
+ /** Permission categories the tool needs. */
35
+ permissions: PermissionCategory[];
36
+ /** Tools that never modify state can run in parallel safely. */
37
+ readonly: boolean;
38
+ execute(input: JsonValue, ctx: ToolContext): Promise<ToolResult>;
39
+ }
40
+ export interface ToolContext {
41
+ workspaceRoot: string;
42
+ cwd: string;
43
+ permissions: PermissionEngineLike;
44
+ /** Long-running shell processes and other stateful resources. */
45
+ processManager: ProcessManagerLike;
46
+ }
47
+ export interface PermissionEngineLike {
48
+ check(categories: PermissionCategory[], detail?: string): Promise<PermissionDecision>;
49
+ }
50
+ export interface ShellProcessRecord {
51
+ pid: number;
52
+ command: string;
53
+ cwd: string;
54
+ stdout: string;
55
+ stderr: string;
56
+ exited: boolean;
57
+ exitCode: number | null;
58
+ startedAt: number;
59
+ }
60
+ export interface ProcessManagerLike {
61
+ start(command: string, cwd: string): Promise<ShellProcessRecord>;
62
+ status(pid: number): ShellProcessRecord | undefined;
63
+ list(): ShellProcessRecord[];
64
+ stop(pid: number): boolean;
65
+ drain(): void;
66
+ }
67
+ export type ChatRole = 'system' | 'user' | 'assistant' | 'tool';
68
+ export interface ChatToolCall {
69
+ id: string;
70
+ name: string;
71
+ arguments: string;
72
+ }
73
+ export interface ChatMessage {
74
+ role: ChatRole;
75
+ content: string | null;
76
+ toolCalls?: ChatToolCall[];
77
+ toolCallId?: string;
78
+ name?: string;
79
+ }
80
+ export interface ChatRequest {
81
+ messages: ChatMessage[];
82
+ tools?: {
83
+ name: string;
84
+ description: string;
85
+ inputSchema: ToolParameterSchema;
86
+ }[];
87
+ temperature?: number;
88
+ maxTokens?: number;
89
+ signal?: AbortSignal;
90
+ /**
91
+ * Reasoning effort hint for models that support it (GLM, o-series, …).
92
+ * Providers that don't support it ignore it silently.
93
+ */
94
+ reasoningEffort?: 'low' | 'medium' | 'high';
95
+ }
96
+ /** Agent working mode: plan first (read-only) or build (full tools). */
97
+ export type AgentMode = 'plan' | 'build';
98
+ export interface UsageInfo {
99
+ promptTokens?: number;
100
+ completionTokens?: number;
101
+ totalTokens?: number;
102
+ }
103
+ export interface ChatResponse {
104
+ content: string | null;
105
+ toolCalls: ChatToolCall[];
106
+ usage?: UsageInfo;
107
+ }
108
+ export interface LLMProvider {
109
+ readonly id: string;
110
+ readonly model: string;
111
+ /** Hard context limit in tokens, used by the context engine. */
112
+ readonly contextLimit: number;
113
+ complete(request: ChatRequest): Promise<ChatResponse>;
114
+ }
115
+ export interface LLMProviderConfig {
116
+ baseUrl: string;
117
+ apiKey?: string;
118
+ model: string;
119
+ contextLimit?: number;
120
+ temperature?: number;
121
+ maxRetries?: number;
122
+ /**
123
+ * Optional curated model list. When set, the /model picker shows exactly
124
+ * these instead of every model the server reports. Useful for routers
125
+ * with huge catalogs.
126
+ */
127
+ models?: string[];
128
+ }
129
+ export interface MemoryRecord {
130
+ id: string;
131
+ content: string;
132
+ tags: string[];
133
+ createdAt: string;
134
+ score?: number;
135
+ }
136
+ export interface MemoryProvider {
137
+ readonly id: string;
138
+ recall(query: string, limit?: number): Promise<MemoryRecord[]>;
139
+ remember(content: string, tags?: string[]): Promise<MemoryRecord>;
140
+ forget(id: string): Promise<boolean>;
141
+ }
142
+ export interface ContextItem {
143
+ kind: 'system' | 'objective' | 'memory' | 'conversation' | 'tool';
144
+ text: string;
145
+ tokens: number;
146
+ }
147
+ export interface ContextCheckpoint {
148
+ objective: string;
149
+ decisions: string[];
150
+ unresolved: string[];
151
+ recentSummary: string;
152
+ }
153
+ export type SkillScope = 'builtin' | 'global' | 'project';
154
+ export interface Skill {
155
+ name: string;
156
+ description: string;
157
+ instructions: string;
158
+ allowedTools?: string[];
159
+ version?: string;
160
+ scope: SkillScope;
161
+ source: string;
162
+ }
163
+ export type AgentStatus = 'pending' | 'running' | 'waiting' | 'completed' | 'failed' | 'cancelled';
164
+ export type AgentCapability = 'research' | 'implementation' | 'debugging' | 'testing' | 'review' | 'general';
165
+ export interface TaskPacket {
166
+ taskId: string;
167
+ agentId: string;
168
+ parentAgentId: string;
169
+ objective: string;
170
+ context: string;
171
+ constraints: string[];
172
+ availableTools: string[];
173
+ workspace: string;
174
+ expectedResult: string;
175
+ }
176
+ export interface TaskResult {
177
+ status: 'completed' | 'failed';
178
+ summary: string;
179
+ evidence: string[];
180
+ filesChanged: string[];
181
+ commandsExecuted: string[];
182
+ tests?: string;
183
+ unresolvedIssues: string[];
184
+ }
185
+ export interface AgentRecord {
186
+ agentId: string;
187
+ parentAgentId: string | null;
188
+ capability: AgentCapability;
189
+ status: AgentStatus;
190
+ task: TaskPacket;
191
+ result?: TaskResult;
192
+ }
193
+ export interface SessionState {
194
+ sessionId: string;
195
+ projectRoot: string;
196
+ model: string;
197
+ objective: string;
198
+ messages: ChatMessage[];
199
+ agents: AgentRecord[];
200
+ createdAt: string;
201
+ updatedAt: string;
202
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared types for the iNeedCodes runtime.
3
+ * These types are intentionally model-independent: tools receive JSON,
4
+ * return JSON, and never depend on a specific LLM SDK.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,5 @@
1
+ export declare function ensureDir(dir: string): Promise<void>;
2
+ export declare function pathExists(p: string): Promise<boolean>;
3
+ export declare function readJson<T>(file: string): Promise<T | undefined>;
4
+ export declare function writeJson(file: string, value: unknown): Promise<void>;
5
+ export declare function isInsideRoot(root: string, target: string): boolean;
@@ -0,0 +1,33 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import * as path from 'node:path';
3
+ export async function ensureDir(dir) {
4
+ await fs.mkdir(dir, { recursive: true });
5
+ }
6
+ export async function pathExists(p) {
7
+ try {
8
+ await fs.access(p);
9
+ return true;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ export async function readJson(file) {
16
+ try {
17
+ const raw = await fs.readFile(file, 'utf8');
18
+ return JSON.parse(raw);
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
24
+ export async function writeJson(file, value) {
25
+ await ensureDir(path.dirname(file));
26
+ await fs.writeFile(file, JSON.stringify(value, null, 2), 'utf8');
27
+ }
28
+ export function isInsideRoot(root, target) {
29
+ const resolved = path.resolve(root, target);
30
+ const relative = path.relative(root, resolved);
31
+ return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
32
+ }
33
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/util/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM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CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Quote a string for use in a shell command on the current platform.
3
+ * - POSIX (bash/sh): single quotes, '\'' escaping.
4
+ * - Windows (cmd.exe): single quotes are NOT special: use double quotes
5
+ * and escape embedded quotes by doubling.
6
+ */
7
+ export declare function shellQuote(s: string): string;
@@ -0,0 +1,20 @@
1
+ import * as os from 'node:os';
2
+ /**
3
+ * Quote a string for use in a shell command on the current platform.
4
+ * - POSIX (bash/sh): single quotes, '\'' escaping.
5
+ * - Windows (cmd.exe): single quotes are NOT special: use double quotes
6
+ * and escape embedded quotes by doubling.
7
+ */
8
+ export function shellQuote(s) {
9
+ if (os.platform() === 'win32') {
10
+ if (/^[A-Za-z0-9_\-:.,\\/+=@() ]+$/.test(s) && !/"/.test(s)) {
11
+ // Unquoted-safe tokens stay unquoted; spaces still need quotes on cmd.
12
+ return /\s/.test(s) ? `"${s}"` : s;
13
+ }
14
+ return `"${s.replaceAll('"', '""')}"`;
15
+ }
16
+ if (/^[A-Za-z0-9_\-:.,/+=@]+$/.test(s))
17
+ return s;
18
+ return `'${s.replaceAll("'", `'\\''`)}'`;
19
+ }
20
+ //# sourceMappingURL=shell-quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-quote.js","sourceRoot":"","sources":["../../src/util/shell-quote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;QAC9B,IAAI,+BAA+B,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,uEAAuE;YACvE,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;IACxC,CAAC;IACD,IAAI,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface WorkspaceInfo {
2
+ root: string;
3
+ projectRoot: string;
4
+ isGitRepo: boolean;
5
+ gitBranch?: string;
6
+ projectInstructions: string;
7
+ instructionsSources: string[];
8
+ /** Stable project identity used for memory isolation. */
9
+ projectId: string;
10
+ }
11
+ /**
12
+ * The workspace provides: project root, git state, file boundary,
13
+ * project instructions, project memory identity, command working directory.
14
+ */
15
+ export declare function discoverWorkspace(startDir: string): Promise<WorkspaceInfo>;
@@ -0,0 +1,84 @@
1
+ import * as path from 'node:path';
2
+ import { promises as fs } from 'node:fs';
3
+ /**
4
+ * The workspace provides: project root, git state, file boundary,
5
+ * project instructions, project memory identity, command working directory.
6
+ */
7
+ export async function discoverWorkspace(startDir) {
8
+ const root = path.resolve(startDir);
9
+ const [gitRoot, isGitRepo, gitBranch] = await gitInfo(root);
10
+ const projectRoot = gitRoot ?? root;
11
+ const instructionsSources = [];
12
+ let projectInstructions = '';
13
+ const candidates = [
14
+ path.join(projectRoot, 'AGENTS.md'),
15
+ path.join(projectRoot, '.ineedcodes', 'instructions.md')
16
+ ];
17
+ for (const file of candidates) {
18
+ const text = await readFileIfSmall(file, 64 * 1024);
19
+ if (text !== undefined) {
20
+ instructionsSources.push(file);
21
+ projectInstructions += text.trimEnd() + '\n\n';
22
+ }
23
+ }
24
+ return {
25
+ root,
26
+ projectRoot,
27
+ isGitRepo,
28
+ gitBranch,
29
+ projectInstructions: projectInstructions.trimEnd(),
30
+ instructionsSources,
31
+ projectId: await projectId(projectRoot)
32
+ };
33
+ }
34
+ async function gitInfo(dir) {
35
+ let current = path.resolve(dir);
36
+ while (true) {
37
+ const gitDir = path.join(current, '.git');
38
+ try {
39
+ const stat = await fs.stat(gitDir);
40
+ const isRepo = stat.isDirectory() || stat.isFile(); // .git file = worktree
41
+ if (isRepo) {
42
+ const branch = await gitBranchOf(current);
43
+ return [current, true, branch];
44
+ }
45
+ }
46
+ catch {
47
+ // not here, walk up
48
+ }
49
+ const parent = path.dirname(current);
50
+ if (parent === current)
51
+ return [null, false, undefined];
52
+ current = parent;
53
+ }
54
+ }
55
+ async function gitBranchOf(repo) {
56
+ try {
57
+ const { execFile } = await import('node:child_process');
58
+ const { promisify } = await import('node:util');
59
+ const run = promisify(execFile);
60
+ const { stdout } = await run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: repo });
61
+ return stdout.trim();
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ async function readFileIfSmall(file, maxBytes) {
68
+ try {
69
+ const stat = await fs.stat(file);
70
+ if (!stat.isFile() || stat.size > maxBytes)
71
+ return undefined;
72
+ return await fs.readFile(file, 'utf8');
73
+ }
74
+ catch {
75
+ return undefined;
76
+ }
77
+ }
78
+ /** Deterministic per-project identity derived from the project root path. */
79
+ async function projectId(projectRoot) {
80
+ const { createHash } = await import('node:crypto');
81
+ const h = createHash('sha256').update(projectRoot).digest('hex');
82
+ return h.slice(0, 16);
83
+ }
84
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/workspace/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAazC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACtD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,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,GAAG,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC7D,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,6EAA6E;AAC7E,KAAK,UAAU,SAAS,CAAC,WAAmB;IAC1C,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@ineedcodes/core",
3
+ "version": "0.1.0",
4
+ "description": "iNeedCodes core runtime: tools, LLM, memory, context, sessions, skills",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": "./dist/index.js"
11
+ },
12
+ "scripts": {
13
+ "build": "tsc -b"
14
+ },
15
+ "dependencies": {
16
+ "yaml": "^2.4.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^22.0.0"
20
+ }
21
+ }