Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@tinyclaw/cli",
"version": "0.0.10",
"type": "module",
"main": "dist/shared.js",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

main field is misleading for an ESM CLI package

The "main": "dist/shared.js" entry points to an internal utility module rather than a primary package entry. Now that the package is ESM ("type": "module"), any external require('@tinyclaw/cli') call will fail because ESM cannot be synchronously required. For a CLI-only package this is generally fine at runtime (since nothing imports it), but it would be cleaner to either:

  • Remove "main" entirely if the package is not meant to be imported programmatically, or
  • Add a proper "exports" field mapping to communicate intent and support Node16 module resolution tooling properly.

Additionally, the absence of a "bin" field means the CLI scripts cannot be installed globally via npm — this was already the case before this PR, but converting to ESM is a good opportunity to revisit the package's public shape.

"scripts": {
"build": "tsc"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
unwrap, cleanId, validateId, required,
writeSettings, requireSettings, SCRIPT_DIR,
providerOptions, promptModel, harnessOptions,
} from './shared';
} from './shared.ts';

// --- agent add ---

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import * as p from '@clack/prompts';
import { readSettings, writeSettings, requireSettings } from './shared';
import { readSettings, writeSettings, requireSettings } from './shared.ts';

// --- provider show ---

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/setup-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
unwrap, cleanId, validateId, required,
writeSettings, SETTINGS_FILE, TINYCLAW_HOME, SCRIPT_DIR,
providerOptions, promptModel,
} from './shared';
} from './shared.ts';

const ALL_CHANNELS = ['telegram', 'discord', 'whatsapp'] as const;

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Settings, updateAgentTeammates } from '@tinyclaw/core';
import {
unwrap, cleanId, validateId,
writeSettings, requireSettings,
} from './shared';
} from './shared.ts';

function refreshTeamInfo(settings: Settings) {
const agents = settings.agents || {};
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import { SCRIPT_DIR } from '@tinyclaw/core';
import { unwrap } from './shared';
import { unwrap } from './shared.ts';

const GITHUB_REPO = 'TinyAGI/tinyclaw';
const UPDATE_CHECK_CACHE = path.join(process.env.HOME || '~', '.tinyclaw', '.update_check');
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
"rootDir": "./src",
"module": "Node16",
"moduleResolution": "Node16",
"rewriteRelativeImportExtensions": true
Comment on lines +6 to +8
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@tinyclaw/core lacks "exports" field required for clean Node16 resolution

With "moduleResolution": "Node16", TypeScript (and Node.js at runtime) prefer packages to declare a "exports" field so the module system knows exactly which format (CJS/ESM) is being published and which entry points are available. The referenced @tinyclaw/core package has no "exports" field — only a "main" field — while remaining a CommonJS package (no "type": "module").

TypeScript falls back to "main" in this case and the build will succeed, but strict Node16/NodeNext tooling (bundlers, tsc --build with declaration emit, newer Jest/Vitest configs) may warn or fail to resolve the package correctly. The safer approach is to add an "exports" field to packages/core/package.json:

"exports": {
  ".": {
    "require": "./dist/index.js",
    "types": "./dist/index.d.ts"
  }
}

This is not introduced by this PR per se, but the move to moduleResolution: "Node16" in the CLI makes the gap visible.

},
"include": ["src/**/*"],
"references": [
Expand Down